Skip to content

Commit

Permalink
Merge branch 'lt/default-abbrev' into maint
Browse files Browse the repository at this point in the history
* lt/default-abbrev:
  Rename core.abbrevlength back to core.abbrev
  Make the default abbrev length configurable
  • Loading branch information
Junio C Hamano committed Apr 3, 2011
2 parents 3967c99 + a71f09f commit be57695
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 3 deletions.
6 changes: 6 additions & 0 deletions Documentation/config.txt
Original file line number Diff line number Diff line change
Expand Up @@ -558,6 +558,12 @@ core.sparseCheckout::
Enable "sparse checkout" feature. See section "Sparse checkout" in
linkgit:git-read-tree[1] for more information.

core.abbrev::
Set the length object names are abbreviated to. If unspecified,
many commands abbreviate to 7 hexdigits, which may not be enough
for abbreviated object names to stay unique for sufficiently long
time.

add.ignore-errors::
add.ignoreErrors::
Tells 'git add' to continue adding files when some files cannot be
Expand Down
6 changes: 5 additions & 1 deletion builtin/describe.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ static int debug; /* Display lots of verbose info */
static int all; /* Any valid ref can be used */
static int tags; /* Allow lightweight tags */
static int longformat;
static int abbrev = DEFAULT_ABBREV;
static int abbrev = -1; /* unspecified */
static int max_candidates = 10;
static struct hash_table names;
static int have_util;
Expand Down Expand Up @@ -420,7 +420,11 @@ int cmd_describe(int argc, const char **argv, const char *prefix)
OPT_END(),
};

git_config(git_default_config, NULL);
argc = parse_options(argc, argv, prefix, options, describe_usage, 0);
if (abbrev < 0)
abbrev = DEFAULT_ABBREV;

if (max_candidates < 0)
max_candidates = 0;
else if (max_candidates > MAX_TAGS)
Expand Down
5 changes: 3 additions & 2 deletions cache.h
Original file line number Diff line number Diff line change
Expand Up @@ -540,6 +540,7 @@ extern int trust_executable_bit;
extern int trust_ctime;
extern int quote_path_fully;
extern int has_symlinks;
extern int minimum_abbrev, default_abbrev;
extern int ignore_case;
extern int assume_unchanged;
extern int prefer_symlink_refs;
Expand Down Expand Up @@ -759,8 +760,8 @@ static inline unsigned int hexval(unsigned char c)
}

/* Convert to/from hex/sha1 representation */
#define MINIMUM_ABBREV 4
#define DEFAULT_ABBREV 7
#define MINIMUM_ABBREV minimum_abbrev
#define DEFAULT_ABBREV default_abbrev

struct object_context {
unsigned char tree[20];
Expand Down
8 changes: 8 additions & 0 deletions config.c
Original file line number Diff line number Diff line change
Expand Up @@ -523,6 +523,14 @@ static int git_default_core_config(const char *var, const char *value)
return 0;
}

if (!strcmp(var, "core.abbrev")) {
int abbrev = git_config_int(var, value);
if (abbrev < minimum_abbrev || abbrev > 40)
return -1;
default_abbrev = abbrev;
return 0;
}

if (!strcmp(var, "core.loosecompression")) {
int level = git_config_int(var, value);
if (level == -1)
Expand Down
1 change: 1 addition & 0 deletions environment.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ int user_ident_explicitly_given;
int trust_executable_bit = 1;
int trust_ctime = 1;
int has_symlinks = 1;
int minimum_abbrev = 4, default_abbrev = 7;
int ignore_case;
int assume_unchanged;
int prefer_symlink_refs;
Expand Down

0 comments on commit be57695

Please sign in to comment.