X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=ls-files.c;h=3085b2fc8c7e8920ecca8e9c0657d6124b0fbfda;hb=794f9fe7db30e2aff8f8f0543c6d18bf579cdbc2;hp=956be09350f6c17a479e96ab8e42575e1ce60762;hpb=6b5ee137e56af8093391411389dd4b18416707ec;p=git.git diff --git a/ls-files.c b/ls-files.c index 956be093..3085b2fc 100644 --- a/ls-files.c +++ b/ls-files.c @@ -9,6 +9,7 @@ #include #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) @@ -530,7 +538,7 @@ static void verify_pathspec(void) static const char ls_files_usage[] = "git-ls-files [-z] [-t] (--[cached|deleted|others|stage|unmerged|killed|modified])* " "[ --ignored ] [--exclude=] [--exclude-from=] " - "[ --exclude-per-directory= ]"; + "[ --exclude-per-directory= ] [--] []*"; int main(int argc, const char **argv) { @@ -544,6 +552,10 @@ int main(int argc, const char **argv) for (i = 1; i < argc; i++) { const char *arg = argv[i]; + if (!strcmp(arg, "--")) { + i++; + break; + } if (!strcmp(arg, "-z")) { line_terminator = 0; continue;