{"thread":{"id":"1650","subject":"[PATCH] Define a shell function to check tree cleanness.","startedAt":"2005-08-26T08:03:40Z","lastAt":"2005-08-26T08:03:40Z","messageCount":1,"participants":["Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"7776","messageId":"7vhdddgm5f.fsf@assigned-by-dhcp.cox.net","threadId":"1650","inReplyTo":null,"subject":"[PATCH] Define a shell function to check tree cleanness.","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2005-08-26T08:03:40Z","receivedAt":"2005-08-26T08:03:40Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"This would be used in places where we require a clean tree, such\nas reverting and rebasing.\n\nSigned-off-by: Junio C Hamano <junkio@cox.net>\n\n---\n\n git-sh-setup-script |   11 +++++++++++\n 1 files changed, 11 insertions(+), 0 deletions(-)\n\n1de6046ded332e2278320be314f7a5e31a431e14\ndiff --git a/git-sh-setup-script b/git-sh-setup-script\n--- a/git-sh-setup-script\n+++ b/git-sh-setup-script\n@@ -11,6 +11,17 @@ die() {\n \texit 1\n }\n \n+check_clean_tree() {\n+    dirty1_=`git-update-cache -q --refresh` && {\n+    dirty2_=`git-diff-cache --name-only --cached HEAD`\n+    case \"$dirty2_\" in '') : ;; *) (exit 1) ;; esac\n+    } || {\n+\techo >&2 \"$dirty1_\"\n+\techo \"$dirty2_\" | sed >&2 -e 's/^/modified: /'\n+\t(exit 1)\n+    }\n+}\n+\n [ -d \"$GIT_DIR\" ] &&\n [ -d \"$GIT_DIR/refs\" ] &&\n [ -d \"$GIT_OBJECT_DIRECTORY\" ] &&\n"}]}