wt-status.c: remove implicit dependency the_repository

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Nguyễn Thái Ngọc Duy committed Nov 10, 2018 at 06:48 UTC 788454576f64dc2d830b0e6704175b05db34ce53
3 files changed +14 -10
ref-filter.c
+1 -1
@@ -1413,7 +1413,7 @@ char *get_head_description(void)
1413 struct strbuf desc = STRBUF_INIT;
1414 struct wt_status_state state;
1415 memset(&state, 0, sizeof(state));
1416 - wt_status_get_state(&state, 1);
1416 + wt_status_get_state(the_repository, &state, 1);
1417 if (state.rebase_in_progress ||
1418 state.rebase_interactive_in_progress) {
1419 if (state.branch)
wt-status.c
+10 -8
@@ -755,7 +755,7 @@ void wt_status_collect(struct wt_status *s)
755 wt_status_collect_changes_index(s);
756 wt_status_collect_untracked(s);
757
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"));
759 if (s->state.merge_in_progress && !has_unmerged(s))
760 s->committable = 1;
761 }
@@ -1482,7 +1482,8 @@ static int grab_1st_switch(struct object_id *ooid, struct object_id *noid,
1482 return 1;
1483 }
1484
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)
1487 {
1488 struct grab_1st_switch_cbdata cb;
1489 struct commit *commit;
@@ -1499,7 +1500,7 @@ static void wt_status_get_detached_from(struct wt_status_state *state)
1500 /* sha1 is a commit? match without further lookup */
1501 (oideq(&cb.noid, &oid) ||
1502 /* 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 &&
1504 oideq(&cb.noid, &commit->object.oid)))) {
1505 const char *from = ref;
1506 if (!skip_prefix(from, "refs/tags/", &from))
@@ -1556,30 +1557,31 @@ int wt_status_check_bisect(const struct worktree *wt,
1557 return 0;
1558 }
1559
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,
1562 int get_detached_from)
1563 {
1564 struct stat st;
1565 struct object_id oid;
1566
1565 - if (!stat(git_path_merge_head(the_repository), &st)) {
1567 + if (!stat(git_path_merge_head(r), &st)) {
1568 state->merge_in_progress = 1;
1569 } else if (wt_status_check_rebase(NULL, state)) {
1570 ; /* 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) &&
1572 !get_oid("CHERRY_PICK_HEAD", &oid)) {
1573 state->cherry_pick_in_progress = 1;
1574 oidcpy(&state->cherry_pick_head_oid, &oid);
1575 }
1576 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) &&
1578 !get_oid("REVERT_HEAD", &oid)) {
1579 state->revert_in_progress = 1;
1580 oidcpy(&state->revert_head_oid, &oid);
1581 }
1582
1583 if (get_detached_from)
1582 - wt_status_get_detached_from(state);
1584 + wt_status_get_detached_from(r, state);
1585 }
1586
1587 static void wt_longstatus_print_state(struct wt_status *s)
wt-status.h
+3 -1
@@ -134,7 +134,9 @@ void wt_status_prepare(struct repository *r, struct wt_status *s);
134 void wt_status_print(struct wt_status *s);
135 void wt_status_collect(struct wt_status *s);
136 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);
140 int wt_status_check_rebase(const struct worktree *wt,
141 struct wt_status_state *state);
142 int wt_status_check_bisect(const struct worktree *wt,