summaryrefslogtreecommitdiff
path: root/wt-status.c
diff options
context:
space:
mode:
authorNguyễn Thái Ngọc Duy <pclouds@gmail.com>2016-04-22 13:01:30 (GMT)
committerJunio C Hamano <gitster@pobox.com>2016-04-22 21:09:38 (GMT)
commitbcd522a1495146113f8e08e84a6717c04508e197 (patch)
treea90472f818ba763a60d1c18791c50e20e64ebe44 /wt-status.c
parent2e641d5825673c7dca384bc12fcaf1681d731bb6 (diff)
downloadgit-bcd522a1495146113f8e08e84a6717c04508e197.zip
git-bcd522a1495146113f8e08e84a6717c04508e197.tar.gz
git-bcd522a1495146113f8e08e84a6717c04508e197.tar.bz2
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>
Diffstat (limited to 'wt-status.c')
-rw-r--r--wt-status.c23
1 files changed, 17 insertions, 6 deletions
diff --git a/wt-status.c b/wt-status.c
index 1ea2ebe..ec9240d 100644
--- a/wt-status.c
+++ b/wt-status.c
@@ -1360,15 +1360,11 @@ static void wt_status_get_detached_from(struct wt_status_state *state)
strbuf_release(&cb.buf);
}
-void wt_status_get_state(struct wt_status_state *state,
- int get_detached_from)
+int wt_status_check_rebase(struct wt_status_state *state)
{
struct stat st;
- unsigned char sha1[20];
- if (!stat(git_path_merge_head(), &st)) {
- state->merge_in_progress = 1;
- } else if (!stat(git_path("rebase-apply"), &st)) {
+ if (!stat(git_path("rebase-apply"), &st)) {
if (!stat(git_path("rebase-apply/applying"), &st)) {
state->am_in_progress = 1;
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,
state->rebase_in_progress = 1;
state->branch = read_and_strip_branch("rebase-merge/head-name");
state->onto = read_and_strip_branch("rebase-merge/onto");
+ } else
+ return 0;
+ return 1;
+}
+
+void wt_status_get_state(struct wt_status_state *state,
+ int get_detached_from)
+{
+ struct stat st;
+ unsigned char sha1[20];
+
+ if (!stat(git_path_merge_head(), &st)) {
+ state->merge_in_progress = 1;
+ } else if (wt_status_check_rebase(state)) {
+ ; /* all set */
} else if (!stat(git_path_cherry_pick_head(), &st) &&
!get_sha1("CHERRY_PICK_HEAD", sha1)) {
state->cherry_pick_in_progress = 1;