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 <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
bcd522a1495146113f8e08e84a6717c04508e197
2 files changed
+18
-6
wt-status.c
+17
-6
@@ -1360,15 +1360,11 @@ static void wt_status_get_detached_from(struct wt_status_state *state)
1360
strbuf_release(&cb.buf);
1361
}
1362
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)
1364
{
1365
struct stat st;
1367
- unsigned char sha1[20];
1366
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)) {
1368
if (!stat(git_path("rebase-apply/applying"), &st)) {
1369
state->am_in_progress = 1;
1370
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,
1381
state->rebase_in_progress = 1;
1382
state->branch = read_and_strip_branch("rebase-merge/head-name");
1383
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 */
1399
} else if (!stat(git_path_cherry_pick_head(), &st) &&
1400
!get_sha1("CHERRY_PICK_HEAD", sha1)) {
1401
state->cherry_pick_in_progress = 1;
wt-status.h
+1
@@ -100,6 +100,7 @@ void wt_status_prepare(struct wt_status *s);
100
void wt_status_print(struct wt_status *s);
101
void wt_status_collect(struct wt_status *s);
102
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);
104
105
void wt_shortstatus_print(struct wt_status *s);
106
void wt_porcelain_print(struct wt_status *s);