threads / patch / 14599

patchperl/Makefile: update NO_PERL_MAKEMAKER section

Subject: [PATCH] perl/Makefile: update NO_PERL_MAKEMAKER section

## tl;dr

23 messages between Jul 22, 2008 and Jul 25, 2008. Diffs are folded; open one to read it.

replies: 22people: 5as markdown or json

Brandon Casey· Jul 22, 2008, 21:15 UTC · lore

The perl modules must be copied to blib/lib so they are available for testing.

Signed-off-by: Brandon Casey <casey@nrlssc.navy.mil>
---
 perl/Makefile |    7 +++++--
 1 files changed, 5 insertions(+), 2 deletions(-)
Show changes to perl/Makefile +5 −2
diff --git a/perl/Makefile b/perl/Makefile
index 5e079ad..2b0d3d5 100644
--- a/perl/Makefile
+++ b/perl/Makefile
@@ -22,8 +22,11 @@ clean:
 ifdef NO_PERL_MAKEMAKER
 instdir_SQ = $(subst ','\'',$(prefix)/lib)
 $(makfile): ../GIT-CFLAGS Makefile
-	echo all: > $@
-	echo '	:' >> $@
+	echo all: private-Error.pm Git.pm > $@
+	echo '	mkdir -p blib/lib' >> $@
+	echo '	$(RM) blib/lib/Git.pm; cp Git.pm blib/lib/' >> $@
+	echo '	$(RM) blib/lib/Error.pm; \
+	cp private-Error.pm blib/lib/Error.pm' >> $@
 	echo install: >> $@
 	echo '	mkdir -p $(instdir_SQ)' >> $@
 	echo '	$(RM) $(instdir_SQ)/Git.pm; cp Git.pm $(instdir_SQ)' >> $@
-- 
1.6.0.rc0.38.g8b8fb7
Petr Baudis· Jul 22, 2008, 23:09 UTC · re: Brandon Casey · lore

Re: [PATCH] perl/Makefile: update NO_PERL_MAKEMAKER section

On Tue, Jul 22, 2008 at 04:15:41PM -0500, Brandon Casey wrote:
> The perl modules must be copied to blib/lib so they are available for
> testing.
> 
> Signed-off-by: Brandon Casey <casey@nrlssc.navy.mil>

I don't understand why do you need to do this; perl.mak should do this on its own during project-wide make all. What Perl version are you using? How does the pm_to_blib target look like?

	pm_to_blib : $(TO_INST_PM)
        $(NOECHO) $(ABSPERLRUN) -MExtUtils::Install -e 'pm_to_blib({@ARGV}, '\''$(INST_LIB)/auto'\'', '\''$(PM_FILTER)'\'')' -- \
          Git.pm $(INST_LIBDIR)/Git.pm
        $(NOECHO) $(TOUCH) pm_to_blib
here. Is your INST_LIB = blib/lib and INST_LIBDIR = $(INST_LIB)?
-- 
				Petr "Pasky" Baudis
As in certain cults it is possible to kill a process if you know
its true name.  -- Ken Thompson and Dennis M. Ritchie
Brandon Casey· Jul 23, 2008, 16:22 UTC · re: Petr Baudis · lore

Re: [PATCH] perl/Makefile: update NO_PERL_MAKEMAKER section

Petr Baudis wrote:
Show 8 quoted lines
> On Tue, Jul 22, 2008 at 04:15:41PM -0500, Brandon Casey wrote:
>> The perl modules must be copied to blib/lib so they are available for
>> testing.
>>
>> Signed-off-by: Brandon Casey <casey@nrlssc.navy.mil>
> 
> I don't understand why do you need to do this; perl.mak should do this
> on its own during project-wide make all.

perl.mak is auto-generated by one of two methods in perl/Makefile. This patch modifies the 'NO_PERL_MAKEMAKER' section. Currently 'make all', when NO_PERL_MAKEMAKER is set, does nothing, and looks like:

  $ cat perl.mak
  all:
	:
  install:
	mkdir -p ...
With this patch it looks like:
  $ cat perl.mak
  all: private-Error.pm Git.pm
          mkdir -p blib/lib
          rm -f blib/lib/Git.pm; cp Git.pm blib/lib/
          rm -f blib/lib/Error.pm;  cp private-Error.pm blib/lib/Error.pm
  install:
          mkdir -p ...
-brandon
Junio C Hamano· Jul 23, 2008, 23:29 UTC · re: Brandon Casey · lore

Re: [PATCH] perl/Makefile: update NO_PERL_MAKEMAKER section

Brandon Casey <casey@nrlssc.navy.mil> writes:
> The perl modules must be copied to blib/lib so they are available for
> testing.

True, but private-Error needs to be handled a bit more carefully, I think.

How about this on top of your patch?
 perl/Makefile |   10 ++++++----
 1 files changed, 6 insertions(+), 4 deletions(-)
Show changes to perl/Makefile +6 −4
diff --git a/perl/Makefile b/perl/Makefile
index 2b0d3d5..b8547db 100644
--- a/perl/Makefile
+++ b/perl/Makefile
@@ -25,13 +25,15 @@ $(makfile): ../GIT-CFLAGS Makefile
 	echo all: private-Error.pm Git.pm > $@
 	echo '	mkdir -p blib/lib' >> $@
 	echo '	$(RM) blib/lib/Git.pm; cp Git.pm blib/lib/' >> $@
-	echo '	$(RM) blib/lib/Error.pm; \
-	cp private-Error.pm blib/lib/Error.pm' >> $@
+	echo '	$(RM) blib/lib/Error.pm' >> $@
+	'$(PERL_PATH_SQ)' -MError -e 'exit($$Error::VERSION < 0.15009)' || \
+	echo '	cp private-Error.pm blib/lib/Error.pm' >> $@
 	echo install: >> $@
 	echo '	mkdir -p $(instdir_SQ)' >> $@
 	echo '	$(RM) $(instdir_SQ)/Git.pm; cp Git.pm $(instdir_SQ)' >> $@
-	echo '	$(RM) $(instdir_SQ)/Error.pm; \
-	cp private-Error.pm $(instdir_SQ)/Error.pm' >> $@
+	echo '	$(RM) $(instdir_SQ)/Error.pm' >> $@
+	'$(PERL_PATH_SQ)' -MError -e 'exit($$Error::VERSION < 0.15009)' || \
+	echo '	cp private-Error.pm $(instdir_SQ)/Error.pm' >> $@
 	echo instlibdir: >> $@
 	echo '	echo $(instdir_SQ)' >> $@
 else
Brandon Casey· Jul 23, 2008, 23:56 UTC · re: Junio C Hamano · lore

Re: [PATCH] perl/Makefile: update NO_PERL_MAKEMAKER section

Junio C Hamano wrote:
Show 9 quoted lines
> Brandon Casey <casey@nrlssc.navy.mil> writes:
> 
>> The perl modules must be copied to blib/lib so they are available for
>> testing.
> 
> True, but private-Error needs to be handled a bit more carefully, I
> think.
> 
> How about this on top of your patch?

That works. Error.pm is not available on my system and the statements to copy private-Error.pm to Error.pm are correctly placed in perl.mak.

I should have gotten a clue when a file named _private_-Error.pm was being copied to Error.pm and taken a look at Makefile.PL.

Thanks.
-brandon
Brandon Casey· Jul 22, 2008, 21:16 UTC · lore

[PATCH] t9700/test.pl: backwards compatibility improvements

Some versions of perl complain when 'STDERR' is used as the third argument in the 3-argument form of open(). Convert to the 2-argument form which is described for duping STDERR in my second edition camel book.

The object oriented version of File::Temp is a rather new incarnation it seems. The File::Temp man page for v5.8.0 says "(NOT YET IMPLEMENTED)" in the 'Objects' section. These can be converted to use File::Temp::tempfile().

Signed-off-by: Brandon Casey <casey@nrlssc.navy.mil>
---
 t/t9700/test.pl |   12 ++++++------
 1 files changed, 6 insertions(+), 6 deletions(-)
Show changes to t/t9700/test.pl +6 −6
diff --git a/t/t9700/test.pl b/t/t9700/test.pl
index 4d23125..70f9836 100755
--- a/t/t9700/test.pl
+++ b/t/t9700/test.pl
@@ -38,7 +38,7 @@ is($r->get_color("color.test.slot1", "red"), $ansi_green, "get_color");
 # Failure cases for config:
 # Save and restore STDERR; we will probably extract this into a
 # "dies_ok" method and possibly move the STDERR handling to Git.pm.
-open our $tmpstderr, ">&", STDERR or die "cannot save STDERR"; close STDERR;
+open our $tmpstderr, ">&STDERR" or die "cannot save STDERR"; close STDERR;
 eval { $r->config("test.dupstring") };
 ok($@, "config: duplicate entry in scalar context fails");
 eval { $r->config_bool("test.boolother") };
@@ -69,18 +69,18 @@ is($r->ident_person("Name", "email", "123 +0000"), "Name <email>",
 
 # objects and hashes
 ok(our $file1hash = $r->command_oneline('rev-parse', "HEAD:file1"), "(get file hash)");
-our $tmpfile = File::Temp->new;
+our ($tmpfile, $tmpnam) = File::Temp::tempfile();
 is($r->cat_blob($file1hash, $tmpfile), 15, "cat_blob: size");
 our $blobcontents;
 { local $/; seek $tmpfile, 0, 0; $blobcontents = <$tmpfile>; }
 is($blobcontents, "changed file 1\n", "cat_blob: data");
 seek $tmpfile, 0, 0;
-is(Git::hash_object("blob", $tmpfile), $file1hash, "hash_object: roundtrip");
-$tmpfile = File::Temp->new();
+is(Git::hash_object("blob", $tmpnam), $file1hash, "hash_object: roundtrip");
+($tmpfile, $tmpnam) = File::Temp::tempfile();
 print $tmpfile my $test_text = "test blob, to be inserted\n";
-like(our $newhash = $r->hash_and_insert_object($tmpfile), qr/[0-9a-fA-F]{40}/,
+like(our $newhash = $r->hash_and_insert_object($tmpnam), qr/[0-9a-fA-F]{40}/,
      "hash_and_insert_object: returns hash");
-$tmpfile = File::Temp->new;
+$tmpfile = File::Temp::tempfile();
 is($r->cat_blob($newhash, $tmpfile), length $test_text, "cat_blob: roundtrip size");
 { local $/; seek $tmpfile, 0, 0; $blobcontents = <$tmpfile>; }
 is($blobcontents, $test_text, "cat_blob: roundtrip data");
-- 
1.6.0.rc0.38.g8b8fb7
Junio C Hamano· Jul 23, 2008, 23:33 UTC · re: Brandon Casey · lore

Re: [PATCH] t9700/test.pl: backwards compatibility improvements

I have applied everything except for this one. I think it is Ok, but let's hear success or breakage stories from the list first and then remind me if the patch seems Ok, please?

Brandon Casey· Jul 24, 2008, 00:08 UTC · re: Junio C Hamano · lore

Re: [PATCH] t9700/test.pl: backwards compatibility improvements

Junio C Hamano wrote:
> I have applied everything except for this one.  I think it is Ok, but
> let's hear success or breakage stories from the list first and then remind
> me if the patch seems Ok, please?
will do.
Brandon Casey· Jul 22, 2008, 21:16 UTC · lore

[PATCH] t4116-apply-reverse.sh: use $TAR rather than tar

Signed-off-by: Brandon Casey <casey@nrlssc.navy.mil>
---
 t/t4116-apply-reverse.sh |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
Show changes to t/t4116-apply-reverse.sh +2 −2
diff --git a/t/t4116-apply-reverse.sh b/t/t4116-apply-reverse.sh
index 1459a90..2298ece 100755
--- a/t/t4116-apply-reverse.sh
+++ b/t/t4116-apply-reverse.sh
@@ -48,12 +48,12 @@ test_expect_success 'apply in reverse' '
 
 test_expect_success 'setup separate repository lacking postimage' '
 
-	git tar-tree initial initial | tar xf - &&
+	git tar-tree initial initial | $TAR xf - &&
 	(
 		cd initial && git init && git add .
 	) &&
 
-	git tar-tree second second | tar xf - &&
+	git tar-tree second second | $TAR xf - &&
 	(
 		cd second && git init && git add .
 	)
-- 
1.6.0.rc0.38.g8b8fb7
Stephan Beyer· Jul 25, 2008, 16:37 UTC · re: Brandon Casey · lore

[PATCH] Set TAR in t/Makefile and in t4116-apply-reverse.sh

Hence, the test passes also when you run "make" in t/ or when you invoke t4116-apply-reverse.sh directly, without $TAR being set.

Signed-off-by: Stephan Beyer <s-beyer@gmx.net>
---
 t/Makefile               |    2 +-
 t/t4116-apply-reverse.sh |    1 +
 2 files changed, 2 insertions(+), 1 deletions(-)
Show changes to 2 files +2 −1

t/Makefile, t/t4116-apply-reverse.sh

diff --git a/t/Makefile b/t/Makefile
index 0d65ced..b720943 100644
--- a/t/Makefile
+++ b/t/Makefile
@@ -5,7 +5,7 @@
 
 #GIT_TEST_OPTS=--verbose --debug
 SHELL_PATH ?= $(SHELL)
-TAR ?= $(TAR)
+TAR ?= tar
 RM ?= rm -f
 
 # Shell quote;
diff --git a/t/t4116-apply-reverse.sh b/t/t4116-apply-reverse.sh
index 2298ece..3ff5d9e 100755
--- a/t/t4116-apply-reverse.sh
+++ b/t/t4116-apply-reverse.sh
@@ -8,6 +8,7 @@ test_description='git apply in reverse
 '
 
 . ./test-lib.sh
+TAR=${TAR:-tar}
 
 test_expect_success setup '
 
-- 
1.6.0.rc0.102.ga1791
Miklos Vajna· Jul 25, 2008, 17:05 UTC · re: Stephan Beyer · lore

Re: [PATCH] Set TAR in t/Makefile and in t4116-apply-reverse.sh

On Fri, Jul 25, 2008 at 06:37:40PM +0200, Stephan Beyer <s-beyer@gmx.net> wrote:
> Hence, the test passes also when you run "make" in t/
> or when you invoke t4116-apply-reverse.sh directly,
> without $TAR being set.
Thanks, I just hit this issue today. ;-)
Stephan Beyer· Jul 25, 2008, 17:12 UTC · re: Miklos Vajna · lore

Re: [PATCH] Set TAR in t/Makefile and in t4116-apply-reverse.sh

Hi,
Miklos Vajna wrote:
Show 6 quoted lines
> On Fri, Jul 25, 2008 at 06:37:40PM +0200, Stephan Beyer <s-beyer@gmx.net> wrote:
> > Hence, the test passes also when you run "make" in t/
> > or when you invoke t4116-apply-reverse.sh directly,
> > without $TAR being set.
> 
> Thanks, I just hit this issue today. ;-)

Puh, I'm glad that you're not writing "I've hit this issue yesterday and already sent a patch to this list" :)

Regards,
  Stephan
-- 
Stephan Beyer <s-beyer@gmx.net>, PGP 0x6EDDD207FCC5040F
Junio C Hamano· Jul 25, 2008, 18:18 UTC · re: Stephan Beyer · lore

Re: [PATCH] Set TAR in t/Makefile and in t4116-apply-reverse.sh

Actually, 455a7f3 (More portability., 2005-09-30) introduced $TAR and it is also used in t5000. cb34882 (fix t5000-tar-tree.sh when $TAR isn't set, 2005-11-08) did the same fix you are adding, but I think both of these fixes are in a wrong place.

I think we should do this instead. That's how SHELL_PATH is passed around from build to all the test scripts already.

---
 Makefile            |    1 +
 t/t5000-tar-tree.sh |    1 -
 2 files changed, 1 insertions(+), 1 deletions(-)
Show changes to 2 files +1 −1

Makefile, t/t5000-tar-tree.sh

diff --git a/Makefile b/Makefile
index b003e3e..1d14209 100644
--- a/Makefile
+++ b/Makefile
@@ -1212,6 +1212,7 @@ GIT-CFLAGS: .FORCE-GIT-CFLAGS
 
 GIT-BUILD-OPTIONS: .FORCE-GIT-BUILD-OPTIONS
 	@echo SHELL_PATH=\''$(SHELL_PATH_SQ)'\' >$@
+	@echo TAR=\''$(subst ','\'',$(TAR))'\' >>$@
 
 ### Detect Tck/Tk interpreter path changes
 ifndef NO_TCLTK
diff --git a/t/t5000-tar-tree.sh b/t/t5000-tar-tree.sh
index 9b0baac..5eb119e 100755
--- a/t/t5000-tar-tree.sh
+++ b/t/t5000-tar-tree.sh
@@ -25,7 +25,6 @@ commit id embedding:
 '
 
 . ./test-lib.sh
-TAR=${TAR:-tar}
 UNZIP=${UNZIP:-unzip}
 
 SUBSTFORMAT=%H%n
Stephan Beyer· Jul 25, 2008, 18:24 UTC · re: Junio C Hamano · lore

Re: [PATCH] Set TAR in t/Makefile and in t4116-apply-reverse.sh

Hi,
Show 12 quoted lines
> diff --git a/Makefile b/Makefile
> index b003e3e..1d14209 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -1212,6 +1212,7 @@ GIT-CFLAGS: .FORCE-GIT-CFLAGS
>  
>  GIT-BUILD-OPTIONS: .FORCE-GIT-BUILD-OPTIONS
>  	@echo SHELL_PATH=\''$(SHELL_PATH_SQ)'\' >$@
> +	@echo TAR=\''$(subst ','\'',$(TAR))'\' >>$@
>  
>  ### Detect Tck/Tk interpreter path changes
>  ifndef NO_TCLTK

But then TAR has to be set in test-lib.sh also, to be able to invoke t5000 and t4116 directly, hasn't it?

Regards.
-- 
Stephan Beyer <s-beyer@gmx.net>, PGP 0x6EDDD207FCC5040F
Junio C Hamano· Jul 25, 2008, 18:54 UTC · re: Stephan Beyer · lore

Re: [PATCH] Set TAR in t/Makefile and in t4116-apply-reverse.sh

Stephan Beyer <s-beyer@gmx.net> writes:
Show 17 quoted lines
> Hi,
>
>> diff --git a/Makefile b/Makefile
>> index b003e3e..1d14209 100644
>> --- a/Makefile
>> +++ b/Makefile
>> @@ -1212,6 +1212,7 @@ GIT-CFLAGS: .FORCE-GIT-CFLAGS
>>  
>>  GIT-BUILD-OPTIONS: .FORCE-GIT-BUILD-OPTIONS
>>  	@echo SHELL_PATH=\''$(SHELL_PATH_SQ)'\' >$@
>> +	@echo TAR=\''$(subst ','\'',$(TAR))'\' >>$@
>>  
>>  ### Detect Tck/Tk interpreter path changes
>>  ifndef NO_TCLTK
>
> But then TAR has to be set in test-lib.sh also, to be able to
> invoke t5000 and t4116 directly, hasn't it?
Dosen't test-lib source GIT-BUILD-OPTIONS?
Stephan Beyer· Jul 25, 2008, 18:58 UTC · re: Junio C Hamano · lore

Re: [PATCH] Set TAR in t/Makefile and in t4116-apply-reverse.sh

Junio C Hamano wrote:
Show 18 quoted lines
> Stephan Beyer <s-beyer@gmx.net> writes:
> >> diff --git a/Makefile b/Makefile
> >> index b003e3e..1d14209 100644
> >> --- a/Makefile
> >> +++ b/Makefile
> >> @@ -1212,6 +1212,7 @@ GIT-CFLAGS: .FORCE-GIT-CFLAGS
> >>  
> >>  GIT-BUILD-OPTIONS: .FORCE-GIT-BUILD-OPTIONS
> >>  	@echo SHELL_PATH=\''$(SHELL_PATH_SQ)'\' >$@
> >> +	@echo TAR=\''$(subst ','\'',$(TAR))'\' >>$@
> >>  
> >>  ### Detect Tck/Tk interpreter path changes
> >>  ifndef NO_TCLTK
> >
> > But then TAR has to be set in test-lib.sh also, to be able to
> > invoke t5000 and t4116 directly, hasn't it?
> 
> Dosen't test-lib source GIT-BUILD-OPTIONS?
It does.  Great, then.
Regards.
-- 
Stephan Beyer <s-beyer@gmx.net>, PGP 0x6EDDD207FCC5040F
Junio C Hamano· Jul 25, 2008, 19:37 UTC · re: Stephan Beyer · lore

Re: [PATCH] Set TAR in t/Makefile and in t4116-apply-reverse.sh

Stephan Beyer <s-beyer@gmx.net> writes:
Show 21 quoted lines
> Junio C Hamano wrote:
>> Stephan Beyer <s-beyer@gmx.net> writes:
>> >> diff --git a/Makefile b/Makefile
>> >> index b003e3e..1d14209 100644
>> >> --- a/Makefile
>> >> +++ b/Makefile
>> >> @@ -1212,6 +1212,7 @@ GIT-CFLAGS: .FORCE-GIT-CFLAGS
>> >>  
>> >>  GIT-BUILD-OPTIONS: .FORCE-GIT-BUILD-OPTIONS
>> >>  	@echo SHELL_PATH=\''$(SHELL_PATH_SQ)'\' >$@
>> >> +	@echo TAR=\''$(subst ','\'',$(TAR))'\' >>$@
>> >>  
>> >>  ### Detect Tck/Tk interpreter path changes
>> >>  ifndef NO_TCLTK
>> >
>> > But then TAR has to be set in test-lib.sh also, to be able to
>> > invoke t5000 and t4116 directly, hasn't it?
>> 
>> Dosen't test-lib source GIT-BUILD-OPTIONS?
>
> It does.  Great, then.
Sorry, but not quite.  The above shell construct is toooootally bogus.
We need this patch on top.

-- >8 -- [PATCH] Makefile: fix shell quoting

Makefile records paths to a few programs in GIT-BUILD-OPTIONS file. These paths need to be quoted twice: once to protect specials from the shell that runs the generated GIT-BUILD-OPTIONS file, and again to protect them (and the first level of quoting itself) from the shell that runs the "echo" inside the Makefile.

You can test this by trying:
    $ ln -s /bin/tar "$HOME/Tes' program/tar"
    $ make TAR="$HOME/Tes' program/tar" test
Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
 Makefile            |    7 +++++--
 t/t5000-tar-tree.sh |   10 +++++-----
 2 files changed, 10 insertions(+), 7 deletions(-)
Show changes to 2 files +10 −7

Makefile, t/t5000-tar-tree.sh

diff --git a/Makefile b/Makefile
index 1d14209..f13184b 100644
--- a/Makefile
+++ b/Makefile
@@ -1210,9 +1210,12 @@ GIT-CFLAGS: .FORCE-GIT-CFLAGS
 		echo "$$FLAGS" >GIT-CFLAGS; \
             fi
 
+# We need to apply sq twice, once to protect from the shell
+# that runs GIT-BUILD-OPTIONS, and then again to protect it
+# and the first level quoting from the shell that runs "echo".
 GIT-BUILD-OPTIONS: .FORCE-GIT-BUILD-OPTIONS
-	@echo SHELL_PATH=\''$(SHELL_PATH_SQ)'\' >$@
-	@echo TAR=\''$(subst ','\'',$(TAR))'\' >>$@
+	@echo SHELL_PATH=\''$(subst ','\'',$(SHELL_PATH_SQ))'\' >$@
+	@echo TAR=\''$(subst ','\'',$(subst ','\'',$(TAR)))'\' >>$@
 
 ### Detect Tck/Tk interpreter path changes
 ifndef NO_TCLTK
diff --git a/t/t5000-tar-tree.sh b/t/t5000-tar-tree.sh
index 5eb119e..87902f8 100755
--- a/t/t5000-tar-tree.sh
+++ b/t/t5000-tar-tree.sh
@@ -67,7 +67,7 @@ test_expect_success \
 test_expect_success \
     'validate file modification time' \
     'mkdir extract &&
-     $TAR xf b.tar -C extract a/a &&
+     "$TAR" xf b.tar -C extract a/a &&
      perl -e '\''print((stat("extract/a/a"))[9], "\n")'\'' >b.mtime &&
      echo "1117231200" >expected.mtime &&
      diff expected.mtime b.mtime'
@@ -79,7 +79,7 @@ test_expect_success \
 
 test_expect_success \
     'extract tar archive' \
-    '(cd b && $TAR xf -) <b.tar'
+    '(cd b && "$TAR" xf -) <b.tar'
 
 test_expect_success \
     'validate filenames' \
@@ -96,7 +96,7 @@ test_expect_success \
 
 test_expect_success \
     'extract tar archive with prefix' \
-    '(cd c && $TAR xf -) <c.tar'
+    '(cd c && "$TAR" xf -) <c.tar'
 
 test_expect_success \
     'validate filenames with prefix' \
@@ -116,7 +116,7 @@ test_expect_success \
 
 test_expect_success \
     'extract substfiles' \
-    '(mkdir f && cd f && $TAR xf -) <f.tar'
+    '(mkdir f && cd f && "$TAR" xf -) <f.tar'
 
 test_expect_success \
      'validate substfile contents' \
@@ -128,7 +128,7 @@ test_expect_success \
 
 test_expect_success \
     'extract substfiles from archive with prefix' \
-    '(mkdir g && cd g && $TAR xf -) <g.tar'
+    '(mkdir g && cd g && "$TAR" xf -) <g.tar'
 
 test_expect_success \
      'validate substfile contents from archive with prefix' \
-- 
1.6.0.rc0.51.g51a9e
Brandon Casey· Jul 22, 2008, 21:16 UTC · lore

[PATCH] t3200,t7201: replace '!' with test_must_fail

Signed-off-by: Brandon Casey <casey@nrlssc.navy.mil>
---
 t/t3200-branch.sh |    2 +-
 t/t7201-co.sh     |    2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
Show changes to 2 files +2 −2

t/t3200-branch.sh, t/t7201-co.sh

diff --git a/t/t3200-branch.sh b/t/t3200-branch.sh
index 7c583c8..7a83fbf 100755
--- a/t/t3200-branch.sh
+++ b/t/t3200-branch.sh
@@ -200,7 +200,7 @@ test_expect_success \
 
 test_expect_success \
     'branch from non-branch HEAD w/--track causes failure' \
-    '!(git branch --track my10 HEAD^)'
+    'test_must_fail git branch --track my10 HEAD^'
 
 # Keep this test last, as it changes the current branch
 cat >expect <<EOF
diff --git a/t/t7201-co.sh b/t/t7201-co.sh
index 3111baa..9ad5d63 100755
--- a/t/t7201-co.sh
+++ b/t/t7201-co.sh
@@ -335,6 +335,6 @@ test_expect_success \
     git checkout -b delete-me master &&
     rm .git/refs/heads/delete-me &&
     test refs/heads/delete-me = "$(git symbolic-ref HEAD)" &&
-    !(git checkout --track -b track)'
+    test_must_fail git checkout --track -b track'
 
 test_done
-- 
1.6.0.rc0.38.g8b8fb7
Brandon Casey· Jul 22, 2008, 21:17 UTC · lore

[PATCH] t/: Replace diff [-u|-U0] with test_cmp to allow compilation with old diff

Signed-off-by: Brandon Casey <casey@nrlssc.navy.mil>
---
 t/t0002-gitfile.sh               |    2 +-
 t/t1002-read-tree-m-u-2way.sh    |   12 ++++++------
 t/t2201-add-update-typechange.sh |   10 +++++-----
 3 files changed, 12 insertions(+), 12 deletions(-)
Show changes to 3 files +12 −12

t/t0002-gitfile.sh, t/t1002-read-tree-m-u-2way.sh, t/t2201-add-update-typechange.sh

diff --git a/t/t0002-gitfile.sh b/t/t0002-gitfile.sh
index c5dbc72..4db4ac4 100755
--- a/t/t0002-gitfile.sh
+++ b/t/t0002-gitfile.sh
@@ -66,7 +66,7 @@ test_expect_success 'check hash-object' '
 
 test_expect_success 'check cat-file' '
 	git cat-file blob $SHA >actual &&
-	diff -u bar actual
+	test_cmp bar actual
 '
 
 test_expect_success 'check update-index' '
diff --git a/t/t1002-read-tree-m-u-2way.sh b/t/t1002-read-tree-m-u-2way.sh
index e04990e..aa9dd58 100755
--- a/t/t1002-read-tree-m-u-2way.sh
+++ b/t/t1002-read-tree-m-u-2way.sh
@@ -112,7 +112,7 @@ test_expect_success \
      git update-index --add frotz &&
      git read-tree -m -u $treeH $treeM &&
      git ls-files --stage >6.out &&
-     diff -U0 M.out 6.out &&
+     test_cmp M.out 6.out &&
      check_cache_at frotz clean &&
      sum bozbar frotz nitfol >actual3.sum &&
      cmp M.sum actual3.sum &&
@@ -129,7 +129,7 @@ test_expect_success \
      echo frotz frotz >frotz &&
      git read-tree -m -u $treeH $treeM &&
      git ls-files --stage >7.out &&
-     diff -U0 M.out 7.out &&
+     test_cmp M.out 7.out &&
      check_cache_at frotz dirty &&
      sum bozbar frotz nitfol >actual7.sum &&
      if cmp M.sum actual7.sum; then false; else :; fi &&
@@ -264,7 +264,7 @@ test_expect_success \
      git update-index --add bozbar &&
      git read-tree -m -u $treeH $treeM &&
      git ls-files --stage >18.out &&
-     diff -U0 M.out 18.out &&
+     test_cmp M.out 18.out &&
      check_cache_at bozbar clean &&
      sum bozbar frotz nitfol >actual18.sum &&
      cmp M.sum actual18.sum'
@@ -278,7 +278,7 @@ test_expect_success \
      echo gnusto gnusto >bozbar &&
      git read-tree -m -u $treeH $treeM &&
      git ls-files --stage >19.out &&
-     diff -U0 M.out 19.out &&
+     test_cmp M.out 19.out &&
      check_cache_at bozbar dirty &&
      sum frotz nitfol >actual19.sum &&
      grep -v bozbar  M.sum > expected19.sum &&
@@ -297,7 +297,7 @@ test_expect_success \
      git update-index --add bozbar &&
      git read-tree -m -u $treeH $treeM &&
      git ls-files --stage >20.out &&
-     diff -U0 M.out 20.out &&
+     test_cmp M.out 20.out &&
      check_cache_at bozbar clean &&
      sum bozbar frotz nitfol >actual20.sum &&
      cmp M.sum actual20.sum'
@@ -338,7 +338,7 @@ test_expect_success \
      git update-index --add DF &&
      git read-tree -m -u $treeDF $treeDFDF &&
      git ls-files --stage >DFDFcheck.out &&
-     diff -U0 DFDF.out DFDFcheck.out &&
+     test_cmp DFDF.out DFDFcheck.out &&
      check_cache_at DF/DF clean'
 
 test_done
diff --git a/t/t2201-add-update-typechange.sh b/t/t2201-add-update-typechange.sh
index e15e3eb..d24c7d9 100755
--- a/t/t2201-add-update-typechange.sh
+++ b/t/t2201-add-update-typechange.sh
@@ -106,12 +106,12 @@ test_expect_success modify '
 
 test_expect_success diff-files '
 	git diff-files --raw >actual &&
-	diff -u expect-files actual
+	test_cmp expect-files actual
 '
 
 test_expect_success diff-index '
 	git diff-index --raw HEAD -- >actual &&
-	diff -u expect-index actual
+	test_cmp expect-index actual
 '
 
 test_expect_success 'add -u' '
@@ -119,7 +119,7 @@ test_expect_success 'add -u' '
 	cp -p ".git/index" ".git/saved-index" &&
 	git add -u &&
 	git ls-files -s >actual &&
-	diff -u expect-final actual
+	test_cmp expect-final actual
 '
 
 test_expect_success 'commit -a' '
@@ -130,11 +130,11 @@ test_expect_success 'commit -a' '
 	fi &&
 	git commit -m "second" -a &&
 	git ls-files -s >actual &&
-	diff -u expect-final actual &&
+	test_cmp expect-final actual &&
 	rm -f .git/index &&
 	git read-tree HEAD &&
 	git ls-files -s >actual &&
-	diff -u expect-final actual
+	test_cmp expect-final actual
 '
 
 test_done
-- 
1.6.0.rc0.38.g8b8fb7
Miklos Vajna· Jul 24, 2008, 00:19 UTC · re: Brandon Casey · lore

Re: [PATCH] t/: Replace diff [-u|-U0] with test_cmp to allow compilation with old diff

On Tue, Jul 22, 2008 at 04:17:43PM -0500, Brandon Casey <casey@nrlssc.navy.mil> wrote:
>  t/t0002-gitfile.sh               |    2 +-
>  t/t1002-read-tree-m-u-2way.sh    |   12 ++++++------
>  t/t2201-add-update-typechange.sh |   10 +++++-----
>  3 files changed, 12 insertions(+), 12 deletions(-)
Hmm, after applying this patch, I have:

~/git/t$ git grep 'diff -U' t1002-read-tree-m-u-2way.sh: diff -U0 M.out 4.out >4diff.out t1002-read-tree-m-u-2way.sh: diff -U0 M.out 5.out >5diff.out t1002-read-tree-m-u-2way.sh: diff -U0 M.out 14.out >14diff.out t1002-read-tree-m-u-2way.sh: diff -U0 M.out 15.out >15diff.out

Any reason you left this out? ;-)
Brandon Casey· Jul 24, 2008, 00:55 UTC · re: Miklos Vajna · lore

Re: [PATCH] t/: Replace diff [-u|-U0] with test_cmp to allow compilation with old diff

Miklos Vajna wrote:
Show 15 quoted lines
> On Tue, Jul 22, 2008 at 04:17:43PM -0500, Brandon Casey <casey@nrlssc.navy.mil> wrote:
>>  t/t0002-gitfile.sh               |    2 +-
>>  t/t1002-read-tree-m-u-2way.sh    |   12 ++++++------
>>  t/t2201-add-update-typechange.sh |   10 +++++-----
>>  3 files changed, 12 insertions(+), 12 deletions(-)
> 
> Hmm, after applying this patch, I have:
> 
> ~/git/t$ git grep 'diff -U'
> t1002-read-tree-m-u-2way.sh:     diff -U0 M.out 4.out >4diff.out
> t1002-read-tree-m-u-2way.sh:     diff -U0 M.out 5.out >5diff.out
> t1002-read-tree-m-u-2way.sh:     diff -U0 M.out 14.out >14diff.out
> t1002-read-tree-m-u-2way.sh:     diff -U0 M.out 15.out >15diff.out
> 
> Any reason you left this out? ;-)

I have the patch below in my repo so I can run this test. (copy/pasted and white-space corrupted since I haven't figured out how to reply to a message and import a patch correctly using thunderbird).

As you can see I just replaced the 'diff -U0' with 'git diff -U0' and then stripped off the git bits from the diff in the compare_change() function.

I think there is probably a better way to fix this, so I left it out.

Thinking about it now, it would have made sense to hold off on the part of the patch I submitted which applies to t1002-read-tree-m-u-2way.sh until I had a solution for the rest of these 'diff -U0's.

-brandon
Show changes to t/t1002-read-tree-m-u-2way.sh +6 −4
diff --git a/t/t1002-read-tree-m-u-2way.sh b/t/t1002-read-tree-m-u-2way.sh
index aa9dd58..5e40cec 100755
--- a/t/t1002-read-tree-m-u-2way.sh
+++ b/t/t1002-read-tree-m-u-2way.sh
@@ -14,6 +14,8 @@ _x40='[0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f]'
 _x40="$_x40$_x40$_x40$_x40$_x40$_x40$_x40$_x40"
 compare_change () {
        sed >current \
+           -e '1{/^diff --git /d;}' \
+           -e '2{/^index /d;}' \
            -e '/^--- /d; /^+++ /d; /^@@ /d;' \
            -e 's/^\(.[0-7][0-7][0-7][0-7][0-7][0-7]\) '"$_x40"' /\1 X /' "$1"
        test_cmp expected current
@@ -75,7 +77,7 @@ test_expect_success \
      git update-index --add yomin &&
      git read-tree -m -u $treeH $treeM &&
      git ls-files --stage >4.out || return 1
-     diff -U0 M.out 4.out >4diff.out
+     git diff -U0 --no-index M.out 4.out >4diff.out
      compare_change 4diff.out expected &&
      check_cache_at yomin clean &&
      sum bozbar frotz nitfol >actual4.sum &&
@@ -94,7 +96,7 @@ test_expect_success \
      echo yomin yomin >yomin &&
      git read-tree -m -u $treeH $treeM &&
      git ls-files --stage >5.out || return 1
-     diff -U0 M.out 5.out >5diff.out
+     git diff -U0 --no-index M.out 5.out >5diff.out
      compare_change 5diff.out expected &&
      check_cache_at yomin dirty &&
      sum bozbar frotz nitfol >actual5.sum &&
@@ -206,7 +208,7 @@ test_expect_success \
      git update-index --add nitfol &&
      git read-tree -m -u $treeH $treeM &&
      git ls-files --stage >14.out || return 1
-     diff -U0 M.out 14.out >14diff.out
+     git diff -U0 --no-index M.out 14.out >14diff.out
      compare_change 14diff.out expected &&
      sum bozbar frotz >actual14.sum &&
      grep -v nitfol M.sum > expected14.sum &&
@@ -227,7 +229,7 @@ test_expect_success \
      echo nitfol nitfol nitfol >nitfol &&
      git read-tree -m -u $treeH $treeM &&
      git ls-files --stage >15.out || return 1
-     diff -U0 M.out 15.out >15diff.out
+     git diff -U0 --no-index M.out 15.out >15diff.out
      compare_change 15diff.out expected &&
      check_cache_at nitfol dirty &&
      sum bozbar frotz >actual15.sum &&
-- 
1.5.6.2
Brandon Casey· Jul 22, 2008, 21:21 UTC · lore

[PATCH] t7502-commit.sh: rearrange test to make more portable

Some shells have problems with one-shot variable assignment notation and function calls. The sequence is rearranged to avoid the one-shot and to allow the test script to be linked together with '&&'.

Signed-off-by: Brandon Casey <casey@nrlssc.navy.mil>
---
 t/t7502-commit.sh |    8 +++++---
 1 files changed, 5 insertions(+), 3 deletions(-)
Show changes to t/t7502-commit.sh +5 −3
diff --git a/t/t7502-commit.sh b/t/t7502-commit.sh
index c25eff9..ad84c3d 100755
--- a/t/t7502-commit.sh
+++ b/t/t7502-commit.sh
@@ -228,10 +228,12 @@ EOF
 
 test_expect_success 'a SIGTERM should break locks' '
 	echo >>negative &&
-	"$SHELL_PATH" -c '\''
+	! "$SHELL_PATH" -c '\''
 	  echo kill -TERM $$ >> .git/FAKE_EDITOR
-	  GIT_EDITOR=.git/FAKE_EDITOR exec git commit -a'\'' && exit 1  # should fail
-	! test -f .git/index.lock
+	  GIT_EDITOR=.git/FAKE_EDITOR 
+	  export GIT_EDITOR
+	  exec git commit -a'\'' &&
+	test ! -f .git/index.lock
 '
 
 rm -f .git/MERGE_MSG .git/COMMIT_EDITMSG
-- 
1.6.0.rc0.38.g8b8fb7
Brandon Casey· Jul 22, 2008, 21:23 UTC · lore

[PATCH] t/t4202-log.sh: add newline at end of file

Some shells hang when parsing the script if the last statement is not followed by a newline. So add one.

Signed-off-by: Brandon Casey <casey@nrlssc.navy.mil>
---

I expect this is a bug in ksh. The ksh installed on my solaris box went into some infinite loop on this script, continually allocating memory. Adding the newline fixed it.

-brandon
 t/t4202-log.sh |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)
Show changes to t/t4202-log.sh +2 −1
diff --git a/t/t4202-log.sh b/t/t4202-log.sh
index b536454..4c8af45 100755
--- a/t/t4202-log.sh
+++ b/t/t4202-log.sh
@@ -71,4 +71,5 @@ test_expect_success 'diff-filter=D' '
 
 
 
-test_done
\ No newline at end of file
+test_done
+
-- 
1.6.0.rc0.38.g8b8fb7

← back to recent threads