@matheusbsbs / matheus-bagliano / commits / 50f9a858ad
Fork 0

Make the "struct tree_desc" operations available to others

We have operations to "extract" and "update" a "struct tree_desc", but we only used them in tree-diff.c and they were static to that file. But other tree traversal functions can use them to their advantage Signed-off-by: Linus Torvalds <torvalds@osdl.org> Signed-off-by: Junio C Hamano <junkio@cox.net>

Linus Torvalds committed Jan 31, 2006 at 14:10 UTC 50f9a858ada10b3b57691a313a1c78b0bcbe5947
2 files changed +9 -6
diff.h
+3
@@ -13,6 +13,9 @@ struct tree_desc {
13 unsigned long size;
14 };
15
16 +extern void update_tree_entry(struct tree_desc *);
17 +extern const unsigned char *tree_entry_extract(struct tree_desc *, const char **, unsigned int *);
18 +
19 struct diff_options;
20
21 typedef void (*change_fn_t)(struct diff_options *options,
tree-diff.c
+6 -6
@@ -9,7 +9,7 @@ static int nr_paths = 0;
9 static const char **paths = NULL;
10 static int *pathlens = NULL;
11
12 -static void update_tree_entry(struct tree_desc *desc)
12 +void update_tree_entry(struct tree_desc *desc)
13 {
14 void *buf = desc->buf;
15 unsigned long size = desc->size;
@@ -21,7 +21,7 @@ static void update_tree_entry(struct tree_desc *desc)
21 desc->size = size - len;
22 }
23
24 -static const unsigned char *extract(struct tree_desc *desc, const char **pathp, unsigned int *modep)
24 +const unsigned char *tree_entry_extract(struct tree_desc *desc, const char **pathp, unsigned int *modep)
25 {
26 void *tree = desc->buf;
27 unsigned long size = desc->size;
@@ -56,8 +56,8 @@ static int compare_tree_entry(struct tree_desc *t1, struct tree_desc *t2, const
56 const unsigned char *sha1, *sha2;
57 int cmp, pathlen1, pathlen2;
58
59 - sha1 = extract(t1, &path1, &mode1);
60 - sha2 = extract(t2, &path2, &mode2);
59 + sha1 = tree_entry_extract(t1, &path1, &mode1);
60 + sha2 = tree_entry_extract(t2, &path2, &mode2);
61
62 pathlen1 = strlen(path1);
63 pathlen2 = strlen(path2);
@@ -109,7 +109,7 @@ static int interesting(struct tree_desc *desc, const char *base)
109 if (!nr_paths)
110 return 1;
111
112 - (void)extract(desc, &path, &mode);
112 + (void)tree_entry_extract(desc, &path, &mode);
113
114 pathlen = strlen(path);
115 baselen = strlen(base);
@@ -167,7 +167,7 @@ static int show_entry(struct diff_options *opt, const char *prefix, struct tree_
167 {
168 unsigned mode;
169 const char *path;
170 - const unsigned char *sha1 = extract(desc, &path, &mode);
170 + const unsigned char *sha1 = tree_entry_extract(desc, &path, &mode);
171
172 if (opt->recursive && S_ISDIR(mode)) {
173 char type[20];