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>
Adam Simpkins committed
May 4, 2008 at 03:36 UTC
885cf808998c4e6d685c669a44f02b37f6965fd9
4 files changed
+9
-7
builtin-rev-list.c
+1
-1
@@ -77,7 +77,7 @@ static void show_commit(struct commit *commit)
77
stdout);
78
else
79
fputs(sha1_to_hex(commit->object.sha1), stdout);
80
- if (revs.parents) {
80
+ if (revs.print_parents) {
81
struct commit_list *parents = commit->parents;
82
while (parents) {
83
printf(" %s", sha1_to_hex(parents->item->object.sha1));
log-tree.c
+2
-2
@@ -231,7 +231,7 @@ void show_log(struct rev_info *opt)
231
putchar('>');
232
}
233
fputs(diff_unique_abbrev(commit->object.sha1, abbrev_commit), stdout);
234
- if (opt->parents)
234
+ if (opt->print_parents)
235
show_parents(commit, abbrev_commit);
236
show_decorations(commit);
237
putchar(opt->diffopt.line_termination);
@@ -271,7 +271,7 @@ void show_log(struct rev_info *opt)
271
}
272
fputs(diff_unique_abbrev(commit->object.sha1, abbrev_commit),
273
stdout);
274
- if (opt->parents)
274
+ if (opt->print_parents)
275
show_parents(commit, abbrev_commit);
276
if (parent)
277
printf(" (from %s)",
revision.c
+4
-3
@@ -1105,7 +1105,8 @@ int setup_revisions(int argc, const char **argv, struct rev_info *revs, const ch
1105
}
1106
}
1107
if (!strcmp(arg, "--parents")) {
1108
- revs->parents = 1;
1108
+ revs->rewrite_parents = 1;
1109
+ revs->print_parents = 1;
1110
continue;
1111
}
1112
if (!strcmp(arg, "--dense")) {
@@ -1524,13 +1525,13 @@ enum commit_action simplify_commit(struct rev_info *revs, struct commit *commit)
1525
/* Commit without changes? */
1526
if (commit->object.flags & TREESAME) {
1527
/* drop merges unless we want parenthood */
1527
- if (!revs->parents)
1528
+ if (!revs->rewrite_parents)
1529
return commit_ignore;
1530
/* non-merge - always ignore it */
1531
if (!commit->parents || !commit->parents->next)
1532
return commit_ignore;
1533
}
1533
- if (revs->parents && rewrite_parents(revs, commit) < 0)
1534
+ if (revs->rewrite_parents && rewrite_parents(revs, commit) < 0)
1535
return commit_error;
1536
}
1537
return commit_show;
revision.h
+2
-1
@@ -46,7 +46,8 @@ struct rev_info {
46
unpacked:1, /* see also ignore_packed below */
47
boundary:2,
48
left_right:1,
49
- parents:1,
49
+ rewrite_parents:1,
50
+ print_parents:1,
51
reverse:1,
52
cherry_pick:1,
53
first_parent_only:1;