lists.zerezo.com
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 1/3] log: add load_ref_decorations()
- Date: Thu, 04 Sep 2008 23:38:08 +0200
- From: René Scharfe <rene.scharfe@xxxxxxxxxxxxxx>
- Subject: [PATCH 1/3] log: add load_ref_decorations()
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@xxxxxxxxxxxxxx>
---
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
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html