diff options
author | Junio C Hamano <junkio@cox.net> | 2006-05-01 22:55:40 -0700 |
---|---|---|
committer | Junio C Hamano <junkio@cox.net> | 2006-05-01 22:55:40 -0700 |
commit | 746437d534a1fa84e210427a94972ed0c7f34ee5 (patch) | |
tree | 3ed4776ac36702873cc1299e066ed2f447d2d1f9 /revision.c | |
parent | cbd800ba7901dc89ce00930334eebf2b6b84cefb (diff) | |
parent | ea4a19e172e8db52779c06723b1e99cc12f228c9 (diff) | |
download | git-746437d534a1fa84e210427a94972ed0c7f34ee5.tar.gz git-746437d534a1fa84e210427a94972ed0c7f34ee5.tar.xz |
Merge branch 'jc/xsha1-2'
* jc/xsha1-2:
Extended SHA1 -- "rev^@" syntax to mean "all parents"
Diffstat (limited to 'revision.c')
-rw-r--r-- | revision.c | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/revision.c b/revision.c index b6ed0149a..ad78efda5 100644 --- a/revision.c +++ b/revision.c @@ -477,6 +477,36 @@ static void handle_all(struct rev_info *revs, unsigned flags) for_each_ref(handle_one_ref); } +static int add_parents_only(struct rev_info *revs, const char *arg, int flags) +{ + unsigned char sha1[20]; + struct object *it; + struct commit *commit; + struct commit_list *parents; + + if (*arg == '^') { + flags ^= UNINTERESTING; + arg++; + } + if (get_sha1(arg, sha1)) + return 0; + while (1) { + it = get_reference(revs, arg, sha1, 0); + if (strcmp(it->type, tag_type)) + break; + memcpy(sha1, ((struct tag*)it)->tagged->sha1, 20); + } + if (strcmp(it->type, commit_type)) + return 0; + commit = (struct commit *)it; + for (parents = commit->parents; parents; parents = parents->next) { + it = &parents->item->object; + it->flags |= flags; + add_pending_object(revs, it, arg); + } + return 1; +} + void init_revisions(struct rev_info *revs) { memset(revs, 0, sizeof(*revs)); @@ -751,6 +781,13 @@ int setup_revisions(int argc, const char **argv, struct rev_info *revs, const ch } *dotdot = '.'; } + dotdot = strstr(arg, "^@"); + if (dotdot && !dotdot[2]) { + *dotdot = 0; + if (add_parents_only(revs, arg, flags)) + continue; + *dotdot = '^'; + } local_flags = 0; if (*arg == '^') { local_flags = UNINTERESTING; |