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

6 messages from 2008-05-18 to 2008-05-19. Participants: drafnel@gmail.com, Junio C Hamano, Brandon Casey, Jeff King.
Thread: https://gitlist.dev/t/13560

## drafnel@gmail.com, 2008-05-18 04:00

Subject: [PATCH] t7701-repack-unpack-unreachable.sh: check timestamp of unpacked objects
Message-ID: <16342222.1211083116270.JavaMail.teamon@b306.teamon.com>
URL: https://gitlist.dev/e/16342222.1211083116270.JavaMail.teamon%40b306.teamon.com

```
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

```

## Junio C Hamano, 2008-05-19 04:37

Subject: Re: [PATCH] t7701-repack-unpack-unreachable.sh: check timestamp of unpacked objects
Message-ID: <7vd4niaozy.fsf@gitster.siamese.dyndns.org>
URL: https://gitlist.dev/e/7vd4niaozy.fsf%40gitster.siamese.dyndns.org
In-Reply-To: <16342222.1211083116270.JavaMail.teamon@b306.teamon.com>

```
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.

```

## Brandon Casey, 2008-05-19 14:20

Subject: Re: [PATCH] t7701-repack-unpack-unreachable.sh: check timestamp of unpacked objects
Message-ID: <OleexvYZfiSxUgrxHbDqLpGl2g7TsoOO7pwZXC1fiyL2KxKVuWLtWw@cipher.nrlssc.navy.mil>
URL: https://gitlist.dev/e/OleexvYZfiSxUgrxHbDqLpGl2g7TsoOO7pwZXC1fiyL2KxKVuWLtWw%40cipher.nrlssc.navy.mil
In-Reply-To: <7vd4niaozy.fsf@gitster.siamese.dyndns.org>

```
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

```

## Brandon Casey, 2008-05-19 20:27

Subject: Re: [PATCH] t7701-repack-unpack-unreachable.sh: check timestamp of unpacked objects
Message-ID: <E8K6ZsektNV-bzzpBDDSjLUNAu6_Tgxq9EV2896g2zCI6VyLsESxXw@cipher.nrlssc.navy.mil>
URL: https://gitlist.dev/e/E8K6ZsektNV-bzzpBDDSjLUNAu6_Tgxq9EV2896g2zCI6VyLsESxXw%40cipher.nrlssc.navy.mil
In-Reply-To: <OleexvYZfiSxUgrxHbDqLpGl2g7TsoOO7pwZXC1fiyL2KxKVuWLtWw@cipher.nrlssc.navy.mil>

```
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

```

## Jeff King, 2008-05-19 21:08

Subject: Re: [PATCH] t7701-repack-unpack-unreachable.sh: check timestamp of unpacked objects
Message-ID: <20080519210843.GA25293@sigill.intra.peff.net>
URL: https://gitlist.dev/e/20080519210843.GA25293%40sigill.intra.peff.net
In-Reply-To: <E8K6ZsektNV-bzzpBDDSjLUNAu6_Tgxq9EV2896g2zCI6VyLsESxXw@cipher.nrlssc.navy.mil>

```
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, 2008-05-19 21:48

Subject: Re: [PATCH] t7701-repack-unpack-unreachable.sh: check timestamp of unpacked objects
Message-ID: <muwFetVdZVj0u7hdn3wbFF5mvUXeSbjeC5MyMipJMopcTE4BPs_RBQ@cipher.nrlssc.navy.mil>
URL: https://gitlist.dev/e/muwFetVdZVj0u7hdn3wbFF5mvUXeSbjeC5MyMipJMopcTE4BPs_RBQ%40cipher.nrlssc.navy.mil
In-Reply-To: <20080519210843.GA25293@sigill.intra.peff.net>

```
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

```
