[PATCH] git-svn: prevent dcommitting if the index is dirty.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



dcommit uses rebase `sync' the history with what has just been pushed to
SVN.  Trying to dcommit with a dirty index is troublesome for rebase, so now
the user will get an error message if he attempts to dcommit with a dirty
index.

Signed-off-by: Benoit Sigoure <tsuna@xxxxxxxxxxxxx>
---
 git-svn.perl                              |    3 +++
 t/t9106-git-svn-dcommit-clobber-series.sh |    6 ++++++
 2 files changed, 9 insertions(+), 0 deletions(-)

diff --git a/git-svn.perl b/git-svn.perl
index dd93e32..a15df4f 100755
--- a/git-svn.perl
+++ b/git-svn.perl
@@ -390,6 +390,9 @@ sub cmd_set_tree {
 
 sub cmd_dcommit {
 	my $head = shift;
+        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";
 	$head ||= 'HEAD';
 	my @refs;
 	my ($url, $rev, $uuid, $gs) = working_head_info($head, \@refs);
diff --git a/t/t9106-git-svn-dcommit-clobber-series.sh b/t/t9106-git-svn-dcommit-clobber-series.sh
index 7eff4cd..44fae3b 100755
--- a/t/t9106-git-svn-dcommit-clobber-series.sh
+++ b/t/t9106-git-svn-dcommit-clobber-series.sh
@@ -53,4 +53,10 @@ test_expect_success 'change file but in unrelated area' "
 		test x\"\`sed -n -e 61p < file\`\" = x6611
 	"
 
+test_expect_failure 'attempt to dcommit with a dirty index' "
+	echo foo >>file &&
+	git add file &&
+	git svn dcommit
+	"
+
 test_done
-- 
1.5.3.5.654.gdd5ec

-
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux