summaryrefslogtreecommitdiff
path: root/http-fetch.c
diff options
context:
space:
mode:
Diffstat (limited to 'http-fetch.c')
-rw-r--r--http-fetch.c26
1 files changed, 19 insertions, 7 deletions
diff --git a/http-fetch.c b/http-fetch.c
index fffda59267..02ab80533f 100644
--- a/http-fetch.c
+++ b/http-fetch.c
@@ -1,12 +1,14 @@
+#define USE_THE_REPOSITORY_VARIABLE
+
#include "git-compat-util.h"
#include "config.h"
-#include "exec-cmd.h"
#include "gettext.h"
#include "hex.h"
#include "http.h"
#include "walker.h"
#include "setup.h"
#include "strvec.h"
+#include "url.h"
#include "urlmatch.h"
#include "trace2.h"
@@ -104,6 +106,7 @@ int cmd_main(int argc, const char **argv)
int nongit;
struct object_id packfile_hash;
struct strvec index_pack_args = STRVEC_INIT;
+ int ret;
setup_git_directory_gently(&nongit);
@@ -127,8 +130,12 @@ int cmd_main(int argc, const char **argv)
} else if (skip_prefix(argv[arg], "--packfile=", &p)) {
const char *end;
+ if (nongit)
+ die(_("not a git repository"));
+
packfile = 1;
- if (parse_oid_hex(p, &packfile_hash, &end) || *end)
+ if (parse_oid_hex_algop(p, &packfile_hash, &end,
+ the_repository->hash_algo) || *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);
@@ -151,8 +158,8 @@ int cmd_main(int argc, const char **argv)
fetch_single_packfile(&packfile_hash, argv[arg],
index_pack_args.v);
-
- return 0;
+ ret = 0;
+ goto out;
}
if (index_pack_args.nr)
@@ -164,7 +171,12 @@ int cmd_main(int argc, const char **argv)
commit_id = (char **) &argv[arg++];
commits = 1;
}
- return fetch_using_walker(argv[arg], get_verbosely, get_recover,
- commits, commit_id, write_ref,
- commits_on_stdin);
+
+ ret = fetch_using_walker(argv[arg], get_verbosely, get_recover,
+ commits, commit_id, write_ref,
+ commits_on_stdin);
+
+out:
+ strvec_clear(&index_pack_args);
+ return ret;
}