threads / patch / 10812

patchgit-svn: prevent dcommitting if the index is dirty.

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

## tl;dr

4 messages between Nov 11, 2007 and Nov 17, 2007. Diffs are folded; open one to read it.

replies: 3people: 2as markdown or json

Benoit Sigoure· Nov 11, 2007, 18:41 UTC · lore

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@lrde.epita.fr>
---
 git-svn.perl                              |    3 +++
 t/t9106-git-svn-dcommit-clobber-series.sh |    6 ++++++
 2 files changed, 9 insertions(+), 0 deletions(-)
Show changes to 2 files +9 −0

git-svn.perl, t/t9106-git-svn-dcommit-clobber-series.sh

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
Eric Wong· Nov 12, 2007, 02:28 UTC · re: Benoit Sigoure · lore

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

Benoit Sigoure <tsuna@lrde.epita.fr> wrote:
Show 6 quoted lines
> 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@lrde.epita.fr>
Thanks,

Minor nit below about indentation (which Junio can fix when applying), but nevertheless:

Acked-by: Eric Wong <normalperson@yhbt.net>
Show 16 quoted lines
> ---
>  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";
We use tabs for indentation, and spaces for alignment.
>  	$head ||= 'HEAD';
>  	my @refs;
>  	my ($url, $rev, $uuid, $gs) = working_head_info($head, \@refs);
-- 
Eric Wong
Benoit Sigoure· Nov 12, 2007, 09:11 UTC · re: Eric Wong · lore

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

On Nov 12, 2007, at 3:28 AM, Eric Wong wrote:
Show 37 quoted lines
> Benoit Sigoure <tsuna@lrde.epita.fr> wrote:
>> 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@lrde.epita.fr>
>
> Thanks,
>
> Minor nit below about indentation (which Junio can fix when applying),
> but nevertheless:
>
> Acked-by: Eric Wong <normalperson@yhbt.net>
>
>> ---
>>  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";
>
> We use tabs for indentation, and spaces for alignment.

Yes, sorry again, would you consider to add `# vi: set noexpandtab:' at the end of the file so that ViM users (like me) don't have to think about it? (it tells ViM to NOT expand tabs to series of spaces)

-- 
Benoit Sigoure aka Tsuna
EPITA Research and Development Laboratory
Eric Wong· Nov 17, 2007, 20:52 UTC · re: Benoit Sigoure · lore

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

Benoit Sigoure <tsuna@lrde.epita.fr> wrote:
Show 6 quoted lines
> On Nov 12, 2007, at 3:28 AM, Eric Wong wrote:
> >We use tabs for indentation, and spaces for alignment.
> 
> Yes, sorry again, would you consider to add `# vi: set noexpandtab:'  
> at the end of the file so that ViM users (like me) don't have to  
> think about it?  (it tells ViM to NOT expand tabs to series of spaces)

No, there are still too many cases where the modelines won't apply: non-VIM users, VIM-users with modelines disabled.

Instead, you can try this in your .vimrc:
augroup filetype
	au BufRead git-svn.perl		set noexpandtab
augroup END
-- 
Eric Wong

← back to recent threads