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

[PATCH] Show the branch name more prominently in "git status".

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

When not working on "master" branch, remind the user at the beginning of the status message, not at the end.

Adjust git-revert-script for this change as well. The way it detected a clean working tree was depending on the git status behaviour too much.

Signed-off-by: Junio C Hamano <junkio@cox.net>
---
 git-revert-script |   10 ++++++----
 git-status-script |   12 ++++++------
 2 files changed, 12 insertions(+), 10 deletions(-)
0f60ee0f83468393fb3bca2b5e4c8e78a8896cf5
diff --git a/git-revert-script b/git-revert-script
--- a/git-revert-script
+++ b/git-revert-script
@@ -2,11 +2,13 @@
 . git-sh-setup-script || die "Not a git archive"
 
 # We want a clean tree and clean index to be able to revert.
-status=$(git status)
-case "$status" in
-'nothing to commit') ;;
+dirty=`git-diff-cache --name-only --cached HEAD`
+case "$dirty" in '') dirty=`git-diff-cache --name-only HEAD` ;; esac
+case "$dirty" in
+'') ;;
 *)
-	echo "$status"
+	echo >&2 "Modified:"
+	echo "$dirty" | sed >&2 -e 's/^/	/'
 	die "Your working tree is dirty; cannot revert a previous patch." ;;
 esac
 
diff --git a/git-status-script b/git-status-script
--- a/git-status-script
+++ b/git-status-script
@@ -28,6 +28,12 @@ report () {
   [ "$header" ]
 }
 
+branch=`readlink "$GIT_DIR/HEAD"`
+case "$branch" in
+refs/heads/master) ;;
+*)	echo "#
+# On branch $branch" ;;
+esac
 git-update-cache --refresh >/dev/null 2>&1
 git-diff-cache -M --cached HEAD | sed 's/^://' | report "Updated but not checked in" "will commit"
 committable="$?"
@@ -37,10 +43,4 @@ then
 	echo "nothing to commit"
 	exit 1
 fi
-branch=`readlink "$GIT_DIR/HEAD"`
-case "$branch" in
-refs/heads/master) ;;
-*)	echo "#
-# On branch $branch" ;;
-esac
 exit 0
Message 1 of 1 in “Show the branch name more prominently in "git status".”
  1. Show the branch name more prominently in "git status".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.