From: Junio C Hamano Date: Sat, 4 Dec 2010 00:10:35 +0000 (-0800) Subject: Merge branch 'jc/abbrev-guard' X-Git-Tag: v1.7.4-rc0~93 X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/63ae595c6d60ac238e8a785bd811db41de74e93d?ds=sidebyside;hp=-c Merge branch 'jc/abbrev-guard' * jc/abbrev-guard: core.abbrevguard: Ensure short object names stay unique a bit longer --- 63ae595c6d60ac238e8a785bd811db41de74e93d diff --combined Documentation/config.txt index 6b7279f883,6994338c90..ad5eb5f21d --- a/Documentation/config.txt +++ b/Documentation/config.txt @@@ -374,6 -374,15 +374,15 @@@ core.warnAmbiguousRefs: If true, git will warn you if the ref name you passed it is ambiguous and might match multiple refs in the .git/refs/ tree. True by default. + core.abbrevguard:: + Even though git makes sure that it uses enough hexdigits to show + an abbreviated object name unambiguously, as more objects are + added to the repository over time, a short name that used to be + unique will stop being unique. Git uses this many extra hexdigits + that are more than necessary to make the object name currently + unique, in the hope that its output will stay unique a bit longer. + Defaults to 0. + core.compression:: An integer -1..9, indicating a default compression level. -1 is the zlib default. 0 means no compression, @@@ -554,13 -563,9 +563,13 @@@ core.sparseCheckout: linkgit:git-read-tree[1] for more information. add.ignore-errors:: +add.ignoreErrors:: Tells 'git add' to continue adding files when some files cannot be added due to indexing errors. Equivalent to the '--ignore-errors' - option of linkgit:git-add[1]. + option of linkgit:git-add[1]. Older versions of git accept only + `add.ignore-errors`, which does not follow the usual naming + convention for configuration variables. Newer versions of git + honor `add.ignoreErrors` as well. alias.*:: Command aliases for the linkgit:git[1] command wrapper - e.g. @@@ -605,9 -610,8 +614,9 @@@ branch.autosetupmerge: this behavior can be chosen per-branch using the `--track` and `--no-track` options. The valid settings are: `false` -- no automatic setup is done; `true` -- automatic setup is done when the - starting point is a remote branch; `always` -- automatic setup is - done when the starting point is either a local branch or remote + starting point is a remote-tracking branch; `always` -- + automatic setup is done when the starting point is either a + local branch or remote-tracking branch. This option defaults to true. branch.autosetuprebase:: @@@ -618,7 -622,7 +627,7 @@@ When `local`, rebase is set to true for tracked branches of other local branches. When `remote`, rebase is set to true for tracked branches of - remote branches. + remote-tracking branches. When `always`, rebase will be set to true for all tracking branches. See "branch.autosetupmerge" for details on how to set up a @@@ -685,7 -689,7 +694,7 @@@ color.branch: color.branch.:: Use customized color for branch coloration. `` is one of `current` (the current branch), `local` (a local branch), - `remote` (a tracking branch in refs/remotes/), `plain` (other + `remote` (a remote-tracking branch in refs/remotes/), `plain` (other refs). + The value for these configuration variables is a list of colors (at most @@@ -713,7 -717,7 +722,7 @@@ color.diff.: color.decorate.:: Use customized color for 'git log --decorate' output. `` is one of `branch`, `remoteBranch`, `tag`, `stash` or `HEAD` for local - branches, remote tracking branches, tags, stash and HEAD, respectively. + branches, remote-tracking branches, tags, stash and HEAD, respectively. color.grep:: When set to `always`, always highlight matches. When `false` (or @@@ -1107,7 -1111,7 +1116,7 @@@ gui.newbranchtemplate: linkgit:git-gui[1]. gui.pruneduringfetch:: - "true" if linkgit:git-gui[1] should prune tracking branches when + "true" if linkgit:git-gui[1] should prune remote-tracking branches when performing a fetch. The default value is "false". gui.trustmtime:: diff --combined cache.h index d85ce86f7f,931fb597ee..e56a0a23ae --- a/cache.h +++ b/cache.h @@@ -545,6 -545,7 +545,7 @@@ extern int assume_unchanged extern int prefer_symlink_refs; extern int log_all_ref_updates; extern int warn_ambiguous_refs; + extern int unique_abbrev_extra_length; extern int shared_repository; extern const char *apply_default_whitespace; extern const char *apply_default_ignorewhitespace; @@@ -859,7 -860,7 +860,7 @@@ struct cache_def extern int has_symlink_leading_path(const char *name, int len); extern int threaded_has_symlink_leading_path(struct cache_def *, const char *, int); -extern int has_symlink_or_noent_leading_path(const char *name, int len); +extern int check_leading_path(const char *name, int len); extern int has_dirs_only_path(const char *name, int len, int prefix_len); extern void schedule_dir_for_removal(const char *name, int len); extern void remove_scheduled_dirs(void); diff --combined config.c index c63d6834e0,1aa72c2c41..f138c34721 --- a/config.c +++ b/config.c @@@ -489,6 -489,13 +489,13 @@@ static int git_default_core_config(cons return 0; } + if (!strcmp(var, "core.abbrevguard")) { + unique_abbrev_extra_length = git_config_int(var, value); + if (unique_abbrev_extra_length < 0) + unique_abbrev_extra_length = 0; + return 0; + } + if (!strcmp(var, "core.bare")) { is_bare_repository_cfg = git_config_bool(var, value); return 0; @@@ -871,7 -878,9 +878,7 @@@ int git_config(config_fn_t fn, void *da if (config_parameters) found += 1; - if (found == 0) - return -1; - return ret; + return ret == 0 ? found : ret; } /* diff --combined sha1_name.c index 3e856b8036,4a226adece..b48b91c507 --- a/sha1_name.c +++ b/sha1_name.c @@@ -206,7 -206,9 +206,9 @@@ const char *find_unique_abbrev(const un if (exists ? !status : status == SHORT_NAME_NOT_FOUND) { - hex[len] = 0; + int cut_at = len + unique_abbrev_extra_length; + cut_at = (cut_at < 40) ? cut_at : 40; + hex[cut_at] = 0; return hex; } len++; @@@ -1069,7 -1071,6 +1071,7 @@@ int get_sha1_with_context_1(const char struct cache_entry *ce; int pos; if (namelen > 2 && name[1] == '/') + /* don't need mode for commit */ return get_sha1_oneline(name + 2, sha1); if (namelen < 3 || name[2] != ':' || @@@ -1097,7 -1098,6 +1099,7 @@@ break; if (ce_stage(ce) == stage) { hashcpy(sha1, ce->sha1); + oc->mode = ce->ce_mode; return 0; } pos++;