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 <pclouds@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Nguyễn Thái Ngọc Duy committed
Apr 22, 2016 at 20:01 UTC
f5d067a2b28143dca237712e5dae7738d563f85c
2 files changed
+16
-9
wt-status.c
+14
-9
@@ -1296,11 +1296,6 @@ got_nothing:
1296
return NULL;
1297
}
1298
1299
-static char *read_and_strip_branch(const char *path)
1300
-{
1301
- return get_branch(NULL, path);
1302
-}
1303
-
1299
struct grab_1st_switch_cbdata {
1300
struct strbuf buf;
1301
unsigned char nsha1[20];
@@ -1393,6 +1388,19 @@ int wt_status_check_rebase(const struct worktree *wt,
1388
return 1;
1389
}
1390
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
+
1404
void wt_status_get_state(struct wt_status_state *state,
1405
int get_detached_from)
1406
{
@@ -1408,10 +1416,7 @@ void wt_status_get_state(struct wt_status_state *state,
1416
state->cherry_pick_in_progress = 1;
1417
hashcpy(state->cherry_pick_head_sha1, sha1);
1418
}
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);
1420
if (!stat(git_path_revert_head(), &st) &&
1421
!get_sha1("REVERT_HEAD", sha1)) {
1422
state->revert_in_progress = 1;
wt-status.h
+2
@@ -104,6 +104,8 @@ void wt_status_collect(struct wt_status *s);
104
void wt_status_get_state(struct wt_status_state *state, int get_detached_from);
105
int wt_status_check_rebase(const struct worktree *wt,
106
struct wt_status_state *state);
107
+int wt_status_check_bisect(const struct worktree *wt,
108
+ struct wt_status_state *state);
109
110
void wt_shortstatus_print(struct wt_status *s);
111
void wt_porcelain_print(struct wt_status *s);