diff options
author | Josef Weidendorfer <Josef.Weidendorfer@gmx.de> | 2005-11-27 22:04:14 +0100 |
---|---|---|
committer | Junio C Hamano <junkio@cox.net> | 2005-11-27 14:40:28 -0800 |
commit | f6bc189a457b2575587f26e27f1eabdd615b2d78 (patch) | |
tree | 5d83477de7a407ab0ef183c6676114e1a507cf86 /git-mv.perl | |
parent | 3ae64dff6894adc995c913aaf7fe2d65c78c3529 (diff) | |
download | git-f6bc189a457b2575587f26e27f1eabdd615b2d78.tar.gz git-f6bc189a457b2575587f26e27f1eabdd615b2d78.tar.xz |
git-mv: keep git index consistent with file system on failed rename
When doing multiple renames, and a rename in the middle fails,
git-mv did not store the successful renames in the git index;
this is fixed by delaying the error message on a failed rename
to after the git updating.
Signed-off-by: Josef Weidendorfer <Josef.Weidendorfer@gmx.de>
Signed-off-by: Junio C Hamano <junkio@cox.net>
Diffstat (limited to 'git-mv.perl')
-rwxr-xr-x | git-mv.perl | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/git-mv.perl b/git-mv.perl index 990bec503..ac19876fe 100755 --- a/git-mv.perl +++ b/git-mv.perl @@ -142,14 +142,17 @@ while(scalar @srcArgs > 0) { # Final pass: rename/move my (@deletedfiles,@addedfiles,@changedfiles); +$bad = ""; while(scalar @srcs > 0) { $src = shift @srcs; $dst = shift @dsts; if ($opt_n || $opt_v) { print "Renaming $src to $dst\n"; } if (!$opt_n) { - rename($src,$dst) - or die "rename failed: $!"; + if (!rename($src,$dst)) { + $bad = "renaming '$src' failed: $!"; + last; + } } $safesrc = quotemeta($src); @@ -209,3 +212,8 @@ else { close(H); } } + +if ($bad ne "") { + print "Error: $bad\n"; + exit(1); +} |