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

[PATCH] rebase: use plumbing to show dirty state

From
Jeff King <peff@peff.net>
Date
Sep 9, 2009, 14:59 UTC
Message-ID
<20090909145937.GA5723@sigill.intra.peff.net>

Commit 4cfbe06 introduced the use of "git diff" to show dirty state in a format more familiar to users. However, it should have used the plumbing "git diff-files" instead.

Not only is it good practice in general to use plumbing in scripts, but in this case we really don't want the automatic pager to kick in for an error message.

Signed-off-by: Jeff King <peff@peff.net>
---
I got quite a surprise when I ran "git rebase" and was presented with a
pager with nothing but:
  M foo.c

in it. I suspect this issue wasn't noticed while testing because most people use "-FX" with "less", so their short list of dirty files causes the pager to exit immediately.

 git-rebase.sh |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/git-rebase.sh b/git-rebase.sh
index 2315d95..6ec155c 100755
--- a/git-rebase.sh
+++ b/git-rebase.sh
@@ -387,7 +387,7 @@ fi
 # The tree must be really really clean.
 if ! git update-index --ignore-submodules --refresh > /dev/null; then
 	echo >&2 "cannot rebase: you have unstaged changes"
-	git diff --name-status -r --ignore-submodules -- >&2
+	git diff-files --name-status -r --ignore-submodules -- >&2
 	exit 1
 fi
 diff=$(git diff-index --cached --name-status -r --ignore-submodules HEAD --)
-- 
1.6.5.rc0.166.ge65f.dirty
Message 1 of 1 in “rebase: use plumbing to show dirty state”
  1. rebase: use plumbing to show dirty stateJeff King, Sep 9, 2009

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.