clone: keep --reference even with -l -s
Both -l -s and --reference update objects/info/alternates and used to write over each other. Signed-off-by: Martin Waitz <tali@admingilde.org> Signed-off-by: Junio C Hamano <junkio@cox.net>
Martin Waitz committed
May 7, 2006 at 20:19 UTC
cf9dc65368113caa28f2829e2ada5477fbb031ec
2 files changed
+79
-1
git-clone.sh
+1
-1
@@ -265,7 +265,7 @@ yes,yes)
265
test -f "$repo/objects/info/alternates" &&
266
cat "$repo/objects/info/alternates";
267
echo "$repo/objects"
268
- } >"$GIT_DIR/objects/info/alternates"
268
+ } >>"$GIT_DIR/objects/info/alternates"
269
;;
270
esac
271
git-ls-remote "$repo" >"$GIT_DIR/CLONE_HEAD"
t/t5700-clone-reference.sh
new
+78
@@ -0,0 +1,78 @@
1
+#!/bin/sh
2
+#
3
+# Copyright (C) 2006 Martin Waitz <tali@admingilde.org>
4
+#
5
+
6
+test_description='test clone --reference'
7
+. ./test-lib.sh
8
+
9
+base_dir=`pwd`
10
+
11
+test_expect_success 'preparing first repository' \
12
+'test_create_repo A && cd A &&
13
+echo first > file1 &&
14
+git add file1 &&
15
+git commit -m initial'
16
+
17
+cd "$base_dir"
18
+
19
+test_expect_success 'preparing second repository' \
20
+'git clone A B && cd B &&
21
+echo second > file2 &&
22
+git add file2 &&
23
+git commit -m addition &&
24
+git repack -a -d &&
25
+git prune'
26
+
27
+cd "$base_dir"
28
+
29
+test_expect_success 'cloning with reference' \
30
+'git clone -l -s --reference B A C'
31
+
32
+cd "$base_dir"
33
+
34
+test_expect_success 'existance of info/alternates' \
35
+'test `wc -l <C/.git/objects/info/alternates` = 2'
36
+
37
+cd "$base_dir"
38
+
39
+test_expect_success 'pulling from reference' \
40
+'cd C &&
41
+git pull ../B'
42
+
43
+cd "$base_dir"
44
+
45
+test_expect_success 'that reference gets used' \
46
+'cd C &&
47
+echo "0 objects, 0 kilobytes" > expected &&
48
+git count-objects > current &&
49
+diff expected current'
50
+
51
+cd "$base_dir"
52
+
53
+test_expect_success 'updating origin' \
54
+'cd A &&
55
+echo third > file3 &&
56
+git add file3 &&
57
+git commit -m update &&
58
+git repack -a -d &&
59
+git prune'
60
+
61
+cd "$base_dir"
62
+
63
+test_expect_success 'pulling changes from origin' \
64
+'cd C &&
65
+git pull origin'
66
+
67
+cd "$base_dir"
68
+
69
+# the 2 local objects are commit and tree from the merge
70
+test_expect_success 'that alternate to origin gets used' \
71
+'cd C &&
72
+echo "2 objects" > expected &&
73
+git count-objects | cut -d, -f1 > current &&
74
+diff expected current'
75
+
76
+cd "$base_dir"
77
+
78
+test_done