@matheusbsbs / matheus-bagliano / commits / 3131b71301
Fork 0

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>

Linus Torvalds committed Feb 9, 2008 at 14:02 UTC 3131b713013f06285cad3ffdcc61f417ac4ba158
4 files changed +33 -7
builtin-rev-list.c
+3 -1
@@ -60,6 +60,8 @@ static void show_commit(struct commit *commit)
60 fputs(header_prefix, stdout);
61 if (commit->object.flags & BOUNDARY)
62 putchar('-');
63 + else if (commit->object.flags & UNINTERESTING)
64 + putchar('^');
65 else if (revs.left_right) {
66 if (commit->object.flags & SYMMETRIC_LEFT)
67 putchar('<');
@@ -84,7 +86,7 @@ static void show_commit(struct commit *commit)
86 else
87 putchar('\n');
88
87 - if (revs.verbose_header) {
89 + if (revs.verbose_header && commit->buffer) {
90 struct strbuf buf;
91 strbuf_init(&buf, 0);
92 pretty_print_commit(revs.commit_format, commit,
log-tree.c
+11 -4
@@ -149,10 +149,12 @@ void show_log(struct rev_info *opt, const char *sep)
149
150 opt->loginfo = NULL;
151 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)
158 putchar('<');
159 else
160 putchar('>');
@@ -250,6 +252,8 @@ void show_log(struct rev_info *opt, const char *sep)
252 fputs("commit ", stdout);
253 if (commit->object.flags & BOUNDARY)
254 putchar('-');
255 + else if (commit->object.flags & UNINTERESTING)
256 + putchar('^');
257 else if (opt->left_right) {
258 if (commit->object.flags & SYMMETRIC_LEFT)
259 putchar('<');
@@ -278,6 +282,9 @@ void show_log(struct rev_info *opt, const char *sep)
282 }
283 }
284
285 + if (!commit->buffer)
286 + return;
287 +
288 /*
289 * And then the pretty-printed message itself
290 */
revision.c
+18 -2
@@ -558,6 +558,12 @@ static void cherry_pick_list(struct commit_list *list, struct rev_info *revs)
558 free_patch_ids(&ids);
559 }
560
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 +
567 static int limit_list(struct rev_info *revs)
568 {
569 struct commit_list *list = revs->commits;
@@ -579,9 +585,13 @@ static int limit_list(struct rev_info *revs)
585 return -1;
586 if (obj->flags & UNINTERESTING) {
587 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);
591 break;
584 - continue;
592 + }
593 + if (!revs->show_all)
594 + continue;
595 }
596 if (revs->min_age != -1 && (commit->date > revs->min_age))
597 continue;
@@ -1055,6 +1065,10 @@ int setup_revisions(int argc, const char **argv, struct rev_info *revs, const ch
1065 revs->dense = 0;
1066 continue;
1067 }
1068 + if (!strcmp(arg, "--show-all")) {
1069 + revs->show_all = 1;
1070 + continue;
1071 + }
1072 if (!strcmp(arg, "--remove-empty")) {
1073 revs->remove_empty_trees = 1;
1074 continue;
@@ -1438,6 +1452,8 @@ enum commit_action simplify_commit(struct rev_info *revs, struct commit *commit)
1452 return commit_ignore;
1453 if (revs->unpacked && has_sha1_pack(commit->object.sha1, revs->ignore_packed))
1454 return commit_ignore;
1455 + if (revs->show_all)
1456 + return commit_show;
1457 if (commit->object.flags & UNINTERESTING)
1458 return commit_ignore;
1459 if (revs->min_age != -1 && (commit->date > revs->min_age))
revision.h
+1
@@ -33,6 +33,7 @@ struct rev_info {
33 prune:1,
34 no_merges:1,
35 no_walk:1,
36 + show_all:1,
37 remove_empty_trees:1,
38 simplify_history:1,
39 lifo:1,