Add "--show-all" revision walker flag for debugging

It's really not very easy to visualize the commit walker, because - on
purpose - it obvously doesn't show the uninteresting commits!

This adds a "--show-all" flag to the revision walker, which will make
it show uninteresting commits too, and they'll have a '^' in front of
them (it also fixes a logic error for !verbose_header for boundary
commits - we should show the '-' even if left_right isn't shown).

A separate patch to gitk to teach it the new '^' was sent
to paulus.  With the change in place, it actually is interesting
even for the cases that git doesn't have any problems with, ie
for the kernel you can do:

	gitk -d --show-all v2.6.24..

and you see just how far down it has to parse things to see it all. The
use of "-d" is a good idea, since the date-ordered toposort is much better
at showing why it goes deep down (ie the date of some of those commits
after 2.6.24 is much older, because they were merged from trees that
weren't rebased).

So I think this is a useful feature even for non-debugging - just to
visualize what git does internally more.

When it actually breaks out due to the "everybody_uninteresting()"
case, it adds the uninteresting commits (both the one it's looking at
now, and the list of pending ones) to the list

This way, we really list *all* the commits we've looked at.

Because we now end up listing commits we may not even have been parsed
at all "show_log" and "show_commit" need to protect against commits
that don't have a commit buffer entry.

That second part is debatable just how it should work. Maybe we shouldn't
show such entries at all (with this patch those entries do get shown, they
just don't get any message shown with them). But I think this is a useful
case.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Linus Torvalds 2008-02-09 14:02:07 -08:00 коммит произвёл Junio C Hamano
Родитель aa8d53ec38
Коммит 3131b71301
4 изменённых файлов: 33 добавлений и 7 удалений

Просмотреть файл

@ -60,6 +60,8 @@ static void show_commit(struct commit *commit)
fputs(header_prefix, stdout); fputs(header_prefix, stdout);
if (commit->object.flags & BOUNDARY) if (commit->object.flags & BOUNDARY)
putchar('-'); putchar('-');
else if (commit->object.flags & UNINTERESTING)
putchar('^');
else if (revs.left_right) { else if (revs.left_right) {
if (commit->object.flags & SYMMETRIC_LEFT) if (commit->object.flags & SYMMETRIC_LEFT)
putchar('<'); putchar('<');
@ -84,7 +86,7 @@ static void show_commit(struct commit *commit)
else else
putchar('\n'); putchar('\n');
if (revs.verbose_header) { if (revs.verbose_header && commit->buffer) {
struct strbuf buf; struct strbuf buf;
strbuf_init(&buf, 0); strbuf_init(&buf, 0);
pretty_print_commit(revs.commit_format, commit, pretty_print_commit(revs.commit_format, commit,

Просмотреть файл

@ -149,10 +149,12 @@ void show_log(struct rev_info *opt, const char *sep)
opt->loginfo = NULL; opt->loginfo = NULL;
if (!opt->verbose_header) { if (!opt->verbose_header) {
if (opt->left_right) { if (commit->object.flags & BOUNDARY)
if (commit->object.flags & BOUNDARY) putchar('-');
putchar('-'); else if (commit->object.flags & UNINTERESTING)
else if (commit->object.flags & SYMMETRIC_LEFT) putchar('^');
else if (opt->left_right) {
if (commit->object.flags & SYMMETRIC_LEFT)
putchar('<'); putchar('<');
else else
putchar('>'); putchar('>');
@ -250,6 +252,8 @@ void show_log(struct rev_info *opt, const char *sep)
fputs("commit ", stdout); fputs("commit ", stdout);
if (commit->object.flags & BOUNDARY) if (commit->object.flags & BOUNDARY)
putchar('-'); putchar('-');
else if (commit->object.flags & UNINTERESTING)
putchar('^');
else if (opt->left_right) { else if (opt->left_right) {
if (commit->object.flags & SYMMETRIC_LEFT) if (commit->object.flags & SYMMETRIC_LEFT)
putchar('<'); putchar('<');
@ -278,6 +282,9 @@ void show_log(struct rev_info *opt, const char *sep)
} }
} }
if (!commit->buffer)
return;
/* /*
* And then the pretty-printed message itself * And then the pretty-printed message itself
*/ */

Просмотреть файл

@ -558,6 +558,12 @@ static void cherry_pick_list(struct commit_list *list, struct rev_info *revs)
free_patch_ids(&ids); free_patch_ids(&ids);
} }
static void add_to_list(struct commit_list **p, struct commit *commit, struct commit_list *n)
{
p = &commit_list_insert(commit, p)->next;
*p = n;
}
static int limit_list(struct rev_info *revs) static int limit_list(struct rev_info *revs)
{ {
struct commit_list *list = revs->commits; struct commit_list *list = revs->commits;
@ -579,9 +585,13 @@ static int limit_list(struct rev_info *revs)
return -1; return -1;
if (obj->flags & UNINTERESTING) { if (obj->flags & UNINTERESTING) {
mark_parents_uninteresting(commit); mark_parents_uninteresting(commit);
if (everybody_uninteresting(list)) if (everybody_uninteresting(list)) {
if (revs->show_all)
add_to_list(p, commit, list);
break; break;
continue; }
if (!revs->show_all)
continue;
} }
if (revs->min_age != -1 && (commit->date > revs->min_age)) if (revs->min_age != -1 && (commit->date > revs->min_age))
continue; continue;
@ -1055,6 +1065,10 @@ int setup_revisions(int argc, const char **argv, struct rev_info *revs, const ch
revs->dense = 0; revs->dense = 0;
continue; continue;
} }
if (!strcmp(arg, "--show-all")) {
revs->show_all = 1;
continue;
}
if (!strcmp(arg, "--remove-empty")) { if (!strcmp(arg, "--remove-empty")) {
revs->remove_empty_trees = 1; revs->remove_empty_trees = 1;
continue; continue;
@ -1438,6 +1452,8 @@ enum commit_action simplify_commit(struct rev_info *revs, struct commit *commit)
return commit_ignore; return commit_ignore;
if (revs->unpacked && has_sha1_pack(commit->object.sha1, revs->ignore_packed)) if (revs->unpacked && has_sha1_pack(commit->object.sha1, revs->ignore_packed))
return commit_ignore; return commit_ignore;
if (revs->show_all)
return commit_show;
if (commit->object.flags & UNINTERESTING) if (commit->object.flags & UNINTERESTING)
return commit_ignore; return commit_ignore;
if (revs->min_age != -1 && (commit->date > revs->min_age)) if (revs->min_age != -1 && (commit->date > revs->min_age))

Просмотреть файл

@ -33,6 +33,7 @@ struct rev_info {
prune:1, prune:1,
no_merges:1, no_merges:1,
no_walk:1, no_walk:1,
show_all:1,
remove_empty_trees:1, remove_empty_trees:1,
simplify_history:1, simplify_history:1,
lifo:1, lifo:1,