summaryrefslogtreecommitdiff
path: root/builtin/hash-object.c
diff options
context:
space:
mode:
authorLibravatar Junio C Hamano <gitster@pobox.com>2016-09-21 15:15:23 -0700
committerLibravatar Junio C Hamano <gitster@pobox.com>2016-09-21 15:15:24 -0700
commitd845d727cb1935202b61a3b7b6c8cfa7c09bd204 (patch)
tree7296be39100177a980c2e3d5700371f11dd5b03d /builtin/hash-object.c
parentMerge branch 'ew/http-do-not-forget-to-call-curl-multi-remove-handle' (diff)
parentt1007: factor out repeated setup (diff)
downloadtgif-d845d727cb1935202b61a3b7b6c8cfa7c09bd204.tar.xz
Merge branch 'jk/setup-sequence-update'
There were numerous corner cases in which the configuration files are read and used or not read at all depending on the directory a Git command was run, leading to inconsistent behaviour. The code to set-up repository access at the beginning of a Git process has been updated to fix them. * jk/setup-sequence-update: t1007: factor out repeated setup init: reset cached config when entering new repo init: expand comments explaining config trickery config: only read .git/config from configured repos test-config: setup git directory t1302: use "git -C" pager: handle early config pager: use callbacks instead of configset pager: make pager_program a file-local static pager: stop loading git_default_config() pager: remove obsolete comment diff: always try to set up the repository diff: handle --no-index prefixes consistently diff: skip implicit no-index check when given --no-index patch-id: use RUN_SETUP_GENTLY hash-object: always try to set up the git repository
Diffstat (limited to 'builtin/hash-object.c')
-rw-r--r--builtin/hash-object.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/builtin/hash-object.c b/builtin/hash-object.c
index f7d3567dd0..9028e1fdcc 100644
--- a/builtin/hash-object.c
+++ b/builtin/hash-object.c
@@ -87,6 +87,7 @@ int cmd_hash_object(int argc, const char **argv, const char *prefix)
int stdin_paths = 0;
int no_filters = 0;
int literally = 0;
+ int nongit = 0;
unsigned flags = HASH_FORMAT_CHECK;
const char *vpath = NULL;
const struct option hash_object_options[] = {
@@ -107,12 +108,14 @@ int cmd_hash_object(int argc, const char **argv, const char *prefix)
argc = parse_options(argc, argv, NULL, hash_object_options,
hash_object_usage, 0);
- if (flags & HASH_WRITE_OBJECT) {
+ if (flags & HASH_WRITE_OBJECT)
prefix = setup_git_directory();
- prefix_length = prefix ? strlen(prefix) : 0;
- if (vpath && prefix)
- vpath = prefix_filename(prefix, prefix_length, vpath);
- }
+ else
+ prefix = setup_git_directory_gently(&nongit);
+
+ prefix_length = prefix ? strlen(prefix) : 0;
+ if (vpath && prefix)
+ vpath = prefix_filename(prefix, prefix_length, vpath);
git_config(git_default_config, NULL);