git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH] rebase-interactive: silence warning when no commits rewritten

From
Jeff King <peff@peff.net>
Date
Apr 18, 2010, 12:01 UTC
Message-ID
<20100418120145.GA14872@coredump.intra.peff.net>

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.

Signed-off-by: Jeff King <peff@peff.net>
---
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(-)
diff --git a/git-rebase--interactive.sh b/git-rebase--interactive.sh
index b817c4a..436b7f5 100755
--- a/git-rebase--interactive.sh
+++ b/git-rebase--interactive.sh
@@ -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"
-- 
1.7.1.rc1.279.gae4efc.dirty
Next: Junio C Hamano
Message 1 of 2 in “rebase-interactive: silence warning when no commits rewritten”
  1. rebase-interactive: silence warning when no commits rewrittenJeff King, Apr 18, 2010
  2. Junio C HamanoApr 18, 2010

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.