#include "utf8.h"
#include "worktree.h"
#include "lockfile.h"
+#include "sequencer.h"
static const char cut_line[] =
"------------------------ >8 ------------------------\n";
void wt_status_collect(struct wt_status *s)
{
+ trace2_region_enter("status", "worktrees", s->repo);
wt_status_collect_changes_worktree(s);
- if (s->is_initial)
+ trace2_region_leave("status", "worktrees", s->repo);
+
+ if (s->is_initial) {
+ trace2_region_enter("status", "initial", s->repo);
wt_status_collect_changes_initial(s);
- else
+ trace2_region_leave("status", "initial", s->repo);
+ } else {
+ trace2_region_enter("status", "index", s->repo);
wt_status_collect_changes_index(s);
+ trace2_region_leave("status", "index", s->repo);
+ }
+
+ trace2_region_enter("status", "untracked", s->repo);
wt_status_collect_untracked(s);
+ trace2_region_leave("status", "untracked", s->repo);
wt_status_get_state(s->repo, &s->state, s->branch && !strcmp(s->branch, "HEAD"));
if (s->state.merge_in_progress && !has_unmerged(s))
return len;
}
-void wt_status_add_cut_line(FILE *fp)
+void wt_status_append_cut_line(struct strbuf *buf)
{
const char *explanation = _("Do not modify or remove the line above.\nEverything below it will be ignored.");
+
+ strbuf_commented_addf(buf, "%s", cut_line);
+ strbuf_add_commented_lines(buf, explanation, strlen(explanation));
+}
+
+void wt_status_add_cut_line(FILE *fp)
+{
struct strbuf buf = STRBUF_INIT;
- fprintf(fp, "%c %s", comment_line_char, cut_line);
- strbuf_add_commented_lines(&buf, explanation, strlen(explanation));
+ wt_status_append_cut_line(&buf);
fputs(buf.buf, fp);
strbuf_release(&buf);
}
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\")"));
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\")"));
{
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);
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);
}
void wt_status_print(struct wt_status *s)
{
+ trace2_data_intmax("status", s->repo, "count/changed", s->change.nr);
+ trace2_data_intmax("status", s->repo, "count/untracked",
+ s->untracked.nr);
+ trace2_data_intmax("status", s->repo, "count/ignored", s->ignored.nr);
+
+ trace2_region_enter("status", "print", s->repo);
+
switch (s->status_format) {
case STATUS_FORMAT_SHORT:
wt_shortstatus_print(s);
wt_longstatus_print(s);
break;
}
+
+ trace2_region_leave("status", "print", s->repo);
}
/**