From e37c1329fa86683c828f04b51bad8bae03939ced Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nguy=E1=BB=85n=20Th=C3=A1i=20Ng=E1=BB=8Dc=20Duy?= Date: Thu, 5 Aug 2010 21:40:35 -0500 Subject: git wrapper: introduce startup_info struct MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The startup_info struct will collect information managed by the git setup code, such as the prefix for relative paths passed on the command line (i.e., path to the starting cwd from the toplevel of the work tree) and whether a git repository has been found. In other words, startup_info is intended to be a collection of global variables with results that were previously returned from setup functions. This state is global anyway (since the cwd is), even if it is not currently tracked that way. Letting these values persist means there is more flexibility in deciding when to run setup. For now, the struct is empty. Signed-off-by: Nguyễn Thái Ngọc Duy Signed-off-by: Junio C Hamano Signed-off-by: Jonathan Nieder Signed-off-by: Junio C Hamano --- cache.h | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'cache.h') diff --git a/cache.h b/cache.h index c9fa3df7f5..0822c3b8be 100644 --- a/cache.h +++ b/cache.h @@ -1097,6 +1097,11 @@ void overlay_tree_on_cache(const char *tree_name, const char *prefix); char *alias_lookup(const char *alias); int split_cmdline(char *cmdline, const char ***argv); +/* git.c */ +struct startup_info { +}; +extern struct startup_info *startup_info; + /* builtin/merge.c */ int checkout_fast_forward(const unsigned char *from, const unsigned char *to); -- cgit v1.2.1 From a60645f9c54c3050cbe25882feba9d5b3d1ca0d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nguy=E1=BB=85n=20Th=C3=A1i=20Ng=E1=BB=8Dc=20Duy?= Date: Thu, 5 Aug 2010 21:46:33 -0500 Subject: setup: remember whether repository was found MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Signed-off-by: Junio C Hamano Signed-off-by: Jonathan Nieder Signed-off-by: Junio C Hamano --- cache.h | 1 + 1 file changed, 1 insertion(+) (limited to 'cache.h') diff --git a/cache.h b/cache.h index 0822c3b8be..f9e82a8ace 100644 --- a/cache.h +++ b/cache.h @@ -1099,6 +1099,7 @@ int split_cmdline(char *cmdline, const char ***argv); /* git.c */ struct startup_info { + int have_repository; }; extern struct startup_info *startup_info; -- cgit v1.2.1