Skip to content

Commit f5d067a

Browse files
pcloudsgitster
authored andcommitted
wt-status.c: split bisect detection out of wt_status_get_state()
And make it work with any given worktree, in preparation for (again) find_shared_symref(). read_and_strip_branch() is deleted because it's no longer used. Signed-off-by: Nguyễn Thái Ngọc Duy <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 8d9fdd7 commit f5d067a

File tree

2 files changed

+16
-9
lines changed

2 files changed

+16
-9
lines changed

wt-status.c

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1296,11 +1296,6 @@ static char *get_branch(const struct worktree *wt, const char *path)
12961296
return NULL;
12971297
}
12981298

1299-
static char *read_and_strip_branch(const char *path)
1300-
{
1301-
return get_branch(NULL, path);
1302-
}
1303-
13041299
struct grab_1st_switch_cbdata {
13051300
struct strbuf buf;
13061301
unsigned char nsha1[20];
@@ -1393,6 +1388,19 @@ int wt_status_check_rebase(const struct worktree *wt,
13931388
return 1;
13941389
}
13951390

1391+
int wt_status_check_bisect(const struct worktree *wt,
1392+
struct wt_status_state *state)
1393+
{
1394+
struct stat st;
1395+
1396+
if (!stat(worktree_git_path(wt, "BISECT_LOG"), &st)) {
1397+
state->bisect_in_progress = 1;
1398+
state->branch = get_branch(wt, "BISECT_START");
1399+
return 1;
1400+
}
1401+
return 0;
1402+
}
1403+
13961404
void wt_status_get_state(struct wt_status_state *state,
13971405
int get_detached_from)
13981406
{
@@ -1408,10 +1416,7 @@ void wt_status_get_state(struct wt_status_state *state,
14081416
state->cherry_pick_in_progress = 1;
14091417
hashcpy(state->cherry_pick_head_sha1, sha1);
14101418
}
1411-
if (!stat(git_path("BISECT_LOG"), &st)) {
1412-
state->bisect_in_progress = 1;
1413-
state->branch = read_and_strip_branch("BISECT_START");
1414-
}
1419+
wt_status_check_bisect(NULL, state);
14151420
if (!stat(git_path_revert_head(), &st) &&
14161421
!get_sha1("REVERT_HEAD", sha1)) {
14171422
state->revert_in_progress = 1;

wt-status.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,8 @@ void wt_status_collect(struct wt_status *s);
104104
void wt_status_get_state(struct wt_status_state *state, int get_detached_from);
105105
int wt_status_check_rebase(const struct worktree *wt,
106106
struct wt_status_state *state);
107+
int wt_status_check_bisect(const struct worktree *wt,
108+
struct wt_status_state *state);
107109

108110
void wt_shortstatus_print(struct wt_status *s);
109111
void wt_porcelain_print(struct wt_status *s);

0 commit comments

Comments
 (0)