Skip to content

Commit 65d1f6c

Browse files
avargitster
authored andcommitted
ls-tree: fold "show_tree_data" into "cb" struct
After the the preceding two commits the only user of the "show_tree_data" struct needed it along with the "options" member, let's instead fold all of that into a "show_tree_data" struct that we'll use only for that callback. Signed-off-by: Ævar Arnfjörð Bjarmason <[email protected]> Signed-off-by: Teng Long <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 030a3d5 commit 65d1f6c

File tree

1 file changed

+5
-13
lines changed

1 file changed

+5
-13
lines changed

builtin/ls-tree.c

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -53,24 +53,19 @@ struct ls_tree_options {
5353
};
5454

5555
struct show_tree_data {
56+
struct ls_tree_options *options;
5657
unsigned mode;
5758
enum object_type type;
5859
const struct object_id *oid;
5960
const char *pathname;
6061
struct strbuf *base;
6162
};
6263

63-
struct show_tree_data_cb {
64-
struct ls_tree_options *options;
65-
struct show_tree_data *data;
66-
};
67-
6864
static size_t expand_show_tree(struct strbuf *sb, const char *start,
6965
void *context)
7066
{
71-
struct show_tree_data_cb *wrapper = context;
72-
struct ls_tree_options *options = wrapper->options;
73-
struct show_tree_data *data = wrapper->data;
67+
struct show_tree_data *data = context;
68+
struct ls_tree_options *options = data->options;
7469
const char *end;
7570
const char *p;
7671
unsigned int errlen;
@@ -153,17 +148,14 @@ static int show_tree_fmt(const struct object_id *oid, struct strbuf *base,
153148
int recurse = 0;
154149
struct strbuf sb = STRBUF_INIT;
155150
enum object_type type = object_type(mode);
156-
struct show_tree_data data = {
151+
struct show_tree_data cb_data = {
152+
.options = options,
157153
.mode = mode,
158154
.type = type,
159155
.oid = oid,
160156
.pathname = pathname,
161157
.base = base,
162158
};
163-
struct show_tree_data_cb cb_data = {
164-
.data = &data,
165-
.options = options,
166-
};
167159

168160
if (type == OBJ_TREE && show_recursive(options, base->buf, base->len, pathname))
169161
recurse = READ_TREE_RECURSIVE;

0 commit comments

Comments
 (0)