git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] t7701-repack-unpack-unreachable.sh: check timestamp of unpacked objects
@ 2008-05-18  4:00 drafnel
  2008-05-19  4:37 ` Junio C Hamano
  0 siblings, 1 reply; 7+ messages in thread
From: drafnel @ 2008-05-18  4:00 UTC (permalink / raw)
  To: gitster; +Cc: git, Brandon Casey

From: Brandon Casey <drafnel@gmail.com>

Unpacked objects should receive the timestamp of the pack they were
unpacked from. Check.

Signed-off-by: Brandon Casey <drafnel@gmail.com>
---
 t/t7701-repack-unpack-unreachable.sh |   28 ++++++++++++++++++++++++++++
 1 files changed, 28 insertions(+), 0 deletions(-)

diff --git a/t/t7701-repack-unpack-unreachable.sh b/t/t7701-repack-unpack-unreachable.sh
index 6a5211f..bdb00d4 100755
--- a/t/t7701-repack-unpack-unreachable.sh
+++ b/t/t7701-repack-unpack-unreachable.sh
@@ -4,6 +4,10 @@ test_description='git-repack works correctly'
 
 . ./test-lib.sh
 
+fsha1=
+csha1=
+tsha1=
+
 test_expect_success '-A option leaves unreachable objects unpacked' '
 	echo content > file1 &&
 	git add . &&
@@ -44,4 +48,28 @@ test_expect_success '-A option leaves unreachable objects unpacked' '
 	git show $tsha1
 '
 
+test_expect_success 'unpacked objects receive timestamp of pack file' '
+	fsha1path=$(echo "$fsha1" | sed -e "s/\(..\)\(.*\)/\1\/\2/") &&
+	fsha1path=".git/objects/$fsha1path" &&
+	csha1path=$(echo "$csha1" | sed -e "s/\(..\)\(.*\)/\1\/\2/") &&
+	csha1path=".git/objects/$csha1path" &&
+	tsha1path=$(echo "$tsha1" | sed -e "s/\(..\)\(.*\)/\1\/\2/") &&
+	tsha1path=".git/objects/$tsha1path" &&
+	git branch transient_branch $csha1 &&
+	git repack -a -d -l &&
+	test ! -f "$fsha1path" &&
+	test ! -f "$csha1path" &&
+	test ! -f "$tsha1path" &&
+	test 1 = $(ls -1 .git/objects/pack/pack-*.pack | wc -l) &&
+	packfile=$(ls .git/objects/pack/pack-*.pack) &&
+	git branch -D transient_branch &&
+	git repack -A -l &&
+	test -f "$fsha1path" -a ! "$fsha1path" -nt "$packfile" -a \
+				! "$fsha1path" -ot "$packfile" &&
+	test -f "$csha1path" -a ! "$csha1path" -nt "$packfile" -a \
+				! "$csha1path" -ot "$packfile" &&
+	test -f "$tsha1path" -a ! "$tsha1path" -nt "$packfile" -a \
+				! "$tsha1path" -ot "$packfile"
+'
+
 test_done
-- 
1.5.5.1.447.geb0a7

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH] t7701-repack-unpack-unreachable.sh: check timestamp of unpacked objects
  2008-05-18  4:00 [PATCH] t7701-repack-unpack-unreachable.sh: check timestamp of unpacked objects drafnel
@ 2008-05-19  4:37 ` Junio C Hamano
  2008-05-19 14:20   ` Brandon Casey
  0 siblings, 1 reply; 7+ messages in thread
From: Junio C Hamano @ 2008-05-19  4:37 UTC (permalink / raw)
  To: drafnel; +Cc: gitster, git

drafnel@gmail.com writes:


> +	test -f "$fsha1path" -a ! "$fsha1path" -nt "$packfile" -a \
> +				! "$fsha1path" -ot "$packfile" &&
> +	test -f "$csha1path" -a ! "$csha1path" -nt "$packfile" -a \
> +				! "$csha1path" -ot "$packfile" &&
> +	test -f "$tsha1path" -a ! "$tsha1path" -nt "$packfile" -a \
> +				! "$tsha1path" -ot "$packfile"
> +'

"Test" primaries -nt/-ot are unfortunately excluded from POSIX.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] t7701-repack-unpack-unreachable.sh: check timestamp of unpacked objects
  2008-05-19  4:37 ` Junio C Hamano
@ 2008-05-19 14:20   ` Brandon Casey
  2008-05-19 20:27     ` Brandon Casey
  0 siblings, 1 reply; 7+ messages in thread
From: Brandon Casey @ 2008-05-19 14:20 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: gitster, git

Junio C Hamano wrote:
> drafnel@gmail.com writes:
> 
> 
>> +	test -f "$fsha1path" -a ! "$fsha1path" -nt "$packfile" -a \
>> +				! "$fsha1path" -ot "$packfile" &&
>> +	test -f "$csha1path" -a ! "$csha1path" -nt "$packfile" -a \
>> +				! "$csha1path" -ot "$packfile" &&
>> +	test -f "$tsha1path" -a ! "$tsha1path" -nt "$packfile" -a \
>> +				! "$tsha1path" -ot "$packfile"
>> +'
> 
> "Test" primaries -nt/-ot are unfortunately excluded from POSIX.

hrmph, and it even worked on solaris ksh.

-brandon

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] t7701-repack-unpack-unreachable.sh: check timestamp of unpacked objects
  2008-05-19 14:20   ` Brandon Casey
@ 2008-05-19 20:27     ` Brandon Casey
  2008-05-19 21:08       ` Jeff King
  0 siblings, 1 reply; 7+ messages in thread
From: Brandon Casey @ 2008-05-19 20:27 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: gitster, git

Brandon Casey wrote:
> Junio C Hamano wrote:
>> drafnel@gmail.com writes:
>>
>>
>>> +	test -f "$fsha1path" -a ! "$fsha1path" -nt "$packfile" -a \
>>> +				! "$fsha1path" -ot "$packfile" &&
>>> +	test -f "$csha1path" -a ! "$csha1path" -nt "$packfile" -a \
>>> +				! "$csha1path" -ot "$packfile" &&
>>> +	test -f "$tsha1path" -a ! "$tsha1path" -nt "$packfile" -a \
>>> +				! "$tsha1path" -ot "$packfile"
>>> +'
>> "Test" primaries -nt/-ot are unfortunately excluded from POSIX.
> 
> hrmph, and it even worked on solaris ksh.

FYI, also works with dash, and there is a use of '-nt' in git-mergetool.sh
which is not exercised by the test suite.

Maybe I'll think about a perl version.

Also, do you have a url to your posix reference?

-brandon

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] t7701-repack-unpack-unreachable.sh: check timestamp of unpacked objects
  2008-05-19 20:27     ` Brandon Casey
@ 2008-05-19 21:08       ` Jeff King
  2008-05-19 21:48         ` Brandon Casey
  0 siblings, 1 reply; 7+ messages in thread
From: Jeff King @ 2008-05-19 21:08 UTC (permalink / raw)
  To: Brandon Casey; +Cc: Junio C Hamano, gitster, git

On Mon, May 19, 2008 at 03:27:02PM -0500, Brandon Casey wrote:

> Also, do you have a url to your posix reference?

I generally use:

  http://www.opengroup.org/onlinepubs/009695399/

Specifically:

  http://www.opengroup.org/onlinepubs/009695399/utilities/test.html

-Peff

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] t7701-repack-unpack-unreachable.sh: check timestamp of unpacked objects
  2008-05-19 21:08       ` Jeff King
@ 2008-05-19 21:48         ` Brandon Casey
  0 siblings, 0 replies; 7+ messages in thread
From: Brandon Casey @ 2008-05-19 21:48 UTC (permalink / raw)
  To: Jeff King; +Cc: Junio C Hamano, gitster, git

Jeff King wrote:
> On Mon, May 19, 2008 at 03:27:02PM -0500, Brandon Casey wrote:
> 
>> Also, do you have a url to your posix reference?
> 
> I generally use:
> 
>   http://www.opengroup.org/onlinepubs/009695399/

That's what I was looking for (didn't look hard enough).

> Specifically:
> 
>   http://www.opengroup.org/onlinepubs/009695399/utilities/test.html

This should be more accurate than my old reference: 'man test' :)

thanks,
-brandon

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH] t7701-repack-unpack-unreachable.sh: check timestamp of unpacked objects
@ 2008-06-29  0:25 drafnel
  0 siblings, 0 replies; 7+ messages in thread
From: drafnel @ 2008-06-29  0:25 UTC (permalink / raw)
  To: gitster; +Cc: git, Brandon Casey

From: Brandon Casey <drafnel@gmail.com>

Unpacked objects should receive the timestamp of the pack they were
unpacked from. Check.

Signed-off-by: Brandon Casey <drafnel@gmail.com>
---
 t/t7701-repack-unpack-unreachable.sh |   34 ++++++++++++++++++++++++++++++++++
 1 files changed, 34 insertions(+), 0 deletions(-)

diff --git a/t/t7701-repack-unpack-unreachable.sh b/t/t7701-repack-unpack-unreachable.sh
index 6a5211f..63485c1 100755
--- a/t/t7701-repack-unpack-unreachable.sh
+++ b/t/t7701-repack-unpack-unreachable.sh
@@ -4,6 +4,10 @@ test_description='git-repack works correctly'
 
 . ./test-lib.sh
 
+fsha1=
+csha1=
+tsha1=
+
 test_expect_success '-A option leaves unreachable objects unpacked' '
 	echo content > file1 &&
 	git add . &&
@@ -44,4 +48,34 @@ test_expect_success '-A option leaves unreachable objects unpacked' '
 	git show $tsha1
 '
 
+compare_mtimes ()
+{
+	perl -e 'my $reference = shift;
+		 foreach my $file (@ARGV) {
+			exit(1) unless(-f $file && -M $file == -M $reference);
+		 }
+		 exit(0);
+		' -- "$@"
+}
+
+test_expect_success 'unpacked objects receive timestamp of pack file' '
+	fsha1path=$(echo "$fsha1" | sed -e "s/\(..\)\(.*\)/\1\/\2/") &&
+	fsha1path=".git/objects/$fsha1path" &&
+	csha1path=$(echo "$csha1" | sed -e "s/\(..\)\(.*\)/\1\/\2/") &&
+	csha1path=".git/objects/$csha1path" &&
+	tsha1path=$(echo "$tsha1" | sed -e "s/\(..\)\(.*\)/\1\/\2/") &&
+	tsha1path=".git/objects/$tsha1path" &&
+	git branch transient_branch $csha1 &&
+	git repack -a -d -l &&
+	test ! -f "$fsha1path" &&
+	test ! -f "$csha1path" &&
+	test ! -f "$tsha1path" &&
+	test 1 = $(ls -1 .git/objects/pack/pack-*.pack | wc -l) &&
+	packfile=$(ls .git/objects/pack/pack-*.pack) &&
+	git branch -D transient_branch &&
+	sleep 1 &&
+	git repack -A -l &&
+	compare_mtimes "$packfile" "$fsha1path" "$csha1path" "$tsha1path"
+'
+
 test_done
-- 
1.5.6.1

^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2008-06-29  0:23 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-05-18  4:00 [PATCH] t7701-repack-unpack-unreachable.sh: check timestamp of unpacked objects drafnel
2008-05-19  4:37 ` Junio C Hamano
2008-05-19 14:20   ` Brandon Casey
2008-05-19 20:27     ` Brandon Casey
2008-05-19 21:08       ` Jeff King
2008-05-19 21:48         ` Brandon Casey
  -- strict thread matches above, loose matches on Subject: below --
2008-06-29  0:25 drafnel

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).