Skip to content
/ git Public
forked from git/git

Commit 70334fc

Browse files
derrickstoleegitster
authored andcommitted
bundle-uri: quiet failed unbundlings
When downloading a list of bundles in "all" mode, Git has no understanding of the dependencies between the bundles. Git attempts to unbundle the bundles in some order, but some may not pass the verify_bundle() step because of missing prerequisites. This is passed as error messages to the user, even when they eventually succeed in later attempts after their dependent bundles are unbundled. Add a new VERIFY_BUNDLE_QUIET flag to verify_bundle() that avoids the error messages from the missing prerequisite commits. The method still returns the number of missing prerequisit commits, allowing callers to unbundle() to notice that the bundle failed to apply. Use this flag in bundle-uri.c and test that the messages go away for 'git clone --bundle-uri' commands. Signed-off-by: Derrick Stolee <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 89bd7fe commit 70334fc

File tree

5 files changed

+32
-9
lines changed

5 files changed

+32
-9
lines changed

builtin/bundle.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ static int cmd_bundle_verify(int argc, const char **argv, const char *prefix) {
120120
}
121121
close(bundle_fd);
122122
if (verify_bundle(the_repository, &header,
123-
quiet ? 0 : VERIFY_BUNDLE_VERBOSE)) {
123+
quiet ? VERIFY_BUNDLE_QUIET : VERIFY_BUNDLE_VERBOSE)) {
124124
ret = 1;
125125
goto cleanup;
126126
}

bundle-uri.c

+2-1
Original file line numberDiff line numberDiff line change
@@ -308,7 +308,8 @@ static int unbundle_from_file(struct repository *r, const char *file)
308308
* a reachable ref pointing to the new tips, which will reach
309309
* the prerequisite commits.
310310
*/
311-
if ((result = unbundle(r, &header, bundle_fd, NULL, 0)))
311+
if ((result = unbundle(r, &header, bundle_fd, NULL,
312+
VERIFY_BUNDLE_QUIET)))
312313
return 1;
313314

314315
/*

bundle.c

+8-2
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,10 @@ int verify_bundle(struct repository *r,
216216
add_pending_object(&revs, o, name);
217217
continue;
218218
}
219-
if (++ret == 1)
219+
ret++;
220+
if (flags & VERIFY_BUNDLE_QUIET)
221+
continue;
222+
if (ret == 1)
220223
error("%s", message);
221224
error("%s %s", oid_to_hex(oid), name);
222225
}
@@ -243,7 +246,10 @@ int verify_bundle(struct repository *r,
243246
assert(o); /* otherwise we'd have returned early */
244247
if (o->flags & SHOWN)
245248
continue;
246-
if (++ret == 1)
249+
ret++;
250+
if (flags & VERIFY_BUNDLE_QUIET)
251+
continue;
252+
if (ret == 1)
247253
error("%s", message);
248254
error("%s %s", oid_to_hex(oid), name);
249255
}

bundle.h

+1
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ int create_bundle(struct repository *r, const char *path,
3232

3333
enum verify_bundle_flags {
3434
VERIFY_BUNDLE_VERBOSE = (1 << 0),
35+
VERIFY_BUNDLE_QUIET = (1 << 1),
3536
};
3637

3738
int verify_bundle(struct repository *r, struct bundle_header *header,

t/t5558-clone-bundle-uri.sh

+20-5
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,10 @@ test_expect_success 'clone bundle list (file, no heuristic)' '
9999
uri = file://$(pwd)/clone-from/bundle-4.bundle
100100
EOF
101101
102-
git clone --bundle-uri="file://$(pwd)/bundle-list" clone-from clone-list-file &&
102+
git clone --bundle-uri="file://$(pwd)/bundle-list" \
103+
clone-from clone-list-file 2>err &&
104+
! grep "Repository lacks these prerequisite commits" err &&
105+
103106
git -C clone-from for-each-ref --format="%(objectname)" >oids &&
104107
git -C clone-list-file cat-file --batch-check <oids &&
105108
@@ -141,7 +144,10 @@ test_expect_success 'clone bundle list (file, all mode, some failures)' '
141144
EOF
142145
143146
GIT_TRACE2_PERF=1 \
144-
git clone --bundle-uri="file://$(pwd)/bundle-list" clone-from clone-all-some &&
147+
git clone --bundle-uri="file://$(pwd)/bundle-list" \
148+
clone-from clone-all-some 2>err &&
149+
! grep "Repository lacks these prerequisite commits" err &&
150+
145151
git -C clone-from for-each-ref --format="%(objectname)" >oids &&
146152
git -C clone-all-some cat-file --batch-check <oids &&
147153
@@ -169,7 +175,10 @@ test_expect_success 'clone bundle list (file, all mode, all failures)' '
169175
uri = file://$(pwd)/clone-from/bundle-5.bundle
170176
EOF
171177
172-
git clone --bundle-uri="file://$(pwd)/bundle-list" clone-from clone-all-fail &&
178+
git clone --bundle-uri="file://$(pwd)/bundle-list" \
179+
clone-from clone-all-fail 2>err &&
180+
! grep "Repository lacks these prerequisite commits" err &&
181+
173182
git -C clone-from for-each-ref --format="%(objectname)" >oids &&
174183
git -C clone-all-fail cat-file --batch-check <oids &&
175184
@@ -195,7 +204,10 @@ test_expect_success 'clone bundle list (file, any mode)' '
195204
uri = file://$(pwd)/clone-from/bundle-5.bundle
196205
EOF
197206
198-
git clone --bundle-uri="file://$(pwd)/bundle-list" clone-from clone-any-file &&
207+
git clone --bundle-uri="file://$(pwd)/bundle-list" \
208+
clone-from clone-any-file 2>err &&
209+
! grep "Repository lacks these prerequisite commits" err &&
210+
199211
git -C clone-from for-each-ref --format="%(objectname)" >oids &&
200212
git -C clone-any-file cat-file --batch-check <oids &&
201213
@@ -284,7 +296,10 @@ test_expect_success 'clone bundle list (HTTP, no heuristic)' '
284296
uri = $HTTPD_URL/bundle-4.bundle
285297
EOF
286298
287-
git clone --bundle-uri="$HTTPD_URL/bundle-list" clone-from clone-list-http &&
299+
git clone --bundle-uri="$HTTPD_URL/bundle-list" \
300+
clone-from clone-list-http 2>err &&
301+
! grep "Repository lacks these prerequisite commits" err &&
302+
288303
git -C clone-from for-each-ref --format="%(objectname)" >oids &&
289304
git -C clone-list-http cat-file --batch-check <oids
290305
'

0 commit comments

Comments
 (0)