Skip to content

Commit e37c132

Browse files
pcloudsgitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]> Signed-off-by: Jonathan Nieder <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 0d0ba03 commit e37c132

File tree

3 files changed

+9
-0
lines changed

3 files changed

+9
-0
lines changed

cache.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1097,6 +1097,11 @@ void overlay_tree_on_cache(const char *tree_name, const char *prefix);
10971097
char *alias_lookup(const char *alias);
10981098
int split_cmdline(char *cmdline, const char ***argv);
10991099

1100+
/* git.c */
1101+
struct startup_info {
1102+
};
1103+
extern struct startup_info *startup_info;
1104+
11001105
/* builtin/merge.c */
11011106
int checkout_fast_forward(const unsigned char *from, const unsigned char *to);
11021107

environment.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ enum object_creation_mode object_creation_mode = OBJECT_CREATION_MODE;
5353
char *notes_ref_name;
5454
int grafts_replace_parents = 1;
5555
int core_apply_sparse_checkout;
56+
struct startup_info *startup_info;
5657

5758
/* Parallel index stat data preload? */
5859
int core_preload_index = 0;

git.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ const char git_usage_string[] =
1414
const char git_more_info_string[] =
1515
"See 'git help COMMAND' for more information on a specific command.";
1616

17+
static struct startup_info git_startup_info;
1718
static int use_pager = -1;
1819
struct pager_config {
1920
const char *cmd;
@@ -489,6 +490,8 @@ int main(int argc, const char **argv)
489490
{
490491
const char *cmd;
491492

493+
startup_info = &git_startup_info;
494+
492495
cmd = git_extract_argv0_path(argv[0]);
493496
if (!cmd)
494497
cmd = "git-help";

0 commit comments

Comments
 (0)