Skip to content

Commit 69d2cfe

Browse files
pcloudsgitster
authored andcommitted
bisect.c: remove the_repository reference
Signed-off-by: Nguyễn Thái Ngọc Duy <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent fb998ea commit 69d2cfe

File tree

3 files changed

+33
-22
lines changed

3 files changed

+33
-22
lines changed

bisect.c

Lines changed: 28 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -626,14 +626,15 @@ static struct commit_list *managed_skipped(struct commit_list *list,
626626
return skip_away(list, count);
627627
}
628628

629-
static void bisect_rev_setup(struct rev_info *revs, const char *prefix,
629+
static void bisect_rev_setup(struct repository *r, struct rev_info *revs,
630+
const char *prefix,
630631
const char *bad_format, const char *good_format,
631632
int read_paths)
632633
{
633634
struct argv_array rev_argv = ARGV_ARRAY_INIT;
634635
int i;
635636

636-
repo_init_revisions(the_repository, revs, prefix);
637+
repo_init_revisions(r, revs, prefix);
637638
revs->abbrev = 0;
638639
revs->commit_format = CMIT_FMT_UNSPECIFIED;
639640

@@ -723,23 +724,25 @@ static int bisect_checkout(const struct object_id *bisect_rev, int no_checkout)
723724
return run_command_v_opt(argv_show_branch, RUN_GIT_CMD);
724725
}
725726

726-
static struct commit *get_commit_reference(const struct object_id *oid)
727+
static struct commit *get_commit_reference(struct repository *r,
728+
const struct object_id *oid)
727729
{
728-
struct commit *r = lookup_commit_reference(the_repository, oid);
729-
if (!r)
730+
struct commit *c = lookup_commit_reference(r, oid);
731+
if (!c)
730732
die(_("Not a valid commit name %s"), oid_to_hex(oid));
731-
return r;
733+
return c;
732734
}
733735

734-
static struct commit **get_bad_and_good_commits(int *rev_nr)
736+
static struct commit **get_bad_and_good_commits(struct repository *r,
737+
int *rev_nr)
735738
{
736739
struct commit **rev;
737740
int i, n = 0;
738741

739742
ALLOC_ARRAY(rev, 1 + good_revs.nr);
740-
rev[n++] = get_commit_reference(current_bad_oid);
743+
rev[n++] = get_commit_reference(r, current_bad_oid);
741744
for (i = 0; i < good_revs.nr; i++)
742-
rev[n++] = get_commit_reference(good_revs.oid + i);
745+
rev[n++] = get_commit_reference(r, good_revs.oid + i);
743746
*rev_nr = n;
744747

745748
return rev;
@@ -823,12 +826,13 @@ static void check_merge_bases(int rev_nr, struct commit **rev, int no_checkout)
823826
free_commit_list(result);
824827
}
825828

826-
static int check_ancestors(int rev_nr, struct commit **rev, const char *prefix)
829+
static int check_ancestors(struct repository *r, int rev_nr,
830+
struct commit **rev, const char *prefix)
827831
{
828832
struct rev_info revs;
829833
int res;
830834

831-
bisect_rev_setup(&revs, prefix, "^%s", "%s", 0);
835+
bisect_rev_setup(r, &revs, prefix, "^%s", "%s", 0);
832836

833837
bisect_common(&revs);
834838
res = (revs.commits != NULL);
@@ -847,7 +851,9 @@ static int check_ancestors(int rev_nr, struct commit **rev, const char *prefix)
847851
* If a merge base must be tested by the user, its source code will be
848852
* checked out to be tested by the user and we will exit.
849853
*/
850-
static void check_good_are_ancestors_of_bad(const char *prefix, int no_checkout)
854+
static void check_good_are_ancestors_of_bad(struct repository *r,
855+
const char *prefix,
856+
int no_checkout)
851857
{
852858
char *filename = git_pathdup("BISECT_ANCESTORS_OK");
853859
struct stat st;
@@ -866,8 +872,8 @@ static void check_good_are_ancestors_of_bad(const char *prefix, int no_checkout)
866872
goto done;
867873

868874
/* Check if all good revs are ancestor of the bad rev. */
869-
rev = get_bad_and_good_commits(&rev_nr);
870-
if (check_ancestors(rev_nr, rev, prefix))
875+
rev = get_bad_and_good_commits(r, &rev_nr);
876+
if (check_ancestors(r, rev_nr, rev, prefix))
871877
check_merge_bases(rev_nr, rev, no_checkout);
872878
free(rev);
873879

@@ -885,12 +891,14 @@ static void check_good_are_ancestors_of_bad(const char *prefix, int no_checkout)
885891
/*
886892
* This does "git diff-tree --pretty COMMIT" without one fork+exec.
887893
*/
888-
static void show_diff_tree(const char *prefix, struct commit *commit)
894+
static void show_diff_tree(struct repository *r,
895+
const char *prefix,
896+
struct commit *commit)
889897
{
890898
struct rev_info opt;
891899

892900
/* diff-tree init */
893-
repo_init_revisions(the_repository, &opt, prefix);
901+
repo_init_revisions(r, &opt, prefix);
894902
git_config(git_diff_basic_config, NULL); /* no "diff" UI options */
895903
opt.abbrev = 0;
896904
opt.diff = 1;
@@ -945,7 +953,7 @@ void read_bisect_terms(const char **read_bad, const char **read_good)
945953
* If no_checkout is non-zero, the bisection process does not
946954
* checkout the trial commit but instead simply updates BISECT_HEAD.
947955
*/
948-
int bisect_next_all(const char *prefix, int no_checkout)
956+
int bisect_next_all(struct repository *r, const char *prefix, int no_checkout)
949957
{
950958
struct rev_info revs;
951959
struct commit_list *tried;
@@ -957,9 +965,9 @@ int bisect_next_all(const char *prefix, int no_checkout)
957965
if (read_bisect_refs())
958966
die(_("reading bisect refs failed"));
959967

960-
check_good_are_ancestors_of_bad(prefix, no_checkout);
968+
check_good_are_ancestors_of_bad(r, prefix, no_checkout);
961969

962-
bisect_rev_setup(&revs, prefix, "%s", "^%s", 1);
970+
bisect_rev_setup(r, &revs, prefix, "%s", "^%s", 1);
963971
revs.limited = 1;
964972

965973
bisect_common(&revs);
@@ -993,7 +1001,7 @@ int bisect_next_all(const char *prefix, int no_checkout)
9931001
exit_if_skipped_commits(tried, current_bad_oid);
9941002
printf("%s is the first %s commit\n", oid_to_hex(bisect_rev),
9951003
term_bad);
996-
show_diff_tree(prefix, revs.commits->item);
1004+
show_diff_tree(r, prefix, revs.commits->item);
9971005
/* This means the bisection process succeeded. */
9981006
exit(10);
9991007
}

bisect.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
#define BISECT_H
33

44
struct commit_list;
5+
struct repository;
56

67
/*
78
* Find bisection. If something is found, `reaches` will be the number of
@@ -30,7 +31,9 @@ struct rev_list_info {
3031
const char *header_prefix;
3132
};
3233

33-
extern int bisect_next_all(const char *prefix, int no_checkout);
34+
extern int bisect_next_all(struct repository *r,
35+
const char *prefix,
36+
int no_checkout);
3437

3538
extern int estimate_bisect_steps(int all);
3639

builtin/bisect--helper.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ int cmd_bisect__helper(int argc, const char **argv, const char *prefix)
137137

138138
switch (cmdmode) {
139139
case NEXT_ALL:
140-
return bisect_next_all(prefix, no_checkout);
140+
return bisect_next_all(the_repository, prefix, no_checkout);
141141
case WRITE_TERMS:
142142
if (argc != 2)
143143
return error(_("--write-terms requires two arguments"));

0 commit comments

Comments
 (0)