Skip to content

Commit 069d786

Browse files
committed
Merge branch 'js/bundle-unbundle-fd-reuse-fix' into jch
The code path used when "git fetch" fetches from a bundle file closed the same file descriptor twice, which sometimes broke things unexpectedly when the file descriptor was reused, which has been corrected. * js/bundle-unbundle-fd-reuse-fix: bundle: avoid closing file descriptor twice
2 parents 3b83cda + 9a84794 commit 069d786

File tree

3 files changed

+6
-1
lines changed

3 files changed

+6
-1
lines changed

bundle.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -607,8 +607,10 @@ int unbundle(struct repository *r, struct bundle_header *header,
607607
if (!opts)
608608
opts = &opts_fallback;
609609

610-
if (verify_bundle(r, header, opts->flags))
610+
if (verify_bundle(r, header, opts->flags)) {
611+
close(bundle_fd);
611612
return -1;
613+
}
612614

613615
strvec_pushl(&ip.args, "index-pack", "--fix-thin", "--stdin", NULL);
614616

bundle.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,8 @@ struct unbundle_opts {
6262
*
6363
* Before unbundling, this method will call verify_bundle() with 'flags'
6464
* provided in 'opts'.
65+
*
66+
* Note that the `bundle_fd` will be closed as part of the operation.
6567
*/
6668
int unbundle(struct repository *r, struct bundle_header *header,
6769
int bundle_fd, struct strvec *extra_index_pack_args,

transport.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,7 @@ static int fetch_refs_from_bundle(struct transport *transport,
207207

208208
ret = unbundle(the_repository, &data->header, data->fd,
209209
&extra_index_pack_args, &opts);
210+
data->fd = -1; /* `unbundle()` closes the file descriptor */
210211
transport->hash_algo = data->header.hash_algo;
211212

212213
strvec_clear(&extra_index_pack_args);

0 commit comments

Comments
 (0)