Skip to contentSkip to conversation

rebase-interactive: silence warning when no commits rewritten

PATCH In review Jeff King 2 participants 2 messages Jun 15, 2016

lore
Share & tools
lore

Jeff King

author
#0 lore raw

PATCH 1/1 rebase-interactive: silence warning when no commits rewritten

If you do a "rebase -i" and don't change any commits, nothing is rewritten, and we have no REWRITTEN_LIST. The shell prints out an ugly message:

  $ GIT_EDITOR=true git rebase -i HEAD^
  /path/to/git-rebase--interactive: 1: cannot open
    /path/to/repo/.git/rebase-merge/rewritten-list: No such file
  Successfully rebased and updated refs/heads/master.

We can fix it by not running "notes copy" at all if nothing was rewritten.

---
We already use the same test just below when deciding whether to run the post-rewrite hook.

 git-rebase--interactive.sh |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)
git-rebase--interactive.sh +1 -0
index b817c4a..436b7f5 100755
@@ -562,12 +562,13 @@ do_next () {
 		;;
 	esac && {
 		test ! -f "$DOTEST"/verbose ||
 			git diff-tree --stat $(cat "$DOTEST"/head)..HEAD
 	} &&
 	{
+		test -s "$REWRITTEN_LIST" &&
 		git notes copy --for-rewrite=rebase < "$REWRITTEN_LIST" ||
 		true # we don't care if this copying failed
 	} &&
 	if test -x "$GIT_DIR"/hooks/post-rewrite &&
 		test -s "$REWRITTEN_LIST"; then
 		"$GIT_DIR"/hooks/post-rewrite rebase < "$REWRITTEN_LIST"
Signature · 1 line
1.7.1.rc1.279.gae4efc.dirty
#1 lore raw

Thanks; I stumbled upon this the other day and was annoyed myself.