Signed-off-by: Nguyễn Thái Ngọc Duy <[email protected]>
---
builtin/list-files.c | 9 ++++++++-
t/t7013-list-files.sh | 24 ++++++++++++++++++++++++
2 files changed, 32 insertions(+), 1 deletion(-)
diff --git a/builtin/list-files.c b/builtin/list-files.c
index 8b74d79..51ff19d 100644
--- a/builtin/list-files.c
+++ b/builtin/list-files.c
@@ -3,6 +3,7 @@
#include "parse-options.h"
#include "pathspec.h"
#include "dir.h"
+#include "quote.h"
enum item_type {
FROM_INDEX
@@ -57,13 +58,19 @@ static void populate_cached_entries(struct item_list
*result,
static void display(const struct item_list *result)
{
+ struct strbuf quoted = STRBUF_INIT;
int i;
+ if (!prefix_length)
+ prefix = NULL;
+
for (i = 0; i < result->nr; i++) {
const struct item *item = result->items + i;
- printf("%s\n", item->path);
+ quote_path_relative(item->path, prefix, "ed);
+ printf("%s\n", quoted.buf);
}
+ strbuf_release("ed);
}
static int ls_config(const char *var, const char *value, void *cb)
diff --git a/t/t7013-list-files.sh b/t/t7013-list-files.sh
index f43776e..a5e555d 100755
--- a/t/t7013-list-files.sh
+++ b/t/t7013-list-files.sh
@@ -32,4 +32,28 @@ test_expect_success 'list-files selectively from index' '
test_cmp expect actual
'
+test_expect_success 'list-files from subdir ' '
+ (
+ cd sa &&
+ git list-files >actual &&
+ cat >expect <<-\EOF &&
+ a
+ sb/b
+ EOF
+ test_cmp expect actual
+ )
+'
+
+test_expect_success 'list-files from subdir (2)' '
+ (
+ cd sa &&
+ git list-files ../a sb >actual &&
+ cat >expect <<-\EOF &&
+ ../a
+ sb/b
+ EOF
+ test_cmp expect actual
+ )
+'
+
test_done
--
2.3.0.rc1.137.g477eb31
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html