Diff: --name-status output format.
The new output format shows only the status letter and paths. Signed-off-by: Junio C Hamano <junkio@cox.net>
This commit is contained in:
parent
8082d8d305
commit
946f5f7c24
@ -15,8 +15,8 @@
|
|||||||
--name-only::
|
--name-only::
|
||||||
Show only names of changed files.
|
Show only names of changed files.
|
||||||
|
|
||||||
--name-only-z::
|
--name-status::
|
||||||
Same as --name-only, but terminate lines with NUL.
|
Show only names and status of changed files.
|
||||||
|
|
||||||
-B::
|
-B::
|
||||||
Break complete rewrite changes into pairs of delete and create.
|
Break complete rewrite changes into pairs of delete and create.
|
||||||
|
22
diff.c
22
diff.c
@ -709,6 +709,8 @@ int diff_opt_parse(struct diff_options *options, const char **av, int ac)
|
|||||||
options->rename_limit = strtoul(arg+2, NULL, 10);
|
options->rename_limit = strtoul(arg+2, NULL, 10);
|
||||||
else if (!strcmp(arg, "--name-only"))
|
else if (!strcmp(arg, "--name-only"))
|
||||||
options->output_format = DIFF_FORMAT_NAME;
|
options->output_format = DIFF_FORMAT_NAME;
|
||||||
|
else if (!strcmp(arg, "--name-status"))
|
||||||
|
options->output_format = DIFF_FORMAT_NAME_STATUS;
|
||||||
else if (!strcmp(arg, "-R"))
|
else if (!strcmp(arg, "-R"))
|
||||||
options->reverse_diff = 1;
|
options->reverse_diff = 1;
|
||||||
else if (!strncmp(arg, "-S", 2))
|
else if (!strncmp(arg, "-S", 2))
|
||||||
@ -835,7 +837,8 @@ void diff_free_filepair(struct diff_filepair *p)
|
|||||||
|
|
||||||
static void diff_flush_raw(struct diff_filepair *p,
|
static void diff_flush_raw(struct diff_filepair *p,
|
||||||
int line_termination,
|
int line_termination,
|
||||||
int inter_name_termination)
|
int inter_name_termination,
|
||||||
|
int output_format)
|
||||||
{
|
{
|
||||||
int two_paths;
|
int two_paths;
|
||||||
char status[10];
|
char status[10];
|
||||||
@ -871,13 +874,12 @@ static void diff_flush_raw(struct diff_filepair *p,
|
|||||||
two_paths = 0;
|
two_paths = 0;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
printf(":%06o %06o %s ",
|
if (output_format != DIFF_FORMAT_NAME_STATUS) {
|
||||||
p->one->mode, p->two->mode, sha1_to_hex(p->one->sha1));
|
printf(":%06o %06o %s ",
|
||||||
printf("%s %s%c%s",
|
p->one->mode, p->two->mode, sha1_to_hex(p->one->sha1));
|
||||||
sha1_to_hex(p->two->sha1),
|
printf("%s ", sha1_to_hex(p->two->sha1));
|
||||||
status,
|
}
|
||||||
inter_name_termination,
|
printf("%s%c%s",status, inter_name_termination, p->one->path);
|
||||||
p->one->path);
|
|
||||||
if (two_paths)
|
if (two_paths)
|
||||||
printf("%c%s", inter_name_termination, p->two->path);
|
printf("%c%s", inter_name_termination, p->two->path);
|
||||||
putchar(line_termination);
|
putchar(line_termination);
|
||||||
@ -1067,8 +1069,10 @@ void diff_flush(struct diff_options *options)
|
|||||||
diff_flush_patch(p);
|
diff_flush_patch(p);
|
||||||
break;
|
break;
|
||||||
case DIFF_FORMAT_RAW:
|
case DIFF_FORMAT_RAW:
|
||||||
|
case DIFF_FORMAT_NAME_STATUS:
|
||||||
diff_flush_raw(p, line_termination,
|
diff_flush_raw(p, line_termination,
|
||||||
inter_name_termination);
|
inter_name_termination,
|
||||||
|
diff_output_format);
|
||||||
break;
|
break;
|
||||||
case DIFF_FORMAT_NAME:
|
case DIFF_FORMAT_NAME:
|
||||||
diff_flush_name(p, line_termination);
|
diff_flush_name(p, line_termination);
|
||||||
|
2
diff.h
2
diff.h
@ -67,6 +67,7 @@ extern void diffcore_std_no_resolve(struct diff_options *);
|
|||||||
" -p output patch format.\n" \
|
" -p output patch format.\n" \
|
||||||
" -u synonym for -p.\n" \
|
" -u synonym for -p.\n" \
|
||||||
" --name-only show only names of changed files.\n" \
|
" --name-only show only names of changed files.\n" \
|
||||||
|
" --name-status show names and status of changed files.\n" \
|
||||||
" -R swap input file pairs.\n" \
|
" -R swap input file pairs.\n" \
|
||||||
" -B detect complete rewrites.\n" \
|
" -B detect complete rewrites.\n" \
|
||||||
" -M detect renames.\n" \
|
" -M detect renames.\n" \
|
||||||
@ -85,6 +86,7 @@ extern int diff_queue_is_empty(void);
|
|||||||
#define DIFF_FORMAT_PATCH 2
|
#define DIFF_FORMAT_PATCH 2
|
||||||
#define DIFF_FORMAT_NO_OUTPUT 3
|
#define DIFF_FORMAT_NO_OUTPUT 3
|
||||||
#define DIFF_FORMAT_NAME 4
|
#define DIFF_FORMAT_NAME 4
|
||||||
|
#define DIFF_FORMAT_NAME_STATUS 5
|
||||||
|
|
||||||
extern void diff_flush(struct diff_options*);
|
extern void diff_flush(struct diff_options*);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user