зеркало из https://github.com/microsoft/git.git
Call setup_git_directory() early
Any git command that expects to work in a subdirectory of a project, and that reads the git config files (which is just about all of them) needs to make sure that it does the "setup_git_directory()" call before it tries to read the config file. This means, among other things, that we need to move the call out of "init_revisions()", and into the caller. This does the mostly trivial conversion to do that. Signed-off-by: Linus Torvalds <torvalds@osdl.org> Signed-off-by: Junio C Hamano <junkio@cox.net>
This commit is contained in:
Родитель
818f477c40
Коммит
db6296a566
2
blame.c
2
blame.c
|
@ -834,7 +834,7 @@ int main(int argc, const char **argv)
|
|||
}
|
||||
|
||||
|
||||
init_revisions(&rev);
|
||||
init_revisions(&rev, setup_git_directory());
|
||||
rev.remove_empty_trees = 1;
|
||||
rev.topo_order = 1;
|
||||
rev.prune_fn = simplify_commit;
|
||||
|
|
|
@ -18,7 +18,7 @@ int cmd_diff_files(int argc, const char **argv, char **envp)
|
|||
struct rev_info rev;
|
||||
int silent = 0;
|
||||
|
||||
init_revisions(&rev);
|
||||
init_revisions(&rev, setup_git_directory());
|
||||
git_config(git_default_config); /* no "diff" UI options */
|
||||
rev.abbrev = 0;
|
||||
|
||||
|
|
|
@ -15,7 +15,7 @@ int cmd_diff_index(int argc, const char **argv, char **envp)
|
|||
int cached = 0;
|
||||
int i;
|
||||
|
||||
init_revisions(&rev);
|
||||
init_revisions(&rev, setup_git_directory());
|
||||
git_config(git_default_config); /* no "diff" UI options */
|
||||
rev.abbrev = 0;
|
||||
|
||||
|
|
|
@ -67,7 +67,7 @@ int cmd_diff_tree(int argc, const char **argv, char **envp)
|
|||
static struct rev_info *opt = &log_tree_opt;
|
||||
int read_stdin = 0;
|
||||
|
||||
init_revisions(opt);
|
||||
init_revisions(opt, setup_git_directory());
|
||||
git_config(git_default_config); /* no "diff" UI options */
|
||||
nr_sha1 = 0;
|
||||
opt->abbrev = 0;
|
||||
|
|
|
@ -227,7 +227,7 @@ int cmd_diff(int argc, const char **argv, char **envp)
|
|||
struct rev_info rev;
|
||||
struct object_array_entry ent[100];
|
||||
int ents = 0, blobs = 0, paths = 0;
|
||||
const char *path = NULL;
|
||||
const char *path = NULL, *prefix;
|
||||
struct blobinfo blob[2];
|
||||
|
||||
/*
|
||||
|
@ -250,9 +250,9 @@ int cmd_diff(int argc, const char **argv, char **envp)
|
|||
* Other cases are errors.
|
||||
*/
|
||||
|
||||
init_revisions(&rev);
|
||||
prefix = setup_git_directory();
|
||||
git_config(git_diff_ui_config);
|
||||
diff_setup(&rev.diffopt);
|
||||
init_revisions(&rev, prefix);
|
||||
|
||||
argc = setup_revisions(argc, argv, &rev, NULL);
|
||||
if (!rev.diffopt.output_format) {
|
||||
|
|
|
@ -250,6 +250,7 @@ int cmd_fmt_merge_msg(int argc, char **argv, char **envp)
|
|||
const char *sep = "";
|
||||
unsigned char head_sha1[20];
|
||||
const char *head, *current_branch;
|
||||
const char *prefix = setup_git_directory();
|
||||
|
||||
git_config(fmt_merge_msg_config);
|
||||
|
||||
|
@ -342,7 +343,7 @@ int cmd_fmt_merge_msg(int argc, char **argv, char **envp)
|
|||
struct rev_info rev;
|
||||
|
||||
head = lookup_commit(head_sha1);
|
||||
init_revisions(&rev);
|
||||
init_revisions(&rev, prefix);
|
||||
rev.commit_format = CMIT_FMT_ONELINE;
|
||||
rev.ignore_merges = 1;
|
||||
rev.limited = 1;
|
||||
|
|
|
@ -48,10 +48,10 @@ static int cmd_log_walk(struct rev_info *rev)
|
|||
int cmd_whatchanged(int argc, const char **argv, char **envp)
|
||||
{
|
||||
struct rev_info rev;
|
||||
const char *prefix = setup_git_directory();
|
||||
|
||||
init_revisions(&rev);
|
||||
git_config(git_diff_ui_config);
|
||||
diff_setup(&rev.diffopt);
|
||||
init_revisions(&rev, prefix);
|
||||
rev.diff = 1;
|
||||
rev.diffopt.recursive = 1;
|
||||
rev.simplify_history = 0;
|
||||
|
@ -64,10 +64,10 @@ int cmd_whatchanged(int argc, const char **argv, char **envp)
|
|||
int cmd_show(int argc, const char **argv, char **envp)
|
||||
{
|
||||
struct rev_info rev;
|
||||
const char *prefix = setup_git_directory();
|
||||
|
||||
init_revisions(&rev);
|
||||
git_config(git_diff_ui_config);
|
||||
diff_setup(&rev.diffopt);
|
||||
init_revisions(&rev, prefix);
|
||||
rev.diff = 1;
|
||||
rev.diffopt.recursive = 1;
|
||||
rev.combine_merges = 1;
|
||||
|
@ -82,10 +82,10 @@ int cmd_show(int argc, const char **argv, char **envp)
|
|||
int cmd_log(int argc, const char **argv, char **envp)
|
||||
{
|
||||
struct rev_info rev;
|
||||
const char *prefix = setup_git_directory();
|
||||
|
||||
init_revisions(&rev);
|
||||
git_config(git_diff_ui_config);
|
||||
diff_setup(&rev.diffopt);
|
||||
init_revisions(&rev, prefix);
|
||||
rev.always_show_header = 1;
|
||||
cmd_log_init(argc, argv, envp, &rev);
|
||||
return cmd_log_walk(&rev);
|
||||
|
@ -188,6 +188,7 @@ static void get_patch_ids(struct rev_info *rev, struct diff_options *options)
|
|||
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.");
|
||||
|
@ -206,7 +207,7 @@ static void get_patch_ids(struct rev_info *rev, struct diff_options *options)
|
|||
die("diff_setup_done failed");
|
||||
|
||||
/* given a range a..b get all patch ids for b..a */
|
||||
init_revisions(&check_rev);
|
||||
init_revisions(&check_rev, prefix);
|
||||
o1->flags ^= UNINTERESTING;
|
||||
o2->flags ^= UNINTERESTING;
|
||||
add_pending_object(&check_rev, o1, "o1");
|
||||
|
@ -260,9 +261,10 @@ 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);
|
||||
init_revisions(&rev, prefix);
|
||||
rev.commit_format = CMIT_FMT_EMAIL;
|
||||
rev.verbose_header = 1;
|
||||
rev.diff = 1;
|
||||
|
|
|
@ -234,7 +234,7 @@ int cmd_prune(int argc, const char **argv, char **envp)
|
|||
* Set up revision parsing, and mark us as being interested
|
||||
* in all object types, not just commits.
|
||||
*/
|
||||
init_revisions(&revs);
|
||||
init_revisions(&revs, setup_git_directory());
|
||||
revs.tag_objects = 1;
|
||||
revs.blob_objects = 1;
|
||||
revs.tree_objects = 1;
|
||||
|
|
|
@ -311,7 +311,7 @@ int cmd_rev_list(int argc, const char **argv, char **envp)
|
|||
struct commit_list *list;
|
||||
int i;
|
||||
|
||||
init_revisions(&revs);
|
||||
init_revisions(&revs, setup_git_directory());
|
||||
revs.abbrev = 0;
|
||||
revs.commit_format = CMIT_FMT_UNSPECIFIED;
|
||||
argc = setup_revisions(argc, argv, &revs, NULL);
|
||||
|
|
|
@ -2521,7 +2521,7 @@ int main(int argc, char **argv)
|
|||
commit_argv[3] = old_sha1_hex;
|
||||
commit_argc++;
|
||||
}
|
||||
init_revisions(&revs);
|
||||
init_revisions(&revs, setup_git_directory());
|
||||
setup_revisions(commit_argc, commit_argv, &revs, NULL);
|
||||
free(new_sha1_hex);
|
||||
if (old_sha1_hex) {
|
||||
|
|
|
@ -509,7 +509,7 @@ static int add_parents_only(struct rev_info *revs, const char *arg, int flags)
|
|||
return 1;
|
||||
}
|
||||
|
||||
void init_revisions(struct rev_info *revs)
|
||||
void init_revisions(struct rev_info *revs, const char *prefix)
|
||||
{
|
||||
memset(revs, 0, sizeof(*revs));
|
||||
|
||||
|
@ -521,7 +521,7 @@ void init_revisions(struct rev_info *revs)
|
|||
revs->pruning.change = file_change;
|
||||
revs->lifo = 1;
|
||||
revs->dense = 1;
|
||||
revs->prefix = setup_git_directory();
|
||||
revs->prefix = prefix;
|
||||
revs->max_age = -1;
|
||||
revs->min_age = -1;
|
||||
revs->max_count = -1;
|
||||
|
|
|
@ -87,7 +87,7 @@ struct rev_info {
|
|||
extern int rev_same_tree_as_empty(struct rev_info *, struct tree *t1);
|
||||
extern int rev_compare_tree(struct rev_info *, struct tree *t1, struct tree *t2);
|
||||
|
||||
extern void init_revisions(struct rev_info *revs);
|
||||
extern void init_revisions(struct rev_info *revs, const char *prefix);
|
||||
extern int setup_revisions(int argc, const char **argv, struct rev_info *revs, const char *def);
|
||||
extern void prepare_revision_walk(struct rev_info *revs);
|
||||
extern struct commit *get_revision(struct rev_info *revs);
|
||||
|
|
Загрузка…
Ссылка в новой задаче