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

[PATCH] Define a shell function to check tree cleanness.

From
Junio C Hamano <junkio@cox.net>
Date
Aug 26, 2005, 08:03 UTC
Message-ID
<7vhdddgm5f.fsf@assigned-by-dhcp.cox.net>

This would be used in places where we require a clean tree, such as reverting and rebasing.

Signed-off-by: Junio C Hamano <junkio@cox.net>
---
 git-sh-setup-script |   11 +++++++++++
 1 files changed, 11 insertions(+), 0 deletions(-)
1de6046ded332e2278320be314f7a5e31a431e14
diff --git a/git-sh-setup-script b/git-sh-setup-script
--- a/git-sh-setup-script
+++ b/git-sh-setup-script
@@ -11,6 +11,17 @@ die() {
 	exit 1
 }
 
+check_clean_tree() {
+    dirty1_=`git-update-cache -q --refresh` && {
+    dirty2_=`git-diff-cache --name-only --cached HEAD`
+    case "$dirty2_" in '') : ;; *) (exit 1) ;; esac
+    } || {
+	echo >&2 "$dirty1_"
+	echo "$dirty2_" | sed >&2 -e 's/^/modified: /'
+	(exit 1)
+    }
+}
+
 [ -d "$GIT_DIR" ] &&
 [ -d "$GIT_DIR/refs" ] &&
 [ -d "$GIT_OBJECT_DIRECTORY" ] &&
Message 1 of 1 in “Define a shell function to check tree cleanness.”
  1. Define a shell function to check tree cleanness.Junio C Hamano, Aug 26, 2005

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.