summaryrefslogtreecommitdiff
path: root/ls-files.c
diff options
context:
space:
mode:
authorJunio C Hamano <junkio@cox.net>2005-10-15 04:56:46 (GMT)
committerJunio C Hamano <junkio@cox.net>2005-10-18 00:41:55 (GMT)
commit22ddf7197958337a8c254122eae4efcd8a54098a (patch)
tree425970bac6109c4b5d541ffb62adb7a570822ae9 /ls-files.c
parent22943f1a52142b0ef669c959f8b4367e579da968 (diff)
downloadgit-22ddf7197958337a8c254122eae4efcd8a54098a.zip
git-22ddf7197958337a8c254122eae4efcd8a54098a.tar.gz
git-22ddf7197958337a8c254122eae4efcd8a54098a.tar.bz2
Update ls-files and ls-tree to use C-style quoting for funny pathnames.
Signed-off-by: Junio C Hamano <junkio@cox.net>
Diffstat (limited to 'ls-files.c')
-rw-r--r--ls-files.c22
1 files changed, 15 insertions, 7 deletions
diff --git a/ls-files.c b/ls-files.c
index f47114a..3085b2f 100644
--- a/ls-files.c
+++ b/ls-files.c
@@ -9,6 +9,7 @@
#include <fnmatch.h>
#include "cache.h"
+#include "quote.h"
static int show_deleted = 0;
static int show_cached = 0;
@@ -342,7 +343,9 @@ static void show_dir_entry(const char *tag, struct nond_on_fs *ent)
if (pathspec && !match(pathspec, ent->name, len))
return;
- printf("%s%s%c", tag, ent->name + offset, line_terminator);
+ fputs(tag, stdout);
+ write_name_quoted("", ent->name + offset, line_terminator, stdout);
+ putchar(line_terminator);
}
static void show_killed_files(void)
@@ -405,15 +408,20 @@ static void show_ce_entry(const char *tag, struct cache_entry *ce)
if (pathspec && !match(pathspec, ce->name, len))
return;
- if (!show_stage)
- printf("%s%s%c", tag, ce->name + offset, line_terminator);
- else
- printf("%s%06o %s %d\t%s%c",
+ if (!show_stage) {
+ fputs(tag, stdout);
+ write_name_quoted("", ce->name + offset, line_terminator, stdout);
+ putchar(line_terminator);
+ }
+ else {
+ printf("%s%06o %s %d\t",
tag,
ntohl(ce->ce_mode),
sha1_to_hex(ce->sha1),
- ce_stage(ce),
- ce->name + offset, line_terminator);
+ ce_stage(ce));
+ write_name_quoted("", ce->name + offset, line_terminator, stdout);
+ putchar(line_terminator);
+ }
}
static void show_files(void)