#12 copy: reduce verbosity of -i and -u with --verbose
Merged 9 months ago by pbrady. Opened 9 months ago by lzaoral.
rpms/ lzaoral/coreutils bz2236321  into  f39

@@ -0,0 +1,141 @@ 

+ From cc078f747f3db00e70b2ae2ad2ab34e8d54316d3 Mon Sep 17 00:00:00 2001

+ From: =?UTF-8?q?P=C3=A1draig=20Brady?= <P@draigBrady.com>

+ Date: Tue, 25 Apr 2023 11:07:36 +0100

+ Subject: [PATCH] copy: reduce verbosity of -i and -u with --verbose

+ 

+ Since skipping of files is central to the operation of -i and -u,

+ and with -u one may be updating few files out of many,

+ reinstate the verbosity of this functionality as it was before 9.3.

+ 

+ * src/copy.c (copy_internal): Only output "skipped" message

+ with --debug.  Also adjust so message never changes with --debug.

+ * tests/cp/cp-i.sh: Adjust accordingly.

+ * tests/mv/mv-n.sh: Likewise.

+ * tests/cp/debug.sh: Add explicit test case for message.

+ 

+ Cherry-picked-from: cc078f747f3db00e70b2ae2ad2ab34e8d54316d3

+ Signed-off-by: Lukáš Zaoral <lzaoral@redhat.com>

+ ---

+  src/copy.c        | 6 +++---

+  tests/cp/cp-i.sh  | 9 ++++-----

+  tests/cp/debug.sh | 4 ++++

+  tests/mv/mv-n.sh  | 9 ++++-----

+  4 files changed, 15 insertions(+), 13 deletions(-)

+ 

+ diff --git a/src/copy.c b/src/copy.c

+ index 13d93324f..0dd059d2e 100644

+ --- a/src/copy.c

+ +++ b/src/copy.c

+ @@ -2433,10 +2433,10 @@ copy_internal (char const *src_name, char const *dst_name,

+  skip:

+            if (skipped)

+              {

+ -              if (x->verbose)

+ -                printf (_("skipped %s\n"), quoteaf (dst_name));

+ -              else if (x->interactive == I_ALWAYS_NO)

+ +              if (x->interactive == I_ALWAYS_NO)

+                  error (0, 0, _("not replacing %s"), quoteaf (dst_name));

+ +              else if (x->debug)

+ +                printf (_("skipped %s\n"), quoteaf (dst_name));

+  

+                return_now = true;

+              }

+ diff --git a/tests/cp/cp-i.sh b/tests/cp/cp-i.sh

+ index 4458b2edd..a9178a99e 100755

+ --- a/tests/cp/cp-i.sh

+ +++ b/tests/cp/cp-i.sh

+ @@ -29,13 +29,12 @@ echo n | returns_ 1 cp -iR a b 2>/dev/null || fail=1

+  # test miscellaneous combinations of -f -i -n parameters

+  touch c d || framework_failure_

+  echo "'c' -> 'd'" > out_copy || framework_failure_

+ -echo "skipped 'd'" > out_skip || framework_failure_

+  echo "cp: not replacing 'd'" > err_skip || framework_failure_

+  touch out_empty || framework_failure_

+  

+  # ask for overwrite, answer no

+  echo n | returns_ 1 cp -vi  c d 2>/dev/null > out1 || fail=1

+ -compare out1 out_skip || fail=1

+ +compare out1 out_empty || fail=1

+  

+  # ask for overwrite, answer yes

+  echo y | cp -vi  c d 2>/dev/null > out2 || fail=1

+ @@ -47,7 +46,7 @@ compare out3 out_copy  || fail=1

+  

+  # -n wins over -i

+  echo y | returns_ 1 cp -vin c d 2>/dev/null > out4 || fail=1

+ -compare out4 out_skip || fail=1

+ +compare out4 out_empty || fail=1

+  

+  # -n wins over -i non verbose

+  echo y | returns_ 1 cp -in c d 2>err4 > out4 || fail=1

+ @@ -60,11 +59,11 @@ compare out5 out_copy  || fail=1

+  

+  # do not ask, prevent from overwrite

+  echo n | returns_ 1 cp -vfn c d 2>/dev/null > out6 || fail=1

+ -compare out6 out_skip || fail=1

+ +compare out6 out_empty || fail=1

+  

+  # do not ask, prevent from overwrite

+  echo n | returns_ 1 cp -vnf c d 2>/dev/null > out7 || fail=1

+ -compare out7 out_skip || fail=1

+ +compare out7 out_empty || fail=1

+  

+  # options --backup and --no-clobber are mutually exclusive

+  returns_ 1 cp -bn c d 2>/dev/null || fail=1

+ diff --git a/tests/cp/debug.sh b/tests/cp/debug.sh

+ index b46adc637..242894de2 100755

+ --- a/tests/cp/debug.sh

+ +++ b/tests/cp/debug.sh

+ @@ -25,4 +25,8 @@ grep 'copy offload:.*reflink:.*sparse detection:' cp.out || fail=1

+  cp --debug --attributes-only file file.cp >cp.out || fail=1

+  returns_ 1 grep 'copy offload:.*reflink:.*sparse detection:' cp.out || fail=1

+  

+ +touch file.cp || framework_failure_

+ +cp --debug --update=none file file.cp >cp.out || fail=1

+ +grep 'skipped' cp.out || fail=1

+ +

+  Exit $fail

+ diff --git a/tests/mv/mv-n.sh b/tests/mv/mv-n.sh

+ index 45d74eb93..60547807c 100755

+ --- a/tests/mv/mv-n.sh

+ +++ b/tests/mv/mv-n.sh

+ @@ -23,14 +23,13 @@ print_ver_ mv

+  # test miscellaneous combinations of -f -i -n parameters

+  touch a b || framework_failure_

+  echo "renamed 'a' -> 'b'" > out_move

+ -echo "skipped 'b'" > out_skip || framework_failure_

+  echo "mv: not replacing 'b'" > err_skip || framework_failure_

+  > out_empty

+  

+  # ask for overwrite, answer no

+  touch a b || framework_failure_

+  echo n | returns_ 1 mv -vi a b 2>/dev/null > out1 || fail=1

+ -compare out1 out_skip || fail=1

+ +compare out1 out_empty || fail=1

+  

+  # ask for overwrite, answer yes

+  touch a b || framework_failure_

+ @@ -40,7 +39,7 @@ compare out2 out_move || fail=1

+  # -n wins (as the last option)

+  touch a b || framework_failure_

+  echo y | returns_ 1 mv -vin a b 2>/dev/null > out3 || fail=1

+ -compare out3 out_skip || fail=1

+ +compare out3 out_empty || fail=1

+  

+  # -n wins (non verbose)

+  touch a b || framework_failure_

+ @@ -51,12 +50,12 @@ compare err3 err_skip || fail=1

+  # -n wins (as the last option)

+  touch a b || framework_failure_

+  echo y | returns_ 1 mv -vfn a b 2>/dev/null > out4 || fail=1

+ -compare out4 out_skip || fail=1

+ +compare out4 out_empty || fail=1

+  

+  # -n wins (as the last option)

+  touch a b || framework_failure_

+  echo y | returns_ 1 mv -vifn a b 2>/dev/null > out5 || fail=1

+ -compare out5 out_skip || fail=1

+ +compare out5 out_empty || fail=1

+  

+  # options --backup and --no-clobber are mutually exclusive

+  touch a || framework_failure_

file modified
+8 -1
@@ -1,7 +1,7 @@ 

  Summary: A set of basic GNU tools commonly used in shell scripts

  Name:    coreutils

  Version: 9.3

- Release: 2%{?dist}

+ Release: 3%{?dist}

  License: GPL-3.0-or-later

  Url:     https://www.gnu.org/software/coreutils/

  Source0: https://ftp.gnu.org/gnu/%{name}/%{name}-%{version}.tar.xz
@@ -31,6 +31,10 @@ 

  # df --direct

  Patch104: coreutils-df-direct.patch

  

+ # copy: reduce verbosity of -i and -u with --verbose (#2236321)

+ # backport of cc078f747f3db00e70b2ae2ad2ab34e8d54316d3.

+ Patch105: coreutils-9.3-reduce--iu-verbosity-with-verbose.patch

+ 

  # (sb) lin18nux/lsb compliance - multibyte functionality patch

  Patch800: coreutils-i18n.patch

  
@@ -254,6 +258,9 @@ 

  %license COPYING

  

  %changelog

+ * Thu Aug 31 2023 Lukáš Zaoral <lzaoral@redhat.com> - 9.3-3

+ - copy: reduce verbosity of -i and -u with --verbose (#2236321)

+ 

  * Wed Jul 19 2023 Fedora Release Engineering <releng@fedoraproject.org> - 9.3-2

  - Rebuilt for https://fedoraproject.org/wiki/Fedora_39_Mass_Rebuild

  

Resolves: rhbz#2236321

Thanks, your scratch build works.

Pull-Request has been merged by pbrady

9 months ago

@nixuser Thanks for the confirmation!

@pbrady Thanks for merging! I'd like to do that myself in the future, though, I just was on a lunch break. :smile: