ls-files: fix "--format" output of relative paths
Fix a bug introduced with the "--format" option in
ce74de93
(ls-files: introduce "--format" option, 2022-07-23),
where relative paths were computed using the output buffer,
which could lead to random garbage data in the output.
Signed-off-by: Adam Johnson <me@adamj.eu>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:

committed by
Junio C Hamano

parent
ce74de931d
commit
cfb62dd006
@ -89,12 +89,15 @@ static void write_name(const char *name)
|
||||
|
||||
static void write_name_to_buf(struct strbuf *sb, const char *name)
|
||||
{
|
||||
const char *rel = relative_path(name, prefix_len ? prefix : NULL, sb);
|
||||
struct strbuf buf = STRBUF_INIT;
|
||||
const char *rel = relative_path(name, prefix_len ? prefix : NULL, &buf);
|
||||
|
||||
if (line_terminator)
|
||||
quote_c_style(rel, sb, NULL, 0);
|
||||
else
|
||||
strbuf_addstr(sb, rel);
|
||||
|
||||
strbuf_release(&buf);
|
||||
}
|
||||
|
||||
static const char *get_tag(const struct cache_entry *ce, const char *tag)
|
||||
|
Reference in New Issue
Block a user