summaryrefslogtreecommitdiff
path: root/http-fetch.c
diff options
context:
space:
mode:
authorJonathan Tan <jonathantanmy@google.com>2021-02-22 19:20:07 (GMT)
committerJunio C Hamano <gitster@pobox.com>2021-02-22 20:07:40 (GMT)
commit27e35ba6c6b532ad6fc88b554d437b6892b4e915 (patch)
treef193e02cb315dc7b30acd5358654a11832d98e9d /http-fetch.c
parent726b25a91ba0e8f26f83c8d39ad16351b7bdb510 (diff)
downloadgit-27e35ba6c6b532ad6fc88b554d437b6892b4e915.zip
git-27e35ba6c6b532ad6fc88b554d437b6892b4e915.tar.gz
git-27e35ba6c6b532ad6fc88b554d437b6892b4e915.tar.bz2
http-fetch: allow custom index-pack args
This is the next step in teaching fetch-pack to pass its index-pack arguments when processing packfiles referenced by URIs. The "--keep" in fetch-pack.c will be replaced with a full message in a subsequent commit. Signed-off-by: Jonathan Tan <jonathantanmy@google.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'http-fetch.c')
-rw-r--r--http-fetch.c20
1 files changed, 15 insertions, 5 deletions
diff --git a/http-fetch.c b/http-fetch.c
index 2d1d9d0..fa64246 100644
--- a/http-fetch.c
+++ b/http-fetch.c
@@ -3,6 +3,7 @@
#include "exec-cmd.h"
#include "http.h"
#include "walker.h"
+#include "strvec.h"
static const char http_fetch_usage[] = "git http-fetch "
"[-c] [-t] [-a] [-v] [--recover] [-w ref] [--stdin | --packfile=hash | commit-id] url";
@@ -43,11 +44,9 @@ static int fetch_using_walker(const char *raw_url, int get_verbosely,
return rc;
}
-static const char *index_pack_args[] =
- {"index-pack", "--stdin", "--keep", NULL};
-
static void fetch_single_packfile(struct object_id *packfile_hash,
- const char *url) {
+ const char *url,
+ const char **index_pack_args) {
struct http_pack_request *preq;
struct slot_results results;
int ret;
@@ -90,6 +89,7 @@ int cmd_main(int argc, const char **argv)
int packfile = 0;
int nongit;
struct object_id packfile_hash;
+ struct strvec index_pack_args = STRVEC_INIT;
setup_git_directory_gently(&nongit);
@@ -116,6 +116,8 @@ int cmd_main(int argc, const char **argv)
packfile = 1;
if (parse_oid_hex(p, &packfile_hash, &end) || *end)
die(_("argument to --packfile must be a valid hash (got '%s')"), p);
+ } else if (skip_prefix(argv[arg], "--index-pack-arg=", &p)) {
+ strvec_push(&index_pack_args, p);
}
arg++;
}
@@ -128,10 +130,18 @@ int cmd_main(int argc, const char **argv)
git_config(git_default_config, NULL);
if (packfile) {
- fetch_single_packfile(&packfile_hash, argv[arg]);
+ if (!index_pack_args.nr)
+ die(_("--packfile requires --index-pack-args"));
+
+ fetch_single_packfile(&packfile_hash, argv[arg],
+ index_pack_args.v);
+
return 0;
}
+ if (index_pack_args.nr)
+ die(_("--index-pack-args can only be used with --packfile"));
+
if (commits_on_stdin) {
commits = walker_targets_stdin(&commit_id, &write_ref);
} else {