提交 5e9bf11c 编写于 作者: R René Scharfe 提交者: Junio C Hamano

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: NRene Scharfe <rene.scharfe@lsrfire.ath.cx>
Signed-off-by: NJunio C Hamano <gitster@pobox.com>
上级 1b23adad
......@@ -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);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册