summaryrefslogtreecommitdiff
path: root/builtin
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2017-01-17 23:11:06 (GMT)
committerJunio C Hamano <gitster@pobox.com>2017-01-17 23:11:06 (GMT)
commitb984bc58ce4e67de7e7f1b360c9e153fb6398bca (patch)
tree6d8f8e68cd612133020725788345866b336a88be /builtin
parent5bc5edbae1c5c3756a8927913d32d2b7519e30b0 (diff)
parent29401e15754518a0e63e00d6cabc5a5f2f9b0973 (diff)
downloadgit-b984bc58ce4e67de7e7f1b360c9e153fb6398bca.zip
git-b984bc58ce4e67de7e7f1b360c9e153fb6398bca.tar.gz
git-b984bc58ce4e67de7e7f1b360c9e153fb6398bca.tar.bz2
Merge branch 'jk/index-pack-wo-repo-from-stdin' into maint
"git index-pack --stdin" needs an access to an existing repository, but "git index-pack file.pack" to generate an .idx file that corresponds to a packfile does not. * jk/index-pack-wo-repo-from-stdin: index-pack: skip collision check when not in repository t: use nongit() function where applicable index-pack: complain when --stdin is used outside of a repo t5000: extract nongit function to test-lib-functions.sh
Diffstat (limited to 'builtin')
-rw-r--r--builtin/index-pack.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/builtin/index-pack.c b/builtin/index-pack.c
index 0a27bab..f4b87c6 100644
--- a/builtin/index-pack.c
+++ b/builtin/index-pack.c
@@ -787,13 +787,15 @@ static void sha1_object(const void *data, struct object_entry *obj_entry,
const unsigned char *sha1)
{
void *new_data = NULL;
- int collision_test_needed;
+ int collision_test_needed = 0;
assert(data || obj_entry);
- read_lock();
- collision_test_needed = has_sha1_file_with_flags(sha1, HAS_SHA1_QUICK);
- read_unlock();
+ if (startup_info->have_repository) {
+ read_lock();
+ collision_test_needed = has_sha1_file_with_flags(sha1, HAS_SHA1_QUICK);
+ read_unlock();
+ }
if (collision_test_needed && !data) {
read_lock();
@@ -1730,6 +1732,8 @@ int cmd_index_pack(int argc, const char **argv, const char *prefix)
usage(index_pack_usage);
if (fix_thin_pack && !from_stdin)
die(_("--fix-thin cannot be used without --stdin"));
+ if (from_stdin && !startup_info->have_repository)
+ die(_("--stdin requires a git repository"));
if (!index_name && pack_name)
index_name = derive_filename(pack_name, ".idx", &index_name_buf);
if (keep_msg && !keep_name && pack_name)