t1408: add a test of stale packed refs covered by loose refs
It is OK for the packed-refs file to contain old reference definitions that might even refer to objects that have since been garbage-collected, as long as there is a corresponding loose reference definition that overrides it. Add a test that such references don't cause problems. Signed-off-by: Junio C Hamano <gitster@pobox.com> Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Junio C Hamano committed
Jun 23, 2017 at 09:01 UTC
74195c69adb922b32a93d5885004337c892e9bc3
1 file changed
+42
t/t1408-packed-refs.sh
new
+42
@@ -0,0 +1,42 @@
1
+#!/bin/sh
2
+
3
+test_description='packed-refs entries are covered by loose refs'
4
+
5
+. ./test-lib.sh
6
+
7
+test_expect_success setup '
8
+ test_tick &&
9
+ git commit --allow-empty -m one &&
10
+ one=$(git rev-parse HEAD) &&
11
+ git for-each-ref >actual &&
12
+ echo "$one commit refs/heads/master" >expect &&
13
+ test_cmp expect actual &&
14
+
15
+ git pack-refs --all &&
16
+ git for-each-ref >actual &&
17
+ echo "$one commit refs/heads/master" >expect &&
18
+ test_cmp expect actual &&
19
+
20
+ git checkout --orphan another &&
21
+ test_tick &&
22
+ git commit --allow-empty -m two &&
23
+ two=$(git rev-parse HEAD) &&
24
+ git checkout -B master &&
25
+ git branch -D another &&
26
+
27
+ git for-each-ref >actual &&
28
+ echo "$two commit refs/heads/master" >expect &&
29
+ test_cmp expect actual &&
30
+
31
+ git reflog expire --expire=now --all &&
32
+ git prune &&
33
+ git tag -m v1.0 v1.0 master
34
+'
35
+
36
+test_expect_success 'no error from stale entry in packed-refs' '
37
+ git describe master >actual 2>&1 &&
38
+ echo "v1.0" >expect &&
39
+ test_cmp expect actual
40
+'
41
+
42
+test_done