revision: new rev^-n shorthand for rev^n..rev
"git log rev^..rev" is commonly used to show all work done on and merged from a side branch. This patch introduces a shorthand "rev^-" for this and additionally allows "rev^-$n" to mean "reachable from rev, excluding what is reachable from the nth parent of rev". For example, for a two-parent merge, you can use rev^-2 to get the set of commits which were made to the main branch while the topic branch was prepared. Signed-off-by: Vegard Nossum <vegard.nossum@oracle.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:

committed by
Junio C Hamano

parent
7c0304af62
commit
8779351dd7
@ -298,14 +298,30 @@ static int try_parent_shorthands(const char *arg)
|
||||
unsigned char sha1[20];
|
||||
struct commit *commit;
|
||||
struct commit_list *parents;
|
||||
int parents_only;
|
||||
int parent_number;
|
||||
int include_rev = 0;
|
||||
int include_parents = 0;
|
||||
int exclude_parent = 0;
|
||||
|
||||
if ((dotdot = strstr(arg, "^!")))
|
||||
parents_only = 0;
|
||||
else if ((dotdot = strstr(arg, "^@")))
|
||||
parents_only = 1;
|
||||
if ((dotdot = strstr(arg, "^!"))) {
|
||||
include_rev = 1;
|
||||
if (dotdot[2])
|
||||
return 0;
|
||||
} else if ((dotdot = strstr(arg, "^@"))) {
|
||||
include_parents = 1;
|
||||
if (dotdot[2])
|
||||
return 0;
|
||||
} else if ((dotdot = strstr(arg, "^-"))) {
|
||||
include_rev = 1;
|
||||
exclude_parent = 1;
|
||||
|
||||
if (!dotdot || dotdot[2])
|
||||
if (dotdot[2]) {
|
||||
char *end;
|
||||
exclude_parent = strtoul(dotdot + 2, &end, 10);
|
||||
if (*end != '\0' || !exclude_parent)
|
||||
return 0;
|
||||
}
|
||||
} else
|
||||
return 0;
|
||||
|
||||
*dotdot = 0;
|
||||
@ -314,12 +330,24 @@ static int try_parent_shorthands(const char *arg)
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!parents_only)
|
||||
show_rev(NORMAL, sha1, arg);
|
||||
commit = lookup_commit_reference(sha1);
|
||||
for (parents = commit->parents; parents; parents = parents->next)
|
||||
show_rev(parents_only ? NORMAL : REVERSED,
|
||||
parents->item->object.oid.hash, arg);
|
||||
if (exclude_parent &&
|
||||
exclude_parent > commit_list_count(commit->parents)) {
|
||||
*dotdot = '^';
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (include_rev)
|
||||
show_rev(NORMAL, sha1, arg);
|
||||
for (parents = commit->parents, parent_number = 1;
|
||||
parents;
|
||||
parents = parents->next, parent_number++) {
|
||||
if (exclude_parent && parent_number != exclude_parent)
|
||||
continue;
|
||||
|
||||
show_rev(include_parents ? NORMAL : REVERSED,
|
||||
parents->item->object.oid.hash, arg);
|
||||
}
|
||||
|
||||
*dotdot = '^';
|
||||
return 1;
|
||||
|
Reference in New Issue
Block a user