Git development
 help / color / mirror / Atom feed
* Re: [PATCH 09/14] imap-send.c: remove namespace fields from struct imap
From: Michael Haggerty @ 2013-01-14  9:31 UTC (permalink / raw)
  To: Jonathan Nieder; +Cc: Junio C Hamano, Jeff King, git
In-Reply-To: <20130114064347.GH3125@elie.Belkin>

On 01/14/2013 07:43 AM, Jonathan Nieder wrote:
> Michael Haggerty wrote:
> 
> [...]
>> @@ -722,9 +667,9 @@ static int get_cmd_result(struct imap_store *ctx, struct imap_cmd *tcmd)
>>  			}
>>  
>>  			if (!strcmp("NAMESPACE", arg)) {
>> -				imap->ns_personal = parse_list(&cmd);
>> -				imap->ns_other = parse_list(&cmd);
>> -				imap->ns_shared = parse_list(&cmd);
>> +				skip_list(&cmd);
>> +				skip_list(&cmd);
>> +				skip_list(&cmd);
> 
> This codepath would only be triggered if we emit a NAMESPACE command,
> right?  If I am understanding correctly, a comment could make this
> less mystifying:
> 
> 				/* rfc2342 NAMESPACE response. */
> 				skip_list(&cmd);	/* Personal mailboxes */
> 				skip_list(&cmd);	/* Others' mailboxes */
> 				skip_list(&cmd);	/* Shared mailboxes */

Yes, the comments are useful.

> Though that's probably academic since hopefully this if branch
> will die soon. :)

Not by my hand :-)  Maybe somebody more familiar with the IMAP protocol
wants to take the code culling further...

Michael

-- 
Michael Haggerty
mhagger@alum.mit.edu
http://softwareswirl.blogspot.com/

^ permalink raw reply

* Re: [PATCH 06/14] imap-send.c: remove some unused fields from struct store
From: Michael Haggerty @ 2013-01-14  9:25 UTC (permalink / raw)
  To: Jonathan Nieder; +Cc: Junio C Hamano, Jeff King, git
In-Reply-To: <20130114061920.GE3125@elie.Belkin>

On 01/14/2013 07:19 AM, Jonathan Nieder wrote:
> Michael Haggerty wrote:
> 
>> --- a/imap-send.c
>> +++ b/imap-send.c
> [...]
>> @@ -772,13 +767,10 @@ static int get_cmd_result(struct imap_store *ctx, struct imap_cmd *tcmd)
>>  				   !strcmp("NO", arg) || !strcmp("BYE", arg)) {
>>  				if ((resp = parse_response_code(ctx, NULL, cmd)) != RESP_OK)
>>  					return resp;
>> -			} else if (!strcmp("CAPABILITY", arg))
>> +			} else if (!strcmp("CAPABILITY", arg)) {
>>  				parse_capability(imap, cmd);
>> -			else if ((arg1 = next_arg(&cmd))) {
>> -				if (!strcmp("EXISTS", arg1))
>> -					ctx->gen.count = atoi(arg);
>> -				else if (!strcmp("RECENT", arg1))
>> -					ctx->gen.recent = atoi(arg);
>> +			} else if ((arg1 = next_arg(&cmd))) {
>> +				/* unused */
> 
> Neat.  Let me try to understand what was going on here:
> 
> When opening a mailbox with the SELECT command, an IMAP server
> responds with tagged data indicating how many messages exist and how
> many are marked Recent.  But git imap-send never reads mailboxes and
> in particular never uses the SELECT command, so there is no need for
> us to parse or record such responses.
> 
> Out of paranoia we are keeping the parsing for now, but the parsed
> response is unused, hence the comment above.
> 
> If I've understood correctly so far (a big assumption), I still am not
> sure what it would mean if we hit this ((arg1 = next_arg(&cmd))) case.
> Does it mean:
> 
>  A. The server has gone haywire and given a tagged response where
>     one is not allowed, but let's tolerate it because we always have
>     done so?  Or
> 
>  B. This is a perfectly normal response to some of the commands we
>     send, and we have always been deliberately ignoring it because it
>     is not important for what imap-send does?

Honestly, I didn't bother to look into this.  I was just doing some
brainless elimination of obviously unused code.

No doubt a deeper analysis (like yours) could find more code to discard,
but I didn't want to invest that much time and this code has absolutely
no tests, so I stuck to the obvious (and even then you found a mistake
in my changes :-( ).

Michael

-- 
Michael Haggerty
mhagger@alum.mit.edu
http://softwareswirl.blogspot.com/

^ permalink raw reply

* [BUG] Bug in git stash
From: Nikolay Frantsev @ 2013-01-14  9:18 UTC (permalink / raw)
  To: git

[-- Attachment #1: Type: text/plain, Size: 2099 bytes --]

Hi, I found very strange bug in git stash. Testcase attached to this mail.

1. I have a test repo with two modified files and one new file with
content witch added to commit (see repo in attached file):

nikolay@localhost:~/Desktop/git-stash_bug/bug$ git status
# On branch master
# Changes to be committed:
#   (use "git reset HEAD <file>..." to unstage)
#
#	new file:   3
#
# Changes not staged for commit:
#   (use "git add <file>..." to update what will be committed)
#   (use "git checkout -- <file>..." to discard changes in working directory)
#
#	modified:   1
#	modified:   2
#

2. Stashing two modified files into stash named one:

nikolay@localhost:~/Desktop/git-stash_bug/bug$ git stash save --keep-index one
Saved working directory and index state On master: one
HEAD is now at 7e495f9 files added

3. Checking status, files stashed successfully:

nikolay@localhost:~/Desktop/git-stash_bug/bug$ git status
# On branch master
# Changes to be committed:
#   (use "git reset HEAD <file>..." to unstage)
#
#	new file:   3
#

4. Stashing one added to commit file into stash named zero:

nikolay@localhost:~/Desktop/git-stash_bug/bug$ git stash save zero
Saved working directory and index state On master: zero
HEAD is now at 7e495f9 files added

5. Checking status, files stashed successfully:

nikolay@localhost:~/Desktop/git-stash_bug/bug$ git status
# On branch master
nothing to commit, working directory clean

6. Trying to unstash first stashed changes (on step 2), there a bug:

nikolay@localhost:~/Desktop/git-stash_bug/bug$ git stash pop stash@{1}
# On branch master
# Changes to be committed:
#   (use "git reset HEAD <file>..." to unstage)
#
#	new file:   3
#
# Changes not staged for commit:
#   (use "git add <file>..." to update what will be committed)
#   (use "git checkout -- <file>..." to discard changes in working directory)
#
#	modified:   1
#	modified:   2
#
Dropped stash@{1} (7926ab7285753c179a368a3a7e8ebfb0f39d0437)

Why there a new empty file named 3?

I'm using git 1.8.1, same problem confirmed on git 1.7.12.4.

--
Nikolay Frantsev
Homepage: http://frantsev.ru/

[-- Attachment #2: git-stash_bug.zip --]
[-- Type: application/zip, Size: 13186 bytes --]

^ permalink raw reply

* Re: [PATCH 01/14] imap-send.c: remove msg_data::flags, which was always zero
From: Michael Haggerty @ 2013-01-14  9:10 UTC (permalink / raw)
  To: Jonathan Nieder; +Cc: Junio C Hamano, Jeff King, git
In-Reply-To: <20130114055721.GD3125@elie.Belkin>

On 01/14/2013 06:57 AM, Jonathan Nieder wrote:
> Michael Haggerty wrote:
> 
>> This removes the need for function imap_make_flags(), so delete it,
>> too.
> [...]
>> --- a/imap-send.c
>> +++ b/imap-send.c
> [...]
>>  	box = gctx->name;
>>  	prefix = !strcmp(box, "INBOX") ? "" : ctx->prefix;
>>  	cb.create = 0;
>> -	ret = imap_exec_m(ctx, &cb, "APPEND \"%s%s\" %s", prefix, box, flagstr);
>> +	ret = imap_exec_m(ctx, &cb, "APPEND \"%s%s\"", prefix, box);
> 
> Before this change, the command is
> 
> 	"APPEND" SP mailbox SP "{" msglen "}" CRLF
> 
> .  After this change, it leaves out the space before the brace.  If I
> understand RFC3501 correctly, the space is required.  Intentional?

No, not intentional.  I simply didn't follow far enough how the string
was used and mistakenly thought it was an entire command.  Thanks for
finding and fixing this.

(It probably would be less error-prone if v_issue_imap_cmd() would be
responsible for adding the extra space in the second branch of the
following if statement:

    if (!cmd->cb.data)
            bufl = nfsnprintf(buf, sizeof(buf), "%d %s\r\n", cmd->tag,
cmd->cmd);
    else
            bufl = nfsnprintf(buf, sizeof(buf), "%d %s{%d%s}\r\n",
                              cmd->tag, cmd->cmd, cmd->cb.dlen,
                              CAP(LITERALPLUS) ? "+" : "");

but that's a design choice that was already in the original version and
I don't care enough to change it.)

> With the below squashed in,
> Reviewed-by: Jonathan Nieder <jrnieder@gmail.com>
> 
> diff --git i/imap-send.c w/imap-send.c
> index 451d5027..f1c8f5a5 100644
> --- i/imap-send.c
> +++ w/imap-send.c
> @@ -1296,7 +1296,7 @@ static int imap_store_msg(struct store *gctx, struct msg_data *msg)
>  	box = gctx->name;
>  	prefix = !strcmp(box, "INBOX") ? "" : ctx->prefix;
>  	cb.create = 0;
> -	ret = imap_exec_m(ctx, &cb, "APPEND \"%s%s\"", prefix, box);
> +	ret = imap_exec_m(ctx, &cb, "APPEND \"%s%s\" ", prefix, box);
>  	imap->caps = imap->rcaps;
>  	if (ret != DRV_OK)
>  		return ret;
> 

ACK.

Michael

-- 
Michael Haggerty
mhagger@alum.mit.edu
http://softwareswirl.blogspot.com/

^ permalink raw reply

* Re: [PATCH] archive-tar: fix sanity check in config parsing
From: Joachim Schmitz @ 2013-01-14  8:17 UTC (permalink / raw)
  To: git
In-Reply-To: <20130113200044.GA3979@sigill.intra.peff.net>

Jeff King wrote:
> On Sun, Jan 13, 2013 at 06:42:01PM +0100, René Scharfe wrote:
>
>> When parsing these config variable names, we currently check that
>> the second dot is found nine characters into the name, disallowing
>> filter names with a length of five characters.  Additionally,
>> git archive crashes when the second dot is omitted:
>>
>> $ ./git -c tar.foo=bar archive HEAD >/dev/null
>> fatal: Data too large to fit into virtual memory space.
>>
>> Instead we should check if the second dot exists at all, or if
>> we only found the first one.
>
> Eek. Thanks for finding it. Your fix is obviously correct.
>
>> --- a/archive-tar.c
>> +++ b/archive-tar.c
>> @@ -335,7 +335,7 @@ static int tar_filter_config(const char *var,
>>  const char *value, void *data) if (prefixcmp(var, "tar."))
>>  return 0;
>>  dot = strrchr(var, '.');
>> - if (dot == var + 9)
>> + if (dot == var + 3)
>>  return 0;
>
> For the curious, the original version of the patch[1] read:
>
> +       if (prefixcmp(var, "tarfilter."))
> +               return 0;
> +       dot = strrchr(var, '.');
> +       if (dot == var + 9)
> +               return 0;
>
> and when I shortened the config section to "tar" in a re-roll of the
> series, I missed the corresponding change to the offset.

Wouldn't it then be better ti use strlen("tar") rather than a 3? Or at least 
a comment?

Bye, Jojo 

^ permalink raw reply

* Re: Announcing git-reparent
From: Junio C Hamano @ 2013-01-14  8:05 UTC (permalink / raw)
  To: Jonathan Nieder; +Cc: Mark Lodato, git list
In-Reply-To: <20130114071608.GL3125@elie.Belkin>

Jonathan Nieder <jrnieder@gmail.com> writes:

> Hi Mark,
>
> Mark Lodato wrote:
>
>> Create a new commit object that has the same tree and commit message as HEAD
>> but with a different set of parents.  If ``--no-reset`` is given, the full
>> object id of this commit is printed and the program exits
>
> I've been wishing for something like this for a long time.  I used to
> fake it using "cat-file commit", sed, and "hash-object -w" when
> stitching together poorly imported history using "git replace".
>
> Thanks for writing it.
>
> Ciao,
> Jonathan

The scriptq is simple enough, and from a cursory look, it may be
fine to throw it in contrib/ after some minor style fixes and such,
if many find it useful.

^ permalink raw reply

* Re: Announcing git-reparent
From: Piotr Krukowiecki @ 2013-01-14  8:03 UTC (permalink / raw)
  To: Jonathan Nieder; +Cc: Mark Lodato, git list
In-Reply-To: <20130114071608.GL3125@elie.Belkin>

Hello,

On Mon, Jan 14, 2013 at 8:16 AM, Jonathan Nieder <jrnieder@gmail.com> wrote:
> Hi Mark,
>
> Mark Lodato wrote:
>
>> Create a new commit object that has the same tree and commit message as HEAD
>> but with a different set of parents.  If ``--no-reset`` is given, the full
>> object id of this commit is printed and the program exits
>
> I've been wishing for something like this for a long time.  I used to
> fake it using "cat-file commit", sed, and "hash-object -w" when
> stitching together poorly imported history using "git replace".

Just wondering, is the result different than something like

git checkout commit_to_reparent
cp -r * ../snapshot/
git reset --hard new_parent
rm -r *
cp -r ../snapshot/* .
git add -A

(assumes 1 parent, does not cope with .dot files, and has probably
other small problems)

--
Piotr Krukowiecki

^ permalink raw reply

* [PATCH v2 8/6] t9600: adjust for new cvsimport
From: Junio C Hamano @ 2013-01-14  7:52 UTC (permalink / raw)
  To: git
In-Reply-To: <1358148351-31552-1-git-send-email-gitster@pobox.com>

The rewritten cvsimport does not skip the latest 10 minutes worth of
CVS commits by default, so there is no need to pass the "-a" option;
it will barf if it sees "-a".

Also it will do the merge itself, so there is no need to merge
"origin" ourselves, either.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
---

 * This is still untested and primarily to illustrate the concept
   introduced by the 5/6 patch, together with 6/6.  Testing by
   interested parties with a working cvsps 3 may be nice.  Something
   like:

    $ make CVSPS3_PATH=/path/to/your/cvsps3/bin/cvsps
    $ cd t && sh t9650-cvsimport3.sh

 t/t9600-cvsimport.sh | 24 +++++++++++++++++-------
 1 file changed, 17 insertions(+), 7 deletions(-)

diff --git a/t/t9600-cvsimport.sh b/t/t9600-cvsimport.sh
index 906cbdc..7b5a9a0 100755
--- a/t/t9600-cvsimport.sh
+++ b/t/t9600-cvsimport.sh
@@ -42,9 +42,13 @@ EOF
 	)
 '
 
-test_expect_success 'import a trivial module' '
+case "$TEST_CVSPS_VERSION" in
+3)	import_all= ;;
+*)	import_all=-a ;;
+esac &&
 
-	git cvsimport -a -R -z 0 -C module-git module &&
+test_expect_success 'import a trivial module' '
+	git cvsimport $import_all -R -z 0 -C module-git module &&
 	test_cmp module-cvs/o_fortuna module-git/o_fortuna
 
 '
@@ -90,8 +94,11 @@ test_expect_success 'update git module' '
 
 	(cd module-git &&
 	git config cvsimport.trackRevisions true &&
-	git cvsimport -a -z 0 module &&
-	git merge origin
+	git cvsimport $import_all -z 0 module &&
+	if test "$TEST_CVSPS_VERSION" = 2
+	then
+		git merge origin
+	fi
 	) &&
 	test_cmp module-cvs/o_fortuna module-git/o_fortuna
 
@@ -119,8 +126,11 @@ test_expect_success 'cvsimport.module config works' '
 	(cd module-git &&
 		git config cvsimport.module module &&
 		git config cvsimport.trackRevisions true &&
-		git cvsimport -a -z0 &&
-		git merge origin
+		git cvsimport $import_all -z0 &&
+		if test "$TEST_CVSPS_VERSION" = 2
+		then
+			git merge origin
+		fi
 	) &&
 	test_cmp module-cvs/tick module-git/tick
 
@@ -140,7 +150,7 @@ test_expect_success 'import from a CVS working tree' '
 	$CVS co -d import-from-wt module &&
 	(cd import-from-wt &&
 		git config cvsimport.trackRevisions false &&
-		git cvsimport -a -z0 &&
+		git cvsimport $import_all -z0 &&
 		echo 1 >expect &&
 		git log -1 --pretty=format:%s%n >actual &&
 		test_cmp actual expect
-- 
1.8.1.421.g6236851

^ permalink raw reply related

* [PATCH v2 7/6] t9600: further prepare for sharing
From: Junio C Hamano @ 2013-01-14  7:48 UTC (permalink / raw)
  To: git
In-Reply-To: <1358148351-31552-1-git-send-email-gitster@pobox.com>

When t9650, which dot-sources this script, really becomes ready to
test the new cvsimport, we no longer depend on having PERL to run
this test through it.  Move the PERL dependency to lib-cvs.sh
instead.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
 t/lib-cvs.sh         |  7 +++++++
 t/t9600-cvsimport.sh | 30 +++++++++++++++---------------
 2 files changed, 22 insertions(+), 15 deletions(-)

diff --git a/t/lib-cvs.sh b/t/lib-cvs.sh
index 3a55b8a..d2bf5bf 100644
--- a/t/lib-cvs.sh
+++ b/t/lib-cvs.sh
@@ -22,6 +22,9 @@ case "$TEST_CVSPS_VERSION" in
 	if test "$CVSPS2_PATH" = NoThanks
 	then
 		skip_all='skipping cvsimport tests, cvsps(2) not used'
+	elif ! test_have_prereq PERL
+	then
+		skip_all='skipping cvsimport tests, Perl not available'
 	else
 		case $($CVSPS2_PATH -h 2>&1 | sed -ne 's/cvsps version //p') in
 		2.1 | 2.2*)
@@ -39,6 +42,10 @@ case "$TEST_CVSPS_VERSION" in
 	if test "$CVSPS3_PATH" = NoThanks
 	then
 		skip_all='skipping cvsimport tests, cvsps(3) not used'
+	elif ! test_have_prereq PYTHON
+	then
+		# NEEDSWORK: we may need Python lower-bound prerequisite
+		skip_all='skipping cvsimport tests, Python not available'
 	else
 		case $($CVSPS3_PATH -h 2>&1 | sed -ne 's/cvsps version //p') in
 		3.*)
diff --git a/t/t9600-cvsimport.sh b/t/t9600-cvsimport.sh
index 4c384ff..906cbdc 100755
--- a/t/t9600-cvsimport.sh
+++ b/t/t9600-cvsimport.sh
@@ -3,14 +3,14 @@
 test_description='git cvsimport basic tests'
 . ./lib-cvs.sh
 
-test_expect_success PERL 'setup cvsroot environment' '
+test_expect_success 'setup cvsroot environment' '
 	CVSROOT=$(pwd)/cvsroot &&
 	export CVSROOT
 '
 
-test_expect_success PERL 'setup cvsroot' '$CVS init'
+test_expect_success 'setup cvsroot' '$CVS init'
 
-test_expect_success PERL 'setup a cvs module' '
+test_expect_success 'setup a cvs module' '
 
 	mkdir "$CVSROOT/module" &&
 	$CVS co -d module-cvs module &&
@@ -42,23 +42,23 @@ EOF
 	)
 '
 
-test_expect_success PERL 'import a trivial module' '
+test_expect_success 'import a trivial module' '
 
 	git cvsimport -a -R -z 0 -C module-git module &&
 	test_cmp module-cvs/o_fortuna module-git/o_fortuna
 
 '
 
-test_expect_success PERL 'pack refs' '(cd module-git && git gc)'
+test_expect_success 'pack refs' '(cd module-git && git gc)'
 
-test_expect_success PERL 'initial import has correct .git/cvs-revisions' '
+test_expect_success 'initial import has correct .git/cvs-revisions' '
 
 	(cd module-git &&
 	 git log --format="o_fortuna 1.1 %H" -1) > expected &&
 	test_cmp expected module-git/.git/cvs-revisions
 '
 
-test_expect_success PERL 'update cvs module' '
+test_expect_success 'update cvs module' '
 	(cd module-cvs &&
 	cat <<EOF >o_fortuna &&
 O Fortune,
@@ -86,7 +86,7 @@ EOF
 	)
 '
 
-test_expect_success PERL 'update git module' '
+test_expect_success 'update git module' '
 
 	(cd module-git &&
 	git config cvsimport.trackRevisions true &&
@@ -97,7 +97,7 @@ test_expect_success PERL 'update git module' '
 
 '
 
-test_expect_success PERL 'update has correct .git/cvs-revisions' '
+test_expect_success 'update has correct .git/cvs-revisions' '
 
 	(cd module-git &&
 	 git log --format="o_fortuna 1.1 %H" -1 HEAD^ &&
@@ -105,7 +105,7 @@ test_expect_success PERL 'update has correct .git/cvs-revisions' '
 	test_cmp expected module-git/.git/cvs-revisions
 '
 
-test_expect_success PERL 'update cvs module' '
+test_expect_success 'update cvs module' '
 
 	(cd module-cvs &&
 		echo 1 >tick &&
@@ -114,7 +114,7 @@ test_expect_success PERL 'update cvs module' '
 	)
 '
 
-test_expect_success PERL 'cvsimport.module config works' '
+test_expect_success 'cvsimport.module config works' '
 
 	(cd module-git &&
 		git config cvsimport.module module &&
@@ -126,7 +126,7 @@ test_expect_success PERL 'cvsimport.module config works' '
 
 '
 
-test_expect_success PERL 'second update has correct .git/cvs-revisions' '
+test_expect_success 'second update has correct .git/cvs-revisions' '
 
 	(cd module-git &&
 	 git log --format="o_fortuna 1.1 %H" -1 HEAD^^ &&
@@ -135,7 +135,7 @@ test_expect_success PERL 'second update has correct .git/cvs-revisions' '
 	test_cmp expected module-git/.git/cvs-revisions
 '
 
-test_expect_success PERL 'import from a CVS working tree' '
+test_expect_success 'import from a CVS working tree' '
 
 	$CVS co -d import-from-wt module &&
 	(cd import-from-wt &&
@@ -148,12 +148,12 @@ test_expect_success PERL 'import from a CVS working tree' '
 
 '
 
-test_expect_success PERL 'no .git/cvs-revisions created by default' '
+test_expect_success 'no .git/cvs-revisions created by default' '
 
 	! test -e import-from-wt/.git/cvs-revisions
 
 '
 
-test_expect_success PERL 'test entire HEAD' 'test_cmp_branch_tree master'
+test_expect_success 'test entire HEAD' 'test_cmp_branch_tree master'
 
 test_done
-- 
1.8.1.421.g6236851

^ permalink raw reply related

* Re: [PATCH v2 0/6] A smoother transition plan for cvsimport
From: Jonathan Nieder @ 2013-01-14  7:47 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git
In-Reply-To: <1358148351-31552-1-git-send-email-gitster@pobox.com>

Junio C Hamano wrote:

> Junio C Hamano (6):
>   Makefile: add description on PERL/PYTHON_PATH
>   cvsimport: allow setting a custom cvsps (2.x) program name
>   cvsimport: introduce a version-switch wrapper
>   cvsimport: start adding cvsps 3.x support
>   cvsimport: make tests reusable for cvsimport-3
>   cvsimport-3: add a sample test

Looks very sane.

^ permalink raw reply

* [PATCH v2 3/6] cvsimport: introduce a version-switch wrapper
From: Junio C Hamano @ 2013-01-14  7:25 UTC (permalink / raw)
  To: git
In-Reply-To: <1358148351-31552-1-git-send-email-gitster@pobox.com>

In preparation to have both old and new cvsimport during the
transition period, rename the cvsimport script to cvsimport-2
and introduce a small wrapper that we can later change it to
allow users to run either frontend (with their corresponding
cvsps backends).

Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
 .gitignore                                 | 1 +
 Makefile                                   | 9 ++++++++-
 git-cvsimport.perl => git-cvsimport-2.perl | 0
 git-cvsimport.sh                           | 5 +++++
 4 files changed, 14 insertions(+), 1 deletion(-)
 rename git-cvsimport.perl => git-cvsimport-2.perl (100%)
 create mode 100755 git-cvsimport.sh

diff --git a/.gitignore b/.gitignore
index aa258a6..8cb799c 100644
--- a/.gitignore
+++ b/.gitignore
@@ -40,6 +40,7 @@
 /git-credential-store
 /git-cvsexportcommit
 /git-cvsimport
+/git-cvsimport-2
 /git-cvsserver
 /git-daemon
 /git-diff
diff --git a/Makefile b/Makefile
index dd2a024..f3113a9 100644
--- a/Makefile
+++ b/Makefile
@@ -253,6 +253,9 @@ all::
 #
 # Define NO_PYTHON if you do not want Python scripts or libraries at all.
 #
+# Define CVSPS2_PATH if you cannot invoke cvsps (version 2.x) as "cvsps"
+# using your $PATH; if you do not have any, define CVSPS2_PATH=NoThanks.
+#
 # Define NO_TCLTK if you do not want Tcl/Tk GUI.
 #
 # The TCL_PATH variable governs the location of the Tcl interpreter
@@ -440,6 +443,7 @@ unexport CDPATH
 
 SCRIPT_SH += git-am.sh
 SCRIPT_SH += git-bisect.sh
+SCRIPT_SH += git-cvsimport.sh
 SCRIPT_SH += git-difftool--helper.sh
 SCRIPT_SH += git-filter-branch.sh
 SCRIPT_SH += git-lost-found.sh
@@ -468,12 +472,15 @@ SCRIPT_PERL += git-add--interactive.perl
 SCRIPT_PERL += git-difftool.perl
 SCRIPT_PERL += git-archimport.perl
 SCRIPT_PERL += git-cvsexportcommit.perl
-SCRIPT_PERL += git-cvsimport.perl
+ifneq ($(CVSPS2_PATH),NoThanks)
+SCRIPT_PERL += git-cvsimport-2.perl
+endif
 SCRIPT_PERL += git-cvsserver.perl
 SCRIPT_PERL += git-relink.perl
 SCRIPT_PERL += git-send-email.perl
 SCRIPT_PERL += git-svn.perl
 
+SCRIPT_PYTHON += git-p4.py
 SCRIPT_PYTHON += git-remote-testpy.py
 SCRIPT_PYTHON += git-p4.py
 
diff --git a/git-cvsimport.perl b/git-cvsimport-2.perl
similarity index 100%
rename from git-cvsimport.perl
rename to git-cvsimport-2.perl
diff --git a/git-cvsimport.sh b/git-cvsimport.sh
new file mode 100755
index 0000000..71ba11d
--- /dev/null
+++ b/git-cvsimport.sh
@@ -0,0 +1,5 @@
+#!/bin/sh
+
+GIT_CVSPS_VERSION=2
+
+exec git cvsimport-$GIT_CVSPS_VERSION "$@"
-- 
1.8.1.421.g6236851

^ permalink raw reply related

* [PATCH v2 6/6] cvsimport-3: add a sample test
From: Junio C Hamano @ 2013-01-14  7:25 UTC (permalink / raw)
  To: git
In-Reply-To: <1358148351-31552-1-git-send-email-gitster@pobox.com>

This is primarily for illustration to show how the support
introduced by the previous step can be used.

Some parts of t9600 needs to be made conditional to the value of
TEST_CVSPS_VERSION to avoid passing options the new cvsimport does
not need or understand, before this can become usable as a real
test.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
 t/t9650-cvsimport3.sh | 4 ++++
 1 file changed, 4 insertions(+)
 create mode 100755 t/t9650-cvsimport3.sh

diff --git a/t/t9650-cvsimport3.sh b/t/t9650-cvsimport3.sh
new file mode 100755
index 0000000..f7ca986
--- /dev/null
+++ b/t/t9650-cvsimport3.sh
@@ -0,0 +1,4 @@
+#!/bin/sh
+
+TEST_CVSPS_VERSION=3
+. ./t9600-cvsimport.sh
-- 
1.8.1.421.g6236851

^ permalink raw reply related

* [PATCH v2 4/6] cvsimport: start adding cvsps 3.x support
From: Junio C Hamano @ 2013-01-14  7:25 UTC (permalink / raw)
  To: git
In-Reply-To: <1358148351-31552-1-git-send-email-gitster@pobox.com>

The new cvsps 3.x series lacks support of some options cvsps 2.x
series had and used by cvsimport-2; add a replacement program from
the author of cvsps 3.x and allow users to choose it by setting the
GIT_CVSPS_VERSION environment variable to 3.  We would later add
support to auto-detect the version of installed cvsps to this code
when the environment variable is not set.

Note that in this step, cvsimport-3 that relies on cvsps 3.x does
not have any test coverage.  As cvsimport-3 supports most of the
command line options cvsimport-2, we should be able to tweak some of
the t96?? tests and run them with GIT_CVSPS_VERSION set to both 2
and 3, but that is a topic of later patches that should come on top.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
 Makefile           |  22 +++-
 git-cvsimport-3.py | 344 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 git-cvsimport.sh   |   4 +-
 3 files changed, 363 insertions(+), 7 deletions(-)
 create mode 100755 git-cvsimport-3.py

diff --git a/Makefile b/Makefile
index f3113a9..00bd3a6 100644
--- a/Makefile
+++ b/Makefile
@@ -256,6 +256,9 @@ all::
 # Define CVSPS2_PATH if you cannot invoke cvsps (version 2.x) as "cvsps"
 # using your $PATH; if you do not have any, define CVSPS2_PATH=NoThanks.
 #
+# Define CVSPS3_PATH if you cannot invoke cvsps (version 3.x) as "cvsps"
+# using your $PATH; if you do not have any, define CVSPS3_PATH=NoThanks.
+#
 # Define NO_TCLTK if you do not want Tcl/Tk GUI.
 #
 # The TCL_PATH variable governs the location of the Tcl interpreter
@@ -480,9 +483,11 @@ SCRIPT_PERL += git-relink.perl
 SCRIPT_PERL += git-send-email.perl
 SCRIPT_PERL += git-svn.perl
 
+ifneq ($(CVSPS3_PATH),NoThanks)
+SCRIPT_PYTHON += git-cvsimport-3.py
+endif
 SCRIPT_PYTHON += git-p4.py
 SCRIPT_PYTHON += git-remote-testpy.py
-SCRIPT_PYTHON += git-p4.py
 
 SCRIPTS = $(patsubst %.sh,%,$(SCRIPT_SH)) \
 	  $(patsubst %.perl,%,$(SCRIPT_PERL)) \
@@ -586,8 +591,11 @@ endif
 ifndef CVSPS2_PATH
 	CVSPS2_PATH = cvsps
 endif
+ifndef CVSPS3_PATH
+	CVSPS3_PATH = cvsps
+endif
 
-export PERL_PATH PYTHON_PATH CVSPS2_PATH
+export PERL_PATH PYTHON_PATH CVSPS2_PATH CVSPS3_PATH
 
 LIB_FILE = libgit.a
 XDIFF_LIB = xdiff/lib.a
@@ -1526,6 +1534,7 @@ PERL_PATH_SQ = $(subst ','\'',$(PERL_PATH))
 PYTHON_PATH_SQ = $(subst ','\'',$(PYTHON_PATH))
 TCLTK_PATH_SQ = $(subst ','\'',$(TCLTK_PATH))
 CVSPS2_PATH_SQ = $(subst ','\'',$(CVSPS2_PATH))
+CVSPS3_PATH_SQ = $(subst ','\'',$(CVSPS3_PATH))
 DIFF_SQ = $(subst ','\'',$(DIFF))
 
 LIBS = $(GITLIBS) $(EXTLIBS)
@@ -1768,12 +1777,14 @@ ifndef NO_PYTHON
 $(patsubst %.py,%,$(SCRIPT_PYTHON)): GIT-CFLAGS GIT-PREFIX GIT-PYTHON-VARS
 $(patsubst %.py,%,$(SCRIPT_PYTHON)): % : %.py
 	$(QUIET_GEN)$(RM) $@ $@+ && \
-	INSTLIBDIR=`MAKEFLAGS= $(MAKE) -C git_remote_helpers -s \
+	INSTLIBDIR_SQ=`MAKEFLAGS= $(MAKE) -C git_remote_helpers -s \
 		--no-print-directory prefix='$(prefix_SQ)' DESTDIR='$(DESTDIR_SQ)' \
-		instlibdir` && \
+		instlibdir | \
+		sed -e "s/'/'\''/g"` && \
 	sed -e '1s|#!.*python|#!$(PYTHON_PATH_SQ)|' \
 	    -e 's|\(os\.getenv("GITPYTHONLIB"\)[^)]*)|\1,"@@INSTLIBDIR@@")|' \
-	    -e 's|@@INSTLIBDIR@@|'"$$INSTLIBDIR"'|g' \
+	    -e 's|@@CVSPS3_PATH@@|$(CVSPS3_PATH_SQ)|g' \
+	    -e 's|@@INSTLIBDIR@@|'"$$INSTLIBDIR_SQ"'|g' \
 	    $@.py >$@+ && \
 	chmod +x $@+ && \
 	mv $@+ $@
@@ -2119,6 +2130,7 @@ GIT-BUILD-OPTIONS: FORCE
 	@echo SHELL_PATH=\''$(subst ','\'',$(SHELL_PATH_SQ))'\' >$@
 	@echo PERL_PATH=\''$(subst ','\'',$(PERL_PATH_SQ))'\' >>$@
 	@echo CVSPS2_PATH=\''$(subst ','\'',$(CVSPS2_PATH_SQ))'\' >>$@
+	@echo CVSPS3_PATH=\''$(subst ','\'',$(CVSPS3_PATH_SQ))'\' >>$@
 	@echo DIFF=\''$(subst ','\'',$(subst ','\'',$(DIFF)))'\' >>$@
 	@echo PYTHON_PATH=\''$(subst ','\'',$(PYTHON_PATH_SQ))'\' >>$@
 	@echo TAR=\''$(subst ','\'',$(subst ','\'',$(TAR)))'\' >>$@
diff --git a/git-cvsimport-3.py b/git-cvsimport-3.py
new file mode 100755
index 0000000..57f13b7
--- /dev/null
+++ b/git-cvsimport-3.py
@@ -0,0 +1,344 @@
+#!/usr/bin/env python
+#
+# Import CVS history into git
+#
+# Intended to be a near-workalike of Matthias Urlichs's Perl implementation.
+#
+# By Eric S. Raymond <esr@thyrsus.com>, December 2012
+# May be redistributed under the license of the git project.
+
+import sys
+
+if sys.hexversion < 0x02060000:
+    sys.stderr.write("git cvsimport: requires Python 2.6 or later.\n")
+    sys.exit(1)
+
+import os, getopt, subprocess, tempfile, shutil
+
+DEBUG_COMMANDS = 1
+
+class Fatal(Exception):
+    "Unrecoverable error."
+    def __init__(self, msg):
+        Exception.__init__(self)
+        self.msg = msg
+
+def do_or_die(dcmd, legend=""):
+    "Either execute a command or raise a fatal exception."
+    if legend:
+        legend = " "  + legend
+    if verbose >= DEBUG_COMMANDS:
+        sys.stdout.write("git cvsimport: executing '%s'%s\n" % (dcmd, legend))
+    try:
+        retcode = subprocess.call(dcmd, shell=True)
+        if retcode < 0:
+            raise Fatal("git cvsimport: child was terminated by signal %d." % -retcode)
+        elif retcode != 0:
+            raise Fatal("git cvsimport: child returned %d." % retcode)
+    except (OSError, IOError) as e:
+        raise Fatal("git cvsimport: execution of %s%s failed: %s" % (dcmd, legend, e))
+
+def capture_or_die(dcmd, legend=""):
+    "Either execute a command and capture its output or die."
+    if legend:
+        legend = " "  + legend
+    if verbose >= DEBUG_COMMANDS:
+        sys.stdout.write("git cvsimport: executing '%s'%s\n" % (dcmd, legend))
+    try:
+        return subprocess.check_output(dcmd, shell=True)
+    except subprocess.CalledProcessError as e:
+        if e.returncode < 0:
+            sys.stderr.write("git cvsimport: child was terminated by signal %d." % -e.returncode)
+        elif e.returncode != 0:
+            sys.stderr.write("git cvsimport: child returned %d." % e.returncode)
+        sys.exit(1)
+
+class cvsps:
+    "Method class for cvsps back end."
+
+    cvsps = "@@CVSPS3_PATH@@"
+    def __init__(self):
+        self.opts = ""
+        self.revmap = None
+    def set_repo(self, val):
+        "Set the repository root option."
+        if not val.startswith(":"):
+            if not val.startswith(os.sep):
+                val = os.path.abspath(val)
+            val = ":local:" + val
+        self.opts += " --root '%s'" % val
+    def set_authormap(self, val):
+        "Set the author-map file."
+        self.opts += " -A '%s'" % val
+    def set_fuzz(self, val):
+        "Set the commit-similarity window."
+        self.opts += " -z %s" % val
+    def set_nokeywords(self):
+        "Suppress CVS keyword expansion."
+        self.opts += " -k"
+    def add_opts(self, val):
+        "Add options to the engine command line."
+        self.opts += " " + val
+    def set_exclusion(self, val):
+        "Set a file exclusion regexp."
+        self.opts += " -n -f '%s'" % val
+    def set_after(self, val):
+        "Set a date threshold for incremental import."
+        self.opts += " -d '%s'" % val
+    def set_revmap(self, val):
+        "Set the file to which the engine should dump a reference map."
+        self.revmap = val
+        self.opts += " -R '%s'" % self.revmap
+    def set_module(self, val):
+        "Set the module to query."
+        self.opts += " " + val
+    def command(self):
+        "Emit the command implied by all previous options."
+        return self.cvsps + "--fast-export " + self.opts
+
+class cvs2git:
+    "Method class for cvs2git back end."
+    def __init__(self):
+        self.opts = ""
+        self.modulepath = "."
+    def set_authormap(self, _val):
+        "Set the author-map file."
+        sys.stderr.write("git cvsimport: author maping is not supported with cvs2git.\n")
+        sys.exit(1)
+    def set_repo(self, _val):
+        "Set the repository root option."
+        sys.stderr.write("git cvsimport: cvs2git must run within a repository checkout directory.\n")
+        sys.exit(1)
+    def set_fuzz(self, _val):
+        "Set the commit-similarity window."
+        sys.stderr.write("git cvsimport: fuzz setting is not supported with cvs2git.\n")
+        sys.exit(1)
+    def set_nokeywords(self):
+        "Suppress CVS keyword expansion."
+        self.opts += " --keywords-off"
+    def add_opts(self, val):
+        "Add options to the engine command line."
+        self.opts += " " + val
+    def set_exclusion(self, val):
+        "Set a file exclusion regexp."
+        self.opts += " --exclude='%s'" % val
+    def set_after(self, _val):
+        "Set a date threshold for incremental import."
+        sys.stderr.write("git cvsimport: incremental import is not supported with cvs2git.\n")
+        sys.exit(1)
+    def set_revmap(self, _val):
+        "Set the file to which the engine should dump a reference map."
+        sys.stderr.write("git cvsimport: can't get a reference map from cvs2git.\n")
+        sys.exit(1)
+    def set_module(self, val):
+        "Set the module to query."
+        self.modulepath = " " + val
+    def command(self):
+        "Emit the command implied by all previous options."
+        return "(cvs2git --username=git-cvsimport --quiet --quiet --blobfile={0} --dumpfile={1} {2} {3} && cat {0} {1} && rm {0} {1})".format(tempfile.mkstemp()[1], tempfile.mkstemp()[1], self.opts, self.modulepath)
+
+class filesource:
+    "Method class for file-source back end."
+    def __init__(self, filename):
+        self.filename = filename
+    def __complain(self, legend):
+        sys.stderr.write("git cvsimport: %s with file source.\n" % legend)
+        sys.exit(1)
+    def set_repo(self, _val):
+        "Set the repository root option."
+        self.__complain("repository can't be set")
+    def set_authormap(self, _val):
+        "Set the author-map file."
+        sys.stderr.write("git cvsimport: author mapping is not supported with filesource.\n")
+        sys.exit(1)
+    def set_fuzz(self, _val):
+        "Set the commit-similarity window."
+        self.__complain("fuzz can't be set")
+    def set_nokeywords(self, _val):
+        "Suppress CVS keyword expansion."
+        self.__complain("keyword suppression can't be set")
+    def add_opts(self, _val):
+        "Add options to the engine command line."
+        self.__complain("other options can't be set")
+    def set_exclusion(self, _val):
+        "Set a file exclusion regexp."
+        self.__complain("exclusions can't be set")
+    def set_after(self, _val):
+        "Set a date threshold for incremental import."
+        pass
+    def set_revmap(self, _val):
+        "Set the file to which the engine should dump a reference map."
+        sys.stderr.write("git cvsimport: can't get a reference map from cvs2git.\n")
+        sys.exit(1)
+    def set_module(self, _val):
+        "Set the module to query."
+        self.__complain("module can't be set")
+    def command(self):
+        "Emit the command implied by all previous options."
+        return "cat " + self.filename
+
+if __name__ == '__main__':
+    if sys.hexversion < 0x02060000:
+        sys.stderr.write("git cvsimport: requires Python 2.6 or later.\n")
+        sys.exit(1)
+    (options, arguments) = getopt.getopt(sys.argv[1:], "vbe:d:C:r:o:ikus:p:z:P:S:aL:A:Rh")
+    verbose = 0
+    bare = False
+    root = None
+    outdir = os.getcwd()
+    remotize = False
+    import_only = False
+    underscore_to_dot = False
+    slashsubst = None
+    authormap = None
+    revisionmap = False
+    backend = cvsps()
+    for (opt, val) in options:
+        if opt == '-v':
+            verbose += 1
+        elif opt == '-b':
+            bare = True
+        elif opt == '-e':
+            for cls in (cvsps, cvs2git):
+                if cls.__name__ == val:
+                    backend = cls()
+                    break
+            else:
+                sys.stderr.write("git cvsimport: unknown engine %s.\n" % val)
+                sys.exit(1)
+        elif opt == '-d':
+            backend.set_repo(val)
+        elif opt == '-C':
+            outdir = val
+        elif opt == '-r':
+            remotize = True
+        elif opt == '-o':
+            sys.stderr.write("git cvsimport: -o is no longer supported.\n")
+            sys.exit(1)
+        elif opt == '-i':
+            import_only = True
+        elif opt == '-k':
+            backend.set_nokeywords()
+        elif opt == '-u':
+            underscore_to_dot = True
+        elif opt == '-s':
+            slashsubst = val
+        elif opt == '-p':
+            backend.add_opts(val.replace(",", " "))
+        elif opt == '-z':
+            backend.set_fuzz(val)
+        elif opt == '-P':
+            backend = filesource(val)
+            sys.exit(1)
+        elif opt in ('-m', '-M'):
+            sys.stderr.write("git cvsimport: -m and -M are no longer supported: use reposurgeon instead.\n")
+            sys.exit(1)
+        elif opt == '-S':
+            backend.set_exclusion(val)
+        elif opt == '-a':
+            sys.stderr.write("git cvsimport: -a is no longer supported.\n")
+            sys.exit(1)
+        elif opt == '-L':
+            sys.stderr.write("git cvsimport: -L is no longer supported.\n")
+            sys.exit(1)
+        elif opt == '-A':
+            authormap = os.path.abspath(val)
+        elif opt == '-R':
+            revisionmap = True
+        else:
+            print """\
+git cvsimport [-A <author-conv-file>] [-C <git_repository>] [-b] [-d <CVSROOT>]
+     [-e engine] [-h] [-i] [-k] [-p <options-for-cvsps>] [-P <source-file>]
+     [-r <remote>] [-R] [-s <subst>] [-S <regex>] [-u] [-v] [-z <fuzz>]
+     [<CVS_module>]
+"""
+    def metadata(fn, outdir='.'):
+        if bare:
+            return os.path.join(outdir, fn)
+        else:
+            return os.path.join(outdir, ".git", fn)
+
+    try:
+        if outdir:
+            try:
+                # If the output directory does not exist, create it
+                # and initialize it as a git repository.
+                os.mkdir(outdir)
+                do_or_die("git init --quiet " + outdir)
+            except OSError:
+                # Otherwise, assume user wants incremental import.
+                if not bare and not os.path.exists(os.path.join(outdir, ".git")):
+                    raise Fatal("output directory is not a git repository")
+                threshold = capture_or_die("git log -1 --format=%ct").strip()
+                backend.set_after(threshold)
+        if revisionmap:
+            backend.set_revmap(tempfile.mkstemp()[1])
+            markmap = tempfile.mkstemp()[1]
+        if arguments:
+            backend.set_module(arguments[0])
+        gitopts = ""
+        if bare:
+            gitopts += " --bare"
+        if revisionmap:
+            gitopts += " --export-marks='%s'" % markmap
+        if authormap:
+            shutil.copyfile(authormap, metadata("cvs-authors", outdir))
+        if os.path.exists(metadata("cvs-authors", outdir)):
+            backend.set_authormap(metadata("cvs-authors", outdir))
+        do_or_die("%s | (cd %s >/dev/null; git fast-import --quiet %s)" \
+                  % (backend.command(), outdir, gitopts))
+        os.chdir(outdir)
+        if underscore_to_dot or slashsubst:
+            tagnames = capture_or_die("git tag -l")
+            for tag in tagnames.split():
+                if tag:
+                    changed = tag
+                    if underscore_to_dot:
+                        changed = changed.replace("_", ".")
+                    if slashsubst:
+                        changed = changed.replace(os.sep, slashsubst)
+                    if changed != tag:
+                        do_or_die("git tag -f %s %s >/dev/null" % (tag, changed))
+        if underscore_to_dot or slashsubst or remotize:
+            branchnames = capture_or_die("git branch -l")
+            for branch in branchnames.split():
+                if branch:
+                    # Ugh - fragile dependency on branch -l output format
+                    branch = branch[2:]
+                    changed = branch
+                    if underscore_to_dot:
+                        changed = changed.replace("_", ".")
+                    if slashsubst:
+                        changed = changed.replace(os.sep, slashsubst)
+                    if remotize:
+                        changed = os.path.join("remotes", remotize, branch)
+                    if changed != branch:
+                        do_or_die("branch --m %s %s >/dev/null" % (branch, changed))
+        if revisionmap:
+            refd = {}
+            for line in open(backend.revmap):
+                if line.startswith("#"):
+                    continue
+                (fn, rev, mark) = line.split()
+                refd[(fn, rev)] = mark
+            markd = {}
+            for line in open(markmap):
+                if line.startswith("#"):
+                    continue
+                (mark, hashd) = line.split()
+                markd[mark] = hashd
+            with open(metadata("cvs-revisions"), "a") as wfp:
+                for ((fn, rev), val) in refd.items():
+                    if val in markd:
+                        wfp.write("%s %s %s\n" % (fn, rev, markd[val]))
+            os.remove(markmap)
+            os.remove(backend.revmap)
+        if not import_only and not bare:
+            do_or_die("git checkout -q")
+    except Fatal, err:
+        sys.stderr.write("git_cvsimport: " + err.msg + "\n")
+        sys.exit(1)
+    except KeyboardInterrupt:
+        pass
+
+# end
diff --git a/git-cvsimport.sh b/git-cvsimport.sh
index 71ba11d..52ce112 100755
--- a/git-cvsimport.sh
+++ b/git-cvsimport.sh
@@ -1,5 +1,5 @@
 #!/bin/sh
 
-GIT_CVSPS_VERSION=2
+: ${GIT_CVSPS_VERSION=2}
 
-exec git cvsimport-$GIT_CVSPS_VERSION "$@"
+exec git "cvsimport-$GIT_CVSPS_VERSION" "$@"
-- 
1.8.1.421.g6236851

^ permalink raw reply related

* [PATCH v2 5/6] cvsimport: make tests reusable for cvsimport-3
From: Junio C Hamano @ 2013-01-14  7:25 UTC (permalink / raw)
  To: git
In-Reply-To: <1358148351-31552-1-git-send-email-gitster@pobox.com>

This way, a dual-use test can be dot-sourced into a new test script
after defining GIT_CVSPS_VERSION=3 to test that the new cvsimport
with cvsps (3.x) works on simple test histories that old cvsimport
can grok correctly.

Also allow CVSPS2_PATH and CVSPS3_PATH to be defined as "NoThanks"
to cause the tests in t96?? series to be skipped.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
 t/lib-cvs.sh | 57 +++++++++++++++++++++++++++++++++++++++++++++++----------
 1 file changed, 47 insertions(+), 10 deletions(-)

diff --git a/t/lib-cvs.sh b/t/lib-cvs.sh
index bdab63c..3a55b8a 100644
--- a/t/lib-cvs.sh
+++ b/t/lib-cvs.sh
@@ -1,5 +1,8 @@
 #!/bin/sh
 
+: ${TEST_CVSPS_VERSION=2}
+export TEST_CVSPS_VERSION
+
 . ./test-lib.sh
 
 unset CVS_SERVER
@@ -13,22 +16,56 @@ fi
 CVS="cvs -f"
 export CVS
 
-CVSPS="$CVSPS2_PATH"
-
-cvsps_version=`$CVSPS -h 2>&1 | sed -ne 's/cvsps version //p'`
-case "$cvsps_version" in
-2.1 | 2.2*)
+skip_all=
+case "$TEST_CVSPS_VERSION" in
+2)
+	if test "$CVSPS2_PATH" = NoThanks
+	then
+		skip_all='skipping cvsimport tests, cvsps(2) not used'
+	else
+		case $($CVSPS2_PATH -h 2>&1 | sed -ne 's/cvsps version //p') in
+		2.1 | 2.2*)
+			;;
+		'')
+			skip_all='skipping cvsimport tests, cvsps(2) not found'
+			;;
+		*)
+			skip_all='skipping cvsimport tests, unsupported cvsps(2)'
+			;;
+		esac
+	fi
 	;;
-'')
-	skip_all='skipping cvsimport tests, cvsps not found'
-	test_done
+3)
+	if test "$CVSPS3_PATH" = NoThanks
+	then
+		skip_all='skipping cvsimport tests, cvsps(3) not used'
+	else
+		case $($CVSPS3_PATH -h 2>&1 | sed -ne 's/cvsps version //p') in
+		3.*)
+			;;
+		'')
+			skip_all='skipping cvsimport tests, cvsps(3) not found'
+			;;
+		*)
+			skip_all='skipping cvsimport tests, unsupported cvsps(3)'
+			;;
+		esac
+	fi
 	;;
 *)
-	skip_all='skipping cvsimport tests, unsupported cvsps version'
-	test_done
+	echo >&2 "Bug in test: set TEST_CVSPS_VESION to either 2 or 3"
+	exit 1
 	;;
 esac
 
+GIT_CVSPS_VERSION=$TEST_CVSPS_VERSION
+export GIT_CVSPS_VERSION
+
+if test -n "$skip_all"
+then
+	test_done
+fi
+
 setup_cvs_test_repository () {
 	CVSROOT="$(pwd)/.cvsroot" &&
 	cp -r "$TEST_DIRECTORY/$1/cvsroot" "$CVSROOT" &&
-- 
1.8.1.421.g6236851

^ permalink raw reply related

* [PATCH v2 2/6] cvsimport: allow setting a custom cvsps (2.x) program name
From: Junio C Hamano @ 2013-01-14  7:25 UTC (permalink / raw)
  To: git
In-Reply-To: <1358148351-31552-1-git-send-email-gitster@pobox.com>

Distros may ship old cvsps under a different name, or the user may
install it outside the normal $PATH.  Allow setting CVSPS2_PATH from
the build environment.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
 Makefile           | 9 +++++++--
 git-cvsimport.perl | 4 +++-
 t/lib-cvs.sh       | 4 +++-
 3 files changed, 13 insertions(+), 4 deletions(-)

diff --git a/Makefile b/Makefile
index 1695075..dd2a024 100644
--- a/Makefile
+++ b/Makefile
@@ -576,9 +576,11 @@ endif
 ifndef PYTHON_PATH
 	PYTHON_PATH = /usr/bin/python
 endif
+ifndef CVSPS2_PATH
+	CVSPS2_PATH = cvsps
+endif
 
-export PERL_PATH
-export PYTHON_PATH
+export PERL_PATH PYTHON_PATH CVSPS2_PATH
 
 LIB_FILE = libgit.a
 XDIFF_LIB = xdiff/lib.a
@@ -1516,6 +1518,7 @@ SHELL_PATH_SQ = $(subst ','\'',$(SHELL_PATH))
 PERL_PATH_SQ = $(subst ','\'',$(PERL_PATH))
 PYTHON_PATH_SQ = $(subst ','\'',$(PYTHON_PATH))
 TCLTK_PATH_SQ = $(subst ','\'',$(TCLTK_PATH))
+CVSPS2_PATH_SQ = $(subst ','\'',$(CVSPS2_PATH))
 DIFF_SQ = $(subst ','\'',$(DIFF))
 
 LIBS = $(GITLIBS) $(EXTLIBS)
@@ -1729,6 +1732,7 @@ $(patsubst %.perl,%,$(SCRIPT_PERL)): % : %.perl GIT-VERSION-FILE
 	    -e '	H' \
 	    -e '	x' \
 	    -e '}' \
+	    -e 's|@@CVSPS2_PATH@@|$(CVSPS2_PATH_SQ)|g' \
 	    -e 's/@@GIT_VERSION@@/$(GIT_VERSION)/g' \
 	    $@.perl >$@+ && \
 	chmod +x $@+ && \
@@ -2107,6 +2111,7 @@ GIT-LDFLAGS: FORCE
 GIT-BUILD-OPTIONS: FORCE
 	@echo SHELL_PATH=\''$(subst ','\'',$(SHELL_PATH_SQ))'\' >$@
 	@echo PERL_PATH=\''$(subst ','\'',$(PERL_PATH_SQ))'\' >>$@
+	@echo CVSPS2_PATH=\''$(subst ','\'',$(CVSPS2_PATH_SQ))'\' >>$@
 	@echo DIFF=\''$(subst ','\'',$(subst ','\'',$(DIFF)))'\' >>$@
 	@echo PYTHON_PATH=\''$(subst ','\'',$(PYTHON_PATH_SQ))'\' >>$@
 	@echo TAR=\''$(subst ','\'',$(subst ','\'',$(TAR)))'\' >>$@
diff --git a/git-cvsimport.perl b/git-cvsimport.perl
index 0a31ebd..ad460a5 100755
--- a/git-cvsimport.perl
+++ b/git-cvsimport.perl
@@ -33,6 +33,8 @@
 our ($opt_h,$opt_o,$opt_v,$opt_k,$opt_u,$opt_d,$opt_p,$opt_C,$opt_z,$opt_i,$opt_P, $opt_s,$opt_m,@opt_M,$opt_A,$opt_S,$opt_L, $opt_a, $opt_r, $opt_R);
 my (%conv_author_name, %conv_author_email, %conv_author_tz);
 
+my $cvsps2 = "@@CVSPS2_PATH@@";
+
 sub usage(;$) {
 	my $msg = shift;
 	print(STDERR "Error: $msg\n") if $msg;
@@ -751,7 +753,7 @@ sub munge_user_filename {
 		unless (defined($opt_p) && $opt_p =~ m/--no-cvs-direct/) {
 			push @opt, '--cvs-direct';
 		}
-		exec("cvsps","--norc",@opt,"-u","-A",'--root',$opt_d,$cvs_tree);
+		exec($cvsps2,"--norc",@opt,"-u","-A",'--root',$opt_d,$cvs_tree);
 		die "Could not start cvsps: $!\n";
 	}
 	($cvspsfh, $cvspsfile) = tempfile('gitXXXXXX', SUFFIX => '.cvsps',
diff --git a/t/lib-cvs.sh b/t/lib-cvs.sh
index 44263ad..bdab63c 100644
--- a/t/lib-cvs.sh
+++ b/t/lib-cvs.sh
@@ -13,7 +13,9 @@ fi
 CVS="cvs -f"
 export CVS
 
-cvsps_version=`cvsps -h 2>&1 | sed -ne 's/cvsps version //p'`
+CVSPS="$CVSPS2_PATH"
+
+cvsps_version=`$CVSPS -h 2>&1 | sed -ne 's/cvsps version //p'`
 case "$cvsps_version" in
 2.1 | 2.2*)
 	;;
-- 
1.8.1.421.g6236851

^ permalink raw reply related

* [PATCH v2 0/6] A smoother transition plan for cvsimport
From: Junio C Hamano @ 2013-01-14  7:25 UTC (permalink / raw)
  To: git
In-Reply-To: <7v8v7wiv3a.fsf@alter.siamese.dyndns.org>

The theme is the same as the previous 3-patch series ($gmane/213415).

The first one is unrelated.

The last two are new, adding the "dual-use test" framework hinted
at the end of the previous round.

Oh, also this time the series is formatted with "format-patch -M",
to avoid overwhelming the readers with the rename.

Junio C Hamano (6):
  Makefile: add description on PERL/PYTHON_PATH
  cvsimport: allow setting a custom cvsps (2.x) program name
  cvsimport: introduce a version-switch wrapper
  cvsimport: start adding cvsps 3.x support
  cvsimport: make tests reusable for cvsimport-3
  cvsimport-3: add a sample test

 .gitignore                                 |   1 +
 Makefile                                   |  43 +++-
 git-cvsimport.perl => git-cvsimport-2.perl |   4 +-
 git-cvsimport-3.py                         | 344 +++++++++++++++++++++++++++++
 git-cvsimport.sh                           |   5 +
 t/lib-cvs.sh                               |  55 ++++-
 t/t9650-cvsimport3.sh                      |   4 +
 7 files changed, 440 insertions(+), 16 deletions(-)
 rename git-cvsimport.perl => git-cvsimport-2.perl (99%)
 create mode 100755 git-cvsimport-3.py
 create mode 100755 git-cvsimport.sh
 create mode 100755 t/t9650-cvsimport3.sh

-- 
1.8.1.421.g6236851

^ permalink raw reply

* [PATCH v2 1/6] Makefile: add description on PERL/PYTHON_PATH
From: Junio C Hamano @ 2013-01-14  7:25 UTC (permalink / raw)
  To: git
In-Reply-To: <1358148351-31552-1-git-send-email-gitster@pobox.com>

Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
 Makefile | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/Makefile b/Makefile
index 1b30d7b..1695075 100644
--- a/Makefile
+++ b/Makefile
@@ -241,11 +241,16 @@ all::
 # apostrophes to be ASCII so that cut&pasting examples to the shell
 # will work.
 #
+# Define PERL_PATH to the path of your Perl binary (usually /usr/bin/perl).
+#
 # Define NO_PERL_MAKEMAKER if you cannot use Makefiles generated by perl's
 # MakeMaker (e.g. using ActiveState under Cygwin).
 #
 # Define NO_PERL if you do not want Perl scripts or libraries at all.
 #
+# Define PYTHON_PATH to the path of your Python binary (often /usr/bin/python
+# but /usr/bin/python2.7 on some platforms).
+#
 # Define NO_PYTHON if you do not want Python scripts or libraries at all.
 #
 # Define NO_TCLTK if you do not want Tcl/Tk GUI.
-- 
1.8.1.421.g6236851

^ permalink raw reply related

* Re: Announcing git-reparent
From: Jonathan Nieder @ 2013-01-14  7:16 UTC (permalink / raw)
  To: Mark Lodato; +Cc: git list
In-Reply-To: <CAHREChhnf44CprHnS=z9KO5aOkfDPSG6Xb2GU=Kvaz38eTgbUg@mail.gmail.com>

Hi Mark,

Mark Lodato wrote:

> Create a new commit object that has the same tree and commit message as HEAD
> but with a different set of parents.  If ``--no-reset`` is given, the full
> object id of this commit is printed and the program exits

I've been wishing for something like this for a long time.  I used to
fake it using "cat-file commit", sed, and "hash-object -w" when
stitching together poorly imported history using "git replace".

Thanks for writing it.

Ciao,
Jonathan

^ permalink raw reply

* Re: git list files
From: Jonathan Nieder @ 2013-01-14  7:08 UTC (permalink / raw)
  To: Jeff King
  Cc: Стойчо Слепцов,
	git, Jakub Narębski, Matthieu Moy
In-Reply-To: <20130113201027.GA4436@sigill.intra.peff.net>

Jeff King wrote:

> As far as I recall, that script works. However, I have a pure-C
> blame-tree implementation that is much faster, which may also be of
> interest. I need to clean up and put a few finishing touches on it to
> send it to the list, but it has been in production at GitHub for a few
> months. You can find it here:
>
>   git://github.com/peff/git jk/blame-tree

Oh, neat.  Would that make sense as an item in
<https://git.wiki.kernel.org/index.php/Interfaces,_frontends,_and_tools>?

^ permalink raw reply

* Re: [PATCH 00/14] Remove unused code from imap-send.c
From: Jonathan Nieder @ 2013-01-14  6:57 UTC (permalink / raw)
  To: Michael Haggerty; +Cc: Junio C Hamano, Jeff King, git
In-Reply-To: <1358141566-26081-1-git-send-email-mhagger@alum.mit.edu>

Michael Haggerty wrote:

>  imap-send.c | 286 +++++++++---------------------------------------------------
>  1 file changed, 39 insertions(+), 247 deletions(-)

See my replies for comments on patches 1, 6, 9, 11, and 12.  The rest
are

Reviewed-by: Jonathan Nieder <jrnieder@gmail.com>

The series is tasteful and easy to follow and it's hard to argue with
the resulting code reduction.  Thanks for a pleasant read.

^ permalink raw reply

* Re: [PATCH 12/14] imap-send.c: use struct imap_store instead of struct store
From: Jonathan Nieder @ 2013-01-14  6:52 UTC (permalink / raw)
  To: Michael Haggerty; +Cc: Junio C Hamano, Jeff King, git
In-Reply-To: <1358141566-26081-13-git-send-email-mhagger@alum.mit.edu>

Michael Haggerty wrote:

> In fact, all struct store instances are upcasts of struct imap_store
> anyway, so stop making the distinction.

Nice.

It is tempting to fold "struct store" into "struct imap_store" at the same
time, as in

	struct imap_store {
		struct {
			struct store_conf *conf; /* foreign */

			/* currently open mailbox */
			const char *name; /* foreign! maybe preset? */
			char *path; /* own */
			struct message *msgs; /* own */
			int uidvalidity;
			unsigned char opts; /* maybe preset? */
			/* note that the following do _not_ reflect stats from msgs, but mailbox totals */
			int count; /* # of messages */
			int recent; /* # of recent messages - don't trust this beyond the initial read */
		} gen;
		int uidvalidity;
		struct imap *imap;
		const char *prefix;
		unsigned /*currentnc:1,*/ trashnc:1;
	};

to help the reader verify that objects of type "struct store" are not
used except through the gen field of imap_store after this change.
But verifying directly worked fine, so never mind. ;-)

^ permalink raw reply

* Re: [PATCH 11/14] imap-send.c: simplify logic in lf_to_crlf()
From: Jonathan Nieder @ 2013-01-14  6:47 UTC (permalink / raw)
  To: Michael Haggerty; +Cc: Junio C Hamano, Jeff King, git
In-Reply-To: <1358141566-26081-12-git-send-email-mhagger@alum.mit.edu>

Michael Haggerty wrote:

> Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
> ---
>  imap-send.c | 31 ++++++++-----------------------
>  1 file changed, 8 insertions(+), 23 deletions(-)

I like the code reduction, but my nighttime brain doesn't have the
patience to understand the preimage or postimage, and the above
description doesn't give any hints.  Maybe a comment right above the
function definition describing its contract would help to prepare the
daunted reader (and to let the uninterested understand call sites
without reading the implementation).

Thanks,
Jonathan

^ permalink raw reply

* Re: [PATCH 09/14] imap-send.c: remove namespace fields from struct imap
From: Jonathan Nieder @ 2013-01-14  6:43 UTC (permalink / raw)
  To: Michael Haggerty; +Cc: Junio C Hamano, Jeff King, git
In-Reply-To: <1358141566-26081-10-git-send-email-mhagger@alum.mit.edu>

Michael Haggerty wrote:

[...]
> @@ -722,9 +667,9 @@ static int get_cmd_result(struct imap_store *ctx, struct imap_cmd *tcmd)
>  			}
>  
>  			if (!strcmp("NAMESPACE", arg)) {
> -				imap->ns_personal = parse_list(&cmd);
> -				imap->ns_other = parse_list(&cmd);
> -				imap->ns_shared = parse_list(&cmd);
> +				skip_list(&cmd);
> +				skip_list(&cmd);
> +				skip_list(&cmd);

This codepath would only be triggered if we emit a NAMESPACE command,
right?  If I am understanding correctly, a comment could make this
less mystifying:

				/* rfc2342 NAMESPACE response. */
				skip_list(&cmd);	/* Personal mailboxes */
				skip_list(&cmd);	/* Others' mailboxes */
				skip_list(&cmd);	/* Shared mailboxes */

Though that's probably academic since hopefully this if branch
will die soon. :)

The rest of the patch is clear and pleasant and also looks correct.

With the above change,
Reviewed-by: Jonathan Nieder <jrnieder@gmail.com>

Thanks.

^ permalink raw reply

* Re: cvs-fast-export release announcement
From: Jonathan Nieder @ 2013-01-14  6:28 UTC (permalink / raw)
  To: Eric S. Raymond; +Cc: git, vcs-fast-import-devs, Johan Herland
In-Reply-To: <20130114001300.57D3640661@snark.thyrsus.com>

Eric S. Raymond wrote:

> cvs-fast-export.  Project page, with links to documentation and the
> public repository, is at <http://www.catb.org/esr/cvs-fast-export/>.

Yay, thanks for building this.

^ permalink raw reply

* Re: [PATCH 06/14] imap-send.c: remove some unused fields from struct store
From: Jonathan Nieder @ 2013-01-14  6:19 UTC (permalink / raw)
  To: Michael Haggerty; +Cc: Junio C Hamano, Jeff King, git
In-Reply-To: <1358141566-26081-7-git-send-email-mhagger@alum.mit.edu>

Michael Haggerty wrote:

> --- a/imap-send.c
> +++ b/imap-send.c
[...]
> @@ -772,13 +767,10 @@ static int get_cmd_result(struct imap_store *ctx, struct imap_cmd *tcmd)
>  				   !strcmp("NO", arg) || !strcmp("BYE", arg)) {
>  				if ((resp = parse_response_code(ctx, NULL, cmd)) != RESP_OK)
>  					return resp;
> -			} else if (!strcmp("CAPABILITY", arg))
> +			} else if (!strcmp("CAPABILITY", arg)) {
>  				parse_capability(imap, cmd);
> -			else if ((arg1 = next_arg(&cmd))) {
> -				if (!strcmp("EXISTS", arg1))
> -					ctx->gen.count = atoi(arg);
> -				else if (!strcmp("RECENT", arg1))
> -					ctx->gen.recent = atoi(arg);
> +			} else if ((arg1 = next_arg(&cmd))) {
> +				/* unused */

Neat.  Let me try to understand what was going on here:

When opening a mailbox with the SELECT command, an IMAP server
responds with tagged data indicating how many messages exist and how
many are marked Recent.  But git imap-send never reads mailboxes and
in particular never uses the SELECT command, so there is no need for
us to parse or record such responses.

Out of paranoia we are keeping the parsing for now, but the parsed
response is unused, hence the comment above.

If I've understood correctly so far (a big assumption), I still am not
sure what it would mean if we hit this ((arg1 = next_arg(&cmd))) case.
Does it mean:

 A. The server has gone haywire and given a tagged response where
    one is not allowed, but let's tolerate it because we always have
    done so?  Or

 B. This is a perfectly normal response to some of the commands we
    send, and we have always been deliberately ignoring it because it
    is not important for what imap-send does?

Curious,
Jonathan

^ permalink raw reply


This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox