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

[PATCH 1/3] log: add load_ref_decorations()

From
René Scharfe <rene.scharfe@lsrfire.ath.cx>
Date
Sep 4, 2008, 21:38 UTC
Message-ID
<48C05540.5070204@lsrfire.ath.cx>
In-Reply-To
<48C002FB.9010401@lsrfire.ath.cx>

Move the loading of all ref names for decoration into its own function. A static variable prevents loading twice, because it's quite expensive. We can do it this way because we currently never unload decorations.

Signed-off-by: Rene Scharfe <rene.scharfe@lsrfire.ath.cx>
---
 builtin-log.c |   12 ++++++++++--
 1 files changed, 10 insertions(+), 2 deletions(-)
diff --git a/builtin-log.c b/builtin-log.c
index 1d3c5cb..0f16462 100644
--- a/builtin-log.c
+++ b/builtin-log.c
@@ -50,6 +50,15 @@ static int add_ref_decoration(const char *refname, const unsigned char *sha1, in
 	return 0;
 }
 
+void load_ref_decorations(void)
+{
+	static int loaded;
+	if (!loaded) {
+		loaded = 1;
+		for_each_ref(add_ref_decoration, NULL);
+	}
+}
+
 static void cmd_log_init(int argc, const char **argv, const char *prefix,
 		      struct rev_info *rev)
 {
@@ -80,8 +89,7 @@ static void cmd_log_init(int argc, const char **argv, const char *prefix,
 	for (i = 1; i < argc; i++) {
 		const char *arg = argv[i];
 		if (!strcmp(arg, "--decorate")) {
-			if (!decorate)
-				for_each_ref(add_ref_decoration, NULL);
+			load_ref_decorations();
 			decorate = 1;
 		} else
 			die("unrecognized argument: %s", arg);
-- 
1.6.0.1.161.g7f314
Previous: René ScharfeNext: René Scharfe
Message 10 of 23 in “add '%d' pretty format specifier to show decoration”
  1. 1/2 add '%d' pretty format specifier to show decorationMichael Dressel, Sep 3, 2008
  2. Jeff KingSep 3, 2008
  3. Junio C HamanoSep 3, 2008
  4. Jeff KingSep 3, 2008
  5. Junio C HamanoSep 3, 2008
  6. Jeff KingSep 3, 2008
  7. René ScharfeSep 3, 2008
  8. Jeff KingSep 4, 2008
  9. René ScharfeSep 4, 2008
  10. 1/3 log: add load_ref_decorations()René Scharfe, Sep 4, 2008
  11. 2/3 move load_ref_decorations() to log-tree.c and export itRené Scharfe, Sep 4, 2008
  12. 3/3 add '%d' pretty format specifier to show decorationRené Scharfe, Sep 4, 2008
  13. Jeff KingSep 5, 2008
  14. Junio C HamanoSep 5, 2008
  15. Jeff KingSep 5, 2008
  16. Junio C HamanoSep 5, 2008
  17. Michael DresselSep 5, 2008
  18. Michael DresselSep 9, 2008
  19. René ScharfeSep 9, 2008
  20. René ScharfeSep 5, 2008
  21. Jeff KingSep 3, 2008
  22. Michael DresselSep 3, 2008
  23. Jeff KingSep 3, 2008

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.