git svn dcommit : new option --interactive
PATCH 1/1 git svn dcommit : new option --interactive
I use git svn daily, at work, and it is so useful that I started using it to track some files which are not supposed to find their way up to the SVN server.
For instance, it may be useful to 'git add & commit' some reference data files, refactor some code, check against the data files, git commit, ..., then discard commits with data files.
This way, it is very easy to monitor the functional changes in your code.
Unfortunately, it may happen that I forget to remove useless commits, and 'git svn dcommit' everything ... forever.
These 2 patches add a --interactive option to 'git svn dcommit', which provides an interactive mode, similar to git-send-email.
Documentation/git-svn.txt | 8 ++++ git-svn.perl | 71 +++++++++++++++++++++++++++++++- t/t9160-git-svn-dcommit-interactive.sh | 64 ++++++++++++++++++++++++++++ 3 files changed, 142 insertions(+), 1 deletions(-)
PATCH 1/2 git svn dcommit: new option --interactive.
Allow the user to check the patch set before it is commited to SNV. It is then possible to accept/discard one patch, accept all, or quit.
This interactive mode is similar with 'git send email' behaviour. However, 'git svn dcommit' returns as soon as one patch is discarded.
Part of the code was taken from git-send-email.perl
Thanks-to: Eric Wong <[email protected]> for the initial idea.
---
I would have preferred not duplicating the code snippets taken from git-send-email ('ask' function, Term related code, ...) but I preferred not to spoil Git.pm with it.
Any comment on a better way to factor perl code would be appreciated.
Documentation/git-svn.txt | 8 +++++ git-svn.perl | 71 ++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 78 insertions(+), 1 deletions(-)
Documentation/git-svn.txt +8 -0
@@ -214,6 +214,14 @@ discouraged. version 1.5 can make use of it. 'git svn' currently does not use it and does not set it automatically. +--interactive;; + Ask the user to confirm that a patch set should actually be sent to SVN. + For each patch, one may answer "yes" (accept this patch), "no" (discard this + patch), "all" (accept all patches), or "quit". + + + 'git svn dcommit' returns immediately if answer if "no" or "quit", without + commiting anything to SVN. + 'branch':: Create a branch in the SVN repository.
git-svn.perl +70 -1
101 lines not on this page · raw message
Signature · 1 line
1.7.6.447.gb9176
Re: [PATCH 1/2] git svn dcommit: new option --interactive.
Quoted 10 lines · Frédéric Heitzmann
Allow the user to check the patch set before it is commited to SNV. It is then possible to accept/discard one patch, accept all, or quit.
This interactive mode is similar with 'git send email' behaviour. However, 'git svn dcommit' returns as soon as one patch is discarded.
Part of the code was taken from git-send-email.perl
Thanks-to: Eric Wong <[email protected]> for the initial idea.
Signed-off-by Frédéric Heitzmann <[email protected]>
I agree with this feature, a few comments inline.
Quoted 4 lines
I would have preferred not duplicating the code snippets taken from git-send-email ('ask' function, Term related code, ...) but I preferred not to spoil Git.pm with it.
Any comment on a better way to factor perl code would be appreciated.
We should put this into Git.pm at some point.
(Somebody should refactor git-svn.perl into separate files too... :x)
Quoted 3 lines
Documentation/git-svn.txt | 8 +++++ git-svn.perl | 71 ++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 78 insertions(+), 1 deletions(-)
Tests and feature should be the same patch
git-svn.perl sub version { · line 394
Quoted 3 lines
git-svn.perl +3
-0+ return defined $default ? $default : undef + unless defined $term->IN and defined fileno($term->IN) and + defined $term->OUT and defined fileno($term->OUT);
Things to make life easier for (mainly) C programmers:
* Use C-style "&&" and "||" for conditionals. "and" and "or" are lower precedence and better used for control flow (see perlop(1) manpage).
* Also, use parentheses for defined(foo) to disambiguate multiple conditions/statements.
Signature · 1 line
Eric Wong
Re: [PATCH 1/2] git svn dcommit: new option --interactive.
Quoted 28 lines · Eric Wong
Quoted 9 lines · Frédéric Heitzmann
Allow the user to check the patch set before it is commited to SNV. It is then possible to accept/discard one patch, accept all, or quit.
This interactive mode is similar with 'git send email' behaviour. However, 'git svn dcommit' returns as soon as one patch is discarded.
Part of the code was taken from git-send-email.perl
Thanks-to: Eric Wong<[email protected]> for the initial idea.Signed-off-by Frédéric Heitzmann<[email protected]>I agree with this feature, a few comments inline.
Quoted 4 lines
I would have preferred not duplicating the code snippets taken from git-send-email ('ask' function, Term related code, ...) but I preferred not to spoil Git.pm with it.
Any comment on a better way to factor perl code would be appreciated.We should put this into Git.pm at some point.
(Somebody should refactor git-svn.perl into separate files too... :x)Quoted 3 lines
Documentation/git-svn.txt | 8 +++++ git-svn.perl | 71 ++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 78 insertions(+), 1 deletions(-)Tests and feature should be the same patch
git-svn.perl sub version { · line 394
Quoted 3 lines
git-svn.perl +3
-0+ return defined $default ? $default : undef + unless defined $term->IN and defined fileno($term->IN) and + defined $term->OUT and defined fileno($term->OUT);Things to make life easier for (mainly) C programmers:
Quoted 6 lines
* Use C-style "&&" and "||" for conditionals. "and" and "or" are lower precedence and better used for control flow (see perlop(1) manpage).
* Also, use parentheses for defined(foo) to disambiguate multiple conditions/statements.
My fault : I copied-pasted the 'ask' function from git-send-email.
Even if I rewrite it a litlle, it should not prevent anyone to mutalize some code into Git.pm. And, indeed, it will improve readability.
I wait a few days to see if anyone else has some comments and I send a V2 patch serie.
Thanks for reviewing.
--
Fred
PATCH 2/2 git svn dcommit: add a test serie for 'git svn dcommit --interactive'
In reply to Frédéric Heitzmanntest several combinations of potential answers to 'git svn dcommit --interactive'. For each of them, test whether patches were commited to SVN or not
--- t/t9160-git-svn-dcommit-interactive.sh | 64 ++++++++++++++++++++++++++++++++ 1 files changed, 64 insertions(+), 0 deletions(-) create mode 100644 t/t9160-git-svn-dcommit-interactive.sh
t/t9160-git-svn-dcommit-interactive.sh new file +64 -0
@@ -0,0 +1,64 @@ +#!/bin/sh +# +# Copyright (c) 2011 Frédéric Heitzmann + +test_description='git svn dcommit --interactive series' +. ./lib-git-svn.sh + +test_expect_success 'initialize repo' ' + svn_cmd mkdir -m"mkdir test-interactive" "$svnrepo/test-interactive" && + git svn clone "$svnrepo/test-interactive" test-interactive && + cd test-interactive && + touch foo && git add foo && git commit -m"foo: first commit" && + git svn dcommit + ' + +test_expect_success 'answers: y [\n] yes' ' + ( + echo "change #1" >> foo && git commit -a -m"change #1" && + echo "change #2" >> foo && git commit -a -m"change #2" && + echo "change #3" >> foo && git commit -a -m"change #3" && + ( echo "y + +y" | GIT_SVN_NOTTY=1 git svn dcommit --interactive ) && + test $(git rev-parse HEAD) = $(git rev-parse remotes/git-svn) + ) + ' + +test_expect_success 'answers: yes yes no' ' + ( + echo "change #1" >> foo && git commit -a -m"change #1" && + echo "change #2" >> foo && git commit -a -m"change #2" && + echo "change #3" >> foo && git commit -a -m"change #3" && + ( echo "yes +yes +no" | GIT_SVN_NOTTY=1 git svn dcommit --interactive ) && + test $(git rev-parse HEAD^^^) = $(git rev-parse remotes/git-svn) && + git reset --hard remotes/git-svn + ) + ' + +test_expect_success 'answers: yes quit' ' + ( + echo "change #1" >> foo && git commit -a -m"change #1" && + echo "change #2" >> foo && git commit -a -m"change #2" && + echo "change #3" >> foo && git commit -a -m"change #3" && + ( echo "yes +quit" | GIT_SVN_NOTTY=1 git svn dcommit --interactive ) && + test $(git rev-parse HEAD^^^) = $(git rev-parse remotes/git-svn) && + git reset --hard remotes/git-svn + ) + ' + +test_expect_success 'answers: all' ' + ( + echo "change #1" >> foo && git commit -a -m"change #1" && + echo "change #2" >> foo && git commit -a -m"change #2" && + echo "change #3" >> foo && git commit -a -m"change #3" && + ( echo "all" | GIT_SVN_NOTTY=1 git svn dcommit --interactive ) && + test $(git rev-parse HEAD) = $(git rev-parse remotes/git-svn) && + git reset --hard remotes/git-svn + ) + ' + +test_done
Signature · 1 line
1.7.6.447.gb9176