author | Junio C Hamano <gitster@pobox.com> | |
Wed, 23 Mar 2011 21:55:40 +0000 (14:55 -0700) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Wed, 23 Mar 2011 21:55:40 +0000 (14:55 -0700) |
* lt/default-abbrev:
Rename core.abbrevlength back to core.abbrev
Make the default abbrev length configurable
Rename core.abbrevlength back to core.abbrev
Make the default abbrev length configurable
Documentation/config.txt | patch | blob | history | |
builtin/describe.c | patch | blob | history | |
cache.h | patch | blob | history | |
config.c | patch | blob | history | |
environment.c | patch | blob | history |
index 701fba92dc1cfda8982aee8b66eb39b8b1c5816b..8ea55d46add1da6d1e810cb126a7ecc5ce456650 100644 (file)
--- a/Documentation/config.txt
+++ b/Documentation/config.txt
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
diff --git a/builtin/describe.c b/builtin/describe.c
index 3ba26dc8192d0a75d7e330d2f73d0d9841a6216c..4afd1504a666d670ec71bdbd61b09bc0530ed04b 100644 (file)
--- a/builtin/describe.c
+++ b/builtin/describe.c
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;
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)
index 872bc9be11d8236673a96ea7ba9c9b77b72034b0..f765cf5da2af379106e0e4e2d99780a268ad21fa 100644 (file)
--- a/cache.h
+++ b/cache.h
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;
}
/* 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];
diff --git a/config.c b/config.c
index e28197a3f64cb8672f8aeef26cc0402c7c22548d..0abcada9381a3e6638f94bcf41bf9ee7b96f4de8 100644 (file)
--- a/config.c
+++ b/config.c
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)
diff --git a/environment.c b/environment.c
index cc670b1562504f9cfe79247d98e50c62c50eaea5..f4549d3f7b0367b31b0fa0042fb12ff183beb081 100644 (file)
--- a/environment.c
+++ b/environment.c
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;