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

Re: [PATCH] Show branch information in short output of git status

From
Knittl <knittl89@googlemail.com>
Date
May 7, 2010, 16:05 UTC
Message-ID
<AANLkTilQZQzijU_xMz34eajpD05ogK01GRByDddoGGmI@mail.gmail.com>
In-Reply-To
<AANLkTikDkrNrzPmIhmcBRKtLKV70f4Kp8wTw6I6ctB4O@mail.gmail.com>
hi all,

here's the second part of the branch, so it will only show branch information in `git status -s` if the additional option `-b` is given.

open for suggestions, daniel

----------8<-------------
From 00d7aa6872a8aaf98c7e5550ba64ec6e093ca897 Mon Sep 17 00:00:00 2001
From: Daniel Knittl-Frank <knittl89+git@googlemail.com>
Date: Tue, 20 Apr 2010 22:40:54 +0200
Subject: [PATCH 2/2] Hide branch information per default in short
output of status

Branch information remains hidden, unless the command line option `-b` is given to `git status -s`. This way the command does not change from older versions.

Also hide branch information in `--porcelain` output
Signed-off-by: Daniel Knittl-Frank <knittl89+git@googlemail.com>
---
 builtin/commit.c |    8 ++++++--
 wt-status.c      |    7 ++++---
 wt-status.h      |    2 +-
 3 files changed, 11 insertions(+), 6 deletions(-)
diff --git a/builtin/commit.c b/builtin/commit.c
index c5ab683..b058e66 100644
--- a/builtin/commit.c
+++ b/builtin/commit.c
@@ -92,6 +92,7 @@ static enum {
 	STATUS_FORMAT_SHORT,
 	STATUS_FORMAT_PORCELAIN,
 } status_format = STATUS_FORMAT_LONG;
+static int status_show_branch;

 static int opt_parse_m(const struct option *opt, const char *arg, int unset)
 {
@@ -133,6 +134,7 @@ static struct option builtin_commit_options[] = {
 	OPT_BOOLEAN(0, "dry-run", &dry_run, "show what would be committed"),
 	OPT_SET_INT(0, "short", &status_format, "show status concisely",
 		    STATUS_FORMAT_SHORT),
+	OPT_BOOLEAN(0, "branch", &status_show_branch, "show branch information"),
 	OPT_SET_INT(0, "porcelain", &status_format,
 		    "show porcelain output format", STATUS_FORMAT_PORCELAIN),
 	OPT_BOOLEAN('z', "null", &null_termination,
@@ -417,7 +419,7 @@ static int run_status(FILE *fp, const char
*index_file, const char *prefix, int

 	switch (status_format) {
 	case STATUS_FORMAT_SHORT:
-		wt_shortstatus_print(s, null_termination);
+		wt_shortstatus_print(s, null_termination, status_show_branch);
 		break;
 	case STATUS_FORMAT_PORCELAIN:
 		wt_porcelain_print(s, null_termination);
@@ -1022,6 +1024,8 @@ int cmd_status(int argc, const char **argv,
const char *prefix)
 		OPT__VERBOSE(&verbose),
 		OPT_SET_INT('s', "short", &status_format,
 			    "show status concisely", STATUS_FORMAT_SHORT),
+		OPT_BOOLEAN('b', "branch", &status_show_branch,
+		            "show branch information"),
 		OPT_SET_INT(0, "porcelain", &status_format,
 			    "show porcelain output format",
 			    STATUS_FORMAT_PORCELAIN),
@@ -1063,7 +1067,7 @@ int cmd_status(int argc, const char **argv,
const char *prefix)

 	switch (status_format) {
 	case STATUS_FORMAT_SHORT:
-		wt_shortstatus_print(&s, null_termination);
+		wt_shortstatus_print(&s, null_termination, status_show_branch);
 		break;
 	case STATUS_FORMAT_PORCELAIN:
 		wt_porcelain_print(&s, null_termination);
diff --git a/wt-status.c b/wt-status.c
index f7f1269..e1b8188 100644
--- a/wt-status.c
+++ b/wt-status.c
@@ -781,11 +781,12 @@ static void wt_shortstatus_print_tracking(struct
wt_status *s)
 	color_fprintf_ln(s->fp, header_color, "]");
 }

-void wt_shortstatus_print(struct wt_status *s, int null_termination)
+void wt_shortstatus_print(struct wt_status *s, int null_termination,
int show_branch)
 {
 	int i;

-	wt_shortstatus_print_tracking(s);
+	if(show_branch)
+		wt_shortstatus_print_tracking(s);

 	for (i = 0; i < s->change.nr; i++) {
 		struct wt_status_change_data *d;
@@ -811,5 +812,5 @@ void wt_porcelain_print(struct wt_status *s, int
null_termination)
 	s->use_color = 0;
 	s->relative_paths = 0;
 	s->prefix = NULL;
-	wt_shortstatus_print(s, null_termination);
+	wt_shortstatus_print(s, null_termination, 0);
 }
diff --git a/wt-status.h b/wt-status.h
index ca5db99..4272539 100644
--- a/wt-status.h
+++ b/wt-status.h
@@ -61,7 +61,7 @@ void wt_status_prepare(struct wt_status *s);
 void wt_status_print(struct wt_status *s);
 void wt_status_collect(struct wt_status *s);

-void wt_shortstatus_print(struct wt_status *s, int null_termination);
+void wt_shortstatus_print(struct wt_status *s, int null_termination,
int show_branch);
 void wt_porcelain_print(struct wt_status *s, int null_termination);

 #endif /* STATUS_H */
-- 
1.7.1.12.g82b44.dirty
Previous: KnittlNext: Jeff King
Message 4 of 13 in “Show branch information in short output of git status”
  1. Show branch information in short output of git statusKnittl, May 2, 2010
  2. Jeff KingMay 5, 2010
  3. KnittlMay 6, 2010
  4. KnittlMay 7, 2010
  5. Jeff KingMay 12, 2010
  6. KnittlMay 14, 2010
  7. Jeff KingMay 23, 2010
  8. Michael J GruberMay 25, 2010
  9. Jeff KingMay 25, 2010
  10. Michael J GruberMay 25, 2010
  11. Documentation/SubmittingPatches: clarify GMail section and SMTPMichael J Gruber, May 25, 2010
  12. Jeff KingMay 25, 2010
  13. Ævar Arnfjörð BjarmasonMay 25, 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.