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 Sep 14, 2024
1 parent 50e9070 commit 149ec7a
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 @@ -296,6 +296,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 @@ -336,6 +337,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 @@ -100,7 +100,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 @@ -167,7 +169,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 @@ -637,7 +641,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 @@ -711,7 +717,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 @@ -804,7 +812,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 @@ -938,7 +948,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 @@ -2271,6 +2271,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 149ec7a

Please sign in to comment.