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

[PATCH 2/4] Move the --decorate option from builtin-log.c to revision.c.

From
Johannes Schindelin <johannes.schindelin@gmx.de>
Date
Jul 11, 2007, 01:29 UTC
Message-ID
<Pine.LNX.4.64.0707110229120.4047@racer.site>
In-Reply-To
<Pine.LNX.4.64.0707110220340.4047@racer.site>

It is more logical to have the --decorate option in revision, like many others affecting the way how commits are shown.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
---
 Documentation/git-log.txt        |    3 ---
 Documentation/pretty-options.txt |    4 ++++
 builtin-log.c                    |   14 ++------------
 revision.c                       |    4 ++++
 4 files changed, 10 insertions(+), 15 deletions(-)
diff --git a/Documentation/git-log.txt b/Documentation/git-log.txt
index 7adcdef..b55a87e 100644
--- a/Documentation/git-log.txt
+++ b/Documentation/git-log.txt
@@ -51,9 +51,6 @@ include::pretty-options.txt[]
 	a record about how the tip of a reference was changed.
 	See also gitlink:git-reflog[1].
 
---decorate::
-	Print out the ref names of any commits that are shown.
-
 --full-diff::
 	Without this flag, "git log -p <paths>..." shows commits that
 	touch the specified paths, and diffs about the same specified
diff --git a/Documentation/pretty-options.txt b/Documentation/pretty-options.txt
index 746bc5b..3b21e0d 100644
--- a/Documentation/pretty-options.txt
+++ b/Documentation/pretty-options.txt
@@ -20,3 +20,7 @@ people using 80-column terminals.
 	command to re-code the commit log message in the encoding
 	preferred by the user.  For non plumbing commands this
 	defaults to UTF-8.
+
+--decorate::
+	When a commit is shown, and it matches a ref, print that ref name
+	in brackets after the commit name.
diff --git a/builtin-log.c b/builtin-log.c
index c14eea5..59372bb 100644
--- a/builtin-log.c
+++ b/builtin-log.c
@@ -24,9 +24,6 @@ void add_head(struct rev_info *revs);
 static void cmd_log_init(int argc, const char **argv, const char *prefix,
 		      struct rev_info *rev)
 {
-	int i;
-	int decorate = 0;
-
 	rev->abbrev = DEFAULT_ABBREV;
 	rev->commit_format = CMIT_FMT_DEFAULT;
 	rev->verbose_header = 1;
@@ -40,15 +37,8 @@ static void cmd_log_init(int argc, const char **argv, const char *prefix,
 		if (rev->diffopt.nr_paths != 1)
 			usage("git logs can only follow renames on one pathname at a time");
 	}
-	for (i = 1; i < argc; i++) {
-		const char *arg = argv[i];
-		if (!strcmp(arg, "--decorate")) {
-			if (!decorate)
-				for_each_ref(add_ref_decoration, NULL);
-			decorate = 1;
-		} else
-			die("unrecognized argument: %s", arg);
-	}
+	if (argc > 1)
+		die("unrecognized argument: %s", argv[1]);
 }
 
 static int cmd_log_walk(struct rev_info *rev)
diff --git a/revision.c b/revision.c
index 33ee9ee..7683d0a 100644
--- a/revision.c
+++ b/revision.c
@@ -1176,6 +1176,10 @@ int setup_revisions(int argc, const char **argv, struct rev_info *revs, const ch
 				revs->reverse ^= 1;
 				continue;
 			}
+			if (!strcmp(arg, "--decorate")) {
+				for_each_ref(add_ref_decoration, NULL);
+				continue;
+			}
 
 			opts = diff_opt_parse(&revs->diffopt, argv+i, argc-i);
 			if (opts > 0) {
-- 
1.5.3.rc0.2783.gf3f7
Previous: Johannes SchindelinNext: Junio C Hamano
Message 3 of 11 in “Make --decorate more useful”
  1. 0/4 Make --decorate more usefulJohannes Schindelin, Jul 11, 2007
  2. 1/4 Move add_name_decoration() and add_ref_decoration() to commit.[ch]Johannes Schindelin, Jul 11, 2007
  3. 2/4 Move the --decorate option from builtin-log.c to revision.c.Johannes Schindelin, Jul 11, 2007
  4. Junio C HamanoJul 12, 2007
  5. Johannes SchindelinJul 13, 2007
  6. 3/4 --decorate now decorates ancestors, tooJohannes Schindelin, Jul 11, 2007
  7. Theodore TsoJul 11, 2007
  8. Junio C HamanoJul 12, 2007
  9. Johannes SchindelinJul 14, 2007
  10. Johannes SchindelinJul 21, 2007
  11. 4/4 --decorate: prefer shorter namesJohannes Schindelin, Jul 11, 2007

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.