Stefan Moch <[email protected]> writes:

> * Jonathan Nieder <[email protected]> [2017-12-15T17:31:30-0800]:
>> This sounds like a reasonable thing to add.  See builtin/mv.c for how
>> "git mv" works if you're looking for inspiration.
>> 
>> cmd_mv in that file looks rather long, so I'd also be happy if someone
>> interested refactors to break it into multiple self-contained pieces
>> for easier reading (git mostly follows
>> https://www.kernel.org/doc/html/latest/process/coding-style.html#functions).
>
> I looked at builtin/mv.c and have a rough idea how to split it
> up to support both mv and cp commands.
>
> But first I noticed and removed a redundant check in cmd_mv,
> also added a test case to check if mv --dry-run does not move
> the file.

I guess these two patches went unnoticed when posted at the end of
last year.  Reading them again, I think they are good changes.

As a no-op clean-up of a127331c ("mv: allow moving nested
submodules", 2016-04-19), the attached would also make sense, I
would think.

Thanks.

 builtin/mv.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/builtin/mv.c b/builtin/mv.c
index 9662804d23..9cb07990fd 100644
--- a/builtin/mv.c
+++ b/builtin/mv.c
@@ -266,10 +266,11 @@ int cmd_mv(int argc, const char **argv, const char 
*prefix)
                const char *src = source[i], *dst = destination[i];
                enum update_mode mode = modes[i];
                int pos;
-               if (show_only || verbose)
-                       printf(_("Renaming %s to %s\n"), src, dst);
-               if (show_only)
+               if (show_only) {
+                       if (verbose)
+                               printf(_("Renaming %s to %s\n"), src, dst);
                        continue;
+               }
                if (mode != INDEX && rename(src, dst) < 0) {
                        if (ignore_errors)
                                continue;

Reply via email to