]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
cp,install,mv: --debug: output debug info when reflinking
authorPádraig Brady <P@draigBrady.com>
Fri, 24 Feb 2023 15:15:20 +0000 (15:15 +0000)
committerPádraig Brady <P@draigBrady.com>
Fri, 24 Feb 2023 15:17:36 +0000 (15:17 +0000)
* src/copy.c (copy_reg): Always check whether to output debug info.
(emit_debug): Restrict output with `cp --attributes-only`.

src/copy.c

index ca43faac25cdc4edf13485a857907db262d5120f..39197872c95455b3c5741d1593b2b682f27a3734 100644 (file)
@@ -187,7 +187,7 @@ copy_debug_sparse_string (enum copy_debug_val debug_val)
 static void
 emit_debug (const struct cp_options *x)
 {
-  if (! x->hard_link && ! x->symbolic_link)
+  if (! x->hard_link && ! x->symbolic_link && x->data_copy_required)
     printf ("copy offload: %s, reflink: %s, sparse detection: %s\n",
             copy_debug_string (copy_debug.offload),
             copy_debug_string (copy_debug.reflink),
@@ -1608,10 +1608,6 @@ copy_reg (char const *src_name, char const *dst_name,
           return_val = false;
           goto close_src_and_dst_desc;
         }
-
-      /* Output debug info for data copying operations.  */
-      if (x->debug)
-        emit_debug (x);
     }
 
   if (x->preserve_timestamps)
@@ -1707,6 +1703,10 @@ close_src_desc:
       return_val = false;
     }
 
+  /* Output debug info for data copying operations.  */
+  if (x->debug)
+    emit_debug (x);
+
   alignfree (buf);
   return return_val;
 }