Call setup_git_directory() much earlier
This changes the calling convention of built-in commands and passes the "prefix" (i.e. pathname of $PWD relative to the project root level) down to them. Signed-off-by: Linus Torvalds <torvalds@osdl.org> Signed-off-by: Junio C Hamano <junkio@cox.net>
This commit is contained in:

committed by
Junio C Hamano

parent
db6296a566
commit
a633fca0c0
@ -16,7 +16,7 @@
|
||||
/* this is in builtin-diff.c */
|
||||
void add_head(struct rev_info *revs);
|
||||
|
||||
static void cmd_log_init(int argc, const char **argv, char **envp,
|
||||
static void cmd_log_init(int argc, const char **argv, const char *prefix,
|
||||
struct rev_info *rev)
|
||||
{
|
||||
rev->abbrev = DEFAULT_ABBREV;
|
||||
@ -45,26 +45,24 @@ static int cmd_log_walk(struct rev_info *rev)
|
||||
return 0;
|
||||
}
|
||||
|
||||
int cmd_whatchanged(int argc, const char **argv, char **envp)
|
||||
int cmd_whatchanged(int argc, const char **argv, const char *prefix)
|
||||
{
|
||||
struct rev_info rev;
|
||||
const char *prefix = setup_git_directory();
|
||||
|
||||
git_config(git_diff_ui_config);
|
||||
init_revisions(&rev, prefix);
|
||||
rev.diff = 1;
|
||||
rev.diffopt.recursive = 1;
|
||||
rev.simplify_history = 0;
|
||||
cmd_log_init(argc, argv, envp, &rev);
|
||||
cmd_log_init(argc, argv, prefix, &rev);
|
||||
if (!rev.diffopt.output_format)
|
||||
rev.diffopt.output_format = DIFF_FORMAT_RAW;
|
||||
return cmd_log_walk(&rev);
|
||||
}
|
||||
|
||||
int cmd_show(int argc, const char **argv, char **envp)
|
||||
int cmd_show(int argc, const char **argv, const char *prefix)
|
||||
{
|
||||
struct rev_info rev;
|
||||
const char *prefix = setup_git_directory();
|
||||
|
||||
git_config(git_diff_ui_config);
|
||||
init_revisions(&rev, prefix);
|
||||
@ -75,19 +73,18 @@ int cmd_show(int argc, const char **argv, char **envp)
|
||||
rev.always_show_header = 1;
|
||||
rev.ignore_merges = 0;
|
||||
rev.no_walk = 1;
|
||||
cmd_log_init(argc, argv, envp, &rev);
|
||||
cmd_log_init(argc, argv, prefix, &rev);
|
||||
return cmd_log_walk(&rev);
|
||||
}
|
||||
|
||||
int cmd_log(int argc, const char **argv, char **envp)
|
||||
int cmd_log(int argc, const char **argv, const char *prefix)
|
||||
{
|
||||
struct rev_info rev;
|
||||
const char *prefix = setup_git_directory();
|
||||
|
||||
git_config(git_diff_ui_config);
|
||||
init_revisions(&rev, prefix);
|
||||
rev.always_show_header = 1;
|
||||
cmd_log_init(argc, argv, envp, &rev);
|
||||
cmd_log_init(argc, argv, prefix, &rev);
|
||||
return cmd_log_walk(&rev);
|
||||
}
|
||||
|
||||
@ -181,14 +178,13 @@ static int get_patch_id(struct commit *commit, struct diff_options *options,
|
||||
return diff_flush_patch_id(options, sha1);
|
||||
}
|
||||
|
||||
static void get_patch_ids(struct rev_info *rev, struct diff_options *options)
|
||||
static void get_patch_ids(struct rev_info *rev, struct diff_options *options, const char *prefix)
|
||||
{
|
||||
struct rev_info check_rev;
|
||||
struct commit *commit;
|
||||
struct object *o1, *o2;
|
||||
unsigned flags1, flags2;
|
||||
unsigned char sha1[20];
|
||||
const char *prefix = setup_git_directory();
|
||||
|
||||
if (rev->pending.nr != 2)
|
||||
die("Need exactly one range.");
|
||||
@ -244,7 +240,7 @@ static void gen_message_id(char *dest, unsigned int length, char *base)
|
||||
(int)(email_end - email_start - 1), email_start + 1);
|
||||
}
|
||||
|
||||
int cmd_format_patch(int argc, const char **argv, char **envp)
|
||||
int cmd_format_patch(int argc, const char **argv, const char *prefix)
|
||||
{
|
||||
struct commit *commit;
|
||||
struct commit **list = NULL;
|
||||
@ -261,7 +257,6 @@ int cmd_format_patch(int argc, const char **argv, char **envp)
|
||||
char *add_signoff = NULL;
|
||||
char message_id[1024];
|
||||
char ref_message_id[1024];
|
||||
const char *prefix = setup_git_directory();
|
||||
|
||||
git_config(git_format_config);
|
||||
init_revisions(&rev, prefix);
|
||||
@ -368,7 +363,7 @@ int cmd_format_patch(int argc, const char **argv, char **envp)
|
||||
}
|
||||
|
||||
if (ignore_if_in_upstream)
|
||||
get_patch_ids(&rev, &patch_id_opts);
|
||||
get_patch_ids(&rev, &patch_id_opts, prefix);
|
||||
|
||||
if (!use_stdout)
|
||||
realstdout = fdopen(dup(1), "w");
|
||||
|
Reference in New Issue
Block a user