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
dc06dc880013d48f2b09c6b4295419382f3b8230
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
@@ -422,7 +422,7 @@ static int ext_index_add_object(struct object *object, const char *name)
422
return bitmap_pos + bitmap_git.pack->num_objects;
423
}
424
425
-static void show_object(struct object *object, const struct name_path *path,
425
+static void show_object(struct object *object, struct strbuf *path,
426
const char *last, void *data)
427
{
428
struct bitmap *base = data;
@@ -903,7 +903,7 @@ struct bitmap_test_data {
903
};
904
905
static void test_show_object(struct object *object,
906
- const struct name_path *path,
906
+ struct strbuf *path,
907
const char *last, void *data)
908
{
909
struct bitmap_test_data *tdata = data;
reachable.c
+1
-1
@@ -36,7 +36,7 @@ static int add_one_ref(const char *path, const unsigned char *sha1, int flag, vo
36
* The traversal will have already marked us as SEEN, so we
37
* only need to handle any progress reporting here.
38
*/
39
-static void mark_object(struct object *obj, const struct name_path *path,
39
+static void mark_object(struct object *obj, struct strbuf *path,
40
const char *name, void *data)
41
{
42
update_progress(data);
revision.c
+3
-3
@@ -21,17 +21,17 @@
21
22
volatile show_early_output_fn_t show_early_output;
23
24
-char *path_name(const struct name_path *path, const char *name)
24
+char *path_name(struct strbuf *path, const char *name)
25
{
26
struct strbuf ret = STRBUF_INIT;
27
if (path)
28
- strbuf_addbuf(&ret, path->base);
28
+ strbuf_addbuf(&ret, path);
29
strbuf_addstr(&ret, name);
30
return strbuf_detach(&ret, NULL);
31
}
32
33
void show_object_with_name(FILE *out, struct object *obj,
34
- const struct name_path *path, const char *component)
34
+ struct strbuf *path, const char *component)
35
{
36
char *name = path_name(path, component);
37
char *p;
revision.h
+2
-6
@@ -256,14 +256,10 @@ extern void put_revision_mark(const struct rev_info *revs,
256
extern void mark_parents_uninteresting(struct commit *commit);
257
extern void mark_tree_uninteresting(struct tree *tree);
258
259
-struct name_path {
260
- struct strbuf *base;
261
-};
262
-
263
-char *path_name(const struct name_path *path, const char *name);
259
+char *path_name(struct strbuf *path, const char *name);
260
261
extern void show_object_with_name(FILE *, struct object *,
266
- const struct name_path *, const char *);
262
+ struct strbuf *, const char *);
263
264
extern void add_pending_object(struct rev_info *revs,
265
struct object *obj, const char *name);