t7701-repack-unpack-unreachable.sh: check timestamp of unpacked objects
Unpacked objects should receive the timestamp of the pack they were unpacked from. Check. Signed-off-by: Brandon Casey <drafnel@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Brandon Casey committed
Jun 28, 2008 at 19:25 UTC
e896912c5edb8f989a2d25e101b2eb14f1a56aa9
1 file changed
+34
t/t7701-repack-unpack-unreachable.sh
+34
@@ -4,6 +4,10 @@ test_description='git-repack works correctly'
4
5
. ./test-lib.sh
6
7
+fsha1=
8
+csha1=
9
+tsha1=
10
+
11
test_expect_success '-A option leaves unreachable objects unpacked' '
12
echo content > file1 &&
13
git add . &&
@@ -44,4 +48,34 @@ test_expect_success '-A option leaves unreachable objects unpacked' '
48
git show $tsha1
49
'
50
51
+compare_mtimes ()
52
+{
53
+ perl -e 'my $reference = shift;
54
+ foreach my $file (@ARGV) {
55
+ exit(1) unless(-f $file && -M $file == -M $reference);
56
+ }
57
+ exit(0);
58
+ ' -- "$@"
59
+}
60
+
61
+test_expect_success 'unpacked objects receive timestamp of pack file' '
62
+ fsha1path=$(echo "$fsha1" | sed -e "s|\(..\)|\1/|") &&
63
+ fsha1path=".git/objects/$fsha1path" &&
64
+ csha1path=$(echo "$csha1" | sed -e "s|\(..\)|\1/|") &&
65
+ csha1path=".git/objects/$csha1path" &&
66
+ tsha1path=$(echo "$tsha1" | sed -e "s|\(..\)|\1/|") &&
67
+ tsha1path=".git/objects/$tsha1path" &&
68
+ git branch transient_branch $csha1 &&
69
+ git repack -a -d -l &&
70
+ test ! -f "$fsha1path" &&
71
+ test ! -f "$csha1path" &&
72
+ test ! -f "$tsha1path" &&
73
+ test 1 = $(ls -1 .git/objects/pack/pack-*.pack | wc -l) &&
74
+ packfile=$(ls .git/objects/pack/pack-*.pack) &&
75
+ git branch -D transient_branch &&
76
+ sleep 1 &&
77
+ git repack -A -l &&
78
+ compare_mtimes "$packfile" "$fsha1path" "$csha1path" "$tsha1path"
79
+'
80
+
81
test_done