mirror of
https://github.com/git/git
synced 2024-08-25 02:35:46 +00:00
Merge branch 'aj/ls-files-format-fix'
Fix for a "ls-files --format="%(path)" that produced nonsense output, which was a bug in 2.38. * aj/ls-files-format-fix: ls-files: fix "--format" output of relative paths
This commit is contained in:
commit
1071deae00
|
@ -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)
|
||||
|
|
|
@ -54,6 +54,22 @@ test_expect_success 'git ls-files --format path v.s. -s' '
|
|||
test_cmp expect actual
|
||||
'
|
||||
|
||||
test_expect_success 'git ls-files --format with relative path' '
|
||||
cat >expect <<-\EOF &&
|
||||
../o1.txt
|
||||
../o2.txt
|
||||
../o3.txt
|
||||
../o4.txt
|
||||
../o5.txt
|
||||
../o6.txt
|
||||
EOF
|
||||
mkdir sub &&
|
||||
cd sub &&
|
||||
git ls-files --format="%(path)" ":/" >../actual &&
|
||||
cd .. &&
|
||||
test_cmp expect actual
|
||||
'
|
||||
|
||||
test_expect_success 'git ls-files --format with -m' '
|
||||
echo change >o1.txt &&
|
||||
cat >expect <<-\EOF &&
|
||||
|
|
Loading…
Reference in a new issue