summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: e37c132)
raw | patch | inline | side by side (parent: e37c132)
author | Nguyễn Thái Ngọc Duy <pclouds@gmail.com> | |
Fri, 6 Aug 2010 02:46:33 +0000 (21:46 -0500) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Wed, 11 Aug 2010 16:24:00 +0000 (09:24 -0700) |
As v1.7.2~16^2 (git --paginate: paginate external commands
again, 2010-07-14) explains, builtins (like git config) that
do not use RUN_SETUP are not finding GIT_DIR set correctly when
it is time to launch the pager from run_builtin(). If they
were to search for a repository sooner, then the outcome of such
early repository accesses would be more predictable and reliable.
The cmd_*() functions learn whether a repository was found through the
*nongit_ok return value from setup_git_directory_gently(). If
run_builtin() is to take care of the repository search itself, that
datum needs to be retrievable from somewhere else. Use the
startup_info struct for this.
As a bonus, this information becomes available to functions such as
git_config() which might want to avoid trying to access a repository
when none is present.
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
again, 2010-07-14) explains, builtins (like git config) that
do not use RUN_SETUP are not finding GIT_DIR set correctly when
it is time to launch the pager from run_builtin(). If they
were to search for a repository sooner, then the outcome of such
early repository accesses would be more predictable and reliable.
The cmd_*() functions learn whether a repository was found through the
*nongit_ok return value from setup_git_directory_gently(). If
run_builtin() is to take care of the repository search itself, that
datum needs to be retrievable from somewhere else. Use the
startup_info struct for this.
As a bonus, this information becomes available to functions such as
git_config() which might want to avoid trying to access a repository
when none is present.
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
cache.h | patch | blob | history | |
setup.c | patch | blob | history |
index 0822c3b8be4cbcfb5c7e8078b5bf4e41797a392e..f9e82a8acea5a607e3c65e9d702de9117b42b520 100644 (file)
--- a/cache.h
+++ b/cache.h
/* git.c */
struct startup_info {
+ int have_repository;
};
extern struct startup_info *startup_info;
index 276916052795c5ffa872b57a7e6723edc71dfdc4..28a2b69d05fec6b07ad8c478676548daf6ad4447 100644 (file)
--- a/setup.c
+++ b/setup.c
* We cannot decide in this function whether we are in the work tree or
* not, since the config can only be read _after_ this function was called.
*/
-const char *setup_git_directory_gently(int *nongit_ok)
+static const char *setup_git_directory_gently_1(int *nongit_ok)
{
const char *work_tree_env = getenv(GIT_WORK_TREE_ENVIRONMENT);
const char *env_ceiling_dirs = getenv(CEILING_DIRECTORIES_ENVIRONMENT);
return cwd + offset;
}
+const char *setup_git_directory_gently(int *nongit_ok)
+{
+ const char *prefix;
+
+ prefix = setup_git_directory_gently_1(nongit_ok);
+ if (startup_info)
+ startup_info->have_repository = !nongit_ok || !*nongit_ok;
+ return prefix;
+}
+
int git_config_perm(const char *var, const char *value)
{
int i;