Skip to content

Commit bcd522a

Browse files
pcloudsgitster
authored andcommitted
wt-status.c: split rebase detection out of wt_status_get_state()
worktree.c:find_shared_symref() later needs to know if a branch is being rebased, and only rebase, no cherry-pick, do detached branch... Split this code so it can be used independently from other in-progress tests. Signed-off-by: Nguyễn Thái Ngọc Duy <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 2e641d5 commit bcd522a

File tree

2 files changed

+18
-6
lines changed

2 files changed

+18
-6
lines changed

wt-status.c

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1360,15 +1360,11 @@ static void wt_status_get_detached_from(struct wt_status_state *state)
13601360
strbuf_release(&cb.buf);
13611361
}
13621362

1363-
void wt_status_get_state(struct wt_status_state *state,
1364-
int get_detached_from)
1363+
int wt_status_check_rebase(struct wt_status_state *state)
13651364
{
13661365
struct stat st;
1367-
unsigned char sha1[20];
13681366

1369-
if (!stat(git_path_merge_head(), &st)) {
1370-
state->merge_in_progress = 1;
1371-
} else if (!stat(git_path("rebase-apply"), &st)) {
1367+
if (!stat(git_path("rebase-apply"), &st)) {
13721368
if (!stat(git_path("rebase-apply/applying"), &st)) {
13731369
state->am_in_progress = 1;
13741370
if (!stat(git_path("rebase-apply/patch"), &st) && !st.st_size)
@@ -1385,6 +1381,21 @@ void wt_status_get_state(struct wt_status_state *state,
13851381
state->rebase_in_progress = 1;
13861382
state->branch = read_and_strip_branch("rebase-merge/head-name");
13871383
state->onto = read_and_strip_branch("rebase-merge/onto");
1384+
} else
1385+
return 0;
1386+
return 1;
1387+
}
1388+
1389+
void wt_status_get_state(struct wt_status_state *state,
1390+
int get_detached_from)
1391+
{
1392+
struct stat st;
1393+
unsigned char sha1[20];
1394+
1395+
if (!stat(git_path_merge_head(), &st)) {
1396+
state->merge_in_progress = 1;
1397+
} else if (wt_status_check_rebase(state)) {
1398+
; /* all set */
13881399
} else if (!stat(git_path_cherry_pick_head(), &st) &&
13891400
!get_sha1("CHERRY_PICK_HEAD", sha1)) {
13901401
state->cherry_pick_in_progress = 1;

wt-status.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ void wt_status_prepare(struct wt_status *s);
100100
void wt_status_print(struct wt_status *s);
101101
void wt_status_collect(struct wt_status *s);
102102
void wt_status_get_state(struct wt_status_state *state, int get_detached_from);
103+
int wt_status_check_rebase(struct wt_status_state *state);
103104

104105
void wt_shortstatus_print(struct wt_status *s);
105106
void wt_porcelain_print(struct wt_status *s);

0 commit comments

Comments
 (0)