tree-diff: inline path_appendnew()
Our path_appendnew() has been simplified to the point that it is mostly just implementing combine_diff_path_new(), plus setting the "next" pointer. Since there's only one caller, let's replace it completely with a call to that helper function. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Jeff King committed
Jan 9, 2025 at 03:49 UTC
b20d7d348c4d32777cd577c221de529452baca03
1 file changed
+4
-27
tree-diff.c
+4
-27
@@ -124,32 +124,6 @@ static int emit_diff_first_parent_only(struct diff_options *opt, struct combine_
124
}
125
126
127
-/*
128
- * Make a new combine_diff_path from path/mode/sha1
129
- * and append it to paths list tail.
130
- */
131
-static struct combine_diff_path *path_appendnew(struct combine_diff_path *last,
132
- int nparent, const char *path, size_t len,
133
- unsigned mode, const struct object_id *oid)
134
-{
135
- struct combine_diff_path *p;
136
- size_t alloclen = combine_diff_path_size(nparent, len);
137
-
138
- p = xmalloc(alloclen);
139
- p->next = NULL;
140
- last->next = p;
141
-
142
- p->path = (char *)&(p->parent[nparent]);
143
- memcpy(p->path, path, len);
144
- p->path[len] = 0;
145
- p->mode = mode;
146
- oidcpy(&p->oid, oid ? oid : null_oid());
147
-
148
- memset(p->parent, 0, sizeof(p->parent[0]) * nparent);
149
-
150
- return p;
151
-}
152
-
127
/*
128
* new path should be added to combine diff
129
*
@@ -206,7 +180,10 @@ static struct combine_diff_path *emit_path(struct combine_diff_path *p,
180
struct combine_diff_path *pprev = p;
181
182
strbuf_add(base, path, pathlen);
209
- p = path_appendnew(p, nparent, base->buf, base->len, mode, oid);
183
+ p = combine_diff_path_new(base->buf, base->len, mode,
184
+ oid ? oid : null_oid(),
185
+ nparent);
186
+ pprev->next = p;
187
strbuf_setlen(base, old_baselen);
188
189
for (i = 0; i < nparent; ++i) {