diff options
Diffstat (limited to 'revision.c')
-rw-r--r-- | revision.c | 25 |
1 files changed, 5 insertions, 20 deletions
diff --git a/revision.c b/revision.c index cf544b6e96..f8c30341ed 100644 --- a/revision.c +++ b/revision.c @@ -23,26 +23,11 @@ volatile show_early_output_fn_t show_early_output; char *path_name(const struct name_path *path, const char *name) { - const struct name_path *p; - char *n, *m; - int nlen = strlen(name); - int len = nlen + 1; - - for (p = path; p; p = p->up) { - if (p->elem_len) - len += p->elem_len + 1; - } - n = xmalloc(len); - m = n + len - (nlen + 1); - strcpy(m, name); - for (p = path; p; p = p->up) { - if (p->elem_len) { - m -= p->elem_len + 1; - memcpy(m, p->elem, p->elem_len); - m[p->elem_len] = '/'; - } - } - return n; + struct strbuf ret = STRBUF_INIT; + if (path) + strbuf_addbuf(&ret, path->base); + strbuf_addstr(&ret, name); + return strbuf_detach(&ret, NULL); } void show_object_with_name(FILE *out, struct object *obj, |