Skip to content

Commit

Permalink
Merge with_raw, with_stat and summary variables to output_format
Browse files Browse the repository at this point in the history
DIFF_FORMAT_* are now bit-flags instead of enumerated values.

Signed-off-by: Timo Hirvonen <tihirvon@gmail.com>
Signed-off-by: Junio C Hamano <junkio@cox.net>
  • Loading branch information
Timo Hirvonen authored and Junio C Hamano committed Jun 26, 2006
1 parent 1ef9e05 commit c674434
Show file tree
Hide file tree
Showing 6 changed files with 136 additions and 144 deletions.
2 changes: 1 addition & 1 deletion builtin-diff.c
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ static int builtin_diff_files(struct rev_info *revs,
3 < revs->max_count)
usage(builtin_diff_usage);
if (revs->max_count < 0 &&
(revs->diffopt.output_format == DIFF_FORMAT_PATCH))
(revs->diffopt.output_format & DIFF_FORMAT_PATCH))
revs->combine_merges = revs->dense_combined_merges = 1;
/*
* Backward compatibility wart - "diff-files -s" used to
Expand Down
4 changes: 1 addition & 3 deletions builtin-log.c
Original file line number Diff line number Diff line change
Expand Up @@ -176,11 +176,9 @@ int cmd_format_patch(int argc, const char **argv, char **envp)
rev.commit_format = CMIT_FMT_EMAIL;
rev.verbose_header = 1;
rev.diff = 1;
rev.diffopt.with_raw = 0;
rev.diffopt.with_stat = 1;
rev.combine_merges = 0;
rev.ignore_merges = 1;
rev.diffopt.output_format = DIFF_FORMAT_PATCH;
rev.diffopt.output_format = DIFF_FORMAT_DIFFSTAT | DIFF_FORMAT_PATCH;

git_config(git_format_config);
rev.extra_headers = extra_headers;
Expand Down
55 changes: 24 additions & 31 deletions combine-diff.c
Original file line number Diff line number Diff line change
Expand Up @@ -771,7 +771,7 @@ static void show_raw_diff(struct combine_diff_path *p, int num_parent, struct re
if (rev->loginfo)
show_log(rev, rev->loginfo, "\n");

if (opt->output_format == DIFF_FORMAT_RAW) {
if (opt->output_format & DIFF_FORMAT_RAW) {
offset = strlen(COLONS) - num_parent;
if (offset < 0)
offset = 0;
Expand All @@ -791,8 +791,7 @@ static void show_raw_diff(struct combine_diff_path *p, int num_parent, struct re
printf(" %s ", diff_unique_abbrev(p->sha1, opt->abbrev));
}

if (opt->output_format == DIFF_FORMAT_RAW ||
opt->output_format == DIFF_FORMAT_NAME_STATUS) {
if (opt->output_format & (DIFF_FORMAT_RAW | DIFF_FORMAT_NAME_STATUS)) {
for (i = 0; i < num_parent; i++)
putchar(p->parent[i].status);
putchar(inter_name_termination);
Expand All @@ -818,17 +817,12 @@ void show_combined_diff(struct combine_diff_path *p,
struct diff_options *opt = &rev->diffopt;
if (!p->len)
return;
switch (opt->output_format) {
case DIFF_FORMAT_RAW:
case DIFF_FORMAT_NAME_STATUS:
case DIFF_FORMAT_NAME:
if (opt->output_format & (DIFF_FORMAT_RAW |
DIFF_FORMAT_NAME |
DIFF_FORMAT_NAME_STATUS)) {
show_raw_diff(p, num_parent, rev);
return;
case DIFF_FORMAT_PATCH:
} else if (opt->output_format & DIFF_FORMAT_PATCH) {
show_patch_diff(p, num_parent, dense, rev);
return;
default:
return;
}
}

Expand All @@ -842,33 +836,28 @@ void diff_tree_combined(const unsigned char *sha1,
struct diff_options diffopts;
struct combine_diff_path *p, *paths = NULL;
int i, num_paths;
int do_diffstat;

do_diffstat = (opt->output_format == DIFF_FORMAT_DIFFSTAT ||
opt->with_stat);
diffopts = *opt;
diffopts.with_raw = 0;
diffopts.with_stat = 0;
diffopts.output_format &= ~(DIFF_FORMAT_RAW | DIFF_FORMAT_DIFFSTAT);
diffopts.recursive = 1;

/* find set of paths that everybody touches */
for (i = 0; i < num_parent; i++) {
/* show stat against the first parent even
* when doing combined diff.
*/
if (i == 0 && do_diffstat)
diffopts.output_format = DIFF_FORMAT_DIFFSTAT;
if (i == 0 && opt->output_format & DIFF_FORMAT_DIFFSTAT)
diffopts.output_format |= DIFF_FORMAT_DIFFSTAT;
else
diffopts.output_format = DIFF_FORMAT_NO_OUTPUT;
diffopts.output_format |= DIFF_FORMAT_NO_OUTPUT;
diff_tree_sha1(parent[i], sha1, "", &diffopts);
diffcore_std(&diffopts);
paths = intersect_paths(paths, i, num_parent);

if (do_diffstat && rev->loginfo)
show_log(rev, rev->loginfo,
opt->with_stat ? "---\n" : "\n");
if (opt->output_format & DIFF_FORMAT_DIFFSTAT && rev->loginfo)
show_log(rev, rev->loginfo, "---\n");
diff_flush(&diffopts);
if (opt->with_stat)
if (opt->output_format & DIFF_FORMAT_DIFFSTAT)
putchar('\n');
}

Expand All @@ -878,17 +867,21 @@ void diff_tree_combined(const unsigned char *sha1,
num_paths++;
}
if (num_paths) {
if (opt->with_raw) {
int saved_format = opt->output_format;
opt->output_format = DIFF_FORMAT_RAW;
if (opt->output_format & (DIFF_FORMAT_RAW |
DIFF_FORMAT_NAME |
DIFF_FORMAT_NAME_STATUS)) {
for (p = paths; p; p = p->next) {
show_combined_diff(p, num_parent, dense, rev);
if (p->len)
show_raw_diff(p, num_parent, rev);
}
opt->output_format = saved_format;
putchar(opt->line_termination);
}
for (p = paths; p; p = p->next) {
show_combined_diff(p, num_parent, dense, rev);
if (opt->output_format & DIFF_FORMAT_PATCH) {
for (p = paths; p; p = p->next) {
if (p->len)
show_patch_diff(p, num_parent, dense,
rev);
}
}
}

Expand Down
Loading

0 comments on commit c674434

Please sign in to comment.