Skip to content

Commit b20d7d3

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

File tree

1 file changed

+4
-27
lines changed

1 file changed

+4
-27
lines changed

tree-diff.c

Lines changed: 4 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -124,32 +124,6 @@ static int emit_diff_first_parent_only(struct diff_options *opt, struct combine_
124124
}
125125

126126

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-
153127
/*
154128
* new path should be added to combine diff
155129
*
@@ -206,7 +180,10 @@ static struct combine_diff_path *emit_path(struct combine_diff_path *p,
206180
struct combine_diff_path *pprev = p;
207181

208182
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;
210187
strbuf_setlen(base, old_baselen);
211188

212189
for (i = 0; i < nparent; ++i) {

0 commit comments

Comments
 (0)