summaryrefslogtreecommitdiff
path: root/cache.h
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2016-10-06 14:53:10 -0700
committerJunio C Hamano <gitster@pobox.com>2016-10-06 14:53:10 -0700
commit66c22ba6fbe0724ecce3d82611ff0ec5c2b0255f (patch)
tree8829eb1f019a57f5bdd3743d081e0751f38340c9 /cache.h
parent0cf36115dce7438a0eafad54a81cc57175e8fb54 (diff)
parent5b33cb1fd733f581da07ae8afa7e9547eafd248e (diff)
downloadgit-66c22ba6fbe0724ecce3d82611ff0ec5c2b0255f.tar.gz
Merge branch 'jk/ambiguous-short-object-names'
When given an abbreviated object name that is not (or more realistically, "no longer") unique, we gave a fatal error "ambiguous argument". This error is now accompanied by hints that lists the objects that begins with the given prefix. During the course of development of this new feature, numerous minor bugs were uncovered and corrected, the most notable one of which is that we gave "short SHA1 xxxx is ambiguous." twice without good reason. * jk/ambiguous-short-object-names: get_short_sha1: make default disambiguation configurable get_short_sha1: list ambiguous objects on error for_each_abbrev: drop duplicate objects sha1_array: let callbacks interrupt iteration get_short_sha1: mark ambiguity error for translation get_short_sha1: NUL-terminate hex prefix get_short_sha1: refactor init of disambiguation code get_short_sha1: parse tags when looking for treeish get_sha1: propagate flags to child functions get_sha1: avoid repeating ourselves via ONLY_TO_DIE get_sha1: detect buggy calls with multiple disambiguators
Diffstat (limited to 'cache.h')
-rw-r--r--cache.h7
1 files changed, 7 insertions, 0 deletions
diff --git a/cache.h b/cache.h
index 6fc0e5ae68..1604e29878 100644
--- a/cache.h
+++ b/cache.h
@@ -1206,6 +1206,11 @@ struct object_context {
#define GET_SHA1_FOLLOW_SYMLINKS 0100
#define GET_SHA1_ONLY_TO_DIE 04000
+#define GET_SHA1_DISAMBIGUATORS \
+ (GET_SHA1_COMMIT | GET_SHA1_COMMITTISH | \
+ GET_SHA1_TREE | GET_SHA1_TREEISH | \
+ GET_SHA1_BLOB)
+
extern int get_sha1(const char *str, unsigned char *sha1);
extern int get_sha1_commit(const char *str, unsigned char *sha1);
extern int get_sha1_committish(const char *str, unsigned char *sha1);
@@ -1220,6 +1225,8 @@ extern int get_oid(const char *str, struct object_id *oid);
typedef int each_abbrev_fn(const unsigned char *sha1, void *);
extern int for_each_abbrev(const char *prefix, each_abbrev_fn, void *);
+extern int set_disambiguate_hint_config(const char *var, const char *value);
+
/*
* Try to read a SHA1 in hexadecimal format from the 40 characters
* starting at hex. Write the 20-byte result to sha1 in binary form.