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. 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
c5ccd8be43df4b916752a176512a9adaf3b94df9
4 files changed
+23
git.c
+15
@@ -363,6 +363,20 @@ static int cmd_whatchanged(int ac, const char **av, char **ep)
363
return cmd_log_wc(ac, av, ep, &wcopt);
364
}
365
366
+static int cmd_show(int ac, const char **av, char **ep)
367
+{
368
+ struct whatchanged_opt wcopt;
369
+
370
+ memset(&wcopt, 0, sizeof(wcopt));
371
+ wcopt.do_diff = 1;
372
+ init_log_tree_opt(&wcopt.logopt);
373
+ wcopt.logopt.ignore_merges = 0;
374
+ wcopt.logopt.combine_merges = 1;
375
+ wcopt.logopt.dense_combined_merges = 1;
376
+ wcopt.logopt.diffopt.recursive = 1;
377
+ return cmd_log_wc(ac, av, ep, &wcopt);
378
+}
379
+
380
static void handle_internal_command(int argc, const char **argv, char **envp)
381
{
382
const char *cmd = argv[0];
@@ -373,6 +387,7 @@ static void handle_internal_command(int argc, const char **argv, char **envp)
387
{ "version", cmd_version },
388
{ "help", cmd_help },
389
{ "log", cmd_log },
390
+ { "show", cmd_show },
391
{ "whatchanged", cmd_whatchanged },
392
};
393
int i;
log-tree.c
+2
@@ -182,6 +182,8 @@ int parse_whatchanged_opt(int ac, const char **av, struct whatchanged_opt *wcopt
182
int left = 1;
183
184
ac = setup_revisions(ac, av, rev, "HEAD");
185
+ if (!strcmp(av[0], "show"))
186
+ rev->no_walk = 1;
187
while (1 < ac) {
188
const char *arg = av[1];
189
if (!strncmp(arg, "--pretty", 8)) {
revision.c
+5
@@ -375,6 +375,9 @@ static void add_parents_to_list(struct rev_info *revs, struct commit *commit, st
375
if (revs->prune_fn)
376
revs->prune_fn(revs, commit);
377
378
+ if (revs->no_walk)
379
+ return;
380
+
381
parent = commit->parents;
382
while (parent) {
383
struct commit *p = parent->item;
@@ -714,6 +717,8 @@ int setup_revisions(int argc, const char **argv, struct rev_info *revs, const ch
717
718
void prepare_revision_walk(struct rev_info *revs)
719
{
720
+ if (revs->no_walk)
721
+ return;
722
sort_by_date(&revs->commits);
723
if (revs->limited)
724
limit_list(revs);
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,