Skip to content

Commit 3131b71

Browse files
torvaldsgitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent aa8d53e commit 3131b71

File tree

4 files changed

+33
-7
lines changed

4 files changed

+33
-7
lines changed

builtin-rev-list.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,8 @@ static void show_commit(struct commit *commit)
6060
fputs(header_prefix, stdout);
6161
if (commit->object.flags & BOUNDARY)
6262
putchar('-');
63+
else if (commit->object.flags & UNINTERESTING)
64+
putchar('^');
6365
else if (revs.left_right) {
6466
if (commit->object.flags & SYMMETRIC_LEFT)
6567
putchar('<');
@@ -84,7 +86,7 @@ static void show_commit(struct commit *commit)
8486
else
8587
putchar('\n');
8688

87-
if (revs.verbose_header) {
89+
if (revs.verbose_header && commit->buffer) {
8890
struct strbuf buf;
8991
strbuf_init(&buf, 0);
9092
pretty_print_commit(revs.commit_format, commit,

log-tree.c

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -149,10 +149,12 @@ void show_log(struct rev_info *opt, const char *sep)
149149

150150
opt->loginfo = NULL;
151151
if (!opt->verbose_header) {
152-
if (opt->left_right) {
153-
if (commit->object.flags & BOUNDARY)
154-
putchar('-');
155-
else if (commit->object.flags & SYMMETRIC_LEFT)
152+
if (commit->object.flags & BOUNDARY)
153+
putchar('-');
154+
else if (commit->object.flags & UNINTERESTING)
155+
putchar('^');
156+
else if (opt->left_right) {
157+
if (commit->object.flags & SYMMETRIC_LEFT)
156158
putchar('<');
157159
else
158160
putchar('>');
@@ -250,6 +252,8 @@ void show_log(struct rev_info *opt, const char *sep)
250252
fputs("commit ", stdout);
251253
if (commit->object.flags & BOUNDARY)
252254
putchar('-');
255+
else if (commit->object.flags & UNINTERESTING)
256+
putchar('^');
253257
else if (opt->left_right) {
254258
if (commit->object.flags & SYMMETRIC_LEFT)
255259
putchar('<');
@@ -278,6 +282,9 @@ void show_log(struct rev_info *opt, const char *sep)
278282
}
279283
}
280284

285+
if (!commit->buffer)
286+
return;
287+
281288
/*
282289
* And then the pretty-printed message itself
283290
*/

revision.c

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -558,6 +558,12 @@ static void cherry_pick_list(struct commit_list *list, struct rev_info *revs)
558558
free_patch_ids(&ids);
559559
}
560560

561+
static void add_to_list(struct commit_list **p, struct commit *commit, struct commit_list *n)
562+
{
563+
p = &commit_list_insert(commit, p)->next;
564+
*p = n;
565+
}
566+
561567
static int limit_list(struct rev_info *revs)
562568
{
563569
struct commit_list *list = revs->commits;
@@ -579,9 +585,13 @@ static int limit_list(struct rev_info *revs)
579585
return -1;
580586
if (obj->flags & UNINTERESTING) {
581587
mark_parents_uninteresting(commit);
582-
if (everybody_uninteresting(list))
588+
if (everybody_uninteresting(list)) {
589+
if (revs->show_all)
590+
add_to_list(p, commit, list);
583591
break;
584-
continue;
592+
}
593+
if (!revs->show_all)
594+
continue;
585595
}
586596
if (revs->min_age != -1 && (commit->date > revs->min_age))
587597
continue;
@@ -1055,6 +1065,10 @@ int setup_revisions(int argc, const char **argv, struct rev_info *revs, const ch
10551065
revs->dense = 0;
10561066
continue;
10571067
}
1068+
if (!strcmp(arg, "--show-all")) {
1069+
revs->show_all = 1;
1070+
continue;
1071+
}
10581072
if (!strcmp(arg, "--remove-empty")) {
10591073
revs->remove_empty_trees = 1;
10601074
continue;
@@ -1438,6 +1452,8 @@ enum commit_action simplify_commit(struct rev_info *revs, struct commit *commit)
14381452
return commit_ignore;
14391453
if (revs->unpacked && has_sha1_pack(commit->object.sha1, revs->ignore_packed))
14401454
return commit_ignore;
1455+
if (revs->show_all)
1456+
return commit_show;
14411457
if (commit->object.flags & UNINTERESTING)
14421458
return commit_ignore;
14431459
if (revs->min_age != -1 && (commit->date > revs->min_age))

revision.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ struct rev_info {
3333
prune:1,
3434
no_merges:1,
3535
no_walk:1,
36+
show_all:1,
3637
remove_empty_trees:1,
3738
simplify_history:1,
3839
lifo:1,

0 commit comments

Comments
 (0)