Skip to content

Commit

Permalink
Tentative built-in "git show"
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Linus Torvalds authored and Junio C Hamano committed Apr 16, 2006
1 parent 5b84f4d commit ba1d450
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 0 deletions.
18 changes: 18 additions & 0 deletions git.c
Original file line number Diff line number Diff line change
Expand Up @@ -354,6 +354,23 @@ static int cmd_wc(int argc, const char **argv, char **envp)
return cmd_log_wc(argc, argv, envp, &rev);
}

static int cmd_show(int argc, const char **argv, char **envp)
{
struct rev_info rev;

init_revisions(&rev);
rev.diff = 1;
rev.ignore_merges = 0;
rev.combine_merges = 1;
rev.dense_combined_merges = 1;
rev.abbrev = DEFAULT_ABBREV;
rev.commit_format = CMIT_FMT_DEFAULT;
rev.diffopt.recursive = 1;
rev.no_walk = 1;
argc = setup_revisions(argc, argv, &rev, "HEAD");
return cmd_log_wc(argc, argv, envp, &rev);
}

static int cmd_log(int argc, const char **argv, char **envp)
{
struct rev_info rev;
Expand All @@ -377,6 +394,7 @@ static void handle_internal_command(int argc, const char **argv, char **envp)
{ "help", cmd_help },
{ "log", cmd_log },
{ "whatchanged", cmd_wc },
{ "show", cmd_show },
};
int i;

Expand Down
5 changes: 5 additions & 0 deletions revision.c
Original file line number Diff line number Diff line change
Expand Up @@ -380,6 +380,9 @@ static void add_parents_to_list(struct rev_info *revs, struct commit *commit, st
if (revs->prune_fn)
revs->prune_fn(revs, commit);

if (revs->no_walk)
return;

parent = commit->parents;
while (parent) {
struct commit *p = parent->item;
Expand Down Expand Up @@ -816,6 +819,8 @@ void prepare_revision_walk(struct rev_info *revs)
list = list->next;
}

if (revs->no_walk)
return;
if (revs->limited)
limit_list(revs);
if (revs->topo_order)
Expand Down
1 change: 1 addition & 0 deletions revision.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ struct rev_info {
/* Traversal flags */
unsigned int dense:1,
no_merges:1,
no_walk:1,
remove_empty_trees:1,
lifo:1,
topo_order:1,
Expand Down

0 comments on commit ba1d450

Please sign in to comment.