diff options
author | Junio C Hamano <gitster@pobox.com> | 2013-02-27 09:47:27 -0800 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2013-02-27 09:47:28 -0800 |
commit | 3e07d2683de55f0e21b13a6724b59bdcd548b5d8 (patch) | |
tree | c176a8b9694174ecc8cc598e1cc267aadf1220df /setup.c | |
parent | 27db5a02c73b35fe6b004fca66a824e022cc3c01 (diff) | |
parent | 7ec30aaa5ba2a71287879d7bd9a5c55363ea1bbe (diff) | |
download | git-3e07d2683de55f0e21b13a6724b59bdcd548b5d8.tar.gz |
Merge branch 'mh/maint-ceil-absolute'
An earlier workaround designed to help people who list logical
directories that will not match what getcwd(3) returns in the
GIT_CEILING_DIRECTORIES had an adverse effect when it is slow to
stat and readlink a directory component of an element listed on it.
* mh/maint-ceil-absolute:
Provide a mechanism to turn off symlink resolution in ceiling paths
Diffstat (limited to 'setup.c')
-rw-r--r-- | setup.c | 32 |
1 files changed, 22 insertions, 10 deletions
@@ -650,22 +650,32 @@ static dev_t get_device_or_die(const char *path, const char *prefix, int prefix_ /* * A "string_list_each_func_t" function that canonicalizes an entry * from GIT_CEILING_DIRECTORIES using real_path_if_valid(), or - * discards it if unusable. + * discards it if unusable. The presence of an empty entry in + * GIT_CEILING_DIRECTORIES turns off canonicalization for all + * subsequent entries. */ static int canonicalize_ceiling_entry(struct string_list_item *item, - void *unused) + void *cb_data) { + int *empty_entry_found = cb_data; char *ceil = item->string; - const char *real_path; - if (!*ceil || !is_absolute_path(ceil)) + if (!*ceil) { + *empty_entry_found = 1; return 0; - real_path = real_path_if_valid(ceil); - if (!real_path) + } else if (!is_absolute_path(ceil)) { return 0; - free(item->string); - item->string = xstrdup(real_path); - return 1; + } else if (*empty_entry_found) { + /* Keep entry but do not canonicalize it */ + return 1; + } else { + const char *real_path = real_path_if_valid(ceil); + if (!real_path) + return 0; + free(item->string); + item->string = xstrdup(real_path); + return 1; + } } /* @@ -705,9 +715,11 @@ static const char *setup_git_directory_gently_1(int *nongit_ok) return setup_explicit_git_dir(gitdirenv, cwd, len, nongit_ok); if (env_ceiling_dirs) { + int empty_entry_found = 0; + string_list_split(&ceiling_dirs, env_ceiling_dirs, PATH_SEP, -1); filter_string_list(&ceiling_dirs, 0, - canonicalize_ceiling_entry, NULL); + canonicalize_ceiling_entry, &empty_entry_found); ceil_offset = longest_ancestor_length(cwd, &ceiling_dirs); string_list_clear(&ceiling_dirs, 0); } |