From: Junio C Hamano Date: Fri, 7 Sep 2012 18:09:18 +0000 (-0700) Subject: Merge branch 'jc/dotdot-is-parent-directory' X-Git-Tag: v1.8.0-rc0~94 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=7764a3b35c53b6859963ddad92bfc90563ac8baa;p=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 --- 7764a3b35c53b6859963ddad92bfc90563ac8baa diff --cc builtin/rev-parse.c index bb3a5161b,47b4e7adb..f267a1d3b --- a/builtin/rev-parse.c +++ b/builtin/rev-parse.c @@@ -241,10 -236,21 +242,21 @@@ static int try_difference(const char *a next += symmetric; if (!*next) - next = "HEAD"; + next = head_by_default; 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(this, sha1) && !get_sha1(next, end)) { + if (!get_sha1_committish(this, sha1) && !get_sha1_committish(next, end)) { show_rev(NORMAL, end, next); show_rev(symmetric ? NORMAL : REVERSED, sha1, this); if (symmetric) { diff --cc revision.c index 442a94523,457868d64..cbcae1086 --- a/revision.c +++ b/revision.c @@@ -1140,11 -1139,22 +1141,22 @@@ int handle_revision_arg(const char *arg next += symmetric; if (!*next) - next = "HEAD"; + next = head_by_default; 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(this, from_sha1) && - !get_sha1(next, sha1)) { + if (!get_sha1_committish(this, from_sha1) && + !get_sha1_committish(next, sha1)) { struct commit *a, *b; struct commit_list *exclude; diff --cc t/t4202-log.sh index 31869dc0d,45058cc8c..0baaad2a2 --- a/t/t4202-log.sh +++ b/t/t4202-log.sh @@@ -803,7 -803,14 +803,14 @@@ sanitize_output () test_expect_success 'log --graph with diff and stats' ' git log --graph --pretty=short --stat -p >actual && sanitize_output >actual.sanitized expect && + ( cd a/b && git log --format=%s .. ) >actual && + test_cmp expect actual + ' + test_done