threads / patch / 13560

patcht7701-repack-unpack-unreachable.sh: check timestamp of unpacked objects

Subject: [PATCH] t7701-repack-unpack-unreachable.sh: check timestamp of unpacked objects

## tl;dr

6 messages between May 18, 2008 and May 19, 2008. Diffs are folded; open one to read it.

replies: 5people: 3as markdown or json

drafnel@gmail.com· May 18, 2008, 04:00 UTC · lore
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(-)
Show changes to t/t7701-repack-unpack-unreachable.sh +28 −0
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
Junio C Hamano· May 19, 2008, 04:37 UTC · re: drafnel@gmail.com · lore

Re: [PATCH] t7701-repack-unpack-unreachable.sh: check timestamp of unpacked objects

drafnel@gmail.com writes:
Show 7 quoted lines
> +	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.
Brandon Casey· May 19, 2008, 14:20 UTC · re: Junio C Hamano · lore

Re: [PATCH] t7701-repack-unpack-unreachable.sh: check timestamp of unpacked objects

Junio C Hamano wrote:
Show 12 quoted lines
> 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
Brandon Casey· May 19, 2008, 20:27 UTC · re: Brandon Casey · lore

Re: [PATCH] t7701-repack-unpack-unreachable.sh: check timestamp of unpacked objects

Brandon Casey wrote:
Show 14 quoted lines
> 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
Jeff King· May 19, 2008, 21:08 UTC · re: Brandon Casey · lore

Re: [PATCH] t7701-repack-unpack-unreachable.sh: check timestamp of unpacked objects

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
Brandon Casey· May 19, 2008, 21:48 UTC · re: Jeff King · lore

Re: [PATCH] t7701-repack-unpack-unreachable.sh: check timestamp of unpacked objects

Jeff King wrote:
Show 7 quoted lines
> 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

← back to recent threads