зеркало из https://github.com/microsoft/git.git
Merge branch 'jc/dotdot-is-parent-directory'
"git log .." errored out saying it is both rev range and a path when there is no disambiguating "--" is on the command line. Update the command line parser to interpret ".." as a path in such a case. * jc/dotdot-is-parent-directory: specifying ranges: we did not mean to make ".." an empty set
This commit is contained in:
Коммит
7764a3b35c
|
@ -213,6 +213,13 @@ of 'r1' and 'r2' and is defined as
|
||||||
It is the set of commits that are reachable from either one of
|
It is the set of commits that are reachable from either one of
|
||||||
'r1' or 'r2' but not from both.
|
'r1' or 'r2' but not from both.
|
||||||
|
|
||||||
|
In these two shorthands, you can omit one end and let it default to HEAD.
|
||||||
|
For example, 'origin..' is a shorthand for 'origin..HEAD' and asks "What
|
||||||
|
did I do since I forked from the origin branch?" Similarly, '..origin'
|
||||||
|
is a shorthand for 'HEAD..origin' and asks "What did the origin do since
|
||||||
|
I forked from them?" Note that '..' would mean 'HEAD..HEAD' which is an
|
||||||
|
empty range that is both reachable and unreachable from HEAD.
|
||||||
|
|
||||||
Two other shorthands for naming a set that is formed by a commit
|
Two other shorthands for naming a set that is formed by a commit
|
||||||
and its parent commits exist. The 'r1{caret}@' notation means all
|
and its parent commits exist. The 'r1{caret}@' notation means all
|
||||||
parents of 'r1'. 'r1{caret}!' includes commit 'r1' but excludes
|
parents of 'r1'. 'r1{caret}!' includes commit 'r1' but excludes
|
||||||
|
|
|
@ -230,6 +230,7 @@ static int try_difference(const char *arg)
|
||||||
const char *next;
|
const char *next;
|
||||||
const char *this;
|
const char *this;
|
||||||
int symmetric;
|
int symmetric;
|
||||||
|
static const char head_by_default[] = "HEAD";
|
||||||
|
|
||||||
if (!(dotdot = strstr(arg, "..")))
|
if (!(dotdot = strstr(arg, "..")))
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -241,9 +242,20 @@ static int try_difference(const char *arg)
|
||||||
next += symmetric;
|
next += symmetric;
|
||||||
|
|
||||||
if (!*next)
|
if (!*next)
|
||||||
next = "HEAD";
|
next = head_by_default;
|
||||||
if (dotdot == arg)
|
if (dotdot == arg)
|
||||||
this = "HEAD";
|
this = head_by_default;
|
||||||
|
|
||||||
|
if (this == head_by_default && next == head_by_default &&
|
||||||
|
!symmetric) {
|
||||||
|
/*
|
||||||
|
* Just ".."? That is not a range but the
|
||||||
|
* pathspec for the parent directory.
|
||||||
|
*/
|
||||||
|
*dotdot = '.';
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
if (!get_sha1_committish(this, sha1) && !get_sha1_committish(next, end)) {
|
if (!get_sha1_committish(this, sha1) && !get_sha1_committish(next, end)) {
|
||||||
show_rev(NORMAL, end, next);
|
show_rev(NORMAL, end, next);
|
||||||
show_rev(symmetric ? NORMAL : REVERSED, sha1, this);
|
show_rev(symmetric ? NORMAL : REVERSED, sha1, this);
|
||||||
|
|
16
revision.c
16
revision.c
|
@ -1134,15 +1134,27 @@ int handle_revision_arg(const char *arg_, struct rev_info *revs, int flags, unsi
|
||||||
const char *this = arg;
|
const char *this = arg;
|
||||||
int symmetric = *next == '.';
|
int symmetric = *next == '.';
|
||||||
unsigned int flags_exclude = flags ^ UNINTERESTING;
|
unsigned int flags_exclude = flags ^ UNINTERESTING;
|
||||||
|
static const char head_by_default[] = "HEAD";
|
||||||
unsigned int a_flags;
|
unsigned int a_flags;
|
||||||
|
|
||||||
*dotdot = 0;
|
*dotdot = 0;
|
||||||
next += symmetric;
|
next += symmetric;
|
||||||
|
|
||||||
if (!*next)
|
if (!*next)
|
||||||
next = "HEAD";
|
next = head_by_default;
|
||||||
if (dotdot == arg)
|
if (dotdot == arg)
|
||||||
this = "HEAD";
|
this = head_by_default;
|
||||||
|
if (this == head_by_default && next == head_by_default &&
|
||||||
|
!symmetric) {
|
||||||
|
/*
|
||||||
|
* Just ".."? That is not a range but the
|
||||||
|
* pathspec for the parent directory.
|
||||||
|
*/
|
||||||
|
if (!cant_be_filename) {
|
||||||
|
*dotdot = '.';
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
if (!get_sha1_committish(this, from_sha1) &&
|
if (!get_sha1_committish(this, from_sha1) &&
|
||||||
!get_sha1_committish(next, sha1)) {
|
!get_sha1_committish(next, sha1)) {
|
||||||
struct commit *a, *b;
|
struct commit *a, *b;
|
||||||
|
|
|
@ -182,4 +182,18 @@ test_expect_success '<commit>:file correctly diagnosed after a pathname' '
|
||||||
test_cmp expect actual
|
test_cmp expect actual
|
||||||
'
|
'
|
||||||
|
|
||||||
|
test_expect_success 'dotdot is not an empty set' '
|
||||||
|
( H=$(git rev-parse HEAD) && echo $H && echo ^$H ) >expect &&
|
||||||
|
|
||||||
|
git rev-parse HEAD.. >actual &&
|
||||||
|
test_cmp expect actual &&
|
||||||
|
|
||||||
|
git rev-parse ..HEAD >actual &&
|
||||||
|
test_cmp expect actual &&
|
||||||
|
|
||||||
|
echo .. >expect &&
|
||||||
|
git rev-parse .. >actual &&
|
||||||
|
test_cmp expect actual
|
||||||
|
'
|
||||||
|
|
||||||
test_done
|
test_done
|
||||||
|
|
|
@ -806,4 +806,11 @@ test_expect_success 'log --graph with diff and stats' '
|
||||||
test_i18ncmp expect actual.sanitized
|
test_i18ncmp expect actual.sanitized
|
||||||
'
|
'
|
||||||
|
|
||||||
|
test_expect_success 'dotdot is a parent directory' '
|
||||||
|
mkdir -p a/b &&
|
||||||
|
( echo sixth && echo fifth ) >expect &&
|
||||||
|
( cd a/b && git log --format=%s .. ) >actual &&
|
||||||
|
test_cmp expect actual
|
||||||
|
'
|
||||||
|
|
||||||
test_done
|
test_done
|
||||||
|
|
Загрузка…
Ссылка в новой задаче