@matheusbsbs / matheus-bagliano / commits / ba1d45051e
Fork 0

Tentative built-in "git show"

This uses the "--no-walk" flag that I never actually implemented (but I'm sure I mentioned it) to make "git show" be essentially the same thing as "git whatchanged --no-walk". It just refuses to add more interesting parents to the revision walking history, so you don't actually get any history, you just get the commit you asked for. I was going to add "--no-walk" as a real argument flag to git-rev-list too, but I'm not sure anybody actually needs it. Although it might be useful for porcelain, so I left the door open. [jc: ported to the unified option structure by Linus] Signed-off-by: Linus Torvalds <torvalds@osdl.org> Signed-off-by: Junio C Hamano <junkio@cox.net>

Linus Torvalds committed Apr 15, 2006 at 12:09 UTC ba1d45051e050cbcf68ccccacea86a4b6ecde731
3 files changed +24
git.c
+18
@@ -354,6 +354,23 @@ static int cmd_wc(int argc, const char **argv, char **envp)
354 return cmd_log_wc(argc, argv, envp, &rev);
355 }
356
357 +static int cmd_show(int argc, const char **argv, char **envp)
358 +{
359 + struct rev_info rev;
360 +
361 + init_revisions(&rev);
362 + rev.diff = 1;
363 + rev.ignore_merges = 0;
364 + rev.combine_merges = 1;
365 + rev.dense_combined_merges = 1;
366 + rev.abbrev = DEFAULT_ABBREV;
367 + rev.commit_format = CMIT_FMT_DEFAULT;
368 + rev.diffopt.recursive = 1;
369 + rev.no_walk = 1;
370 + argc = setup_revisions(argc, argv, &rev, "HEAD");
371 + return cmd_log_wc(argc, argv, envp, &rev);
372 +}
373 +
374 static int cmd_log(int argc, const char **argv, char **envp)
375 {
376 struct rev_info rev;
@@ -377,6 +394,7 @@ static void handle_internal_command(int argc, const char **argv, char **envp)
394 { "help", cmd_help },
395 { "log", cmd_log },
396 { "whatchanged", cmd_wc },
397 + { "show", cmd_show },
398 };
399 int i;
400
revision.c
+5
@@ -380,6 +380,9 @@ static void add_parents_to_list(struct rev_info *revs, struct commit *commit, st
380 if (revs->prune_fn)
381 revs->prune_fn(revs, commit);
382
383 + if (revs->no_walk)
384 + return;
385 +
386 parent = commit->parents;
387 while (parent) {
388 struct commit *p = parent->item;
@@ -816,6 +819,8 @@ void prepare_revision_walk(struct rev_info *revs)
819 list = list->next;
820 }
821
822 + if (revs->no_walk)
823 + return;
824 if (revs->limited)
825 limit_list(revs);
826 if (revs->topo_order)
revision.h
+1
@@ -26,6 +26,7 @@ struct rev_info {
26 /* Traversal flags */
27 unsigned int dense:1,
28 no_merges:1,
29 + no_walk:1,
30 remove_empty_trees:1,
31 lifo:1,
32 topo_order:1,