4

I've written a script to automate a git rebase --interactive to edit a specified commit using GIT_SEQUENCE_EDITOR=sed ...s/pick/edit/...

How do I prevent the "helpful" message that git rebase --interactive prints out:

Stopped at 307c446...  Add candy-text
You can amend the commit now, with

  git commit --amend 

Once you are satisfied with your changes, run

  git rebase --continue

This message is printed to STDERR, and I still want to see any errors of the rebase command itself and/or any {pre,post}-rebase hooks, so 2>/dev/null isn't an option.

From the git config documentation, I've tried:

git -c advice.statusHints=false rebase --quiet --interactive --autostash --autosquash "$commit"~

I've also tried disabling advice.resolveConflict and advise.detachedHead.

There don't seem to be any useful options under rebase.*.

kostix
  • 51,517
  • 14
  • 93
  • 176
Tom Hale
  • 40,825
  • 36
  • 187
  • 242

1 Answers1

4

Both git-rebase--preserve-merges.sh (which calls warn ()) and the sequencer.c don't offer any option to prevent the display of that warning.

You can modify git-rebase--preserve-merges.sh locally, but that won't be portable (plus git rebase is being rewritten in C anyway, starting with Git 2.19)

Or you can submit a patch with a new setting allowing to silence that warning.


Or, as kostix suggests in the comments, you need to process the output of your command to filter out what you don't need:

your best bet may be to match it exactly by your hook script and wipe out.
Possibly do this in two steps:

  1. match ^Stopped at [[:xdigit:]]+.*$ and remove it if matched;
  2. if matched and removed, match the whole following banner and remove, if matched.

(although kostix suggests to do this with a more advanced language than bash)

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • @tom-hale, the message appears to be mostly static, so I'd say your best bet may be to match it exactly by your hook script and wipe out. Possibly do this in two steps: 1) match `^Stopped at [[:xdigit:]]+.*$` and remove it if matched; 2) if matched and removed, match the whole following banner and remove, if matched. – kostix Sep 14 '18 at 13:45
  • @tom-hale, it looks like, if possible, it would be better to engage a real programming language instead of `bash` to write your hook to make less jumps through the hoops. I'd say Python should cut the task just fine. – kostix Sep 14 '18 at 13:48
  • @kostix Thank you. I have included your comment in the answer for more visibility. – VonC Sep 14 '18 at 13:49