diff-* --patch-with-raw
This new flag outputs the diff-raw output and diff-patch output at the same time. Requested by Cogito. Signed-off-by: Junio C Hamano <junkio@cox.net>
This commit is contained in:
parent
944e3a88fe
commit
86ff1d2012
@ -832,6 +832,7 @@ const char *diff_tree_combined_merge(const unsigned char *sha1,
|
|||||||
|
|
||||||
diffopts = *opt;
|
diffopts = *opt;
|
||||||
diffopts.output_format = DIFF_FORMAT_NO_OUTPUT;
|
diffopts.output_format = DIFF_FORMAT_NO_OUTPUT;
|
||||||
|
diffopts.with_raw = 0;
|
||||||
diffopts.recursive = 1;
|
diffopts.recursive = 1;
|
||||||
|
|
||||||
/* count parents */
|
/* count parents */
|
||||||
@ -858,6 +859,16 @@ const char *diff_tree_combined_merge(const unsigned char *sha1,
|
|||||||
num_paths++;
|
num_paths++;
|
||||||
}
|
}
|
||||||
if (num_paths) {
|
if (num_paths) {
|
||||||
|
if (opt->with_raw) {
|
||||||
|
int saved_format = opt->output_format;
|
||||||
|
opt->output_format = DIFF_FORMAT_RAW;
|
||||||
|
for (p = paths; p; p = p->next) {
|
||||||
|
if (show_combined_diff(p, num_parent, dense,
|
||||||
|
header, opt))
|
||||||
|
header = NULL;
|
||||||
|
}
|
||||||
|
opt->output_format = saved_format;
|
||||||
|
}
|
||||||
for (p = paths; p; p = p->next) {
|
for (p = paths; p; p = p->next) {
|
||||||
if (show_combined_diff(p, num_parent, dense,
|
if (show_combined_diff(p, num_parent, dense,
|
||||||
header, opt))
|
header, opt))
|
||||||
|
84
diff.c
84
diff.c
@ -862,6 +862,10 @@ int diff_opt_parse(struct diff_options *options, const char **av, int ac)
|
|||||||
const char *arg = av[0];
|
const char *arg = av[0];
|
||||||
if (!strcmp(arg, "-p") || !strcmp(arg, "-u"))
|
if (!strcmp(arg, "-p") || !strcmp(arg, "-u"))
|
||||||
options->output_format = DIFF_FORMAT_PATCH;
|
options->output_format = DIFF_FORMAT_PATCH;
|
||||||
|
else if (!strcmp(arg, "--patch-with-raw")) {
|
||||||
|
options->output_format = DIFF_FORMAT_PATCH;
|
||||||
|
options->with_raw = 1;
|
||||||
|
}
|
||||||
else if (!strcmp(arg, "-z"))
|
else if (!strcmp(arg, "-z"))
|
||||||
options->line_termination = 0;
|
options->line_termination = 0;
|
||||||
else if (!strncmp(arg, "-l", 2))
|
else if (!strncmp(arg, "-l", 2))
|
||||||
@ -1048,13 +1052,13 @@ const char *diff_unique_abbrev(const unsigned char *sha1, int len)
|
|||||||
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,
|
||||||
struct diff_options *options)
|
struct diff_options *options,
|
||||||
|
int output_format)
|
||||||
{
|
{
|
||||||
int two_paths;
|
int two_paths;
|
||||||
char status[10];
|
char status[10];
|
||||||
int abbrev = options->abbrev;
|
int abbrev = options->abbrev;
|
||||||
const char *path_one, *path_two;
|
const char *path_one, *path_two;
|
||||||
int output_format = options->output_format;
|
|
||||||
|
|
||||||
path_one = p->one->path;
|
path_one = p->one->path;
|
||||||
path_two = p->two->path;
|
path_two = p->two->path;
|
||||||
@ -1270,46 +1274,58 @@ static void diff_resolve_rename_copy(void)
|
|||||||
diff_debug_queue("resolve-rename-copy done", q);
|
diff_debug_queue("resolve-rename-copy done", q);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void flush_one_pair(struct diff_filepair *p,
|
||||||
|
int diff_output_format,
|
||||||
|
struct diff_options *options)
|
||||||
|
{
|
||||||
|
int inter_name_termination = '\t';
|
||||||
|
int line_termination = options->line_termination;
|
||||||
|
if (!line_termination)
|
||||||
|
inter_name_termination = 0;
|
||||||
|
|
||||||
|
switch (p->status) {
|
||||||
|
case DIFF_STATUS_UNKNOWN:
|
||||||
|
break;
|
||||||
|
case 0:
|
||||||
|
die("internal error in diff-resolve-rename-copy");
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
switch (diff_output_format) {
|
||||||
|
case DIFF_FORMAT_PATCH:
|
||||||
|
diff_flush_patch(p, options);
|
||||||
|
break;
|
||||||
|
case DIFF_FORMAT_RAW:
|
||||||
|
case DIFF_FORMAT_NAME_STATUS:
|
||||||
|
diff_flush_raw(p, line_termination,
|
||||||
|
inter_name_termination,
|
||||||
|
options, diff_output_format);
|
||||||
|
break;
|
||||||
|
case DIFF_FORMAT_NAME:
|
||||||
|
diff_flush_name(p,
|
||||||
|
inter_name_termination,
|
||||||
|
line_termination);
|
||||||
|
break;
|
||||||
|
case DIFF_FORMAT_NO_OUTPUT:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void diff_flush(struct diff_options *options)
|
void diff_flush(struct diff_options *options)
|
||||||
{
|
{
|
||||||
struct diff_queue_struct *q = &diff_queued_diff;
|
struct diff_queue_struct *q = &diff_queued_diff;
|
||||||
int i;
|
int i;
|
||||||
int inter_name_termination = '\t';
|
|
||||||
int diff_output_format = options->output_format;
|
int diff_output_format = options->output_format;
|
||||||
int line_termination = options->line_termination;
|
|
||||||
|
|
||||||
if (!line_termination)
|
|
||||||
inter_name_termination = 0;
|
|
||||||
|
|
||||||
|
if (options->with_raw) {
|
||||||
|
for (i = 0; i < q->nr; i++) {
|
||||||
|
struct diff_filepair *p = q->queue[i];
|
||||||
|
flush_one_pair(p, DIFF_FORMAT_RAW, options);
|
||||||
|
}
|
||||||
|
}
|
||||||
for (i = 0; i < q->nr; i++) {
|
for (i = 0; i < q->nr; i++) {
|
||||||
struct diff_filepair *p = q->queue[i];
|
struct diff_filepair *p = q->queue[i];
|
||||||
|
flush_one_pair(p, diff_output_format, options);
|
||||||
switch (p->status) {
|
|
||||||
case DIFF_STATUS_UNKNOWN:
|
|
||||||
break;
|
|
||||||
case 0:
|
|
||||||
die("internal error in diff-resolve-rename-copy");
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
switch (diff_output_format) {
|
|
||||||
case DIFF_FORMAT_PATCH:
|
|
||||||
diff_flush_patch(p, options);
|
|
||||||
break;
|
|
||||||
case DIFF_FORMAT_RAW:
|
|
||||||
case DIFF_FORMAT_NAME_STATUS:
|
|
||||||
diff_flush_raw(p, line_termination,
|
|
||||||
inter_name_termination,
|
|
||||||
options);
|
|
||||||
break;
|
|
||||||
case DIFF_FORMAT_NAME:
|
|
||||||
diff_flush_name(p,
|
|
||||||
inter_name_termination,
|
|
||||||
line_termination);
|
|
||||||
break;
|
|
||||||
case DIFF_FORMAT_NO_OUTPUT:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
diff_free_filepair(p);
|
diff_free_filepair(p);
|
||||||
}
|
}
|
||||||
free(q->queue);
|
free(q->queue);
|
||||||
|
1
diff.h
1
diff.h
@ -24,6 +24,7 @@ struct diff_options {
|
|||||||
const char *orderfile;
|
const char *orderfile;
|
||||||
const char *pickaxe;
|
const char *pickaxe;
|
||||||
unsigned recursive:1,
|
unsigned recursive:1,
|
||||||
|
with_raw:1,
|
||||||
tree_in_recursive:1,
|
tree_in_recursive:1,
|
||||||
full_index:1;
|
full_index:1;
|
||||||
int break_opt;
|
int break_opt;
|
||||||
|
Loading…
Reference in New Issue
Block a user