From: Junio C Hamano Date: Thu, 27 Oct 2016 21:58:48 +0000 (-0700) Subject: Merge branch 'jk/no-looking-at-dotgit-outside-repo' X-Git-Tag: v2.11.0-rc0~21 X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/0d9c527d5963fca098ea4964f4129511bd5d82d8 Merge branch 'jk/no-looking-at-dotgit-outside-repo' Update "git diff --no-index" codepath not to try to peek into .git/ directory that happens to be under the current directory, when we know we are operating outside any repository. * jk/no-looking-at-dotgit-outside-repo: diff: handle sha1 abbreviations outside of repository diff_aligned_abbrev: use "struct oid" diff_unique_abbrev: rename to diff_aligned_abbrev find_unique_abbrev: use 4-buffer ring test-*-cache-tree: setup git dir read info/{attributes,exclude} only when in repository --- 0d9c527d5963fca098ea4964f4129511bd5d82d8 diff --cc diff.c index 5a4e9b31ef,4c47bb3a2d..4c09314cc7 --- a/diff.c +++ b/diff.c @@@ -3096,6 -3096,19 +3096,21 @@@ static int similarity_index(struct diff return p->score * 100 / MAX_SCORE; } + static const char *diff_abbrev_oid(const struct object_id *oid, int abbrev) + { + if (startup_info->have_repository) + return find_unique_abbrev(oid->hash, abbrev); + else { + char *hex = oid_to_hex(oid); - if (abbrev < 0 || abbrev > GIT_SHA1_HEXSZ) ++ if (abbrev < 0) ++ abbrev = FALLBACK_DEFAULT_ABBREV; ++ if (abbrev > GIT_SHA1_HEXSZ) + die("BUG: oid abbreviation out of range: %d", abbrev); + hex[abbrev] = '\0'; + return hex; + } + } + static void fill_metainfo(struct strbuf *msg, const char *name, const char *other,