Skip to content

Commit 726b25a

Browse files
jonathantanmygitster
authored andcommitted
http: allow custom index-pack args
Currently, when fetching, packfiles referenced by URIs are run through index-pack without any arguments other than --stdin and --keep, no matter what arguments are used for the packfile that is inline in the fetch response. As a preparation for ensuring that all packs (whether inline or not) use the same index-pack arguments, teach the http subsystem to allow custom index-pack arguments. http-fetch has been updated to use the new API. For now, it passes --keep alone instead of --keep with a process ID, but this is only temporary because http-fetch itself will be taught to accept index-pack parameters (instead of using a hardcoded constant) in a subsequent commit. Signed-off-by: Jonathan Tan <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 66e871b commit 726b25a

File tree

3 files changed

+18
-13
lines changed

3 files changed

+18
-13
lines changed

http-fetch.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,9 @@ static int fetch_using_walker(const char *raw_url, int get_verbosely,
4343
return rc;
4444
}
4545

46+
static const char *index_pack_args[] =
47+
{"index-pack", "--stdin", "--keep", NULL};
48+
4649
static void fetch_single_packfile(struct object_id *packfile_hash,
4750
const char *url) {
4851
struct http_pack_request *preq;
@@ -55,7 +58,8 @@ static void fetch_single_packfile(struct object_id *packfile_hash,
5558
if (preq == NULL)
5659
die("couldn't create http pack request");
5760
preq->slot->results = &results;
58-
preq->generate_keep = 1;
61+
preq->index_pack_args = index_pack_args;
62+
preq->preserve_index_pack_stdout = 1;
5963

6064
if (start_active_slot(preq->slot)) {
6165
run_active_slot(preq->slot);

http.c

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2259,6 +2259,9 @@ void release_http_pack_request(struct http_pack_request *preq)
22592259
free(preq);
22602260
}
22612261

2262+
static const char *default_index_pack_args[] =
2263+
{"index-pack", "--stdin", NULL};
2264+
22622265
int finish_http_pack_request(struct http_pack_request *preq)
22632266
{
22642267
struct child_process ip = CHILD_PROCESS_INIT;
@@ -2270,17 +2273,15 @@ int finish_http_pack_request(struct http_pack_request *preq)
22702273

22712274
tmpfile_fd = xopen(preq->tmpfile.buf, O_RDONLY);
22722275

2273-
strvec_push(&ip.args, "index-pack");
2274-
strvec_push(&ip.args, "--stdin");
22752276
ip.git_cmd = 1;
22762277
ip.in = tmpfile_fd;
2277-
if (preq->generate_keep) {
2278-
strvec_pushf(&ip.args, "--keep=git %"PRIuMAX,
2279-
(uintmax_t)getpid());
2278+
ip.argv = preq->index_pack_args ? preq->index_pack_args
2279+
: default_index_pack_args;
2280+
2281+
if (preq->preserve_index_pack_stdout)
22802282
ip.out = 0;
2281-
} else {
2283+
else
22822284
ip.no_stdout = 1;
2283-
}
22842285

22852286
if (run_command(&ip)) {
22862287
ret = -1;

http.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -218,12 +218,12 @@ struct http_pack_request {
218218
char *url;
219219

220220
/*
221-
* If this is true, finish_http_pack_request() will pass "--keep" to
222-
* index-pack, resulting in the creation of a keep file, and will not
223-
* suppress its stdout (that is, the "keep\t<hash>\n" line will be
224-
* printed to stdout).
221+
* index-pack command to run. Must be terminated by NULL.
222+
*
223+
* If NULL, defaults to {"index-pack", "--stdin", NULL}.
225224
*/
226-
unsigned generate_keep : 1;
225+
const char **index_pack_args;
226+
unsigned preserve_index_pack_stdout : 1;
227227

228228
FILE *packfile;
229229
struct strbuf tmpfile;

0 commit comments

Comments
 (0)