@matheusbsbs / matheus-bagliano / commits / 181264ad59
Fork 0

git svn: fix dcommit to work with touched files

The dcommit command fails if an otherwise unmodified file has been touched in the working directory: Cannot dcommit with a dirty index. Commit your changes first, or stash them with `git stash'. This happens because "git diff-index" reports a difference between the index and the filesystem: :100644 100644 d00491...... 000000...... M file The fix is to run "git update-index --refresh" before "git diff-index" as is done in git-rebase and git-rebase--interactive before "git diff-files". This changes dcommit to display a list of modified files before exiting. Also add a similar test case for "git svn rebase". [ew: rearranged commit message subject] Signed-off-by: David D. Kilzer <ddkilzer@kilzer.net> Acked-by: Eric Wong <normalperson@yhbt.net>

David D. Kilzer committed Aug 2, 2010 at 12:58 UTC 181264ad590ffef9d956fdd023369869c2d0a55f
2 files changed +12
git-svn.perl
+1
@@ -494,6 +494,7 @@ sub cmd_set_tree {
494
495 sub cmd_dcommit {
496 my $head = shift;
497 + command_noisy(qw/update-index --refresh/);
498 git_cmd_try { command_oneline(qw/diff-index --quiet HEAD/) }
499 'Cannot dcommit with a dirty index. Commit your changes first, '
500 . "or stash them with `git stash'.\n";
t/t9100-git-svn-basic.sh
+11
@@ -271,6 +271,17 @@ test_expect_success 'able to dcommit to a subdirectory' "
271 test -z \"\`git diff refs/heads/my-bar refs/remotes/bar\`\"
272 "
273
274 +test_expect_success 'dcommit should not fail with a touched file' '
275 + test_commit "commit-new-file-foo2" foo2 &&
276 + test-chmtime =-60 foo &&
277 + git svn dcommit
278 +'
279 +
280 +test_expect_success 'rebase should not fail with a touched file' '
281 + test-chmtime =-60 foo &&
282 + git svn rebase
283 +'
284 +
285 test_expect_success 'able to set-tree to a subdirectory' "
286 echo cba > d &&
287 git update-index d &&