зеркало из https://github.com/microsoft/git.git
Make --raw option available for all diff commands
Signed-off-by: Timo Hirvonen <tihirvon@gmail.com> Signed-off-by: Junio C Hamano <junkio@cox.net>
This commit is contained in:
Родитель
c6744349df
Коммит
a610786f4b
|
@ -39,8 +39,6 @@ static int builtin_diff_files(struct rev_info *revs,
|
||||||
revs->max_count = 3;
|
revs->max_count = 3;
|
||||||
else if (!strcmp(arg, "-q"))
|
else if (!strcmp(arg, "-q"))
|
||||||
silent = 1;
|
silent = 1;
|
||||||
else if (!strcmp(arg, "--raw"))
|
|
||||||
revs->diffopt.output_format = DIFF_FORMAT_RAW;
|
|
||||||
else
|
else
|
||||||
usage(builtin_diff_usage);
|
usage(builtin_diff_usage);
|
||||||
argv++; argc--;
|
argv++; argc--;
|
||||||
|
@ -107,14 +105,9 @@ static int builtin_diff_b_f(struct rev_info *revs,
|
||||||
/* Blob vs file in the working tree*/
|
/* Blob vs file in the working tree*/
|
||||||
struct stat st;
|
struct stat st;
|
||||||
|
|
||||||
while (1 < argc) {
|
if (argc > 1)
|
||||||
const char *arg = argv[1];
|
usage(builtin_diff_usage);
|
||||||
if (!strcmp(arg, "--raw"))
|
|
||||||
revs->diffopt.output_format = DIFF_FORMAT_RAW;
|
|
||||||
else
|
|
||||||
usage(builtin_diff_usage);
|
|
||||||
argv++; argc--;
|
|
||||||
}
|
|
||||||
if (lstat(path, &st))
|
if (lstat(path, &st))
|
||||||
die("'%s': %s", path, strerror(errno));
|
die("'%s': %s", path, strerror(errno));
|
||||||
if (!(S_ISREG(st.st_mode) || S_ISLNK(st.st_mode)))
|
if (!(S_ISREG(st.st_mode) || S_ISLNK(st.st_mode)))
|
||||||
|
@ -137,14 +130,9 @@ static int builtin_diff_blobs(struct rev_info *revs,
|
||||||
*/
|
*/
|
||||||
unsigned mode = canon_mode(S_IFREG | 0644);
|
unsigned mode = canon_mode(S_IFREG | 0644);
|
||||||
|
|
||||||
while (1 < argc) {
|
if (argc > 1)
|
||||||
const char *arg = argv[1];
|
usage(builtin_diff_usage);
|
||||||
if (!strcmp(arg, "--raw"))
|
|
||||||
revs->diffopt.output_format = DIFF_FORMAT_RAW;
|
|
||||||
else
|
|
||||||
usage(builtin_diff_usage);
|
|
||||||
argv++; argc--;
|
|
||||||
}
|
|
||||||
stuff_change(&revs->diffopt,
|
stuff_change(&revs->diffopt,
|
||||||
mode, mode,
|
mode, mode,
|
||||||
blob[1].sha1, blob[0].sha1,
|
blob[1].sha1, blob[0].sha1,
|
||||||
|
@ -162,8 +150,6 @@ static int builtin_diff_index(struct rev_info *revs,
|
||||||
const char *arg = argv[1];
|
const char *arg = argv[1];
|
||||||
if (!strcmp(arg, "--cached"))
|
if (!strcmp(arg, "--cached"))
|
||||||
cached = 1;
|
cached = 1;
|
||||||
else if (!strcmp(arg, "--raw"))
|
|
||||||
revs->diffopt.output_format = DIFF_FORMAT_RAW;
|
|
||||||
else
|
else
|
||||||
usage(builtin_diff_usage);
|
usage(builtin_diff_usage);
|
||||||
argv++; argc--;
|
argv++; argc--;
|
||||||
|
@ -185,14 +171,9 @@ static int builtin_diff_tree(struct rev_info *revs,
|
||||||
{
|
{
|
||||||
const unsigned char *(sha1[2]);
|
const unsigned char *(sha1[2]);
|
||||||
int swap = 0;
|
int swap = 0;
|
||||||
while (1 < argc) {
|
|
||||||
const char *arg = argv[1];
|
if (argc > 1)
|
||||||
if (!strcmp(arg, "--raw"))
|
usage(builtin_diff_usage);
|
||||||
revs->diffopt.output_format = DIFF_FORMAT_RAW;
|
|
||||||
else
|
|
||||||
usage(builtin_diff_usage);
|
|
||||||
argv++; argc--;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* We saw two trees, ent[0] and ent[1].
|
/* We saw two trees, ent[0] and ent[1].
|
||||||
* if ent[1] is unintesting, they are swapped
|
* if ent[1] is unintesting, they are swapped
|
||||||
|
@ -214,14 +195,9 @@ static int builtin_diff_combined(struct rev_info *revs,
|
||||||
const unsigned char (*parent)[20];
|
const unsigned char (*parent)[20];
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
while (1 < argc) {
|
if (argc > 1)
|
||||||
const char *arg = argv[1];
|
usage(builtin_diff_usage);
|
||||||
if (!strcmp(arg, "--raw"))
|
|
||||||
revs->diffopt.output_format = DIFF_FORMAT_RAW;
|
|
||||||
else
|
|
||||||
usage(builtin_diff_usage);
|
|
||||||
argv++; argc--;
|
|
||||||
}
|
|
||||||
if (!revs->dense_combined_merges && !revs->combine_merges)
|
if (!revs->dense_combined_merges && !revs->combine_merges)
|
||||||
revs->dense_combined_merges = revs->combine_merges = 1;
|
revs->dense_combined_merges = revs->combine_merges = 1;
|
||||||
parent = xmalloc(ents * sizeof(*parent));
|
parent = xmalloc(ents * sizeof(*parent));
|
||||||
|
|
2
diff.c
2
diff.c
|
@ -1533,6 +1533,8 @@ int diff_opt_parse(struct diff_options *options, const char **av, int ac)
|
||||||
options->output_format |= DIFF_FORMAT_PATCH;
|
options->output_format |= DIFF_FORMAT_PATCH;
|
||||||
else if (opt_arg(arg, 'U', "unified", &options->context))
|
else if (opt_arg(arg, 'U', "unified", &options->context))
|
||||||
options->output_format |= DIFF_FORMAT_PATCH;
|
options->output_format |= DIFF_FORMAT_PATCH;
|
||||||
|
else if (!strcmp(arg, "--raw"))
|
||||||
|
options->output_format |= DIFF_FORMAT_RAW;
|
||||||
else if (!strcmp(arg, "--patch-with-raw")) {
|
else if (!strcmp(arg, "--patch-with-raw")) {
|
||||||
options->output_format |= DIFF_FORMAT_PATCH | DIFF_FORMAT_RAW;
|
options->output_format |= DIFF_FORMAT_PATCH | DIFF_FORMAT_RAW;
|
||||||
}
|
}
|
||||||
|
|
Загрузка…
Ссылка в новой задаче