@matheusbsbs / matheus-bagliano / commits / e37c1329fa
Fork 0

git wrapper: introduce startup_info struct

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 <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>

Nguyễn Thái Ngọc Duy committed Aug 5, 2010 at 21:40 UTC e37c1329fa86683c828f04b51bad8bae03939ced
3 files changed +9
cache.h
+5
@@ -1097,6 +1097,11 @@ void overlay_tree_on_cache(const char *tree_name, const char *prefix);
1097 char *alias_lookup(const char *alias);
1098 int split_cmdline(char *cmdline, const char ***argv);
1099
1100 +/* git.c */
1101 +struct startup_info {
1102 +};
1103 +extern struct startup_info *startup_info;
1104 +
1105 /* builtin/merge.c */
1106 int checkout_fast_forward(const unsigned char *from, const unsigned char *to);
1107
environment.c
+1
@@ -53,6 +53,7 @@ enum object_creation_mode object_creation_mode = OBJECT_CREATION_MODE;
53 char *notes_ref_name;
54 int grafts_replace_parents = 1;
55 int core_apply_sparse_checkout;
56 +struct startup_info *startup_info;
57
58 /* Parallel index stat data preload? */
59 int core_preload_index = 0;
git.c
+3
@@ -14,6 +14,7 @@ const char git_usage_string[] =
14 const char git_more_info_string[] =
15 "See 'git help COMMAND' for more information on a specific command.";
16
17 +static struct startup_info git_startup_info;
18 static int use_pager = -1;
19 struct pager_config {
20 const char *cmd;
@@ -489,6 +490,8 @@ int main(int argc, const char **argv)
490 {
491 const char *cmd;
492
493 + startup_info = &git_startup_info;
494 +
495 cmd = git_extract_argv0_path(argv[0]);
496 if (!cmd)
497 cmd = "git-help";