Skip to content

Commit

Permalink
git wrapper: introduce startup_info struct
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Nguyễn Thái Ngọc Duy authored and Junio C Hamano committed Aug 11, 2010
1 parent 0d0ba03 commit e37c132
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 0 deletions.
5 changes: 5 additions & 0 deletions cache.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
1 change: 1 addition & 0 deletions environment.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ enum object_creation_mode object_creation_mode = OBJECT_CREATION_MODE;
char *notes_ref_name;
int grafts_replace_parents = 1;
int core_apply_sparse_checkout;
struct startup_info *startup_info;

/* Parallel index stat data preload? */
int core_preload_index = 0;
Expand Down
3 changes: 3 additions & 0 deletions git.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ const char git_usage_string[] =
const char git_more_info_string[] =
"See 'git help COMMAND' for more information on a specific command.";

static struct startup_info git_startup_info;
static int use_pager = -1;
struct pager_config {
const char *cmd;
Expand Down Expand Up @@ -489,6 +490,8 @@ int main(int argc, const char **argv)
{
const char *cmd;

startup_info = &git_startup_info;

cmd = git_extract_argv0_path(argv[0]);
if (!cmd)
cmd = "git-help";
Expand Down

0 comments on commit e37c132

Please sign in to comment.