All of lore.kernel.org
 help / color / mirror / Atom feed
From: "René Scharfe" <rene.scharfe@lsrfire.ath.cx>
To: Michael Dressel <MichaelTiloDressel@t-online.de>
Cc: Jeff King <peff@peff.net>, Junio C Hamano <gitster@pobox.com>,
	git@vger.kernel.org
Subject: [PATCH 1/3] log: add load_ref_decorations()
Date: Thu, 04 Sep 2008 23:38:08 +0200	[thread overview]
Message-ID: <48C05540.5070204@lsrfire.ath.cx> (raw)
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

  reply	other threads:[~2008-09-04 21:39 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-09-03 18:40 [PATCH 1/2] add '%d' pretty format specifier to show decoration Michael Dressel
2008-09-03 19:12 ` Jeff King
2008-09-03 20:10   ` Junio C Hamano
2008-09-03 20:36     ` Jeff King
2008-09-03 20:59       ` Junio C Hamano
2008-09-03 21:04         ` Jeff King
2008-09-03 22:06         ` René Scharfe
2008-09-04  3:51           ` Jeff King
2008-09-04 15:47             ` René Scharfe
2008-09-04 21:38               ` René Scharfe [this message]
2008-09-04 21:39               ` [PATCH 2/3] move load_ref_decorations() to log-tree.c and export it René Scharfe
2008-09-04 21:40               ` [PATCH 3/3] add '%d' pretty format specifier to show decoration René Scharfe
2008-09-05  0:11                 ` Jeff King
2008-09-05  0:28                   ` Junio C Hamano
2008-09-05  0:37                     ` Jeff King
2008-09-05  0:41                       ` Junio C Hamano
2008-09-05 18:38                     ` Michael Dressel
2008-09-09 17:33                       ` Michael Dressel
2008-09-09 20:15                         ` René Scharfe
2008-09-05 16:14                   ` René Scharfe
2008-09-03 19:17 ` [PATCH 1/2] " Jeff King
2008-09-03 20:06   ` Michael Dressel
2008-09-03 20:33     ` Jeff King

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=48C05540.5070204@lsrfire.ath.cx \
    --to=rene.scharfe@lsrfire.ath.cx \
    --cc=MichaelTiloDressel@t-online.de \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=peff@peff.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.