зеркало из https://github.com/microsoft/git.git
Update ls-files and ls-tree to use C-style quoting for funny pathnames.
Signed-off-by: Junio C Hamano <junkio@cox.net>
This commit is contained in:
Родитель
22943f1a52
Коммит
22ddf71979
22
ls-files.c
22
ls-files.c
|
@ -9,6 +9,7 @@
|
||||||
#include <fnmatch.h>
|
#include <fnmatch.h>
|
||||||
|
|
||||||
#include "cache.h"
|
#include "cache.h"
|
||||||
|
#include "quote.h"
|
||||||
|
|
||||||
static int show_deleted = 0;
|
static int show_deleted = 0;
|
||||||
static int show_cached = 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))
|
if (pathspec && !match(pathspec, ent->name, len))
|
||||||
return;
|
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)
|
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))
|
if (pathspec && !match(pathspec, ce->name, len))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (!show_stage)
|
if (!show_stage) {
|
||||||
printf("%s%s%c", tag, ce->name + offset, line_terminator);
|
fputs(tag, stdout);
|
||||||
else
|
write_name_quoted("", ce->name + offset, line_terminator, stdout);
|
||||||
printf("%s%06o %s %d\t%s%c",
|
putchar(line_terminator);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
printf("%s%06o %s %d\t",
|
||||||
tag,
|
tag,
|
||||||
ntohl(ce->ce_mode),
|
ntohl(ce->ce_mode),
|
||||||
sha1_to_hex(ce->sha1),
|
sha1_to_hex(ce->sha1),
|
||||||
ce_stage(ce),
|
ce_stage(ce));
|
||||||
ce->name + offset, line_terminator);
|
write_name_quoted("", ce->name + offset, line_terminator, stdout);
|
||||||
|
putchar(line_terminator);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void show_files(void)
|
static void show_files(void)
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
#include "cache.h"
|
#include "cache.h"
|
||||||
#include "blob.h"
|
#include "blob.h"
|
||||||
#include "tree.h"
|
#include "tree.h"
|
||||||
|
#include "quote.h"
|
||||||
|
|
||||||
static int line_termination = '\n';
|
static int line_termination = '\n';
|
||||||
#define LS_RECURSIVE 1
|
#define LS_RECURSIVE 1
|
||||||
|
@ -156,8 +157,9 @@ static int show_entry(struct tree_entry_list *e, int level, char *pathbuf)
|
||||||
int err = 0;
|
int err = 0;
|
||||||
|
|
||||||
if (e != &root_entry) {
|
if (e != &root_entry) {
|
||||||
printf("%06o %s %s %s%s", e->mode, entry_type(e),
|
printf("%06o %s %s ",
|
||||||
entry_hex(e), pathbuf, e->name);
|
e->mode, entry_type(e), entry_hex(e));
|
||||||
|
write_name_quoted(pathbuf, e->name, line_termination, stdout);
|
||||||
putchar(line_termination);
|
putchar(line_termination);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Загрузка…
Ссылка в новой задаче