move load_ref_decorations() to log-tree.c and export it
log-tree.c is the ideal place for load_ref_decorations() and its helper functions to live in, because the variable name_decoration they're operating on is already located there, so move them thither. 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:39 UTC
cab4feb67db64d3d201145d9748b33d148f96185
3 files changed
+37
-35
builtin-log.c
-35
@@ -14,7 +14,6 @@
14
#include "tag.h"
15
#include "reflog-walk.h"
16
#include "patch-ids.h"
17
-#include "refs.h"
17
#include "run-command.h"
18
#include "shortlog.h"
19
@@ -25,40 +24,6 @@ static int default_show_root = 1;
24
static const char *fmt_patch_subject_prefix = "PATCH";
25
static const char *fmt_pretty;
26
28
-static void add_name_decoration(const char *prefix, const char *name, struct object *obj)
29
-{
30
- int plen = strlen(prefix);
31
- int nlen = strlen(name);
32
- struct name_decoration *res = xmalloc(sizeof(struct name_decoration) + plen + nlen);
33
- memcpy(res->name, prefix, plen);
34
- memcpy(res->name + plen, name, nlen + 1);
35
- res->next = add_decoration(&name_decoration, obj, res);
36
-}
37
-
38
-static int add_ref_decoration(const char *refname, const unsigned char *sha1, int flags, void *cb_data)
39
-{
40
- struct object *obj = parse_object(sha1);
41
- if (!obj)
42
- return 0;
43
- add_name_decoration("", refname, obj);
44
- while (obj->type == OBJ_TAG) {
45
- obj = ((struct tag *)obj)->tagged;
46
- if (!obj)
47
- break;
48
- add_name_decoration("tag: ", refname, obj);
49
- }
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
-
27
static void cmd_log_init(int argc, const char **argv, const char *prefix,
28
struct rev_info *rev)
29
{
log-tree.c
+36
@@ -1,12 +1,48 @@
1
#include "cache.h"
2
#include "diff.h"
3
#include "commit.h"
4
+#include "tag.h"
5
#include "graph.h"
6
#include "log-tree.h"
7
#include "reflog-walk.h"
8
+#include "refs.h"
9
10
struct decoration name_decoration = { "object names" };
11
12
+static void add_name_decoration(const char *prefix, const char *name, struct object *obj)
13
+{
14
+ int plen = strlen(prefix);
15
+ int nlen = strlen(name);
16
+ struct name_decoration *res = xmalloc(sizeof(struct name_decoration) + plen + nlen);
17
+ memcpy(res->name, prefix, plen);
18
+ memcpy(res->name + plen, name, nlen + 1);
19
+ res->next = add_decoration(&name_decoration, obj, res);
20
+}
21
+
22
+static int add_ref_decoration(const char *refname, const unsigned char *sha1, int flags, void *cb_data)
23
+{
24
+ struct object *obj = parse_object(sha1);
25
+ if (!obj)
26
+ return 0;
27
+ add_name_decoration("", refname, obj);
28
+ while (obj->type == OBJ_TAG) {
29
+ obj = ((struct tag *)obj)->tagged;
30
+ if (!obj)
31
+ break;
32
+ add_name_decoration("tag: ", refname, obj);
33
+ }
34
+ return 0;
35
+}
36
+
37
+void load_ref_decorations(void)
38
+{
39
+ static int loaded;
40
+ if (!loaded) {
41
+ loaded = 1;
42
+ for_each_ref(add_ref_decoration, NULL);
43
+ }
44
+}
45
+
46
static void show_parents(struct commit *commit, int abbrev)
47
{
48
struct commit_list *p;
log-tree.h
+1
@@ -17,5 +17,6 @@ void log_write_email_headers(struct rev_info *opt, const char *name,
17
const char **subject_p,
18
const char **extra_headers_p,
19
int *need_8bit_cte_p);
20
+void load_ref_decorations(void);
21
22
#endif