Skip to content

Commit 7884545

Browse files
pcloudsgitster
authored andcommitted
wt-status.c: remove implicit dependency the_repository
Signed-off-by: Nguyễn Thái Ngọc Duy <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 5b02ca3 commit 7884545

File tree

3 files changed

+14
-10
lines changed

3 files changed

+14
-10
lines changed

ref-filter.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1413,7 +1413,7 @@ char *get_head_description(void)
14131413
struct strbuf desc = STRBUF_INIT;
14141414
struct wt_status_state state;
14151415
memset(&state, 0, sizeof(state));
1416-
wt_status_get_state(&state, 1);
1416+
wt_status_get_state(the_repository, &state, 1);
14171417
if (state.rebase_in_progress ||
14181418
state.rebase_interactive_in_progress) {
14191419
if (state.branch)

wt-status.c

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -755,7 +755,7 @@ void wt_status_collect(struct wt_status *s)
755755
wt_status_collect_changes_index(s);
756756
wt_status_collect_untracked(s);
757757

758-
wt_status_get_state(&s->state, s->branch && !strcmp(s->branch, "HEAD"));
758+
wt_status_get_state(s->repo, &s->state, s->branch && !strcmp(s->branch, "HEAD"));
759759
if (s->state.merge_in_progress && !has_unmerged(s))
760760
s->committable = 1;
761761
}
@@ -1482,7 +1482,8 @@ static int grab_1st_switch(struct object_id *ooid, struct object_id *noid,
14821482
return 1;
14831483
}
14841484

1485-
static void wt_status_get_detached_from(struct wt_status_state *state)
1485+
static void wt_status_get_detached_from(struct repository *r,
1486+
struct wt_status_state *state)
14861487
{
14871488
struct grab_1st_switch_cbdata cb;
14881489
struct commit *commit;
@@ -1499,7 +1500,7 @@ static void wt_status_get_detached_from(struct wt_status_state *state)
14991500
/* sha1 is a commit? match without further lookup */
15001501
(oideq(&cb.noid, &oid) ||
15011502
/* perhaps sha1 is a tag, try to dereference to a commit */
1502-
((commit = lookup_commit_reference_gently(the_repository, &oid, 1)) != NULL &&
1503+
((commit = lookup_commit_reference_gently(r, &oid, 1)) != NULL &&
15031504
oideq(&cb.noid, &commit->object.oid)))) {
15041505
const char *from = ref;
15051506
if (!skip_prefix(from, "refs/tags/", &from))
@@ -1556,30 +1557,31 @@ int wt_status_check_bisect(const struct worktree *wt,
15561557
return 0;
15571558
}
15581559

1559-
void wt_status_get_state(struct wt_status_state *state,
1560+
void wt_status_get_state(struct repository *r,
1561+
struct wt_status_state *state,
15601562
int get_detached_from)
15611563
{
15621564
struct stat st;
15631565
struct object_id oid;
15641566

1565-
if (!stat(git_path_merge_head(the_repository), &st)) {
1567+
if (!stat(git_path_merge_head(r), &st)) {
15661568
state->merge_in_progress = 1;
15671569
} else if (wt_status_check_rebase(NULL, state)) {
15681570
; /* all set */
1569-
} else if (!stat(git_path_cherry_pick_head(the_repository), &st) &&
1571+
} else if (!stat(git_path_cherry_pick_head(r), &st) &&
15701572
!get_oid("CHERRY_PICK_HEAD", &oid)) {
15711573
state->cherry_pick_in_progress = 1;
15721574
oidcpy(&state->cherry_pick_head_oid, &oid);
15731575
}
15741576
wt_status_check_bisect(NULL, state);
1575-
if (!stat(git_path_revert_head(the_repository), &st) &&
1577+
if (!stat(git_path_revert_head(r), &st) &&
15761578
!get_oid("REVERT_HEAD", &oid)) {
15771579
state->revert_in_progress = 1;
15781580
oidcpy(&state->revert_head_oid, &oid);
15791581
}
15801582

15811583
if (get_detached_from)
1582-
wt_status_get_detached_from(state);
1584+
wt_status_get_detached_from(r, state);
15831585
}
15841586

15851587
static void wt_longstatus_print_state(struct wt_status *s)

wt-status.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,9 @@ void wt_status_prepare(struct repository *r, struct wt_status *s);
134134
void wt_status_print(struct wt_status *s);
135135
void wt_status_collect(struct wt_status *s);
136136
void wt_status_collect_free_buffers(struct wt_status *s);
137-
void wt_status_get_state(struct wt_status_state *state, int get_detached_from);
137+
void wt_status_get_state(struct repository *repo,
138+
struct wt_status_state *state,
139+
int get_detached_from);
138140
int wt_status_check_rebase(const struct worktree *wt,
139141
struct wt_status_state *state);
140142
int wt_status_check_bisect(const struct worktree *wt,

0 commit comments

Comments
 (0)