Ævar Arnfjörð Bjarmason | 760486a | 2021-08-05 03:25:41 +0200 | [diff] [blame] | 1 | #!/bin/sh |
| 2 | |
| 3 | test_description='test functionality common to smart fetch & push' |
| 4 | |
Ævar Arnfjörð Bjarmason | 760486a | 2021-08-05 03:25:41 +0200 | [diff] [blame] | 5 | . ./test-lib.sh |
| 6 | |
| 7 | test_expect_success 'setup' ' |
| 8 | test_commit --no-tag initial |
| 9 | ' |
| 10 | |
Ævar Arnfjörð Bjarmason | 98e2d9d | 2021-08-05 03:25:43 +0200 | [diff] [blame] | 11 | test_expect_success 'git upload-pack --http-backend-info-refs and --advertise-refs are aliased' ' |
| 12 | git upload-pack --http-backend-info-refs . >expected 2>err.expected && |
| 13 | git upload-pack --advertise-refs . >actual 2>err.actual && |
| 14 | test_cmp err.expected err.actual && |
| 15 | test_cmp expected actual |
| 16 | ' |
| 17 | |
| 18 | test_expect_success 'git receive-pack --http-backend-info-refs and --advertise-refs are aliased' ' |
| 19 | git receive-pack --http-backend-info-refs . >expected 2>err.expected && |
| 20 | git receive-pack --advertise-refs . >actual 2>err.actual && |
| 21 | test_cmp err.expected err.actual && |
| 22 | test_cmp expected actual |
| 23 | ' |
| 24 | |
Ævar Arnfjörð Bjarmason | 760486a | 2021-08-05 03:25:41 +0200 | [diff] [blame] | 25 | test_expect_success 'git upload-pack --advertise-refs' ' |
| 26 | cat >expect <<-EOF && |
| 27 | $(git rev-parse HEAD) HEAD |
| 28 | $(git rev-parse HEAD) $(git symbolic-ref HEAD) |
| 29 | 0000 |
| 30 | EOF |
| 31 | |
| 32 | # We only care about GIT_PROTOCOL, not GIT_TEST_PROTOCOL_VERSION |
| 33 | sane_unset GIT_PROTOCOL && |
| 34 | GIT_TEST_PROTOCOL_VERSION=2 \ |
| 35 | git upload-pack --advertise-refs . >out 2>err && |
| 36 | |
| 37 | test-tool pkt-line unpack <out >actual && |
| 38 | test_must_be_empty err && |
| 39 | test_cmp actual expect && |
| 40 | |
| 41 | # The --advertise-refs alias works |
| 42 | git upload-pack --advertise-refs . >out 2>err && |
| 43 | |
| 44 | test-tool pkt-line unpack <out >actual && |
| 45 | test_must_be_empty err && |
| 46 | test_cmp actual expect |
| 47 | ' |
| 48 | |
| 49 | test_expect_success 'git upload-pack --advertise-refs: v0' ' |
| 50 | # With no specified protocol |
| 51 | cat >expect <<-EOF && |
| 52 | $(git rev-parse HEAD) HEAD |
| 53 | $(git rev-parse HEAD) $(git symbolic-ref HEAD) |
| 54 | 0000 |
| 55 | EOF |
| 56 | |
| 57 | git upload-pack --advertise-refs . >out 2>err && |
| 58 | test-tool pkt-line unpack <out >actual && |
| 59 | test_must_be_empty err && |
| 60 | test_cmp actual expect && |
| 61 | |
| 62 | # With explicit v0 |
| 63 | GIT_PROTOCOL=version=0 \ |
| 64 | git upload-pack --advertise-refs . >out 2>err && |
| 65 | test-tool pkt-line unpack <out >actual 2>err && |
| 66 | test_must_be_empty err && |
| 67 | test_cmp actual expect |
| 68 | |
| 69 | ' |
| 70 | |
| 71 | test_expect_success 'git receive-pack --advertise-refs: v0' ' |
| 72 | # With no specified protocol |
| 73 | cat >expect <<-EOF && |
| 74 | $(git rev-parse HEAD) $(git symbolic-ref HEAD) |
| 75 | 0000 |
| 76 | EOF |
| 77 | |
| 78 | git receive-pack --advertise-refs . >out 2>err && |
| 79 | test-tool pkt-line unpack <out >actual && |
| 80 | test_must_be_empty err && |
| 81 | test_cmp actual expect && |
| 82 | |
| 83 | # With explicit v0 |
| 84 | GIT_PROTOCOL=version=0 \ |
| 85 | git receive-pack --advertise-refs . >out 2>err && |
| 86 | test-tool pkt-line unpack <out >actual 2>err && |
| 87 | test_must_be_empty err && |
| 88 | test_cmp actual expect |
| 89 | |
| 90 | ' |
| 91 | |
| 92 | test_expect_success 'git upload-pack --advertise-refs: v1' ' |
| 93 | # With no specified protocol |
| 94 | cat >expect <<-EOF && |
| 95 | version 1 |
| 96 | $(git rev-parse HEAD) HEAD |
| 97 | $(git rev-parse HEAD) $(git symbolic-ref HEAD) |
| 98 | 0000 |
| 99 | EOF |
| 100 | |
| 101 | GIT_PROTOCOL=version=1 \ |
| 102 | git upload-pack --advertise-refs . >out && |
| 103 | |
| 104 | test-tool pkt-line unpack <out >actual 2>err && |
| 105 | test_must_be_empty err && |
| 106 | test_cmp actual expect |
| 107 | ' |
| 108 | |
| 109 | test_expect_success 'git receive-pack --advertise-refs: v1' ' |
| 110 | # With no specified protocol |
| 111 | cat >expect <<-EOF && |
| 112 | version 1 |
| 113 | $(git rev-parse HEAD) $(git symbolic-ref HEAD) |
| 114 | 0000 |
| 115 | EOF |
| 116 | |
| 117 | GIT_PROTOCOL=version=1 \ |
| 118 | git receive-pack --advertise-refs . >out && |
| 119 | |
| 120 | test-tool pkt-line unpack <out >actual 2>err && |
| 121 | test_must_be_empty err && |
| 122 | test_cmp actual expect |
| 123 | ' |
| 124 | |
| 125 | test_expect_success 'git upload-pack --advertise-refs: v2' ' |
| 126 | cat >expect <<-EOF && |
| 127 | version 2 |
| 128 | agent=FAKE |
| 129 | ls-refs=unborn |
| 130 | fetch=shallow wait-for-done |
| 131 | server-option |
| 132 | object-format=$(test_oid algo) |
Ævar Arnfjörð Bjarmason | 760486a | 2021-08-05 03:25:41 +0200 | [diff] [blame] | 133 | 0000 |
| 134 | EOF |
| 135 | |
| 136 | GIT_PROTOCOL=version=2 \ |
| 137 | GIT_USER_AGENT=FAKE \ |
| 138 | git upload-pack --advertise-refs . >out 2>err && |
| 139 | |
| 140 | test-tool pkt-line unpack <out >actual && |
| 141 | test_must_be_empty err && |
| 142 | test_cmp actual expect |
| 143 | ' |
| 144 | |
| 145 | test_expect_success 'git receive-pack --advertise-refs: v2' ' |
| 146 | # There is no v2 yet for receive-pack, implicit v0 |
| 147 | cat >expect <<-EOF && |
| 148 | $(git rev-parse HEAD) $(git symbolic-ref HEAD) |
| 149 | 0000 |
| 150 | EOF |
| 151 | |
| 152 | GIT_PROTOCOL=version=2 \ |
| 153 | git receive-pack --advertise-refs . >out 2>err && |
| 154 | |
| 155 | test-tool pkt-line unpack <out >actual && |
| 156 | test_must_be_empty err && |
| 157 | test_cmp actual expect |
| 158 | ' |
| 159 | |
| 160 | test_done |