From: Junio C Hamano Date: Thu, 6 Oct 2016 21:53:10 +0000 (-0700) Subject: Merge branch 'vn/revision-shorthand-for-side-branch-log' X-Git-Tag: v2.11.0-rc0~81 X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/8c98a68981177013dfa0380968b57a1a37a45539?ds=inline;hp=-c Merge branch 'vn/revision-shorthand-for-side-branch-log' "git log rev^..rev" is an often-used revision range specification to show what was done on a side branch merged at rev. This has gained a short-hand "rev^-1". In general "rev^-$n" is the same as "^rev^$n rev", i.e. what has happened on other branches while the history leading to nth parent was looking the other way. * vn/revision-shorthand-for-side-branch-log: revision: new rev^-n shorthand for rev^n..rev --- 8c98a68981177013dfa0380968b57a1a37a45539 diff --combined revision.c index 969b3d149f,c141a398ac..b37dbec378 --- a/revision.c +++ b/revision.c @@@ -1275,7 -1275,7 +1275,7 @@@ void add_index_objects_to_pending(struc if (S_ISGITLINK(ce->ce_mode)) continue; - blob = lookup_blob(ce->sha1); + blob = lookup_blob(ce->oid.hash); if (!blob) die("unable to add index blob to traversal"); add_pending_object_with_path(revs, &blob->object, "", @@@ -1289,12 -1289,14 +1289,14 @@@ } } - static int add_parents_only(struct rev_info *revs, const char *arg_, int flags) + static int add_parents_only(struct rev_info *revs, const char *arg_, int flags, + int exclude_parent) { unsigned char sha1[20]; struct object *it; struct commit *commit; struct commit_list *parents; + int parent_number; const char *arg = arg_; if (*arg == '^') { @@@ -1316,7 -1318,15 +1318,15 @@@ if (it->type != OBJ_COMMIT) return 0; commit = (struct commit *)it; - for (parents = commit->parents; parents; parents = parents->next) { + if (exclude_parent && + exclude_parent > commit_list_count(commit->parents)) + return 0; + for (parents = commit->parents, parent_number = 1; + parents; + parents = parents->next, parent_number++) { + if (exclude_parent && parent_number != exclude_parent) + continue; + it = &parents->item->object; it->flags |= flags; add_rev_cmdline(revs, it, arg_, REV_CMD_PARENTS_ONLY, flags); @@@ -1519,17 -1529,33 +1529,33 @@@ int handle_revision_arg(const char *arg } *dotdot = '.'; } + dotdot = strstr(arg, "^@"); if (dotdot && !dotdot[2]) { *dotdot = 0; - if (add_parents_only(revs, arg, flags)) + if (add_parents_only(revs, arg, flags, 0)) return 0; *dotdot = '^'; } dotdot = strstr(arg, "^!"); if (dotdot && !dotdot[2]) { *dotdot = 0; - if (!add_parents_only(revs, arg, flags ^ (UNINTERESTING | BOTTOM))) + if (!add_parents_only(revs, arg, flags ^ (UNINTERESTING | BOTTOM), 0)) + *dotdot = '^'; + } + dotdot = strstr(arg, "^-"); + if (dotdot) { + int exclude_parent = 1; + + if (dotdot[2]) { + char *end; + exclude_parent = strtoul(dotdot + 2, &end, 10); + if (*end != '\0' || !exclude_parent) + return -1; + } + + *dotdot = 0; + if (!add_parents_only(revs, arg, flags ^ (UNINTERESTING | BOTTOM), exclude_parent)) *dotdot = '^'; }