Skip to content

Commit 699eb54

Browse files
committed
Merge branch 'jk/maint-mv' into maint
* jk/maint-mv: mv: be quiet about overwriting mv: improve overwrite warning mv: make non-directory destination error more clear mv: honor --verbose flag docs: mention "-k" for both forms of "git mv"
2 parents 7a5638a + 534376c commit 699eb54

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

Documentation/git-mv.txt

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ DESCRIPTION
1515
-----------
1616
This script is used to move or rename a file, directory or symlink.
1717

18-
git mv [-f] [-n] <source> <destination>
19-
git mv [-f] [-n] [-k] <source> ... <destination directory>
18+
git mv [-v] [-f] [-n] [-k] <source> <destination>
19+
git mv [-v] [-f] [-n] [-k] <source> ... <destination directory>
2020

2121
In the first form, it renames <source>, which must exist and be either
2222
a file, symlink or directory, to <destination>.
@@ -40,6 +40,10 @@ OPTIONS
4040
--dry-run::
4141
Do nothing; only show what would happen
4242

43+
-v::
44+
--verbose::
45+
Report the names of files as they are moved.
46+
4347
GIT
4448
---
4549
Part of the linkgit:git[1] suite

builtin/mv.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ int cmd_mv(int argc, const char **argv, const char *prefix)
5959
int i, newfd;
6060
int verbose = 0, show_only = 0, force = 0, ignore_errors = 0;
6161
struct option builtin_mv_options[] = {
62+
OPT__VERBOSE(&verbose, "be verbose"),
6263
OPT__DRY_RUN(&show_only, "dry run"),
6364
OPT__FORCE(&force, "force move/rename even if target exists"),
6465
OPT_BOOLEAN('k', NULL, &ignore_errors, "skip move/rename errors"),
@@ -93,7 +94,7 @@ int cmd_mv(int argc, const char **argv, const char *prefix)
9394
destination = copy_pathspec(dest_path[0], argv, argc, 1);
9495
} else {
9596
if (argc != 1)
96-
usage_with_options(builtin_mv_usage, builtin_mv_options);
97+
die("destination '%s' is not a directory", dest_path[0]);
9798
destination = dest_path;
9899
}
99100

@@ -176,7 +177,8 @@ int cmd_mv(int argc, const char **argv, const char *prefix)
176177
* check both source and destination
177178
*/
178179
if (S_ISREG(st.st_mode) || S_ISLNK(st.st_mode)) {
179-
warning(_("%s; will overwrite!"), bad);
180+
if (verbose)
181+
warning(_("overwriting '%s'"), dst);
180182
bad = NULL;
181183
} else
182184
bad = _("Cannot overwrite");

0 commit comments

Comments
 (0)