Skip to content

Commit

Permalink
git svn: fix dcommit to work with touched files
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
David D. Kilzer authored and Eric Wong committed Aug 2, 2010
1 parent 3713e22 commit 181264a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
1 change: 1 addition & 0 deletions git-svn.perl
Original file line number Diff line number Diff line change
Expand Up @@ -494,6 +494,7 @@ sub cmd_set_tree {

sub cmd_dcommit {
my $head = shift;
command_noisy(qw/update-index --refresh/);
git_cmd_try { command_oneline(qw/diff-index --quiet HEAD/) }
'Cannot dcommit with a dirty index. Commit your changes first, '
. "or stash them with `git stash'.\n";
Expand Down
11 changes: 11 additions & 0 deletions t/t9100-git-svn-basic.sh
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,17 @@ test_expect_success 'able to dcommit to a subdirectory' "
test -z \"\`git diff refs/heads/my-bar refs/remotes/bar\`\"
"

test_expect_success 'dcommit should not fail with a touched file' '
test_commit "commit-new-file-foo2" foo2 &&
test-chmtime =-60 foo &&
git svn dcommit
'

test_expect_success 'rebase should not fail with a touched file' '
test-chmtime =-60 foo &&
git svn rebase
'

test_expect_success 'able to set-tree to a subdirectory' "
echo cba > d &&
git update-index d &&
Expand Down

0 comments on commit 181264a

Please sign in to comment.