revision API: split parent rewriting and parent printing options
This change allows parent rewriting to be performed without causing the log and rev-list commands to print the parents. Signed-off-by: Adam Simpkins <adam@adamsimpkins.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:

committed by
Junio C Hamano

parent
c697ad143b
commit
885cf80899
@ -77,7 +77,7 @@ static void show_commit(struct commit *commit)
|
|||||||
stdout);
|
stdout);
|
||||||
else
|
else
|
||||||
fputs(sha1_to_hex(commit->object.sha1), stdout);
|
fputs(sha1_to_hex(commit->object.sha1), stdout);
|
||||||
if (revs.parents) {
|
if (revs.print_parents) {
|
||||||
struct commit_list *parents = commit->parents;
|
struct commit_list *parents = commit->parents;
|
||||||
while (parents) {
|
while (parents) {
|
||||||
printf(" %s", sha1_to_hex(parents->item->object.sha1));
|
printf(" %s", sha1_to_hex(parents->item->object.sha1));
|
||||||
|
@ -231,7 +231,7 @@ void show_log(struct rev_info *opt)
|
|||||||
putchar('>');
|
putchar('>');
|
||||||
}
|
}
|
||||||
fputs(diff_unique_abbrev(commit->object.sha1, abbrev_commit), stdout);
|
fputs(diff_unique_abbrev(commit->object.sha1, abbrev_commit), stdout);
|
||||||
if (opt->parents)
|
if (opt->print_parents)
|
||||||
show_parents(commit, abbrev_commit);
|
show_parents(commit, abbrev_commit);
|
||||||
show_decorations(commit);
|
show_decorations(commit);
|
||||||
putchar(opt->diffopt.line_termination);
|
putchar(opt->diffopt.line_termination);
|
||||||
@ -271,7 +271,7 @@ void show_log(struct rev_info *opt)
|
|||||||
}
|
}
|
||||||
fputs(diff_unique_abbrev(commit->object.sha1, abbrev_commit),
|
fputs(diff_unique_abbrev(commit->object.sha1, abbrev_commit),
|
||||||
stdout);
|
stdout);
|
||||||
if (opt->parents)
|
if (opt->print_parents)
|
||||||
show_parents(commit, abbrev_commit);
|
show_parents(commit, abbrev_commit);
|
||||||
if (parent)
|
if (parent)
|
||||||
printf(" (from %s)",
|
printf(" (from %s)",
|
||||||
|
@ -1105,7 +1105,8 @@ int setup_revisions(int argc, const char **argv, struct rev_info *revs, const ch
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!strcmp(arg, "--parents")) {
|
if (!strcmp(arg, "--parents")) {
|
||||||
revs->parents = 1;
|
revs->rewrite_parents = 1;
|
||||||
|
revs->print_parents = 1;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (!strcmp(arg, "--dense")) {
|
if (!strcmp(arg, "--dense")) {
|
||||||
@ -1524,13 +1525,13 @@ enum commit_action simplify_commit(struct rev_info *revs, struct commit *commit)
|
|||||||
/* Commit without changes? */
|
/* Commit without changes? */
|
||||||
if (commit->object.flags & TREESAME) {
|
if (commit->object.flags & TREESAME) {
|
||||||
/* drop merges unless we want parenthood */
|
/* drop merges unless we want parenthood */
|
||||||
if (!revs->parents)
|
if (!revs->rewrite_parents)
|
||||||
return commit_ignore;
|
return commit_ignore;
|
||||||
/* non-merge - always ignore it */
|
/* non-merge - always ignore it */
|
||||||
if (!commit->parents || !commit->parents->next)
|
if (!commit->parents || !commit->parents->next)
|
||||||
return commit_ignore;
|
return commit_ignore;
|
||||||
}
|
}
|
||||||
if (revs->parents && rewrite_parents(revs, commit) < 0)
|
if (revs->rewrite_parents && rewrite_parents(revs, commit) < 0)
|
||||||
return commit_error;
|
return commit_error;
|
||||||
}
|
}
|
||||||
return commit_show;
|
return commit_show;
|
||||||
|
@ -46,7 +46,8 @@ struct rev_info {
|
|||||||
unpacked:1, /* see also ignore_packed below */
|
unpacked:1, /* see also ignore_packed below */
|
||||||
boundary:2,
|
boundary:2,
|
||||||
left_right:1,
|
left_right:1,
|
||||||
parents:1,
|
rewrite_parents:1,
|
||||||
|
print_parents:1,
|
||||||
reverse:1,
|
reverse:1,
|
||||||
cherry_pick:1,
|
cherry_pick:1,
|
||||||
first_parent_only:1;
|
first_parent_only:1;
|
||||||
|
Reference in New Issue
Block a user