]> git.ipfire.org Git - thirdparty/git.git/blobdiff - wt-status.c
travis-ci: build with GCC 4.8 as well
[thirdparty/git.git] / wt-status.c
index b81fcd428de0d694308cb1a86439005701194a97..d2a1bec226ba0dfef9e3ddd96c0b3a83ea6884bb 100644 (file)
@@ -17,6 +17,7 @@
 #include "utf8.h"
 #include "worktree.h"
 #include "lockfile.h"
+#include "sequencer.h"
 
 static const char cut_line[] =
 "------------------------ >8 ------------------------\n";
@@ -1214,7 +1215,9 @@ static void abbrev_sha1_in_line(struct strbuf *line)
        int i;
 
        if (starts_with(line->buf, "exec ") ||
-           starts_with(line->buf, "x "))
+           starts_with(line->buf, "x ") ||
+           starts_with(line->buf, "label ") ||
+           starts_with(line->buf, "l "))
                return;
 
        split = strbuf_split_max(line, ' ', 3);
@@ -1386,12 +1389,22 @@ static void show_rebase_in_progress(struct wt_status *s,
 static void show_cherry_pick_in_progress(struct wt_status *s,
                                         const char *color)
 {
-       status_printf_ln(s, color, _("You are currently cherry-picking commit %s."),
-                       find_unique_abbrev(&s->state.cherry_pick_head_oid, DEFAULT_ABBREV));
+       if (is_null_oid(&s->state.cherry_pick_head_oid))
+               status_printf_ln(s, color,
+                       _("Cherry-pick currently in progress."));
+       else
+               status_printf_ln(s, color,
+                       _("You are currently cherry-picking commit %s."),
+                       find_unique_abbrev(&s->state.cherry_pick_head_oid,
+                                          DEFAULT_ABBREV));
+
        if (s->hints) {
                if (has_unmerged(s))
                        status_printf_ln(s, color,
                                _("  (fix conflicts and run \"git cherry-pick --continue\")"));
+               else if (is_null_oid(&s->state.cherry_pick_head_oid))
+                       status_printf_ln(s, color,
+                               _("  (run \"git cherry-pick --continue\" to continue)"));
                else
                        status_printf_ln(s, color,
                                _("  (all conflicts fixed: run \"git cherry-pick --continue\")"));
@@ -1404,12 +1417,21 @@ static void show_cherry_pick_in_progress(struct wt_status *s,
 static void show_revert_in_progress(struct wt_status *s,
                                    const char *color)
 {
-       status_printf_ln(s, color, _("You are currently reverting commit %s."),
-                        find_unique_abbrev(&s->state.revert_head_oid, DEFAULT_ABBREV));
+       if (is_null_oid(&s->state.revert_head_oid))
+               status_printf_ln(s, color,
+                       _("Revert currently in progress."));
+       else
+               status_printf_ln(s, color,
+                       _("You are currently reverting commit %s."),
+                       find_unique_abbrev(&s->state.revert_head_oid,
+                                          DEFAULT_ABBREV));
        if (s->hints) {
                if (has_unmerged(s))
                        status_printf_ln(s, color,
                                _("  (fix conflicts and run \"git revert --continue\")"));
+               else if (is_null_oid(&s->state.revert_head_oid))
+                       status_printf_ln(s, color,
+                               _("  (run \"git revert --continue\" to continue)"));
                else
                        status_printf_ln(s, color,
                                _("  (all conflicts fixed: run \"git revert --continue\")"));
@@ -1580,6 +1602,7 @@ void wt_status_get_state(struct repository *r,
 {
        struct stat st;
        struct object_id oid;
+       enum replay_action action;
 
        if (!stat(git_path_merge_head(r), &st)) {
                wt_status_check_rebase(NULL, state);
@@ -1597,7 +1620,15 @@ void wt_status_get_state(struct repository *r,
                state->revert_in_progress = 1;
                oidcpy(&state->revert_head_oid, &oid);
        }
-
+       if (!sequencer_get_last_command(r, &action)) {
+               if (action == REPLAY_PICK) {
+                       state->cherry_pick_in_progress = 1;
+                       oidcpy(&state->cherry_pick_head_oid, &null_oid);
+               } else {
+                       state->revert_in_progress = 1;
+                       oidcpy(&state->revert_head_oid, &null_oid);
+               }
+       }
        if (get_detached_from)
                wt_status_get_detached_from(r, state);
 }
@@ -1857,7 +1888,7 @@ static void wt_shortstatus_print_tracking(struct wt_status *s)
        color_fprintf(s->fp, branch_color_local, "%s", branch_name);
 
        sti = stat_tracking_info(branch, &num_ours, &num_theirs, &base,
-                                s->ahead_behind_flags);
+                                0, s->ahead_behind_flags);
        if (sti < 0) {
                if (!base)
                        goto conclude;
@@ -1996,7 +2027,7 @@ static void wt_porcelain_v2_print_tracking(struct wt_status *s)
                branch = branch_get(branch_name);
                base = NULL;
                ab_info = stat_tracking_info(branch, &nr_ahead, &nr_behind,
-                                            &base, s->ahead_behind_flags);
+                                            &base, 0, s->ahead_behind_flags);
                if (base) {
                        base = shorten_unambiguous_ref(base, 0);
                        fprintf(s->fp, "# branch.upstream %s%c", base, eol);