Skip to content

Commit 0722c80

Browse files
pcloudsgitster
authored andcommitted
status: show the branch name if possible in in-progress info
The typical use-case is starting a rebase, do something else, come back the day after, run "git status" or make a new commit and wonder what in the world's going on. Which branch is being rebased is probably the most useful tidbit to help, but the target may help too. Ideally, I would have loved to see "rebasing master on origin/master", but the target ref name is not stored during rebase, so this patch writes "rebasing master on a78c8c98b" as a half-measure to remind future users of that potential improvement. Signed-off-by: Nguyễn Thái Ngọc Duy <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent bcd45b4 commit 0722c80

File tree

3 files changed

+142
-41
lines changed

3 files changed

+142
-41
lines changed

t/t7512-status-help.sh

Lines changed: 52 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -73,10 +73,11 @@ test_expect_success 'prepare for rebase conflicts' '
7373

7474
test_expect_success 'status when rebase in progress before resolving conflicts' '
7575
test_when_finished "git rebase --abort" &&
76+
ONTO=$(git rev-parse --short HEAD^^) &&
7677
test_must_fail git rebase HEAD^ --onto HEAD^^ &&
77-
cat >expected <<-\EOF &&
78+
cat >expected <<-EOF &&
7879
# Not currently on any branch.
79-
# You are currently rebasing.
80+
# You are currently rebasing branch '\''rebase_conflicts'\'' on '\''$ONTO'\''.
8081
# (fix conflicts and then run "git rebase --continue")
8182
# (use "git rebase --skip" to skip this patch)
8283
# (use "git rebase --abort" to check out the original branch)
@@ -97,12 +98,13 @@ test_expect_success 'status when rebase in progress before resolving conflicts'
9798
test_expect_success 'status when rebase in progress before rebase --continue' '
9899
git reset --hard rebase_conflicts &&
99100
test_when_finished "git rebase --abort" &&
101+
ONTO=$(git rev-parse --short HEAD^^) &&
100102
test_must_fail git rebase HEAD^ --onto HEAD^^ &&
101103
echo three >main.txt &&
102104
git add main.txt &&
103-
cat >expected <<-\EOF &&
105+
cat >expected <<-EOF &&
104106
# Not currently on any branch.
105-
# You are currently rebasing.
107+
# You are currently rebasing branch '\''rebase_conflicts'\'' on '\''$ONTO'\''.
106108
# (all conflicts fixed: run "git rebase --continue")
107109
#
108110
# Changes to be committed:
@@ -130,10 +132,11 @@ test_expect_success 'prepare for rebase_i_conflicts' '
130132

131133
test_expect_success 'status during rebase -i when conflicts unresolved' '
132134
test_when_finished "git rebase --abort" &&
135+
ONTO=$(git rev-parse --short rebase_i_conflicts) &&
133136
test_must_fail git rebase -i rebase_i_conflicts &&
134-
cat >expected <<-\EOF &&
137+
cat >expected <<-EOF &&
135138
# Not currently on any branch.
136-
# You are currently rebasing.
139+
# You are currently rebasing branch '\''rebase_i_conflicts_second'\'' on '\''$ONTO'\''.
137140
# (fix conflicts and then run "git rebase --continue")
138141
# (use "git rebase --skip" to skip this patch)
139142
# (use "git rebase --abort" to check out the original branch)
@@ -154,11 +157,12 @@ test_expect_success 'status during rebase -i when conflicts unresolved' '
154157
test_expect_success 'status during rebase -i after resolving conflicts' '
155158
git reset --hard rebase_i_conflicts_second &&
156159
test_when_finished "git rebase --abort" &&
160+
ONTO=$(git rev-parse --short rebase_i_conflicts) &&
157161
test_must_fail git rebase -i rebase_i_conflicts &&
158162
git add main.txt &&
159-
cat >expected <<-\EOF &&
163+
cat >expected <<-EOF &&
160164
# Not currently on any branch.
161-
# You are currently rebasing.
165+
# You are currently rebasing branch '\''rebase_i_conflicts_second'\'' on '\''$ONTO'\''.
162166
# (all conflicts fixed: run "git rebase --continue")
163167
#
164168
# Changes to be committed:
@@ -182,10 +186,11 @@ test_expect_success 'status when rebasing -i in edit mode' '
182186
FAKE_LINES="1 edit 2" &&
183187
export FAKE_LINES &&
184188
test_when_finished "git rebase --abort" &&
189+
ONTO=$(git rev-parse --short HEAD~2) &&
185190
git rebase -i HEAD~2 &&
186-
cat >expected <<-\EOF &&
191+
cat >expected <<-EOF &&
187192
# Not currently on any branch.
188-
# You are currently editing a commit during a rebase.
193+
# You are currently editing a commit while rebasing branch '\''rebase_i_edit'\'' on '\''$ONTO'\''.
189194
# (use "git commit --amend" to amend the current commit)
190195
# (use "git rebase --continue" once you are satisfied with your changes)
191196
#
@@ -206,11 +211,12 @@ test_expect_success 'status when splitting a commit' '
206211
FAKE_LINES="1 edit 2 3" &&
207212
export FAKE_LINES &&
208213
test_when_finished "git rebase --abort" &&
214+
ONTO=$(git rev-parse --short HEAD~3) &&
209215
git rebase -i HEAD~3 &&
210216
git reset HEAD^ &&
211-
cat >expected <<-\EOF &&
217+
cat >expected <<-EOF &&
212218
# Not currently on any branch.
213-
# You are currently splitting a commit during a rebase.
219+
# You are currently splitting a commit while rebasing branch '\''split_commit'\'' on '\''$ONTO'\''.
214220
# (Once your working directory is clean, run "git rebase --continue")
215221
#
216222
# Changes not staged for commit:
@@ -236,11 +242,12 @@ test_expect_success 'status after editing the last commit with --amend during a
236242
FAKE_LINES="1 2 edit 3" &&
237243
export FAKE_LINES &&
238244
test_when_finished "git rebase --abort" &&
245+
ONTO=$(git rev-parse --short HEAD~3) &&
239246
git rebase -i HEAD~3 &&
240247
git commit --amend -m "foo" &&
241-
cat >expected <<-\EOF &&
248+
cat >expected <<-EOF &&
242249
# Not currently on any branch.
243-
# You are currently editing a commit during a rebase.
250+
# You are currently editing a commit while rebasing branch '\''amend_last'\'' on '\''$ONTO'\''.
244251
# (use "git commit --amend" to amend the current commit)
245252
# (use "git rebase --continue" once you are satisfied with your changes)
246253
#
@@ -265,11 +272,12 @@ test_expect_success 'status: (continue first edit) second edit' '
265272
FAKE_LINES="edit 1 edit 2 3" &&
266273
export FAKE_LINES &&
267274
test_when_finished "git rebase --abort" &&
275+
ONTO=$(git rev-parse --short HEAD~3) &&
268276
git rebase -i HEAD~3 &&
269277
git rebase --continue &&
270-
cat >expected <<-\EOF &&
278+
cat >expected <<-EOF &&
271279
# Not currently on any branch.
272-
# You are currently editing a commit during a rebase.
280+
# You are currently editing a commit while rebasing branch '\''several_edits'\'' on '\''$ONTO'\''.
273281
# (use "git commit --amend" to amend the current commit)
274282
# (use "git rebase --continue" once you are satisfied with your changes)
275283
#
@@ -285,12 +293,13 @@ test_expect_success 'status: (continue first edit) second edit and split' '
285293
FAKE_LINES="edit 1 edit 2 3" &&
286294
export FAKE_LINES &&
287295
test_when_finished "git rebase --abort" &&
296+
ONTO=$(git rev-parse --short HEAD~3) &&
288297
git rebase -i HEAD~3 &&
289298
git rebase --continue &&
290299
git reset HEAD^ &&
291-
cat >expected <<-\EOF &&
300+
cat >expected <<-EOF &&
292301
# Not currently on any branch.
293-
# You are currently splitting a commit during a rebase.
302+
# You are currently splitting a commit while rebasing branch '\''several_edits'\'' on '\''$ONTO'\''.
294303
# (Once your working directory is clean, run "git rebase --continue")
295304
#
296305
# Changes not staged for commit:
@@ -311,12 +320,13 @@ test_expect_success 'status: (continue first edit) second edit and amend' '
311320
FAKE_LINES="edit 1 edit 2 3" &&
312321
export FAKE_LINES &&
313322
test_when_finished "git rebase --abort" &&
323+
ONTO=$(git rev-parse --short HEAD~3) &&
314324
git rebase -i HEAD~3 &&
315325
git rebase --continue &&
316326
git commit --amend -m "foo" &&
317-
cat >expected <<-\EOF &&
327+
cat >expected <<-EOF &&
318328
# Not currently on any branch.
319-
# You are currently editing a commit during a rebase.
329+
# You are currently editing a commit while rebasing branch '\''several_edits'\'' on '\''$ONTO'\''.
320330
# (use "git commit --amend" to amend the current commit)
321331
# (use "git rebase --continue" once you are satisfied with your changes)
322332
#
@@ -332,12 +342,13 @@ test_expect_success 'status: (amend first edit) second edit' '
332342
FAKE_LINES="edit 1 edit 2 3" &&
333343
export FAKE_LINES &&
334344
test_when_finished "git rebase --abort" &&
345+
ONTO=$(git rev-parse --short HEAD~3) &&
335346
git rebase -i HEAD~3 &&
336347
git commit --amend -m "a" &&
337348
git rebase --continue &&
338-
cat >expected <<-\EOF &&
349+
cat >expected <<-EOF &&
339350
# Not currently on any branch.
340-
# You are currently editing a commit during a rebase.
351+
# You are currently editing a commit while rebasing branch '\''several_edits'\'' on '\''$ONTO'\''.
341352
# (use "git commit --amend" to amend the current commit)
342353
# (use "git rebase --continue" once you are satisfied with your changes)
343354
#
@@ -353,13 +364,14 @@ test_expect_success 'status: (amend first edit) second edit and split' '
353364
FAKE_LINES="edit 1 edit 2 3" &&
354365
export FAKE_LINES &&
355366
test_when_finished "git rebase --abort" &&
367+
ONTO=$(git rev-parse --short HEAD~3) &&
356368
git rebase -i HEAD~3 &&
357369
git commit --amend -m "b" &&
358370
git rebase --continue &&
359371
git reset HEAD^ &&
360-
cat >expected <<-\EOF &&
372+
cat >expected <<-EOF &&
361373
# Not currently on any branch.
362-
# You are currently splitting a commit during a rebase.
374+
# You are currently splitting a commit while rebasing branch '\''several_edits'\'' on '\''$ONTO'\''.
363375
# (Once your working directory is clean, run "git rebase --continue")
364376
#
365377
# Changes not staged for commit:
@@ -380,13 +392,14 @@ test_expect_success 'status: (amend first edit) second edit and amend' '
380392
FAKE_LINES="edit 1 edit 2 3" &&
381393
export FAKE_LINES &&
382394
test_when_finished "git rebase --abort" &&
395+
ONTO=$(git rev-parse --short HEAD~3) &&
383396
git rebase -i HEAD~3 &&
384397
git commit --amend -m "c" &&
385398
git rebase --continue &&
386399
git commit --amend -m "d" &&
387-
cat >expected <<-\EOF &&
400+
cat >expected <<-EOF &&
388401
# Not currently on any branch.
389-
# You are currently editing a commit during a rebase.
402+
# You are currently editing a commit while rebasing branch '\''several_edits'\'' on '\''$ONTO'\''.
390403
# (use "git commit --amend" to amend the current commit)
391404
# (use "git rebase --continue" once you are satisfied with your changes)
392405
#
@@ -402,14 +415,15 @@ test_expect_success 'status: (split first edit) second edit' '
402415
FAKE_LINES="edit 1 edit 2 3" &&
403416
export FAKE_LINES &&
404417
test_when_finished "git rebase --abort" &&
418+
ONTO=$(git rev-parse --short HEAD~3) &&
405419
git rebase -i HEAD~3 &&
406420
git reset HEAD^ &&
407421
git add main.txt &&
408422
git commit -m "e" &&
409423
git rebase --continue &&
410-
cat >expected <<-\EOF &&
424+
cat >expected <<-EOF &&
411425
# Not currently on any branch.
412-
# You are currently editing a commit during a rebase.
426+
# You are currently editing a commit while rebasing branch '\''several_edits'\'' on '\''$ONTO'\''.
413427
# (use "git commit --amend" to amend the current commit)
414428
# (use "git rebase --continue" once you are satisfied with your changes)
415429
#
@@ -425,15 +439,16 @@ test_expect_success 'status: (split first edit) second edit and split' '
425439
FAKE_LINES="edit 1 edit 2 3" &&
426440
export FAKE_LINES &&
427441
test_when_finished "git rebase --abort" &&
442+
ONTO=$(git rev-parse --short HEAD~3) &&
428443
git rebase -i HEAD~3 &&
429444
git reset HEAD^ &&
430445
git add main.txt &&
431446
git commit --amend -m "f" &&
432447
git rebase --continue &&
433448
git reset HEAD^ &&
434-
cat >expected <<-\EOF &&
449+
cat >expected <<-EOF &&
435450
# Not currently on any branch.
436-
# You are currently splitting a commit during a rebase.
451+
# You are currently splitting a commit while rebasing branch '\''several_edits'\'' on '\''$ONTO'\''.
437452
# (Once your working directory is clean, run "git rebase --continue")
438453
#
439454
# Changes not staged for commit:
@@ -454,15 +469,16 @@ test_expect_success 'status: (split first edit) second edit and amend' '
454469
FAKE_LINES="edit 1 edit 2 3" &&
455470
export FAKE_LINES &&
456471
test_when_finished "git rebase --abort" &&
472+
ONTO=$(git rev-parse --short HEAD~3) &&
457473
git rebase -i HEAD~3 &&
458474
git reset HEAD^ &&
459475
git add main.txt &&
460476
git commit --amend -m "g" &&
461477
git rebase --continue &&
462478
git commit --amend -m "h" &&
463-
cat >expected <<-\EOF &&
479+
cat >expected <<-EOF &&
464480
# Not currently on any branch.
465-
# You are currently editing a commit during a rebase.
481+
# You are currently editing a commit while rebasing branch '\''several_edits'\'' on '\''$ONTO'\''.
466482
# (use "git commit --amend" to amend the current commit)
467483
# (use "git rebase --continue" once you are satisfied with your changes)
468484
#
@@ -558,7 +574,7 @@ test_expect_success 'status when bisecting' '
558574
git bisect good one_bisect &&
559575
cat >expected <<-\EOF &&
560576
# Not currently on any branch.
561-
# You are currently bisecting.
577+
# You are currently bisecting branch '\''bisect'\''.
562578
# (use "git bisect reset" to get back to the original branch)
563579
#
564580
nothing to commit (use -u to show untracked files)
@@ -577,10 +593,11 @@ test_expect_success 'status when rebase conflicts with statushints disabled' '
577593
test_commit two_statushints main.txt two &&
578594
test_commit three_statushints main.txt three &&
579595
test_when_finished "git rebase --abort" &&
596+
ONTO=$(git rev-parse --short HEAD^^) &&
580597
test_must_fail git rebase HEAD^ --onto HEAD^^ &&
581-
cat >expected <<-\EOF &&
598+
cat >expected <<-EOF &&
582599
# Not currently on any branch.
583-
# You are currently rebasing.
600+
# You are currently rebasing branch '\''statushints_disabled'\'' on '\''$ONTO'\''.
584601
#
585602
# Unmerged paths:
586603
# both modified: main.txt

0 commit comments

Comments
 (0)