Skip to content

Commit ec50631

Browse files
artagnongitster
authored andcommitted
status: do not depend on rebase reflog messages
b397ea4 (status: show more info than "currently not on any branch", 2013-03-13) attempted to make the output of 'git status' richer in the case of a detached HEAD. Before this patch, with a detached HEAD, we saw: $ git status # Not currently on any branch. But after the patch, we see: $ git checkout v1.8.2 $ git status # HEAD detached at v1.8.2. It works by digging the reflog for the most recent message of the form "checkout: moving from xxxx to yyyy". It then asserts that HEAD and "yyyy" are the same, and displays this message. When they aren't equal, it displays: $ git status # HEAD detached from fe11db. so that the user can see where the HEAD was first detached. In case of a rebase [-i] operation in progress, this message depends on the implementation of rebase writing "checkout: " messages to the reflog, but that is an implementation detail of "rebase". To remove this dependency so that rebase can be updated to write better reflog messages, replace this "HEAD detached from" message with: # rebase in progress; onto $ONTO Changes to the commit object name in the expected output for some of the tests shows that what the test expected "status" to show during "rebase -i" was not consistent with the output during a vanilla "rebase", which showed on top of what commit the series is being replayed. Now we consistently expect something meaningful to the end user. Signed-off-by: Ramkumar Ramachandra <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 89f2fea commit ec50631

File tree

2 files changed

+21
-21
lines changed

2 files changed

+21
-21
lines changed

t/t7512-status-help.sh

Lines changed: 17 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ test_expect_success 'status when rebase in progress before resolving conflicts'
7777
ONTO=$(git rev-parse --short HEAD^^) &&
7878
test_must_fail git rebase HEAD^ --onto HEAD^^ &&
7979
cat >expected <<-EOF &&
80-
# HEAD detached at $ONTO
80+
# rebase in progress; onto $ONTO
8181
# You are currently rebasing branch '\''rebase_conflicts'\'' on '\''$ONTO'\''.
8282
# (fix conflicts and then run "git rebase --continue")
8383
# (use "git rebase --skip" to skip this patch)
@@ -104,7 +104,7 @@ test_expect_success 'status when rebase in progress before rebase --continue' '
104104
echo three >main.txt &&
105105
git add main.txt &&
106106
cat >expected <<-EOF &&
107-
# HEAD detached at $ONTO
107+
# rebase in progress; onto $ONTO
108108
# You are currently rebasing branch '\''rebase_conflicts'\'' on '\''$ONTO'\''.
109109
# (all conflicts fixed: run "git rebase --continue")
110110
#
@@ -136,7 +136,7 @@ test_expect_success 'status during rebase -i when conflicts unresolved' '
136136
ONTO=$(git rev-parse --short rebase_i_conflicts) &&
137137
test_must_fail git rebase -i rebase_i_conflicts &&
138138
cat >expected <<-EOF &&
139-
# HEAD detached at $ONTO
139+
# rebase in progress; onto $ONTO
140140
# You are currently rebasing branch '\''rebase_i_conflicts_second'\'' on '\''$ONTO'\''.
141141
# (fix conflicts and then run "git rebase --continue")
142142
# (use "git rebase --skip" to skip this patch)
@@ -162,7 +162,7 @@ test_expect_success 'status during rebase -i after resolving conflicts' '
162162
test_must_fail git rebase -i rebase_i_conflicts &&
163163
git add main.txt &&
164164
cat >expected <<-EOF &&
165-
# HEAD detached at $ONTO
165+
# rebase in progress; onto $ONTO
166166
# You are currently rebasing branch '\''rebase_i_conflicts_second'\'' on '\''$ONTO'\''.
167167
# (all conflicts fixed: run "git rebase --continue")
168168
#
@@ -188,10 +188,9 @@ test_expect_success 'status when rebasing -i in edit mode' '
188188
export FAKE_LINES &&
189189
test_when_finished "git rebase --abort" &&
190190
ONTO=$(git rev-parse --short HEAD~2) &&
191-
TGT=$(git rev-parse --short two_rebase_i) &&
192191
git rebase -i HEAD~2 &&
193192
cat >expected <<-EOF &&
194-
# HEAD detached from $TGT
193+
# rebase in progress; onto $ONTO
195194
# You are currently editing a commit while rebasing branch '\''rebase_i_edit'\'' on '\''$ONTO'\''.
196195
# (use "git commit --amend" to amend the current commit)
197196
# (use "git rebase --continue" once you are satisfied with your changes)
@@ -216,9 +215,8 @@ test_expect_success 'status when splitting a commit' '
216215
ONTO=$(git rev-parse --short HEAD~3) &&
217216
git rebase -i HEAD~3 &&
218217
git reset HEAD^ &&
219-
TGT=$(git rev-parse --short HEAD) &&
220218
cat >expected <<-EOF &&
221-
# HEAD detached at $TGT
219+
# rebase in progress; onto $ONTO
222220
# You are currently splitting a commit while rebasing branch '\''split_commit'\'' on '\''$ONTO'\''.
223221
# (Once your working directory is clean, run "git rebase --continue")
224222
#
@@ -246,11 +244,10 @@ test_expect_success 'status after editing the last commit with --amend during a
246244
export FAKE_LINES &&
247245
test_when_finished "git rebase --abort" &&
248246
ONTO=$(git rev-parse --short HEAD~3) &&
249-
TGT=$(git rev-parse --short three_amend) &&
250247
git rebase -i HEAD~3 &&
251248
git commit --amend -m "foo" &&
252249
cat >expected <<-EOF &&
253-
# HEAD detached from $TGT
250+
# rebase in progress; onto $ONTO
254251
# You are currently editing a commit while rebasing branch '\''amend_last'\'' on '\''$ONTO'\''.
255252
# (use "git commit --amend" to amend the current commit)
256253
# (use "git rebase --continue" once you are satisfied with your changes)
@@ -280,7 +277,7 @@ test_expect_success 'status: (continue first edit) second edit' '
280277
git rebase -i HEAD~3 &&
281278
git rebase --continue &&
282279
cat >expected <<-EOF &&
283-
# HEAD detached from $ONTO
280+
# rebase in progress; onto $ONTO
284281
# You are currently editing a commit while rebasing branch '\''several_edits'\'' on '\''$ONTO'\''.
285282
# (use "git commit --amend" to amend the current commit)
286283
# (use "git rebase --continue" once you are satisfied with your changes)
@@ -302,7 +299,7 @@ test_expect_success 'status: (continue first edit) second edit and split' '
302299
git rebase --continue &&
303300
git reset HEAD^ &&
304301
cat >expected <<-EOF &&
305-
# HEAD detached from $ONTO
302+
# rebase in progress; onto $ONTO
306303
# You are currently splitting a commit while rebasing branch '\''several_edits'\'' on '\''$ONTO'\''.
307304
# (Once your working directory is clean, run "git rebase --continue")
308305
#
@@ -329,7 +326,7 @@ test_expect_success 'status: (continue first edit) second edit and amend' '
329326
git rebase --continue &&
330327
git commit --amend -m "foo" &&
331328
cat >expected <<-EOF &&
332-
# HEAD detached from $ONTO
329+
# rebase in progress; onto $ONTO
333330
# You are currently editing a commit while rebasing branch '\''several_edits'\'' on '\''$ONTO'\''.
334331
# (use "git commit --amend" to amend the current commit)
335332
# (use "git rebase --continue" once you are satisfied with your changes)
@@ -351,7 +348,7 @@ test_expect_success 'status: (amend first edit) second edit' '
351348
git commit --amend -m "a" &&
352349
git rebase --continue &&
353350
cat >expected <<-EOF &&
354-
# HEAD detached from $ONTO
351+
# rebase in progress; onto $ONTO
355352
# You are currently editing a commit while rebasing branch '\''several_edits'\'' on '\''$ONTO'\''.
356353
# (use "git commit --amend" to amend the current commit)
357354
# (use "git rebase --continue" once you are satisfied with your changes)
@@ -374,7 +371,7 @@ test_expect_success 'status: (amend first edit) second edit and split' '
374371
git rebase --continue &&
375372
git reset HEAD^ &&
376373
cat >expected <<-EOF &&
377-
# HEAD detached from $ONTO
374+
# rebase in progress; onto $ONTO
378375
# You are currently splitting a commit while rebasing branch '\''several_edits'\'' on '\''$ONTO'\''.
379376
# (Once your working directory is clean, run "git rebase --continue")
380377
#
@@ -402,7 +399,7 @@ test_expect_success 'status: (amend first edit) second edit and amend' '
402399
git rebase --continue &&
403400
git commit --amend -m "d" &&
404401
cat >expected <<-EOF &&
405-
# HEAD detached from $ONTO
402+
# rebase in progress; onto $ONTO
406403
# You are currently editing a commit while rebasing branch '\''several_edits'\'' on '\''$ONTO'\''.
407404
# (use "git commit --amend" to amend the current commit)
408405
# (use "git rebase --continue" once you are satisfied with your changes)
@@ -426,7 +423,7 @@ test_expect_success 'status: (split first edit) second edit' '
426423
git commit -m "e" &&
427424
git rebase --continue &&
428425
cat >expected <<-EOF &&
429-
# HEAD detached from $ONTO
426+
# rebase in progress; onto $ONTO
430427
# You are currently editing a commit while rebasing branch '\''several_edits'\'' on '\''$ONTO'\''.
431428
# (use "git commit --amend" to amend the current commit)
432429
# (use "git rebase --continue" once you are satisfied with your changes)
@@ -451,7 +448,7 @@ test_expect_success 'status: (split first edit) second edit and split' '
451448
git rebase --continue &&
452449
git reset HEAD^ &&
453450
cat >expected <<-EOF &&
454-
# HEAD detached from $ONTO
451+
# rebase in progress; onto $ONTO
455452
# You are currently splitting a commit while rebasing branch '\''several_edits'\'' on '\''$ONTO'\''.
456453
# (Once your working directory is clean, run "git rebase --continue")
457454
#
@@ -481,7 +478,7 @@ test_expect_success 'status: (split first edit) second edit and amend' '
481478
git rebase --continue &&
482479
git commit --amend -m "h" &&
483480
cat >expected <<-EOF &&
484-
# HEAD detached from $ONTO
481+
# rebase in progress; onto $ONTO
485482
# You are currently editing a commit while rebasing branch '\''several_edits'\'' on '\''$ONTO'\''.
486483
# (use "git commit --amend" to amend the current commit)
487484
# (use "git rebase --continue" once you are satisfied with your changes)
@@ -601,7 +598,7 @@ test_expect_success 'status when rebase conflicts with statushints disabled' '
601598
ONTO=$(git rev-parse --short HEAD^^) &&
602599
test_must_fail git rebase HEAD^ --onto HEAD^^ &&
603600
cat >expected <<-EOF &&
604-
# HEAD detached at $ONTO
601+
# rebase in progress; onto $ONTO
605602
# You are currently rebasing branch '\''statushints_disabled'\'' on '\''$ONTO'\''.
606603
#
607604
# Unmerged paths:

wt-status.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1174,7 +1174,10 @@ void wt_status_print(struct wt_status *s)
11741174
branch_name += 11;
11751175
else if (!strcmp(branch_name, "HEAD")) {
11761176
branch_status_color = color(WT_STATUS_NOBRANCH, s);
1177-
if (state.detached_from) {
1177+
if (state.rebase_in_progress || state.rebase_interactive_in_progress) {
1178+
on_what = _("rebase in progress; onto ");
1179+
branch_name = state.onto;
1180+
} else if (state.detached_from) {
11781181
unsigned char sha1[20];
11791182
branch_name = state.detached_from;
11801183
if (!get_sha1("HEAD", sha1) &&

0 commit comments

Comments
 (0)