Skip to content

Commit dc06dc8

Browse files
peffgitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent f3badae commit dc06dc8

9 files changed

+19
-25
lines changed

builtin/pack-objects.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2285,7 +2285,7 @@ static void show_commit(struct commit *commit, void *data)
22852285
}
22862286

22872287
static void show_object(struct object *obj,
2288-
const struct name_path *path, const char *last,
2288+
struct strbuf *path, const char *last,
22892289
void *data)
22902290
{
22912291
char *name = path_name(path, last);
@@ -2480,7 +2480,7 @@ static int get_object_list_from_bitmap(struct rev_info *revs)
24802480
}
24812481

24822482
static void record_recent_object(struct object *obj,
2483-
const struct name_path *path,
2483+
struct strbuf *path,
24842484
const char *last,
24852485
void *data)
24862486
{

builtin/rev-list.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ static void finish_commit(struct commit *commit, void *data)
178178
}
179179

180180
static void finish_object(struct object *obj,
181-
const struct name_path *path, const char *name,
181+
struct strbuf *path, const char *name,
182182
void *cb_data)
183183
{
184184
struct rev_list_info *info = cb_data;
@@ -189,7 +189,7 @@ static void finish_object(struct object *obj,
189189
}
190190

191191
static void show_object(struct object *obj,
192-
const struct name_path *path, const char *component,
192+
struct strbuf *path, const char *component,
193193
void *cb_data)
194194
{
195195
struct rev_list_info *info = cb_data;

list-objects.c

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
static void process_blob(struct rev_info *revs,
1212
struct blob *blob,
1313
show_object_fn show,
14-
struct name_path *path,
14+
struct strbuf *path,
1515
const char *name,
1616
void *cb_data)
1717
{
@@ -52,7 +52,7 @@ static void process_blob(struct rev_info *revs,
5252
static void process_gitlink(struct rev_info *revs,
5353
const unsigned char *sha1,
5454
show_object_fn show,
55-
struct name_path *path,
55+
struct strbuf *path,
5656
const char *name,
5757
void *cb_data)
5858
{
@@ -69,7 +69,6 @@ static void process_tree(struct rev_info *revs,
6969
struct object *obj = &tree->object;
7070
struct tree_desc desc;
7171
struct name_entry entry;
72-
struct name_path me;
7372
enum interesting match = revs->diffopt.pathspec.nr == 0 ?
7473
all_entries_interesting: entry_not_interesting;
7574
int baselen = base->len;
@@ -87,8 +86,7 @@ static void process_tree(struct rev_info *revs,
8786
}
8887

8988
obj->flags |= SEEN;
90-
me.base = base;
91-
show(obj, &me, name, cb_data);
89+
show(obj, base, name, cb_data);
9290

9391
strbuf_addstr(base, name);
9492
if (base->len)
@@ -113,12 +111,12 @@ static void process_tree(struct rev_info *revs,
113111
cb_data);
114112
else if (S_ISGITLINK(entry.mode))
115113
process_gitlink(revs, entry.sha1,
116-
show, &me, entry.path,
114+
show, base, entry.path,
117115
cb_data);
118116
else
119117
process_blob(revs,
120118
lookup_blob(entry.sha1),
121-
show, &me, entry.path,
119+
show, base, entry.path,
122120
cb_data);
123121
}
124122
strbuf_setlen(base, baselen);

list-objects.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
#define LIST_OBJECTS_H
33

44
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 *);
66
void traverse_commit_list(struct rev_info *, show_commit_fn, show_object_fn, void *);
77

88
typedef void (*show_edge_fn)(struct commit *);

pack-bitmap-write.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ static uint32_t find_object_pos(const unsigned char *sha1)
148148
return entry->in_pack_pos;
149149
}
150150

151-
static void show_object(struct object *object, const struct name_path *path,
151+
static void show_object(struct object *object, struct strbuf *path,
152152
const char *last, void *data)
153153
{
154154
struct bitmap *base = data;

pack-bitmap.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -422,7 +422,7 @@ static int ext_index_add_object(struct object *object, const char *name)
422422
return bitmap_pos + bitmap_git.pack->num_objects;
423423
}
424424

425-
static void show_object(struct object *object, const struct name_path *path,
425+
static void show_object(struct object *object, struct strbuf *path,
426426
const char *last, void *data)
427427
{
428428
struct bitmap *base = data;
@@ -903,7 +903,7 @@ struct bitmap_test_data {
903903
};
904904

905905
static void test_show_object(struct object *object,
906-
const struct name_path *path,
906+
struct strbuf *path,
907907
const char *last, void *data)
908908
{
909909
struct bitmap_test_data *tdata = data;

reachable.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ static int add_one_ref(const char *path, const unsigned char *sha1, int flag, vo
3636
* The traversal will have already marked us as SEEN, so we
3737
* only need to handle any progress reporting here.
3838
*/
39-
static void mark_object(struct object *obj, const struct name_path *path,
39+
static void mark_object(struct object *obj, struct strbuf *path,
4040
const char *name, void *data)
4141
{
4242
update_progress(data);

revision.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,17 +21,17 @@
2121

2222
volatile show_early_output_fn_t show_early_output;
2323

24-
char *path_name(const struct name_path *path, const char *name)
24+
char *path_name(struct strbuf *path, const char *name)
2525
{
2626
struct strbuf ret = STRBUF_INIT;
2727
if (path)
28-
strbuf_addbuf(&ret, path->base);
28+
strbuf_addbuf(&ret, path);
2929
strbuf_addstr(&ret, name);
3030
return strbuf_detach(&ret, NULL);
3131
}
3232

3333
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)
3535
{
3636
char *name = path_name(path, component);
3737
char *p;

revision.h

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -256,14 +256,10 @@ extern void put_revision_mark(const struct rev_info *revs,
256256
extern void mark_parents_uninteresting(struct commit *commit);
257257
extern void mark_tree_uninteresting(struct tree *tree);
258258

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);
264260

265261
extern void show_object_with_name(FILE *, struct object *,
266-
const struct name_path *, const char *);
262+
struct strbuf *, const char *);
267263

268264
extern void add_pending_object(struct rev_info *revs,
269265
struct object *obj, const char *name);

0 commit comments

Comments
 (0)