git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [Annoyance] "git log .." thinks ".." is ambiguous
@ 2011-05-02 19:15 Junio C Hamano
  2011-05-02 19:33 ` Jeff King
                   ` (2 more replies)
  0 siblings, 3 replies; 19+ messages in thread
From: Junio C Hamano @ 2011-05-02 19:15 UTC (permalink / raw)
  To: git

Either end of revision range operator can be omitted to default to
HEAD, as in "origin.." (what did I do since I forked) or "..origin" (what
did they do since I forked).  But this resulted in ".." to be interpreted
as an empty range "HEAD..HEAD", and worse yet, because ".." does exist on
the filesystem, we get this annoying output:

  $ cd Documentation/howto
  $ git log .. ;# give me recent commits that touch Documentation/ area.
  fatal: ambiguous argument '..': both revision and filename
  Use '--' to separate filenames from revisions

Surely we could say "git log .. --", but we shouldn't have to.

---
 * I don't have very strong feeling about this, but just got annoyed
   enough to write this patch.  Should apply cleanly all the way down to
   at least 1.6.0 if not earlier.

 revision.c |   16 ++++++++++++++--
 1 files changed, 14 insertions(+), 2 deletions(-)

diff --git a/revision.c b/revision.c
index f4b8b38..26271d1 100644
--- a/revision.c
+++ b/revision.c
@@ -905,14 +905,26 @@ int handle_revision_arg(const char *arg, struct rev_info *revs,
 		const char *this = arg;
 		int symmetric = *next == '.';
 		unsigned int flags_exclude = flags ^ UNINTERESTING;
+		static const char head_by_default[] = "HEAD";
 
 		*dotdot = 0;
 		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)) {
 			struct commit *a, *b;

^ permalink raw reply related	[flat|nested] 19+ messages in thread

end of thread, other threads:[~2011-05-04 18:00 UTC | newest]

Thread overview: 19+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-05-02 19:15 [Annoyance] "git log .." thinks ".." is ambiguous Junio C Hamano
2011-05-02 19:33 ` Jeff King
2011-05-02 19:36   ` Jeff King
2011-05-02 20:36   ` Junio C Hamano
2011-05-02 20:42     ` Jeff King
2011-05-02 20:56     ` [PATCH v2] specifying ranges: we did not mean to make ".." an empty set Junio C Hamano
2011-05-02 21:01       ` Jeff King
2011-05-02 21:48         ` Junio C Hamano
2011-05-03  6:39         ` Michael J Gruber
2011-05-03 17:38           ` Junio C Hamano
2011-05-04  6:55             ` Michael J Gruber
2011-05-04 15:36               ` Junio C Hamano
2011-05-04 18:00                 ` Junio C Hamano
2011-05-03  1:57 ` [Annoyance] "git log .." thinks ".." is ambiguous Joshua Juran
2011-05-03  6:33   ` Michael J Gruber
2011-05-03  8:17     ` Joshua Juran
2011-05-03  8:45       ` Michael J Gruber
2011-05-03 19:00       ` Junio C Hamano
2011-05-03  8:38 ` John Szakmeister

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).