File tree 2 files changed +51
-6
lines changed 2 files changed +51
-6
lines changed Original file line number Diff line number Diff line change @@ -286,6 +286,37 @@ __git_eread ()
286
286
test -r " $1 " && IFS=$' \r\n ' read " $2 " < " $1 "
287
287
}
288
288
289
+ # see if a cherry-pick or revert is in progress, if the user has committed a
290
+ # conflict resolution with 'git commit' in the middle of a sequence of picks or
291
+ # reverts then CHERRY_PICK_HEAD/REVERT_HEAD will not exist so we have to read
292
+ # the todo file.
293
+ __git_sequencer_status ()
294
+ {
295
+ local todo
296
+ if test -f " $g /CHERRY_PICK_HEAD"
297
+ then
298
+ r=" |CHERRY-PICKING"
299
+ return 0;
300
+ elif test -f " $g /REVERT_HEAD"
301
+ then
302
+ r=" |REVERTING"
303
+ return 0;
304
+ elif __git_eread " $g /sequencer/todo" todo
305
+ then
306
+ case " $todo " in
307
+ p[\ \ ]|pick[\ \ ]* )
308
+ r=" |CHERRY-PICKING"
309
+ return 0
310
+ ;;
311
+ revert[\ \ ]* )
312
+ r=" |REVERTING"
313
+ return 0
314
+ ;;
315
+ esac
316
+ fi
317
+ return 1
318
+ }
319
+
289
320
# __git_ps1 accepts 0 or 1 arguments (i.e., format string)
290
321
# when called from PS1 using command substitution
291
322
# in this mode it prints text to add to bash PS1 prompt (includes branch name)
@@ -417,10 +448,8 @@ __git_ps1 ()
417
448
fi
418
449
elif [ -f " $g /MERGE_HEAD" ]; then
419
450
r=" |MERGING"
420
- elif [ -f " $g /CHERRY_PICK_HEAD" ]; then
421
- r=" |CHERRY-PICKING"
422
- elif [ -f " $g /REVERT_HEAD" ]; then
423
- r=" |REVERTING"
451
+ elif __git_sequencer_status; then
452
+ :
424
453
elif [ -f " $g /BISECT_LOG" ]; then
425
454
r=" |BISECTING"
426
455
fi
Original file line number Diff line number Diff line change @@ -211,8 +211,24 @@ test_expect_success 'prompt - merge' '
211
211
212
212
test_expect_success ' prompt - cherry-pick' '
213
213
printf " (master|CHERRY-PICKING)" >expected &&
214
- test_must_fail git cherry-pick b1 &&
215
- test_when_finished "git reset --hard" &&
214
+ test_must_fail git cherry-pick b1 b1^ &&
215
+ test_when_finished "git cherry-pick --abort" &&
216
+ __git_ps1 >"$actual" &&
217
+ test_cmp expected "$actual" &&
218
+ git reset --merge &&
219
+ test_must_fail git rev-parse CHERRY_PICK_HEAD &&
220
+ __git_ps1 >"$actual" &&
221
+ test_cmp expected "$actual"
222
+ '
223
+
224
+ test_expect_success ' prompt - revert' '
225
+ printf " (master|REVERTING)" >expected &&
226
+ test_must_fail git revert b1^ b1 &&
227
+ test_when_finished "git revert --abort" &&
228
+ __git_ps1 >"$actual" &&
229
+ test_cmp expected "$actual" &&
230
+ git reset --merge &&
231
+ test_must_fail git rev-parse REVERT_HEAD &&
216
232
__git_ps1 >"$actual" &&
217
233
test_cmp expected "$actual"
218
234
'
You can’t perform that action at this time.
0 commit comments