Merge branch 'jk/no-looking-at-dotgit-outside-repo'
authorJunio C Hamano <gitster@pobox.com>
Thu, 27 Oct 2016 21:58:48 +0000 (14:58 -0700)
committerJunio C Hamano <gitster@pobox.com>
Thu, 27 Oct 2016 21:58:48 +0000 (14:58 -0700)
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

1  2 
cache.h
diff.c
sha1_name.c
diff --cc cache.h
Simple merge
diff --cc diff.c
index 5a4e9b31efd5ba6ab43e715effe4d97b13ef2a07,4c47bb3a2d23d2f747b416669895744c331f3dd5..4c09314cc7970788382a01c6ff839563d4563241
--- 1/diff.c
--- 2/diff.c
+++ b/diff.c
@@@ -3096,6 -3096,19 +3096,21 @@@ static int similarity_index(struct diff
        return p->score * 100 / MAX_SCORE;
  }
  
 -              if (abbrev < 0 || abbrev > GIT_SHA1_HEXSZ)
+ 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 = 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,
diff --cc sha1_name.c
Simple merge