Skip to content

Commit

Permalink
status: show in-progress info for porcelain v2
Browse files Browse the repository at this point in the history
Porcelain v2 format is intended to be extendable. So we add in-progress
information unconditionally to the branch information (in case that is
shown at all).

Note that - in contrast to the short status info - we add all available
information in case multiple operations are in progress, and we do so by
outputting one line per operation.
  • Loading branch information
mjg committed Apr 15, 2024
1 parent b181769 commit e81f9be
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 6 deletions.
2 changes: 2 additions & 0 deletions t/t7064-wtstatus-pv2.sh
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,7 @@ test_expect_success 'verify AA (add-add) conflict' '
cat >expect <<-EOF &&
# branch.oid $HM
# branch.head AA_M
# branch.inprogress MERGING
u AA N... 000000 100644 100644 100644 $ZERO_OID $OID_AA_B $OID_AA_A conflict.txt
EOF
Expand Down Expand Up @@ -335,6 +336,7 @@ test_expect_success 'verify UU (edit-edit) conflict' '
cat >expect <<-EOF &&
# branch.oid $HM
# branch.head UU_M
# branch.inprogress MERGING
u UU N... 100644 100644 100644 100644 $OID_UU_ANC $OID_UU_B $OID_UU_A conflict.txt
EOF
Expand Down
24 changes: 18 additions & 6 deletions t/t7512-status-help.sh
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,9 @@ EOF
UU main.txt
EOF
git status --untracked-files=no --short --branch --in-progress >actual &&
test_cmp expected actual
test_cmp expected actual &&
git status --untracked-files=no --porcelain=v2 --branch >actual &&
test_grep "^# branch.inprogress REBASE-m$" actual
'


Expand Down Expand Up @@ -166,7 +168,9 @@ EOF
UU main.txt
EOF
git status --untracked-files=no --short --branch --in-progress >actual &&
test_cmp expected actual
test_cmp expected actual &&
git status --untracked-files=no --porcelain=v2 --branch >actual &&
test_grep "^# branch.inprogress REBASE-i$" actual
'


Expand Down Expand Up @@ -636,7 +640,9 @@ EOF
## am_already_exists; AM
EOF
git status --untracked-files=no --short --branch --in-progress >actual &&
test_cmp expected actual
test_cmp expected actual &&
git status --untracked-files=no --porcelain=v2 --branch >actual &&
test_grep "^# branch.inprogress AM$" actual
'


Expand Down Expand Up @@ -710,7 +716,9 @@ EOF
## HEAD (no branch); BISECTING
EOF
git status --untracked-files=no --short --branch --in-progress >actual &&
test_cmp expected actual
test_cmp expected actual &&
git status --untracked-files=no --porcelain=v2 --branch >actual &&
test_grep "^# branch.inprogress BISECTING$" actual
'


Expand Down Expand Up @@ -803,7 +811,9 @@ EOF
UU main.txt
EOF
git status --untracked-files=no --short --branch --in-progress >actual &&
test_cmp expected actual
test_cmp expected actual &&
git status --untracked-files=no --porcelain=v2 --branch >actual &&
test_grep "^# branch.inprogress CHERRY-PICKING$" actual
'


Expand Down Expand Up @@ -937,7 +947,9 @@ EOF
UU to-revert.txt
EOF
git status --untracked-files=no --short --branch --in-progress >actual &&
test_cmp expected actual
test_cmp expected actual &&
git status --untracked-files=no --porcelain=v2 --branch >actual &&
test_grep "^# branch.inprogress REVERTING$" actual
'


Expand Down
14 changes: 14 additions & 0 deletions wt-status.c
Original file line number Diff line number Diff line change
Expand Up @@ -2264,6 +2264,20 @@ static void wt_porcelain_v2_print_tracking(struct wt_status *s)
}
}
}
if (s->state.merge_in_progress)
fprintf(s->fp, "# branch.inprogress %s%c", "MERGING", eol);
if (s->state.am_in_progress)
fprintf(s->fp, "# branch.inprogress %s%c", "AM", eol);
if (s->state.rebase_in_progress)
fprintf(s->fp, "# branch.inprogress %s%c", "REBASE-m", eol);
if (s->state.rebase_interactive_in_progress)
fprintf(s->fp, "# branch.inprogress %s%c", "REBASE-i", eol);
if (s->state.cherry_pick_in_progress)
fprintf(s->fp, "# branch.inprogress %s%c", "CHERRY-PICKING", eol);
if (s->state.revert_in_progress)
fprintf(s->fp, "# branch.inprogress %s%c", "REVERTING", eol);
if (s->state.bisect_in_progress)
fprintf(s->fp, "# branch.inprogress %s%c", "BISECTING", eol);
}

/*
Expand Down

0 comments on commit e81f9be

Please sign in to comment.