]> git.ipfire.org Git - thirdparty/git.git/blame - t/t5306-pack-nobase.sh
Sync with Git 2.45.1
[thirdparty/git.git] / t / t5306-pack-nobase.sh
CommitLineData
6d6f9cdd
SP
1#!/bin/sh
2#
3# Copyright (c) 2008 Google Inc.
4#
5
6test_description='git-pack-object with missing base
7
8'
b2e5d75d
ÆAB
9
10TEST_PASSES_SANITIZE_LEAK=true
6d6f9cdd
SP
11. ./test-lib.sh
12
13# Create A-B chain
14#
a45bb750
JC
15test_expect_success 'setup base' '
16 test_write_lines a b c d e f g h i >text &&
17 echo side >side &&
18 git update-index --add text side &&
19 A=$(echo A | git commit-tree $(git write-tree)) &&
6d6f9cdd 20
a45bb750
JC
21 echo m >>text &&
22 git update-index text &&
23 B=$(echo B | git commit-tree $(git write-tree) -p $A) &&
24 git update-ref HEAD $B
25'
6d6f9cdd
SP
26
27# Create repository with C whose parent is B.
28# Repository contains C, C^{tree}, C:text, B, B^{tree}.
29# Repository is missing B:text (best delta base for C:text).
30# Repository is missing A (parent of B).
31# Repository is missing A:side.
32#
a45bb750
JC
33test_expect_success 'setup patch_clone' '
34 base_objects=$(pwd)/.git/objects &&
35 (mkdir patch_clone &&
36 cd patch_clone &&
37 git init &&
38 echo "$base_objects" >.git/objects/info/alternates &&
39 echo q >>text &&
40 git read-tree $B &&
41 git update-index text &&
42 git update-ref HEAD $(echo C | git commit-tree $(git write-tree) -p $B) &&
43 rm .git/objects/info/alternates &&
6d6f9cdd 44
a45bb750
JC
45 git --git-dir=../.git cat-file commit $B |
46 git hash-object -t commit -w --stdin &&
6d6f9cdd 47
a45bb750
JC
48 git --git-dir=../.git cat-file tree "$B^{tree}" |
49 git hash-object -t tree -w --stdin
50 ) &&
51 C=$(git --git-dir=patch_clone/.git rev-parse HEAD)
52'
6d6f9cdd
SP
53
54# Clone patch_clone indirectly by cloning base and fetching.
55#
a45bb750
JC
56test_expect_success 'indirectly clone patch_clone' '
57 (mkdir user_clone &&
58 cd user_clone &&
59 git init &&
60 git pull ../.git &&
61 test $(git rev-parse HEAD) = $B &&
6d6f9cdd 62
a45bb750
JC
63 git pull ../patch_clone/.git &&
64 test $(git rev-parse HEAD) = $C
65 )
66'
6d6f9cdd
SP
67
68# Cloning the patch_clone directly should fail.
69#
a45bb750
JC
70test_expect_success 'clone of patch_clone is incomplete' '
71 (mkdir user_direct &&
72 cd user_direct &&
73 git init &&
74 test_must_fail git fetch ../patch_clone/.git
75 )
76'
6d6f9cdd
SP
77
78test_done