From: "David D. Kilzer" <ddkilzer@kilzer.net>
To: git@vger.kernel.org
Cc: Eric Wong <normalperson@yhbt.net>,
"David D. Kilzer" <ddkilzer@kilzer.net>
Subject: [PATCH] Fix git svn dcommit to work with touched files
Date: Mon, 2 Aug 2010 12:58:19 -0700 [thread overview]
Message-ID: <1280779099-29742-1-git-send-email-ddkilzer@kilzer.net> (raw)
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".
Signed-off-by: David D. Kilzer <ddkilzer@kilzer.net>
---
git-svn.perl | 1 +
t/t9100-git-svn-basic.sh | 11 +++++++++++
2 files changed, 12 insertions(+), 0 deletions(-)
diff --git a/git-svn.perl b/git-svn.perl
index c416358..b8a98d4 100755
--- a/git-svn.perl
+++ b/git-svn.perl
@@ -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";
diff --git a/t/t9100-git-svn-basic.sh b/t/t9100-git-svn-basic.sh
index 13766ab..d5adae6 100755
--- a/t/t9100-git-svn-basic.sh
+++ b/t/t9100-git-svn-basic.sh
@@ -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 &&
--
1.7.2.1.9.g74fb9
next reply other threads:[~2010-08-02 19:58 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-08-02 19:58 David D. Kilzer [this message]
2010-08-02 22:20 ` [PATCH] Fix git svn dcommit to work with touched files Eric Wong
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1280779099-29742-1-git-send-email-ddkilzer@kilzer.net \
--to=ddkilzer@kilzer.net \
--cc=git@vger.kernel.org \
--cc=normalperson@yhbt.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).