list-objects: drop name_path entirely
In the previous commit, we left name_path as a thin wrapper around a strbuf. This patch drops it entirely. As a result, every show_object_fn callback needs to be adjusted. However, none of their code needs to be changed at all, because the only use was to pass it to path_name(), which now handles the bare strbuf. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Jeff King committed
Feb 11, 2016 at 17:26 UTC
bd64516aca4d4e22acb33c71429d293a14d355cf
9 files changed
+19
-25
builtin/pack-objects.c
+2
-2
@@ -2285,7 +2285,7 @@ static void show_commit(struct commit *commit, void *data)
2285
}
2286
2287
static void show_object(struct object *obj,
2288
- const struct name_path *path, const char *last,
2288
+ struct strbuf *path, const char *last,
2289
void *data)
2290
{
2291
char *name = path_name(path, last);
@@ -2480,7 +2480,7 @@ static int get_object_list_from_bitmap(struct rev_info *revs)
2480
}
2481
2482
static void record_recent_object(struct object *obj,
2483
- const struct name_path *path,
2483
+ struct strbuf *path,
2484
const char *last,
2485
void *data)
2486
{
builtin/rev-list.c
+2
-2
@@ -178,7 +178,7 @@ static void finish_commit(struct commit *commit, void *data)
178
}
179
180
static void finish_object(struct object *obj,
181
- const struct name_path *path, const char *name,
181
+ struct strbuf *path, const char *name,
182
void *cb_data)
183
{
184
struct rev_list_info *info = cb_data;
@@ -189,7 +189,7 @@ static void finish_object(struct object *obj,
189
}
190
191
static void show_object(struct object *obj,
192
- const struct name_path *path, const char *component,
192
+ struct strbuf *path, const char *component,
193
void *cb_data)
194
{
195
struct rev_list_info *info = cb_data;
list-objects.c
+5
-7
@@ -11,7 +11,7 @@
11
static void process_blob(struct rev_info *revs,
12
struct blob *blob,
13
show_object_fn show,
14
- struct name_path *path,
14
+ struct strbuf *path,
15
const char *name,
16
void *cb_data)
17
{
@@ -52,7 +52,7 @@ static void process_blob(struct rev_info *revs,
52
static void process_gitlink(struct rev_info *revs,
53
const unsigned char *sha1,
54
show_object_fn show,
55
- struct name_path *path,
55
+ struct strbuf *path,
56
const char *name,
57
void *cb_data)
58
{
@@ -69,7 +69,6 @@ static void process_tree(struct rev_info *revs,
69
struct object *obj = &tree->object;
70
struct tree_desc desc;
71
struct name_entry entry;
72
- struct name_path me;
72
enum interesting match = revs->diffopt.pathspec.nr == 0 ?
73
all_entries_interesting: entry_not_interesting;
74
int baselen = base->len;
@@ -87,8 +86,7 @@ static void process_tree(struct rev_info *revs,
86
}
87
88
obj->flags |= SEEN;
90
- me.base = base;
91
- show(obj, &me, name, cb_data);
89
+ show(obj, base, name, cb_data);
90
91
strbuf_addstr(base, name);
92
if (base->len)
@@ -113,12 +111,12 @@ static void process_tree(struct rev_info *revs,
111
cb_data);
112
else if (S_ISGITLINK(entry.mode))
113
process_gitlink(revs, entry.sha1,
116
- show, &me, entry.path,
114
+ show, base, entry.path,
115
cb_data);
116
else
117
process_blob(revs,
118
lookup_blob(entry.sha1),
121
- show, &me, entry.path,
119
+ show, base, entry.path,
120
cb_data);
121
}
122
strbuf_setlen(base, baselen);
list-objects.h
+1
-1
@@ -2,7 +2,7 @@
2
#define LIST_OBJECTS_H
3
4
typedef void (*show_commit_fn)(struct commit *, void *);
5
-typedef void (*show_object_fn)(struct object *, const struct name_path *, const char *, void *);
5
+typedef void (*show_object_fn)(struct object *, struct strbuf *, const char *, void *);
6
void traverse_commit_list(struct rev_info *, show_commit_fn, show_object_fn, void *);
7
8
typedef void (*show_edge_fn)(struct commit *);
pack-bitmap-write.c
+1
-1
@@ -148,7 +148,7 @@ static uint32_t find_object_pos(const unsigned char *sha1)
148
return entry->in_pack_pos;
149
}
150
151
-static void show_object(struct object *object, const struct name_path *path,
151
+static void show_object(struct object *object, struct strbuf *path,
152
const char *last, void *data)
153
{
154
struct bitmap *base = data;
pack-bitmap.c
+2
-2
@@ -414,7 +414,7 @@ static int ext_index_add_object(struct object *object, const char *name)
414
return bitmap_pos + bitmap_git.pack->num_objects;
415
}
416
417
-static void show_object(struct object *object, const struct name_path *path,
417
+static void show_object(struct object *object, struct strbuf *path,
418
const char *last, void *data)
419
{
420
struct bitmap *base = data;
@@ -895,7 +895,7 @@ struct bitmap_test_data {
895
};
896
897
static void test_show_object(struct object *object,
898
- const struct name_path *path,
898
+ struct strbuf *path,
899
const char *last, void *data)
900
{
901
struct bitmap_test_data *tdata = data;
reachable.c
+1
-1
@@ -43,7 +43,7 @@ static int add_one_ref(const char *path, const struct object_id *oid,
43
* The traversal will have already marked us as SEEN, so we
44
* only need to handle any progress reporting here.
45
*/
46
-static void mark_object(struct object *obj, const struct name_path *path,
46
+static void mark_object(struct object *obj, struct strbuf *path,
47
const char *name, void *data)
48
{
49
update_progress(data);
revision.c
+3
-3
@@ -25,17 +25,17 @@ volatile show_early_output_fn_t show_early_output;
25
static const char *term_bad;
26
static const char *term_good;
27
28
-char *path_name(const struct name_path *path, const char *name)
28
+char *path_name(struct strbuf *path, const char *name)
29
{
30
struct strbuf ret = STRBUF_INIT;
31
if (path)
32
- strbuf_addbuf(&ret, path->base);
32
+ strbuf_addbuf(&ret, path);
33
strbuf_addstr(&ret, name);
34
return strbuf_detach(&ret, NULL);
35
}
36
37
void show_object_with_name(FILE *out, struct object *obj,
38
- const struct name_path *path, const char *component)
38
+ struct strbuf *path, const char *component)
39
{
40
char *name = path_name(path, component);
41
char *p;
revision.h
+2
-6
@@ -257,14 +257,10 @@ extern void put_revision_mark(const struct rev_info *revs,
257
extern void mark_parents_uninteresting(struct commit *commit);
258
extern void mark_tree_uninteresting(struct tree *tree);
259
260
-struct name_path {
261
- struct strbuf *base;
262
-};
263
-
264
-char *path_name(const struct name_path *path, const char *name);
260
+char *path_name(struct strbuf *path, const char *name);
261
262
extern void show_object_with_name(FILE *, struct object *,
267
- const struct name_path *, const char *);
263
+ struct strbuf *, const char *);
264
265
extern void add_pending_object(struct rev_info *revs,
266
struct object *obj, const char *name);