@matheusbsbs / matheus-bagliano / commits / 5e9bf11c1a
Fork 0

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@lsrfire.ath.cx> Signed-off-by: Junio C Hamano <gitster@pobox.com>

René Scharfe committed Sep 4, 2008 at 23:38 UTC 5e9bf11c1a3052f01f86d7eb28ae4c5b8d9c7495
1 file changed +10 -2
builtin-log.c
+10 -2
@@ -50,6 +50,15 @@ static int add_ref_decoration(const char *refname, const unsigned char *sha1, in
50 return 0;
51 }
52
53 +void load_ref_decorations(void)
54 +{
55 + static int loaded;
56 + if (!loaded) {
57 + loaded = 1;
58 + for_each_ref(add_ref_decoration, NULL);
59 + }
60 +}
61 +
62 static void cmd_log_init(int argc, const char **argv, const char *prefix,
63 struct rev_info *rev)
64 {
@@ -80,8 +89,7 @@ static void cmd_log_init(int argc, const char **argv, const char *prefix,
89 for (i = 1; i < argc; i++) {
90 const char *arg = argv[i];
91 if (!strcmp(arg, "--decorate")) {
83 - if (!decorate)
84 - for_each_ref(add_ref_decoration, NULL);
92 + load_ref_decorations();
93 decorate = 1;
94 } else
95 die("unrecognized argument: %s", arg);