git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* log/show: relative pathnames do not work in rev:path
@ 2007-12-18 17:33 Alex Riesen
  2007-12-18 17:50 ` Jakub Narebski
  0 siblings, 1 reply; 43+ messages in thread
From: Alex Riesen @ 2007-12-18 17:33 UTC (permalink / raw
  To: git

Noticed by a collegue of mine. Consider:

    $ cd $GIT/t
    $ git show 570f32266:t/test-lib.sh    # works
    $ git show 570f32266:test-lib.sh      # does not work
    $ git show 570f32266:./test-lib.sh    # does not work
    $ git show 570f32266:/t/test-lib.sh   # does not work

Considering that the relative path names work as filters (and many
agreed on that being useful), it would be nice to allow relative
pathnames in blob specifications for git-show and git-cat-file.

(besides the colon is a good delimiter, even tab-completion works with it)

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

* Re: log/show: relative pathnames do not work in rev:path
  2007-12-18 17:33 log/show: relative pathnames do not work in rev:path Alex Riesen
@ 2007-12-18 17:50 ` Jakub Narebski
  2007-12-18 20:46   ` Alex Riesen
  0 siblings, 1 reply; 43+ messages in thread
From: Jakub Narebski @ 2007-12-18 17:50 UTC (permalink / raw
  To: Alex Riesen; +Cc: git

Alex Riesen <raa.lkml@gmail.com> writes:

> Noticed by a collegue of mine. Consider:
> 
>     $ cd $GIT/t
>     $ git show 570f32266:t/test-lib.sh    # works
>     $ git show 570f32266:test-lib.sh      # does not work
>     $ git show 570f32266:./test-lib.sh    # does not work
>     $ git show 570f32266:/t/test-lib.sh   # does not work
> 
> Considering that the relative path names work as filters (and many
> agreed on that being useful), it would be nice to allow relative
> pathnames in blob specifications for git-show and git-cat-file.
> 
> (besides the colon is a good delimiter, even tab-completion works with it)

If you think about it a bit, relative path names nor absolute
path names does and should not work.  570f32266:t/test-lib.sh
means path t/test-lib.sh staring from 570f32266^{tree}.  Where
you are in the filesystem is not important and matters not for
this syntax.  Besides if you access other branch file might be
not in filesystem (deleted file, or disjoint branch with separate
contents like 'todo' or 'html' branch in git.git repository).

Besides,

    $ git show 570f32266:t/test-lib.sh    # works
    $ git show cc5ac8b72:test-lib.sh      # also works

works... but 49d8bcd7a2df5 here is SHA-1 id of a 't/' tree
(shortened output of "git rev-parse 570f32266:t").

And I think that with bash-completion from contrib you complete
correct pathnames; don't rely on filesystem pathnames completion.

-- 
Jakub Narebski
Poland
ShadeHawk on #git

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

* Re: log/show: relative pathnames do not work in rev:path
  2007-12-18 17:50 ` Jakub Narebski
@ 2007-12-18 20:46   ` Alex Riesen
  2007-12-18 20:47     ` [PATCH] Simple support for tree entry specification with relative pathnames Alex Riesen
  2007-12-18 21:24     ` log/show: relative pathnames do not work in rev:path Jakub Narebski
  0 siblings, 2 replies; 43+ messages in thread
From: Alex Riesen @ 2007-12-18 20:46 UTC (permalink / raw
  To: Jakub Narebski; +Cc: git, Junio C Hamano, Johannes Schindelin, Linus Torvalds

Jakub Narebski, Tue, Dec 18, 2007 18:50:20 +0100:
> Alex Riesen <raa.lkml@gmail.com> writes:
> 
> > Noticed by a collegue of mine. Consider:
> > 
> >     $ cd $GIT/t
> >     $ git show 570f32266:t/test-lib.sh    # works
> >     $ git show 570f32266:test-lib.sh      # does not work
> >     $ git show 570f32266:./test-lib.sh    # does not work
> >     $ git show 570f32266:/t/test-lib.sh   # does not work
> > 
> > Considering that the relative path names work as filters (and many
> > agreed on that being useful), it would be nice to allow relative
> > pathnames in blob specifications for git-show and git-cat-file.
> > 
> > (besides the colon is a good delimiter, even tab-completion works with it)
> 
> If you think about it a bit, relative path names nor absolute
> path names does and should not work.  570f32266:t/test-lib.sh
> means path t/test-lib.sh staring from 570f32266^{tree}.  Where
> you are in the filesystem is not important and matters not for
> this syntax.  Besides if you access other branch file might be
> not in filesystem (deleted file, or disjoint branch with separate
> contents like 'todo' or 'html' branch in git.git repository).

Not convinced. It is *not* the plumbing problem I was trying to
describe. They discussion, metaphorically, should not have left the
command-line parser.

I think that we have parsing of the blob locators at the wrong level:
so that git-show, git-log and git-diff can handle its pathnames as
they handle path filters (relative to cwd), and git-cat-file,
git-diff-tree, git-rev-list, etc can handle theirs always relative to
the project root.

I actually do not see any problem for git-show (being porcelain-level
program) to treat *each and every* path anywhere relatively to the
current directory. It is just more comfortable.

Please consider the following patches.

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

* [PATCH] Simple support for tree entry specification with relative pathnames
  2007-12-18 20:46   ` Alex Riesen
@ 2007-12-18 20:47     ` Alex Riesen
  2007-12-18 20:49       ` [PATCH] Introduce pathexpand: syntax-level chdir into the given cwd Alex Riesen
  2007-12-18 21:03       ` [PATCH] Simple support for tree entry specification with relative pathnames Dana How
  2007-12-18 21:24     ` log/show: relative pathnames do not work in rev:path Jakub Narebski
  1 sibling, 2 replies; 43+ messages in thread
From: Alex Riesen @ 2007-12-18 20:47 UTC (permalink / raw
  To: Jakub Narebski; +Cc: git, Junio C Hamano, Johannes Schindelin, Linus Torvalds

This allows git show to understand something like this:

    $ test -f DIR/file && cd DIR &&  git show rev:file

Signed-off-by: Alex Riesen <raa.lkml@gmail.com>
---

This is a bit too simplistic and can be fooled easily:

    .../t$ git show HEAD:../t/test-lib.sh

wont work. It is short, though.

 cache.h     |    1 +
 revision.c  |    4 ++--
 sha1_name.c |   27 ++++++++++++++++++++++++---
 3 files changed, 27 insertions(+), 5 deletions(-)

diff --git a/cache.h b/cache.h
index 39331c2..054f106 100644
--- a/cache.h
+++ b/cache.h
@@ -416,6 +416,7 @@ static inline unsigned int hexval(unsigned char c)
 
 extern int get_sha1(const char *str, unsigned char *sha1);
 extern int get_sha1_with_mode(const char *str, unsigned char *sha1, unsigned *mode);
+extern int get_sha1_with_prefix(const char *prefix, const char *name, unsigned char *sha1, unsigned *mode);
 extern int get_sha1_hex(const char *hex, unsigned char *sha1);
 extern char *sha1_to_hex(const unsigned char *sha1);	/* static buffer result! */
 extern int read_ref(const char *filename, unsigned char *sha1);
diff --git a/revision.c b/revision.c
index 7e2f4f1..cac283c 100644
--- a/revision.c
+++ b/revision.c
@@ -855,7 +855,7 @@ int handle_revision_arg(const char *arg, struct rev_info *revs,
 		local_flags = UNINTERESTING;
 		arg++;
 	}
-	if (get_sha1_with_mode(arg, sha1, &mode))
+	if (get_sha1_with_prefix(revs->prefix, arg, sha1, &mode))
 		return -1;
 	if (!cant_be_filename)
 		verify_non_filename(revs->prefix, arg);
@@ -1280,7 +1280,7 @@ int setup_revisions(int argc, const char **argv, struct rev_info *revs, const ch
 		unsigned char sha1[20];
 		struct object *object;
 		unsigned mode;
-		if (get_sha1_with_mode(def, sha1, &mode))
+		if (get_sha1_with_prefix(revs->prefix, def, sha1, &mode))
 			die("bad default revision '%s'", def);
 		object = get_reference(revs, def, sha1, 0);
 		add_pending_object_with_mode(revs, object, def, mode);
diff --git a/sha1_name.c b/sha1_name.c
index 13e1164..358aab7 100644
--- a/sha1_name.c
+++ b/sha1_name.c
@@ -656,6 +656,12 @@ int get_sha1(const char *name, unsigned char *sha1)
 
 int get_sha1_with_mode(const char *name, unsigned char *sha1, unsigned *mode)
 {
+	return get_sha1_with_prefix(NULL, name, sha1, mode);
+}
+
+int get_sha1_with_prefix(const char *prefix, const char *name, unsigned char *sha1, unsigned *mode)
+{
+	char *prefixpath;
 	int ret, bracket_depth;
 	int namelen = strlen(name);
 	const char *cp;
@@ -664,6 +670,9 @@ int get_sha1_with_mode(const char *name, unsigned char *sha1, unsigned *mode)
 	ret = get_sha1_1(name, namelen, sha1);
 	if (!ret)
 		return ret;
+
+	prefixpath = prefix ? xmalloc(strlen(prefix) + namelen + 1): NULL;
+
 	/* sha1:path --> object name of path in ent sha1
 	 * :path -> object name of path in index
 	 * :[0-3]:path -> object name of path in index at stage
@@ -685,6 +694,10 @@ int get_sha1_with_mode(const char *name, unsigned char *sha1, unsigned *mode)
 		namelen = namelen - (cp - name);
 		if (!active_cache)
 			read_cache();
+		if (prefix) {
+			namelen = sprintf(prefixpath, "%s%s", prefix, cp);
+			cp = prefixpath;
+		}
 		pos = cache_name_pos(cp, namelen);
 		if (pos < 0)
 			pos = -pos - 1;
@@ -696,10 +709,12 @@ int get_sha1_with_mode(const char *name, unsigned char *sha1, unsigned *mode)
 			if (ce_stage(ce) == stage) {
 				hashcpy(sha1, ce->sha1);
 				*mode = ntohl(ce->ce_mode);
+				free(prefixpath);
 				return 0;
 			}
 			pos++;
 		}
+		free(prefixpath);
 		return -1;
 	}
 	for (cp = name, bracket_depth = 0; *cp; cp++) {
@@ -712,9 +727,15 @@ int get_sha1_with_mode(const char *name, unsigned char *sha1, unsigned *mode)
 	}
 	if (*cp == ':') {
 		unsigned char tree_sha1[20];
-		if (!get_sha1_1(name, cp-name, tree_sha1))
-			return get_tree_entry(tree_sha1, cp+1, sha1,
-					      mode);
+		if (!get_sha1_1(name, cp-name, tree_sha1)) {
+			if (!prefix)
+				ret = get_tree_entry(tree_sha1, cp + 1, sha1, mode);
+			else {
+				sprintf(prefixpath, "%s%s", prefix, cp + 1);
+				ret = get_tree_entry(tree_sha1, prefixpath, sha1, mode);
+				free(prefixpath);
+			}
+		}
 	}
 	return ret;
 }
-- 
1.5.4.rc0.86.g30f5

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

* [PATCH] Introduce pathexpand: syntax-level chdir into the given cwd
  2007-12-18 20:47     ` [PATCH] Simple support for tree entry specification with relative pathnames Alex Riesen
@ 2007-12-18 20:49       ` Alex Riesen
  2007-12-18 20:52         ` [PATCH] Use pathexpand to preparse the relative pathnames in blob references Alex Riesen
  2007-12-18 21:03       ` [PATCH] Simple support for tree entry specification with relative pathnames Dana How
  1 sibling, 1 reply; 43+ messages in thread
From: Alex Riesen @ 2007-12-18 20:49 UTC (permalink / raw
  To: Jakub Narebski; +Cc: git, Junio C Hamano, Johannes Schindelin, Linus Torvalds

Signed-off-by: Alex Riesen <raa.lkml@gmail.com>
---

This will be used by the following patch. I actually already have sent
this one in, as suggestion for some problem back then. It is a bit
generic, so it gets its own patch.

 cache.h |    2 ++
 path.c  |   59 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 61 insertions(+), 0 deletions(-)

diff --git a/cache.h b/cache.h
index 054f106..25ce5da 100644
--- a/cache.h
+++ b/cache.h
@@ -383,6 +383,8 @@ static inline int is_absolute_path(const char *path)
 	return path[0] == '/';
 }
 const char *make_absolute_path(const char *path);
+/* Returns the analog of "cd path" from a directory "cwd" */
+extern char *pathexpand(const char *cwd, const char *path);
 
 /* Read and unpack a sha1 file into memory, write memory to a sha1 file */
 extern int sha1_object_info(const unsigned char *, unsigned long *);
diff --git a/path.c b/path.c
index 4260952..8231cd8 100644
--- a/path.c
+++ b/path.c
@@ -353,3 +353,62 @@ const char *make_absolute_path(const char *path)
 
 	return buf;
 }
+
+/*
+ * Returns the analog of "cd path" from a directory "cwd".
+ * The root is defined as empty path (instead of "/")
+ * An attempt to go past the root (with "..") leaves the path at root.
+ * The cwd is not expanded.
+ */
+char *pathexpand(const char *cwd, const char *path)
+{
+	static const char SEP[] = "/";
+	if (!*path) /* empty path -> "." (don't move) */
+		path = ".";
+	if (!cwd || !*cwd || *SEP == *path) /* no cwd, or path begins with "/" */
+		cwd = "";
+
+	while (*cwd && *SEP == *cwd)
+		++cwd;
+
+	size_t len = strlen(cwd);
+	char *out = malloc(len + 1 + strlen(path) + 1);
+	char *p = strcpy(out, cwd) + len;
+
+	for (; *path; ++path)
+	{
+		char *pl;
+		if (p > out && p[-1] != *SEP)
+			*p++ = *SEP;
+		pl = p;
+		while (*path && *SEP != *path)
+			*p++ = *path++;
+		*p = '\0';
+		/* ..."//"... */
+		if (p == pl)
+			; /* just ignore */
+		/* ..."/./"...  */
+		else if ( p - pl == 1 && '.' == *pl )
+			--p; /* just ignore */
+		/* ..."/../"...  */
+		else if ( p - pl == 2 && '.' == pl[0] && '.' == pl[1] )
+		{
+			/* drop the last element of the resulting path */
+			if (pl > out && --pl > out)
+				for (--pl; pl > out && *SEP != *pl; --pl)
+					;
+			p = pl > out ? ++pl: out;
+		}
+		/* ..."/path/"...  */
+		else if (*path)
+			*p++ = *path; /* just add the separator */
+
+		if (!*path)
+			break;
+	}
+	if (p > out+1 && *SEP == p[-1])
+		--p;
+	*p = '\0';
+	return out;
+}
+
-- 
1.5.4.rc0.86.g30f5

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

* [PATCH] Use pathexpand to preparse the relative pathnames in blob references
  2007-12-18 20:49       ` [PATCH] Introduce pathexpand: syntax-level chdir into the given cwd Alex Riesen
@ 2007-12-18 20:52         ` Alex Riesen
  2007-12-18 21:06           ` Dana How
  2007-12-19 14:37           ` Jeff King
  0 siblings, 2 replies; 43+ messages in thread
From: Alex Riesen @ 2007-12-18 20:52 UTC (permalink / raw
  To: Jakub Narebski; +Cc: git, Junio C Hamano, Johannes Schindelin, Linus Torvalds

Signed-off-by: Alex Riesen <raa.lkml@gmail.com>
---

This, OTOH, is a bit intrusive and changes the current behaviour a bit
too far. git-show cannot use the absolute pathnames in blob locators
at all now, which I consider bad. An obvious way to use rev:/path is
blocked by Johannes' get_sha1_oneline. It would have worked, though.

 sha1_name.c |   21 +++++++--------------
 1 files changed, 7 insertions(+), 14 deletions(-)

diff --git a/sha1_name.c b/sha1_name.c
index 358aab7..369e7d0 100644
--- a/sha1_name.c
+++ b/sha1_name.c
@@ -661,7 +661,7 @@ int get_sha1_with_mode(const char *name, unsigned char *sha1, unsigned *mode)
 
 int get_sha1_with_prefix(const char *prefix, const char *name, unsigned char *sha1, unsigned *mode)
 {
-	char *prefixpath;
+	char *prefixpath = NULL;
 	int ret, bracket_depth;
 	int namelen = strlen(name);
 	const char *cp;
@@ -671,8 +671,6 @@ int get_sha1_with_prefix(const char *prefix, const char *name, unsigned char *sh
 	if (!ret)
 		return ret;
 
-	prefixpath = prefix ? xmalloc(strlen(prefix) + namelen + 1): NULL;
-
 	/* sha1:path --> object name of path in ent sha1
 	 * :path -> object name of path in index
 	 * :[0-3]:path -> object name of path in index at stage
@@ -694,10 +692,9 @@ int get_sha1_with_prefix(const char *prefix, const char *name, unsigned char *sh
 		namelen = namelen - (cp - name);
 		if (!active_cache)
 			read_cache();
-		if (prefix) {
-			namelen = sprintf(prefixpath, "%s%s", prefix, cp);
-			cp = prefixpath;
-		}
+		prefixpath = pathexpand(prefix, cp);
+		namelen = strlen(prefixpath);
+		cp = prefixpath;
 		pos = cache_name_pos(cp, namelen);
 		if (pos < 0)
 			pos = -pos - 1;
@@ -728,13 +725,9 @@ int get_sha1_with_prefix(const char *prefix, const char *name, unsigned char *sh
 	if (*cp == ':') {
 		unsigned char tree_sha1[20];
 		if (!get_sha1_1(name, cp-name, tree_sha1)) {
-			if (!prefix)
-				ret = get_tree_entry(tree_sha1, cp + 1, sha1, mode);
-			else {
-				sprintf(prefixpath, "%s%s", prefix, cp + 1);
-				ret = get_tree_entry(tree_sha1, prefixpath, sha1, mode);
-				free(prefixpath);
-			}
+			prefixpath = pathexpand(prefix, cp + 1);
+			ret = get_tree_entry(tree_sha1, prefixpath, sha1, mode);
+			free(prefixpath);
 		}
 	}
 	return ret;
-- 
1.5.4.rc0.86.g30f5

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

* Re: [PATCH] Simple support for tree entry specification with relative pathnames
  2007-12-18 20:47     ` [PATCH] Simple support for tree entry specification with relative pathnames Alex Riesen
  2007-12-18 20:49       ` [PATCH] Introduce pathexpand: syntax-level chdir into the given cwd Alex Riesen
@ 2007-12-18 21:03       ` Dana How
  2007-12-18 21:17         ` Alex Riesen
  1 sibling, 1 reply; 43+ messages in thread
From: Dana How @ 2007-12-18 21:03 UTC (permalink / raw
  To: Alex Riesen
  Cc: Jakub Narebski, git, Junio C Hamano, Johannes Schindelin,
	Linus Torvalds, danahow

ACK from me...

I submitted a similar patch last May 4 which also
changed sha1_name.c to do this.  The patch
added a config variable to control this
(probably not desirable).  The patch also handled
leading/embedded . and .. .

In p4 you can say
  p4 <operation> file#rev
and file is interpreted relatively.

I wanted to be able to say
  git <operation> tree:file
and have file interpreted relatively.
This should only happen when you are inside the work tree.

Good luck!

Dana

On Dec 18, 2007 12:47 PM, Alex Riesen <raa.lkml@gmail.com> wrote:
> This allows git show to understand something like this:
>
>     $ test -f DIR/file && cd DIR &&  git show rev:file
>
> Signed-off-by: Alex Riesen <raa.lkml@gmail.com>
> ---
>
> This is a bit too simplistic and can be fooled easily:
>
>     .../t$ git show HEAD:../t/test-lib.sh
>
> wont work. It is short, though.

-- 
Dana L. How  danahow@gmail.com  +1 650 804 5991 cell

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

* Re: [PATCH] Use pathexpand to preparse the relative pathnames in blob references
  2007-12-18 20:52         ` [PATCH] Use pathexpand to preparse the relative pathnames in blob references Alex Riesen
@ 2007-12-18 21:06           ` Dana How
  2007-12-19 14:37           ` Jeff King
  1 sibling, 0 replies; 43+ messages in thread
From: Dana How @ 2007-12-18 21:06 UTC (permalink / raw
  To: Alex Riesen
  Cc: Jakub Narebski, git, Junio C Hamano, Johannes Schindelin,
	Linus Torvalds, danahow

On Dec 18, 2007 12:52 PM, Alex Riesen <raa.lkml@gmail.com> wrote:
> This, OTOH, is a bit intrusive and changes the current behaviour a bit
> too far. git-show cannot use the absolute pathnames in blob locators
> at all now, which I consider bad. An obvious way to use rev:/path is
> blocked by Johannes' get_sha1_oneline. It would have worked, though.

Last May Junio proposed the current :/ should be changed to :?
since it actually searches backwards.  Then :/ would be an absolute path,
and : could default to relative (like Unix command line).

Because of this incompatibility I think he wanted to delay it
until 1.5.6 or 1.6 (see old thread).
-- 
Dana L. How  danahow@gmail.com  +1 650 804 5991 cell

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

* Re: [PATCH] Simple support for tree entry specification with relative pathnames
  2007-12-18 21:03       ` [PATCH] Simple support for tree entry specification with relative pathnames Dana How
@ 2007-12-18 21:17         ` Alex Riesen
       [not found]           ` <56b7f5510712181539g27bd4fc9y632ebe74d91b8e82@mail.gmail.com>
  0 siblings, 1 reply; 43+ messages in thread
From: Alex Riesen @ 2007-12-18 21:17 UTC (permalink / raw
  To: Dana How
  Cc: Jakub Narebski, git, Junio C Hamano, Johannes Schindelin,
	Linus Torvalds

Dana How, Tue, Dec 18, 2007 22:03:04 +0100:
> ACK from me...

But NAK from me. Definitely not in this form. Please consider the
patches *only* as an RFC.

> I submitted a similar patch last May 4 which also changed
> sha1_name.c to do this.  The patch added a config variable to
> control this (probably not desirable).  The patch also handled
> leading/embedded . and .. .

This one (the last in series) too.

> In p4 you can say
>   p4 <operation> file#rev
> and file is interpreted relatively.
> 
> I wanted to be able to say
>   git <operation> tree:file
> and have file interpreted relatively.
> This should only happen when you are inside the work tree.

It is pure coincedence the syntaxes look similar. They are very deeply
different in Git and Perforce.

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

* Re: log/show: relative pathnames do not work in rev:path
  2007-12-18 20:46   ` Alex Riesen
  2007-12-18 20:47     ` [PATCH] Simple support for tree entry specification with relative pathnames Alex Riesen
@ 2007-12-18 21:24     ` Jakub Narebski
  2007-12-18 21:53       ` Linus Torvalds
  2007-12-18 22:20       ` Alex Riesen
  1 sibling, 2 replies; 43+ messages in thread
From: Jakub Narebski @ 2007-12-18 21:24 UTC (permalink / raw
  To: Alex Riesen
  Cc: git, Junio C Hamano, Johannes Schindelin, Linus Torvalds,
	Dana How

On Tue, 18 Dec 2007, Alex Riesen wrote:
> Jakub Narebski, Tue, Dec 18, 2007 18:50:20 +0100:
>> Alex Riesen <raa.lkml@gmail.com> writes:
>> 
>>> Noticed by a collegue of mine. Consider:
>>> 
>>>     $ cd $GIT/t
>>>     $ git show 570f32266:t/test-lib.sh    # works
>>>     $ git show 570f32266:test-lib.sh      # does not work
>>>     $ git show 570f32266:./test-lib.sh    # does not work
>>>     $ git show 570f32266:/t/test-lib.sh   # does not work
>>> 
>>> Considering that the relative path names work as filters (and many
>>> agreed on that being useful), it would be nice to allow relative
>>> pathnames in blob specifications for git-show and git-cat-file.
>>> 
>>> (besides the colon is a good delimiter, even tab-completion
>>> works with it) 
>> 
>> If you think about it a bit, relative path names nor absolute
>> path names does and should not work.  570f32266:t/test-lib.sh
>> means path t/test-lib.sh staring from 570f32266^{tree}.  Where
>> you are in the filesystem is not important and matters not for
>> this syntax.  Besides if you access other branch file might be
>> not in filesystem (deleted file, or disjoint branch with separate
>> contents like 'todo' or 'html' branch in git.git repository).
> 
> Not convinced. It is *not* the plumbing problem I was trying to
> describe. They discussion, metaphorically, should not have left the
> command-line parser.
> 
> I think that we have parsing of the blob locators at the wrong level:
> so that git-show, git-log and git-diff can handle its pathnames as
> they handle path filters (relative to cwd),

What cwd? <path> in <tree-ish>:<path> syntax is "relative" to <tree-ish>.
IMHO "<tree-ish>:<path>" should be considered (and is considered) as
one object: current working directory doesn't matter at all there,
contrary to "<tree-ish> -- <pathspec>" where it is natural that <pathspec>
is relative to current working directory.

What should git do in your proposal when we are on master branch in
Documentation subdirectory, and want to check TODO file in todo branch?
"git show todo:TODO" is most natural IMHO.

Note that for true <tree> as <tree-ish> you just don't know where
in the working area directory hierarchy <tree> can be. This means you
do't know relation of <tree> and <path> in <tree>:<path> to cwd.

> and git-cat-file, 
> git-diff-tree, git-rev-list, etc can handle theirs always relative to
> the project root.

Not "relative to project root". Relative to tree-ish used on right hand
side in <tree-ish>:<path> extended SHA-1 syntax. It is usually project
root, because when you specify <commit> or <tag> as <tree-ish> it refers
to top/root directory of a project.

> I actually do not see any problem for git-show (being porcelain-level
> program) to treat *each and every* path anywhere relatively to the
> current directory. It is just more comfortable.

This breaks backward compatibility, hard. And IMHO breaks layers.

But if (big if) it was to be implemented, default behavior should be
unchanged, and relative to the cwd (layers!) should use new syntax,
for example

     $ cd $GIT/t
     $ git show 570f32266:t/test-lib.sh    # works
     $ git show 570f32266:test-lib.sh      # should not work
     $ git show 570f32266:./test-lib.sh    # should work
     $ git show 570f32266:/t/test-lib.sh   # should perhaps work
 
Currently ":/<text>" (but not "<ref>:/<text>") is taken; see
git-rev-parse(1), "Specifying revisions".

-- 
Jakub Narebski
Poland

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

* Re: log/show: relative pathnames do not work in rev:path
  2007-12-18 21:24     ` log/show: relative pathnames do not work in rev:path Jakub Narebski
@ 2007-12-18 21:53       ` Linus Torvalds
  2007-12-18 22:08         ` Dana How
  2007-12-18 22:20         ` Junio C Hamano
  2007-12-18 22:20       ` Alex Riesen
  1 sibling, 2 replies; 43+ messages in thread
From: Linus Torvalds @ 2007-12-18 21:53 UTC (permalink / raw
  To: Jakub Narebski
  Cc: Alex Riesen, git, Junio C Hamano, Johannes Schindelin, Dana How



On Tue, 18 Dec 2007, Jakub Narebski wrote:
> 
> What cwd? <path> in <tree-ish>:<path> syntax is "relative" to <tree-ish>.
> IMHO "<tree-ish>:<path>" should be considered (and is considered) as
> one object: current working directory doesn't matter at all there,
> contrary to "<tree-ish> -- <pathspec>" where it is natural that <pathspec>
> is relative to current working directory.

Indeed.

The <treeish>:<path> syntax *is* relative, but it's relative to the exact 
*treeish* that is given. It has nothing what-so-ever to do with the 
current working directory, since the user has explicitly given an exact 
tree object, and trying to fake that out would be actively wrong.

That said, I can kind of understand the wish for something like this, and 
I suspect that we could make the "commit->tree" translation take the 
current path into account. In other words, maybe we should have something 
like this:

	/*
	 * This sequence currently works
	 */
	[torvalds@woody git]$ git rev-parse HEAD
	f9c5a80cdf2265f2df7712fad9f1fb7ef68b4768

	[torvalds@woody git]$ git rev-parse HEAD^{tree}
	051fb0c0dff4371f97f8ad9407f9f1fd335b1682

	[torvalds@woody git]$ git rev-parse HEAD^{tree}:t
	49d8bcd7a2df5c17193b1d002c4a8489d4fa990c

	/*
	 * .. but this would be new
	 */
	[torvalds@woody git]$ cd t
	[torvalds@woody t]$ git rev-parse HEAD^{tree}
	49d8bcd7a2df5c17193b1d002c4a8489d4fa990c

where the magic is *not* done by any "SHA1 path lookup" at all, but is 
simply done by the commit->tree lookup. At least at that point it would 
make logical sense (although it would probably be quite painful to 
implement).

			Linus

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

* Re: log/show: relative pathnames do not work in rev:path
  2007-12-18 21:53       ` Linus Torvalds
@ 2007-12-18 22:08         ` Dana How
  2007-12-18 22:29           ` Alex Riesen
  2007-12-18 22:20         ` Junio C Hamano
  1 sibling, 1 reply; 43+ messages in thread
From: Dana How @ 2007-12-18 22:08 UTC (permalink / raw
  To: Linus Torvalds
  Cc: Jakub Narebski, Alex Riesen, git, Junio C Hamano,
	Johannes Schindelin, danahow

On Dec 18, 2007 1:53 PM, Linus Torvalds <torvalds@linux-foundation.org> wrote:
> On Tue, 18 Dec 2007, Jakub Narebski wrote:
> >
> > What cwd? <path> in <tree-ish>:<path> syntax is "relative" to <tree-ish>.
> > IMHO "<tree-ish>:<path>" should be considered (and is considered) as
> > one object: current working directory doesn't matter at all there,
> > contrary to "<tree-ish> -- <pathspec>" where it is natural that <pathspec>
> > is relative to current working directory.
>
> Indeed.
>
> The <treeish>:<path> syntax *is* relative, but it's relative to the exact
> *treeish* that is given. It has nothing what-so-ever to do with the
> current working directory, since the user has explicitly given an exact
> tree object, and trying to fake that out would be actively wrong.

I think the solution is to use the cwd only when the tree-ish refers
to a commit.
If it refers explicitly to a tree (or to a tree through a tag w/o
going through a commit)
then you don't make any modification.

When it *does* refer to a commit,  then for commit:relpath you prefix
relpath with the suffix of the cwd which is an extension beyond the root
of the working tree.

At the time I thought this through submodules didn't exist.
Clearly that case needs to be thought through as well.

> That said, I can kind of understand the wish for something like this, and
> I suspect that we could make the "commit->tree" translation take the
> current path into account. In other words, maybe we should have something
> like this:
>
>         /*
>          * This sequence currently works
>          */
>         [torvalds@woody git]$ git rev-parse HEAD
>         f9c5a80cdf2265f2df7712fad9f1fb7ef68b4768
>
>         [torvalds@woody git]$ git rev-parse HEAD^{tree}
>         051fb0c0dff4371f97f8ad9407f9f1fd335b1682
>
>         [torvalds@woody git]$ git rev-parse HEAD^{tree}:t
>         49d8bcd7a2df5c17193b1d002c4a8489d4fa990c
>
>         /*
>          * .. but this would be new
>          */
>         [torvalds@woody git]$ cd t
>         [torvalds@woody t]$ git rev-parse HEAD^{tree}
>         49d8bcd7a2df5c17193b1d002c4a8489d4fa990c
>
> where the magic is *not* done by any "SHA1 path lookup" at all, but is
> simply done by the commit->tree lookup. At least at that point it would
> make logical sense (although it would probably be quite painful to
> implement).

I must be missing something.  The old patch I submitted did this.
Its defect was that it did NOT make the cwd insertion conditional
on whether the tree-ish involved a commit or not (a test which also
_seems_ doable,  but I don't think I finished it & sent it in).

Thanks,
-- 
Dana L. How  danahow@gmail.com  +1 650 804 5991 cell

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

* Re: log/show: relative pathnames do not work in rev:path
  2007-12-18 21:53       ` Linus Torvalds
  2007-12-18 22:08         ` Dana How
@ 2007-12-18 22:20         ` Junio C Hamano
  2007-12-18 22:30           ` Dana How
  1 sibling, 1 reply; 43+ messages in thread
From: Junio C Hamano @ 2007-12-18 22:20 UTC (permalink / raw
  To: Linus Torvalds
  Cc: Jakub Narebski, Alex Riesen, git, Johannes Schindelin, Dana How

Linus Torvalds <torvalds@linux-foundation.org> writes:

> On Tue, 18 Dec 2007, Jakub Narebski wrote:
>> 
>> What cwd? <path> in <tree-ish>:<path> syntax is "relative" to <tree-ish>.
>> IMHO "<tree-ish>:<path>" should be considered (and is considered) as
>> one object: current working directory doesn't matter at all there,
>> contrary to "<tree-ish> -- <pathspec>" where it is natural that <pathspec>
>> is relative to current working directory.
>
> Indeed.
>
> The <treeish>:<path> syntax *is* relative, but it's relative to the exact 
> *treeish* that is given. It has nothing what-so-ever to do with the 
> current working directory, since the user has explicitly given an exact 
> tree object, and trying to fake that out would be actively wrong.
>
> That said, I can kind of understand the wish for something like this, and 
> I suspect that we could make the "commit->tree" translation take the 
> current path into account. In other words, maybe we should have something 
> like this:
>
> 	/*
> 	 * This sequence currently works
> 	 */
> 	[torvalds@woody git]$ git rev-parse HEAD
> 	f9c5a80cdf2265f2df7712fad9f1fb7ef68b4768
>
> 	[torvalds@woody git]$ git rev-parse HEAD^{tree}
> 	051fb0c0dff4371f97f8ad9407f9f1fd335b1682
>
> 	[torvalds@woody git]$ git rev-parse HEAD^{tree}:t
> 	49d8bcd7a2df5c17193b1d002c4a8489d4fa990c
>
> 	/*
> 	 * .. but this would be new
> 	 */
> 	[torvalds@woody git]$ cd t
> 	[torvalds@woody t]$ git rev-parse HEAD^{tree}
> 	49d8bcd7a2df5c17193b1d002c4a8489d4fa990c
>
> where the magic is *not* done by any "SHA1 path lookup" at all, but is 
> simply done by the commit->tree lookup. At least at that point it would 
> make logical sense (although it would probably be quite painful to 
> implement).

It is not just painful to implement.

Although I can buy that purely from the user (read: people who do not
know how the world works) experience point of view, you have to be extra
careful if you do this.  There are existing codepaths that take a string
that names a treeish from the end user, appends "^{tree}" to that
string, and passes the result to get_sha1() to obtain a tree object name
they want to operate on (the alternative is parse_tree_indirect() but it
forces them to go through the object layer).  You will need to update
these callers to keep them working from subdirectories.

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

* Re: log/show: relative pathnames do not work in rev:path
  2007-12-18 21:24     ` log/show: relative pathnames do not work in rev:path Jakub Narebski
  2007-12-18 21:53       ` Linus Torvalds
@ 2007-12-18 22:20       ` Alex Riesen
  2007-12-18 22:43         ` Johannes Schindelin
  2007-12-18 23:05         ` Jakub Narebski
  1 sibling, 2 replies; 43+ messages in thread
From: Alex Riesen @ 2007-12-18 22:20 UTC (permalink / raw
  To: Jakub Narebski
  Cc: git, Junio C Hamano, Johannes Schindelin, Linus Torvalds,
	Dana How

Jakub Narebski, Tue, Dec 18, 2007 22:24:26 +0100:
> On Tue, 18 Dec 2007, Alex Riesen wrote:
> > I think that we have parsing of the blob locators at the wrong level:
> > so that git-show, git-log and git-diff can handle its pathnames as
> > they handle path filters (relative to cwd),
> 
> What cwd? <path> in <tree-ish>:<path> syntax is "relative" to <tree-ish>.

But the act of running "git-show <tree-ish>:<path>" does have a
working directory relative to the project root. And usually the
relative directory makes a lot of sense in git-show commands.

> What should git do in your proposal when we are on master branch in
> Documentation subdirectory, and want to check TODO file in todo branch?
> "git show todo:TODO" is most natural IMHO.

Yes, and that's why I NAKed the patches in the mail to Dana. I just
hope the problem gets some attention. Maybe I even get something out
of it, maybe not. It is not that hard to keep the patches in my tree.

> Note that for true <tree> as <tree-ish> you just don't know where
> in the working area directory hierarchy <tree> can be. This means you
> do't know relation of <tree> and <path> in <tree>:<path> to cwd.

I understand. But... How often do you think people use git show with a
tree which was not pointed by a commit?

> > and git-cat-file, 
> > git-diff-tree, git-rev-list, etc can handle theirs always relative to
> > the project root.
> 
> Not "relative to project root". Relative to tree-ish used on right hand
> side in <tree-ish>:<path> extended SHA-1 syntax. It is usually project
> root, because when you specify <commit> or <tag> as <tree-ish> it refers
> to top/root directory of a project.

I know. My problem: it is also awkward. git-show :test-l<Tab>ib.sh just
does not do what I expect. Nor does git cat-file HEAD:test-l<Tab>ib.sh.
And git cat-file HEAD:t/test-l<Tab> does not work at all. And this is
very simple example. Normally the pathnames are about 100 characters
long.

You know, it maybe as much correct as you wish, but is not very
usable (and no, I can't use the contributed completion. For lots of
reasons).

> > I actually do not see any problem for git-show (being porcelain-level
> > program) to treat *each and every* path anywhere relatively to the
> > current directory. It is just more comfortable.
> 
> This breaks backward compatibility, hard. And IMHO breaks layers.

Maybe they should be broken in porcelain...

> But if (big if) it was to be implemented, default behavior should be
> unchanged, and relative to the cwd (layers!) should use new syntax,
> for example
> 
>      $ cd $GIT/t
>      $ git show 570f32266:t/test-lib.sh    # works
>      $ git show 570f32266:test-lib.sh      # should not work

Well... Frankly, I suggest changing this for porcelain-level
commands (show and diff) and leave it as it is for plumbing.

>      $ git show 570f32266:./test-lib.sh    # should work

Definitely. I even implemented a patch to allow just this, but scraped
it: it looked a bit small and the syntax is not obvious to the user.
Maybe that is what I end up with, though.

>      $ git show 570f32266:/t/test-lib.sh   # should perhaps work
> Currently ":/<text>" (but not "<ref>:/<text>") is taken; see

Yes, and it becomes more and more an obstacle. With just one user
standing, AFAICS (/me considers Dscho's assassination for moment...
Nah... Maybe poison?)

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

* Re: log/show: relative pathnames do not work in rev:path
  2007-12-18 22:08         ` Dana How
@ 2007-12-18 22:29           ` Alex Riesen
  0 siblings, 0 replies; 43+ messages in thread
From: Alex Riesen @ 2007-12-18 22:29 UTC (permalink / raw
  To: Dana How
  Cc: Linus Torvalds, Jakub Narebski, git, Junio C Hamano,
	Johannes Schindelin

Dana How, Tue, Dec 18, 2007 23:08:33 +0100:
> When it *does* refer to a commit,  then for commit:relpath you prefix
> relpath with the suffix of the cwd which is an extension beyond the root
> of the working tree.

...universally known as "prefix" (the last argument of builtin
commands) :)

> > where the magic is *not* done by any "SHA1 path lookup" at all, but is
> > simply done by the commit->tree lookup. At least at that point it would
> > make logical sense (although it would probably be quite painful to
> > implement).
> 
> I must be missing something.  The old patch I submitted did this.
> Its defect was that it did NOT make the cwd insertion conditional
> on whether the tree-ish involved a commit or not (a test which also
> _seems_ doable,  but I don't think I finished it & sent it in).

It is also a bit painful: lots of funtions (sha1_name.c) will have
their prototypes changed to get the prefix (aka suffix). And their
callers...

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

* Re: log/show: relative pathnames do not work in rev:path
  2007-12-18 22:20         ` Junio C Hamano
@ 2007-12-18 22:30           ` Dana How
  2007-12-18 23:02             ` Johannes Schindelin
  2007-12-19 20:45             ` Junio C Hamano
  0 siblings, 2 replies; 43+ messages in thread
From: Dana How @ 2007-12-18 22:30 UTC (permalink / raw
  To: Junio C Hamano
  Cc: Linus Torvalds, Jakub Narebski, Alex Riesen, git,
	Johannes Schindelin, danahow

On Dec 18, 2007 2:20 PM, Junio C Hamano <gitster@pobox.com> wrote:
> Linus Torvalds <torvalds@linux-foundation.org> writes:
> > where the magic is *not* done by any "SHA1 path lookup" at all, but is
> > simply done by the commit->tree lookup. At least at that point it would
> > make logical sense (although it would probably be quite painful to
> > implement).
>
> It is not just painful to implement.
>
> Although I can buy that purely from the user (read: people who do not
> know how the world works) experience point of view, you have to be extra
> careful if you do this.  There are existing codepaths that take a string
> that names a treeish from the end user, appends "^{tree}" to that
> string, and passes the result to get_sha1() to obtain a tree object name
> they want to operate on (the alternative is parse_tree_indirect() but it
> forces them to go through the object layer).  You will need to update
> these callers to keep them working from subdirectories.

Thanks,  I didn't know about those "^{tree}" codepaths.

How about this:
<tree-ish>:./path -> NEW: relative
<tree-ish>:../path -> NEW: relative
<tree-ish>:?pattern -> NEW: same as next (current :/ )
<tree-ish>:/pattern -> unchanged (sha1_name_oneline IIRC)
<tree-ish>:path -> unchanged: absolute
This shouldn't need to know if tree-ish references a commit or not.

Someday later,  the last 2 cases could be changed to be more
like the Unix command line if desired.  This is very similar to
Junio's response last May (by memory).

Typing an extra "./" is a big improvement over a long path prefix.

Thanks,
-- 
Dana L. How  danahow@gmail.com  +1 650 804 5991 cell

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

* Re: log/show: relative pathnames do not work in rev:path
  2007-12-18 22:20       ` Alex Riesen
@ 2007-12-18 22:43         ` Johannes Schindelin
  2007-12-18 23:03           ` Dana How
                             ` (2 more replies)
  2007-12-18 23:05         ` Jakub Narebski
  1 sibling, 3 replies; 43+ messages in thread
From: Johannes Schindelin @ 2007-12-18 22:43 UTC (permalink / raw
  To: Alex Riesen; +Cc: Jakub Narebski, git, Junio C Hamano, Linus Torvalds, Dana How

Hi,

On Tue, 18 Dec 2007, Alex Riesen wrote:

> Jakub Narebski, Tue, Dec 18, 2007 22:24:26 +0100:
> > On Tue, 18 Dec 2007, Alex Riesen wrote:
> >
> > > I think that we have parsing of the blob locators at the wrong 
> > > level: so that git-show, git-log and git-diff can handle its 
> > > pathnames as they handle path filters (relative to cwd),
> > 
> > What cwd? <path> in <tree-ish>:<path> syntax is "relative" to 
> > <tree-ish>.
> 
> But the act of running "git-show <tree-ish>:<path>" does have a working 
> directory relative to the project root.

Not necessarily.  My primary use of "git show <tree-ish>:<path>" (yes, I 
already use the dash-less form ;-) is in _bare_ repositories.

And I still maintain that expecting <tree-ish>:<path> to take the current 
relative path into account would be just like if you expected

	C:\> cd WINDOWS
	C:\WINDOWS> dir D:system32

to show you the contents of D:\WINDOWS\system32.

Or another, less Windowsy example:

	$ cd /usr/bin
	$ scp home:bash ./

No, this does not copy home:/usr/bin/bash but home:$HOME/bash.

Hth,
Dscho

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

* Re: log/show: relative pathnames do not work in rev:path
  2007-12-18 22:30           ` Dana How
@ 2007-12-18 23:02             ` Johannes Schindelin
  2007-12-19 20:45             ` Junio C Hamano
  1 sibling, 0 replies; 43+ messages in thread
From: Johannes Schindelin @ 2007-12-18 23:02 UTC (permalink / raw
  To: Dana How; +Cc: Junio C Hamano, Linus Torvalds, Jakub Narebski, Alex Riesen, git

Hi,

On Tue, 18 Dec 2007, Dana How wrote:

> [lots about rev:path taking path to be relative to the project root, 
>  preferring it to be relative to the current prefix instead]
> 
> Typing an extra "./" is a big improvement over a long path prefix.

Have you tried the path completion?

Alternatively, I suggest making a script

	$ cat > $HOME/bin/git-showrel << \EOF
	#!/bin/sh
	git show "$(echo "$1" | sed "s|:|:$(git rev-parse --show-prefix)|")"
	EOF
	$ chmod a+x $HOME/bin/git-showrel

Then

	$ git showrel HEAD:file

will do what you want.

(An alias will not work, since the cwd will be the project root.)

Hth,
Dscho

P.S.: I just tried "git show HEAD~20:<filename with : in it>" and it did 
not work...  I consider this a more serious issue than the relative path 
one.

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

* Re: log/show: relative pathnames do not work in rev:path
  2007-12-18 22:43         ` Johannes Schindelin
@ 2007-12-18 23:03           ` Dana How
  2007-12-18 23:26             ` Johannes Schindelin
  2007-12-19  1:16             ` Linus Torvalds
  2007-12-18 23:11           ` log/show: relative pathnames do not work in rev:path Jakub Narebski
  2007-12-18 23:18           ` Junio C Hamano
  2 siblings, 2 replies; 43+ messages in thread
From: Dana How @ 2007-12-18 23:03 UTC (permalink / raw
  To: Johannes Schindelin
  Cc: Alex Riesen, Jakub Narebski, git, Junio C Hamano, Linus Torvalds

On Dec 18, 2007 2:43 PM, Johannes Schindelin <Johannes.Schindelin@gmx.de> wrote:
> On Tue, 18 Dec 2007, Alex Riesen wrote:
> > But the act of running "git-show <tree-ish>:<path>" does have a working
> > directory relative to the project root.
>
> Not necessarily.  My primary use of "git show <tree-ish>:<path>" (yes, I
> already use the dash-less form ;-) is in _bare_ repositories.
>
> And I still maintain that expecting <tree-ish>:<path> to take the current
> relative path into account would be just like if you expected
>
>         C:\> cd WINDOWS
>         C:\WINDOWS> dir D:system32
>
> to show you the contents of D:\WINDOWS\system32.
>
> Or another, less Windowsy example:
>
>         $ cd /usr/bin
>         $ scp home:bash ./
>
> No, this does not copy home:/usr/bin/bash but home:$HOME/bash.

Both of your counterexamples use 2 disjoint directory trees:
C: vs D:,  or trees on different machines.

The cases we are talking about are all subtrees of the working tree.
There is a useful cwd suffix.

Don't you think that
  git <op> commit:./file.c
could occasionally be more convenient than
  git <op> commit:very/long/and/boring/path/equal/to/cwd/file.c
?

Thanks,
-- 
Dana L. How  danahow@gmail.com  +1 650 804 5991 cell

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

* Re: log/show: relative pathnames do not work in rev:path
  2007-12-18 22:20       ` Alex Riesen
  2007-12-18 22:43         ` Johannes Schindelin
@ 2007-12-18 23:05         ` Jakub Narebski
  1 sibling, 0 replies; 43+ messages in thread
From: Jakub Narebski @ 2007-12-18 23:05 UTC (permalink / raw
  To: Alex Riesen
  Cc: git, Junio C Hamano, Johannes Schindelin, Linus Torvalds,
	Dana How

Dnia wtorek 18. grudnia 2007 23:20, Alex Riesen napisał:
> Jakub Narebski, Tue, Dec 18, 2007 22:24:26 +0100:

>> Not "relative to project root". Relative to tree-ish used on right hand
>> side in <tree-ish>:<path> extended SHA-1 syntax. It is usually project
>> root, because when you specify <commit> or <tag> as <tree-ish> it refers
>> to top/root directory of a project.
> 
> I know. My problem: it is also awkward. git-show :test-l<Tab>ib.sh just
> does not do what I expect. Nor does git cat-file HEAD:test-l<Tab>ib.sh.
> And git cat-file HEAD:t/test-l<Tab> does not work at all. And this is
> very simple example. Normally the pathnames are about 100 characters
> long.

Doesn't bash completion (or zsh compltion) for git implement this?
Let me check... it does

 $ . contrib/completion/git-completion.bash
 $ git cat-file -p HEAD:t/test-<TAB>
 $ git cat-file -p HEAD:t/test-lib.sh    # autocompleted

It does work correctly also from within t/ directory.

-- 
Jakub Narebski
Poland

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

* Re: log/show: relative pathnames do not work in rev:path
  2007-12-18 22:43         ` Johannes Schindelin
  2007-12-18 23:03           ` Dana How
@ 2007-12-18 23:11           ` Jakub Narebski
  2007-12-18 23:15             ` Dana How
  2007-12-18 23:18           ` Junio C Hamano
  2 siblings, 1 reply; 43+ messages in thread
From: Jakub Narebski @ 2007-12-18 23:11 UTC (permalink / raw
  To: Johannes Schindelin
  Cc: Alex Riesen, git, Junio C Hamano, Linus Torvalds, Dana How

Johannes Schindelin wrote:
> On Tue, 18 Dec 2007, Alex Riesen wrote:
>> Jakub Narebski, Tue, Dec 18, 2007 22:24:26 +0100:
>>> 
>>> What cwd? <path> in <tree-ish>:<path> syntax is "relative" to 
>>> <tree-ish>.
>> 
>> But the act of running "git-show <tree-ish>:<path>" does have a working 
>> directory relative to the project root.
> 
> Not necessarily.  My primary use of "git show <tree-ish>:<path>" (yes, I 
> already use the dash-less form ;-) is in _bare_ repositories.
> 
> And I still maintain that expecting <tree-ish>:<path> to take the current 
> relative path into account would be just like if you expected
[...]

> 	$ cd /usr/bin
> 	$ scp home:bash ./
> 
> No, this does not copy home:/usr/bin/bash but home:$HOME/bash.

Great example! In scp <machine>:<path>, <path> by default is relative
to the login (ssh) directory on <machine>. In git's <tree-ish>:<path>,
<path> by default is relative to <tree-ish>.

Although Linus argument about thinking that cwd affects translation
from _commit_ sha1 to _tree-ish_ is also sound. Nevertheless I'd rather
have separate syntax for cwd-relative paths, i.e. <commit>:./<relpath>.

-- 
Jakub Narebski
Poland

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

* Re: log/show: relative pathnames do not work in rev:path
  2007-12-18 23:11           ` log/show: relative pathnames do not work in rev:path Jakub Narebski
@ 2007-12-18 23:15             ` Dana How
  0 siblings, 0 replies; 43+ messages in thread
From: Dana How @ 2007-12-18 23:15 UTC (permalink / raw
  To: Jakub Narebski
  Cc: Johannes Schindelin, Alex Riesen, git, Junio C Hamano,
	Linus Torvalds, danahow

On Dec 18, 2007 3:11 PM, Jakub Narebski <jnareb@gmail.com> wrote:
> Although Linus argument about thinking that cwd affects translation
> from _commit_ sha1 to _tree-ish_ is also sound. Nevertheless I'd rather
> have separate syntax for cwd-relative paths, i.e. <commit>:./<relpath>.

Cool -- so adding recognition for ":." will support relative paths
when useful and will not interfere with any current syntax.

Thanks,
-- 
Dana L. How  danahow@gmail.com  +1 650 804 5991 cell

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

* Re: log/show: relative pathnames do not work in rev:path
  2007-12-18 22:43         ` Johannes Schindelin
  2007-12-18 23:03           ` Dana How
  2007-12-18 23:11           ` log/show: relative pathnames do not work in rev:path Jakub Narebski
@ 2007-12-18 23:18           ` Junio C Hamano
  2 siblings, 0 replies; 43+ messages in thread
From: Junio C Hamano @ 2007-12-18 23:18 UTC (permalink / raw
  To: Johannes Schindelin
  Cc: Alex Riesen, Jakub Narebski, git, Linus Torvalds, Dana How

Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:

> And I still maintain that expecting <tree-ish>:<path> to take the current 
> relative path into account would be just like if you expected
>
> 	C:\> cd WINDOWS
> 	C:\WINDOWS> dir D:system32
>
> to show you the contents of D:\WINDOWS\system32.
>
> Or another, less Windowsy example:
>
> 	$ cd /usr/bin
> 	$ scp home:bash ./
>
> No, this does not copy home:/usr/bin/bash but home:$HOME/bash.

Please do not cc me on this topic, unless it is a patch implementing
suggestion from Linus to treat $commit^{tree} as relative to $(cwd) but
for only when the user directly specified that in full, including ^{tree}
part.

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

* Re: log/show: relative pathnames do not work in rev:path
  2007-12-18 23:03           ` Dana How
@ 2007-12-18 23:26             ` Johannes Schindelin
  2007-12-19  1:16             ` Linus Torvalds
  1 sibling, 0 replies; 43+ messages in thread
From: Johannes Schindelin @ 2007-12-18 23:26 UTC (permalink / raw
  To: Dana How; +Cc: Alex Riesen, Jakub Narebski, git, Junio C Hamano, Linus Torvalds

Hi,

On Tue, 18 Dec 2007, Dana How wrote:

> On Dec 18, 2007 2:43 PM, Johannes Schindelin <Johannes.Schindelin@gmx.de> wrote:
> > On Tue, 18 Dec 2007, Alex Riesen wrote:
> > > But the act of running "git-show <tree-ish>:<path>" does have a working
> > > directory relative to the project root.
> >
> > Not necessarily.  My primary use of "git show <tree-ish>:<path>" (yes, I
> > already use the dash-less form ;-) is in _bare_ repositories.
> >
> > And I still maintain that expecting <tree-ish>:<path> to take the current
> > relative path into account would be just like if you expected
> >
> >         C:\> cd WINDOWS
> >         C:\WINDOWS> dir D:system32
> >
> > to show you the contents of D:\WINDOWS\system32.
> >
> > Or another, less Windowsy example:
> >
> >         $ cd /usr/bin
> >         $ scp home:bash ./
> >
> > No, this does not copy home:/usr/bin/bash but home:$HOME/bash.
> 
> Both of your counterexamples use 2 disjoint directory trees:
> C: vs D:,  or trees on different machines.

Well, the first actually only uses 1 "disjoint" directory tree.  You did 
not address the concern of the bare repository.

> The cases we are talking about are all subtrees of the working tree. 
> There is a useful cwd suffix.

Not necessarily.  You can be in a subdirectory that was not even created 
in _any_ revision.  Or you can access a different branch with a different 
history.

It boils down to this: if you need relative paths _only_, you narrowed 
yourself very much in your use cases.

> Don't you think that
>   git <op> commit:./file.c
> could occasionally be more convenient than
>   git <op> commit:very/long/and/boring/path/equal/to/cwd/file.c
> ?

Actually, it depends on the <op>.  And guess what, for those operations 
that I would like to have that, it already works!  "grep", "diff", "log".

Ciao,
Dscho

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

* Re: log/show: relative pathnames do not work in rev:path
  2007-12-18 23:03           ` Dana How
  2007-12-18 23:26             ` Johannes Schindelin
@ 2007-12-19  1:16             ` Linus Torvalds
  2007-12-19  1:52               ` Dana How
  1 sibling, 1 reply; 43+ messages in thread
From: Linus Torvalds @ 2007-12-19  1:16 UTC (permalink / raw
  To: Dana How
  Cc: Johannes Schindelin, Alex Riesen, Jakub Narebski, git,
	Junio C Hamano



On Tue, 18 Dec 2007, Dana How wrote:
> 
> Both of your counterexamples use 2 disjoint directory trees:
> C: vs D:,  or trees on different machines.
> 
> The cases we are talking about are all subtrees of the working tree.
> There is a useful cwd suffix.

No.

The cases we're talking of are *not* subtrees of the working tree.

The SHA1 of a commit may well be a totally disjoint tree. Try it in the 
git repository with something like

	git show origin/man:man1/git-fsck.1

or

	git show origin/todo:TODO

and realize that Dscho's examples of using the DOS/Windows drive letters 
is actually a really good example of what that <commit>:<pathname> syntax 
is. 

In fact, you can very well think of the commit/tree as a "drive letter". 
It really does go into another namespace entirely. It's just that often 
that namespace does bear some relationship to the currently checked out 
branch. But that's just an "often", it's not at all a given.

> Don't you think that
>   git <op> commit:./file.c
> could occasionally be more convenient than
>   git <op> commit:very/long/and/boring/path/equal/to/cwd/file.c

It's not about "convenience". It's about *sanity* and good design. And the 
fact is, that "commit:path" format really has nothing to do with the CWD 
in the general case.

		Linus

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

* Re: log/show: relative pathnames do not work in rev:path
  2007-12-19  1:16             ` Linus Torvalds
@ 2007-12-19  1:52               ` Dana How
  2007-12-19  7:42                 ` Alex Riesen
                                   ` (2 more replies)
  0 siblings, 3 replies; 43+ messages in thread
From: Dana How @ 2007-12-19  1:52 UTC (permalink / raw
  To: Linus Torvalds
  Cc: Johannes Schindelin, Alex Riesen, Jakub Narebski, git, danahow

On Dec 18, 2007 5:16 PM, Linus Torvalds <torvalds@linux-foundation.org> wrote:
> On Tue, 18 Dec 2007, Dana How wrote:
> > The cases we are talking about are all subtrees of the working tree.
> > There is a useful cwd suffix.
>
> No.
>
> The cases we're talking of are *not* subtrees of the working tree.
>
> The SHA1 of a commit may well be a totally disjoint tree. Try it in the
> git repository with something like

Agreed,  but note you wrote *may*.

I'd like to move some stuff currently in a p4 repository into git.
The directory structure within the repo is 13 levels deep;
I didn't design it nor can I change it.

For the majority of the cases of interest to me git already accepts
relative paths.  However,  one thing people do often in p4 (or any SCM)
is look at (or compare, etc) specific revisions.  Unfortunately,  these are
not part of branches or commits,  they are just file-specific revisions
(don't get me started on p4 "branches").  The equivalent in git is
to use a commit name (or a tag) and then name the file.  The
basic commit:file syntax doesn't accept relative paths.  I am not
specifically hung up on the commit:./path syntax;  I just want some
notation that will get those 13 directories from $cwd instead of
making me type them again.  Yes,  sometimes that might not make
sense to request.

There was some mention of bash/zsh completions  Unfortunately,
much of our CAD environment is not configured in bash/zsh,
so although I use bash for some scripting,
it's not the default for command-line,  and won't be used by
others I need to drag along with me...

> In fact, you can very well think of the commit/tree as a "drive letter".
> It really does go into another namespace entirely. It's just that often
> that namespace does bear some relationship to the currently checked out
> branch. But that's just an "often", it's not at all a given.
>
> > Don't you think that
> >   git <op> commit:./file.c
> > could occasionally be more convenient than
> >   git <op> commit:very/long/and/boring/path/equal/to/cwd/file.c
>
> It's not about "convenience". It's about *sanity* and good design. And the
> fact is, that "commit:path" format really has nothing to do with the CWD
> in the general case.

Yes I frequently get to be one of the people here pushing for
(and sometimes losing the case for) "good design".
But I will never be able to successfully argue for retyping 13 directories
already in the cwd because it's the "good" or "sane" thing to do.

Given that the root of the current working tree,  the commit, the cwd,
and the path (suffix) given on the command line are all known precisely,
it does not seem dangerous to come up with an exact rule to combine them
which is only triggered by some specific syntax.

This does not need to work in bare repositories.

Thanks,
-- 
Dana L. How  danahow@gmail.com  +1 650 804 5991 cell

(Junio removed from cc: at his request)

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

* Re: [PATCH] Simple support for tree entry specification with relative pathnames
       [not found]           ` <56b7f5510712181539g27bd4fc9y632ebe74d91b8e82@mail.gmail.com>
@ 2007-12-19  7:36             ` Alex Riesen
  0 siblings, 0 replies; 43+ messages in thread
From: Alex Riesen @ 2007-12-19  7:36 UTC (permalink / raw
  To: Dana How; +Cc: git

Dana How, Wed, Dec 19, 2007 00:39:13 +0100:
> So has this idea been shut down again?

So it seems. Definitely not for 1.5.*

> I don't have the time to update my May 4 patch right now,
> but you are welcome to look at it and see if it has anything useful.

It is very similar.

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

* Re: log/show: relative pathnames do not work in rev:path
  2007-12-19  1:52               ` Dana How
@ 2007-12-19  7:42                 ` Alex Riesen
  2007-12-19 11:23                 ` Jakub Narebski
  2007-12-19 13:40                 ` [PATCH v0] sha1_name: grok <revision>:./<relative-path> Johannes Schindelin
  2 siblings, 0 replies; 43+ messages in thread
From: Alex Riesen @ 2007-12-19  7:42 UTC (permalink / raw
  To: Dana How; +Cc: Linus Torvalds, Johannes Schindelin, Jakub Narebski, git

Dana How, Wed, Dec 19, 2007 02:52:23 +0100:
> Given that the root of the current working tree,  the commit, the cwd,
> and the path (suffix) given on the command line are all known precisely,
> it does not seem dangerous to come up with an exact rule to combine them
> which is only triggered by some specific syntax.
> 
> This does not need to work in bare repositories.
> 

And it wont in both patches (your and mine): they don't have prefix
(aka cwd) at all. The bare repos are just no problem, the pathnames
there are always project-absolute.

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

* Re: log/show: relative pathnames do not work in rev:path
  2007-12-19  1:52               ` Dana How
  2007-12-19  7:42                 ` Alex Riesen
@ 2007-12-19 11:23                 ` Jakub Narebski
  2007-12-19 17:21                   ` Dana How
  2007-12-19 13:40                 ` [PATCH v0] sha1_name: grok <revision>:./<relative-path> Johannes Schindelin
  2 siblings, 1 reply; 43+ messages in thread
From: Jakub Narebski @ 2007-12-19 11:23 UTC (permalink / raw
  To: Dana How; +Cc: Linus Torvalds, Johannes Schindelin, Alex Riesen, git

On Wed, 19 Dec 2007, Dana How wrote:
> On Dec 18, 2007 5:16 PM, Linus Torvalds <torvalds@linux-foundation.org> wrote:
>> On Tue, 18 Dec 2007, Dana How wrote:
>>
>>> The cases we are talking about are all subtrees of the working tree.
>>> There is a useful cwd suffix.
>>
>> No.
>>
>> The cases we're talking of are *not* subtrees of the working tree.
>>
>> The SHA1 of a commit may well be a totally disjoint tree. Try it in the
>> git repository with something like
> 
> Agreed,  but note you wrote *may*.
> 
> I'd like to move some stuff currently in a p4 repository into git.
> The directory structure within the repo is 13 levels deep;
> I didn't design it nor can I change it.
> 
> For the majority of the cases of interest to me git already accepts
> relative paths.  However,  one thing people do often in p4 (or any SCM)
> is look at (or compare, etc) specific revisions.  Unfortunately,  these are
> not part of branches or commits,  they are just file-specific revisions
> (don't get me started on p4 "branches").  The equivalent in git is
> to use a commit name (or a tag) and then name the file.  The
> basic commit:file syntax doesn't accept relative paths.  I am not
> specifically hung up on the commit:./path syntax;  I just want some
> notation that will get those 13 directories from $cwd instead of
> making me type them again.  Yes,  sometimes that might not make
> sense to request.
[...]

I think new feature like this should be postponed after 1.5.4 is out;
we are now in feature freeze (only bugfixes are accepted).

That said, does git-showrel solution proposed by  Johannes Schindelin
in
  Message-ID: <Pine.LNX.4.64.0712182250040.23902@racer.site>
  http://permalink.gmane.org/gmane.comp.version-control.git/68840
work for you?

Below version of git-showrel script which uses proposed 'commit:./relpath'
syntax (it could be improved, of course):

cat > git-showrel <<\EOF
#!/bin/sh

rel=$(git rev-parse --show-prefix 2>/dev/null)
git show $(echo "$@" | sed -e "s!:./!:${rel}!")

EOF
-- 
Jakub Narebski
Poland

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

* [PATCH v0] sha1_name: grok <revision>:./<relative-path>
  2007-12-19  1:52               ` Dana How
  2007-12-19  7:42                 ` Alex Riesen
  2007-12-19 11:23                 ` Jakub Narebski
@ 2007-12-19 13:40                 ` Johannes Schindelin
  2007-12-19 15:05                   ` Jeff King
                                     ` (2 more replies)
  2 siblings, 3 replies; 43+ messages in thread
From: Johannes Schindelin @ 2007-12-19 13:40 UTC (permalink / raw
  To: Dana How; +Cc: Linus Torvalds, Alex Riesen, Jakub Narebski, git


When you are in a deeply-nested directory structure, and just want
to reference a blob in a past revision, it can be pretty slow to
type out "HEAD~29:/bla/blub/.../that-file".

This patch makes "HEAD~29:./that-file" substitute the current prefix
for "./".  If there is not working directory, the prefix is empty.

Note that this patch does not handle "../", and neither do I plan to.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
---

	On Tue, 18 Dec 2007, Dana How wrote:

	> On Dec 18, 2007 5:16 PM, Linus Torvalds 
	>			<torvalds@linux-foundation.org> wrote:
	> > On Tue, 18 Dec 2007, Dana How wrote:
	> >
	> > > The cases we are talking about are all subtrees of the 
	> > > working tree. There is a useful cwd suffix.
	> >
	> > No.
	> >
	> > The cases we're talking of are *not* subtrees of the working 
	> > tree.
	> >
	> > The SHA1 of a commit may well be a totally disjoint tree. Try 
	> > it in the git repository with something like
	> 
	> Agreed,  but note you wrote *may*.

	Okay, this is a proposed patch.  It leaves the existing 
	"HEAD:<path>" handling alone, and only touches "HEAD:./<path>", 
	which would have been invalid anyway (except if you hacked your 
	objects database to include a tree named ".").

	Note: this patch is not meant for application directly.  It should 
	be split into get_current_prefix() as one patch, and the 
	sha1_name.c stuff as the second.  (Not only to boost my ohloh 
	statistics, but because they are logically two separate things.)

	Note, too: this is a quick and little-bit-dirty patch, not well 
	tested.  Particularly, I was unable to trigger the "No <path> in 
	<rev>" error path, so I am not confident that this handling is 
	correct.

	Note also: in contrast to Alex' approach, this will not only work 
	for git-show, but for all callers of get_sha1().

 cache.h     |    1 +
 setup.c     |   16 +++++++++++++---
 sha1_name.c |   17 ++++++++++++++---
 3 files changed, 28 insertions(+), 6 deletions(-)

diff --git a/cache.h b/cache.h
index 39331c2..83a2c31 100644
--- a/cache.h
+++ b/cache.h
@@ -225,6 +225,7 @@ extern char *get_index_file(void);
 extern char *get_graft_file(void);
 extern int set_git_dir(const char *path);
 extern const char *get_git_work_tree(void);
+extern const char *get_current_prefix(void);
 
 #define ALTERNATE_DB_ENVIRONMENT "GIT_ALTERNATE_OBJECT_DIRECTORIES"
 
diff --git a/setup.c b/setup.c
index b59dbe7..fb9b680 100644
--- a/setup.c
+++ b/setup.c
@@ -3,6 +3,12 @@
 
 static int inside_git_dir = -1;
 static int inside_work_tree = -1;
+static const char *current_prefix;
+
+const char *get_current_prefix()
+{
+	return current_prefix;
+}
 
 const char *prefix_path(const char *prefix, int len, const char *path)
 {
@@ -267,6 +273,7 @@ const char *setup_git_directory_gently(int *nongit_ok)
 				/* config may override worktree */
 				if (check_repository_format_gently(nongit_ok))
 					return NULL;
+				current_prefix = retval;
 				return retval;
 			}
 			if (check_repository_format_gently(nongit_ok))
@@ -279,7 +286,8 @@ const char *setup_git_directory_gently(int *nongit_ok)
 			if (chdir(work_tree_env) < 0)
 				die ("Could not chdir to %s", work_tree_env);
 			strcat(buffer, "/");
-			return retval;
+			current_prefix = retval;
+			return current_prefix;
 		}
 		if (nongit_ok) {
 			*nongit_ok = 1;
@@ -339,7 +347,8 @@ const char *setup_git_directory_gently(int *nongit_ok)
 	offset++;
 	cwd[len++] = '/';
 	cwd[len] = 0;
-	return cwd + offset;
+	current_prefix = cwd + offset;
+	return current_prefix;
 }
 
 int git_config_perm(const char *var, const char *value)
@@ -396,7 +405,8 @@ const char *setup_git_directory(void)
 		if (retval && chdir(retval))
 			die ("Could not jump back into original cwd");
 		rel = get_relative_cwd(buffer, PATH_MAX, get_git_work_tree());
-		return rel && *rel ? strcat(rel, "/") : NULL;
+		current_prefix = rel && *rel ? strcat(rel, "/") : NULL;
+		return current_prefix;
 	}
 
 	return retval;
diff --git a/sha1_name.c b/sha1_name.c
index 13e1164..6f61d26 100644
--- a/sha1_name.c
+++ b/sha1_name.c
@@ -712,9 +712,20 @@ int get_sha1_with_mode(const char *name, unsigned char *sha1, unsigned *mode)
 	}
 	if (*cp == ':') {
 		unsigned char tree_sha1[20];
-		if (!get_sha1_1(name, cp-name, tree_sha1))
-			return get_tree_entry(tree_sha1, cp+1, sha1,
-					      mode);
+		if (!get_sha1_1(name, cp-name, tree_sha1)) {
+			const char *prefix;
+			if (!prefixcmp(cp + 1, "./") &&
+					(prefix = get_current_prefix())) {
+				unsigned char subtree_sha1[20];
+				if (get_tree_entry(tree_sha1, prefix,
+							subtree_sha1, mode))
+					return error("No '%s' in '%.*s'",
+							prefix, cp-name, name);
+				memcpy(tree_sha1, subtree_sha1, 20);
+				cp += 2;
+			}
+			return get_tree_entry(tree_sha1, cp+1, sha1, mode);
+		}
 	}
 	return ret;
 }
-- 
1.5.4.rc0.72.g536e9

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

* Re: [PATCH] Use pathexpand to preparse the relative pathnames in blob references
  2007-12-18 20:52         ` [PATCH] Use pathexpand to preparse the relative pathnames in blob references Alex Riesen
  2007-12-18 21:06           ` Dana How
@ 2007-12-19 14:37           ` Jeff King
  1 sibling, 0 replies; 43+ messages in thread
From: Jeff King @ 2007-12-19 14:37 UTC (permalink / raw
  To: Alex Riesen
  Cc: Jakub Narebski, git, Junio C Hamano, Johannes Schindelin,
	Linus Torvalds

On Tue, Dec 18, 2007 at 09:52:53PM +0100, Alex Riesen wrote:

> This, OTOH, is a bit intrusive and changes the current behaviour a bit
> too far. git-show cannot use the absolute pathnames in blob locators
> at all now, which I consider bad. An obvious way to use rev:/path is
> blocked by Johannes' get_sha1_oneline. It would have worked, though.

IMO, this is backwards. The default should be absolute naming (after
all, you have already rooted it at a tree by saying HEAD:), and you
should treat '.' as a short-hand for "my current prefix". IOW, this
works as before:

  cd t && git show HEAD:t/test-lib.sh

but this would now work:

  cd t && git show HEAD:./test-lib.sh

and of course supporting '..' could be added, as well.

This works under the assumption that you don't have tree entries of '.'
or '..'; I don't think the data structure enforces any such assumption,
but I doubt you could easily create such a tree without hacking the git
tools (and you would have to be insane to do so anyway).

-Peff

PS I didn't just think of this...I'm pretty sure this discussion came up
sometime in the past year and somebody more clever than I thought of it.

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

* Re: [PATCH v0] sha1_name: grok <revision>:./<relative-path>
  2007-12-19 13:40                 ` [PATCH v0] sha1_name: grok <revision>:./<relative-path> Johannes Schindelin
@ 2007-12-19 15:05                   ` Jeff King
  2007-12-19 17:40                     ` Dana How
  2007-12-20  1:07                   ` Junio C Hamano
  2007-12-21 14:17                   ` Nguyen Thai Ngoc Duy
  2 siblings, 1 reply; 43+ messages in thread
From: Jeff King @ 2007-12-19 15:05 UTC (permalink / raw
  To: Johannes Schindelin
  Cc: Dana How, Linus Torvalds, Alex Riesen, Jakub Narebski, git

On Wed, Dec 19, 2007 at 01:40:27PM +0000, Johannes Schindelin wrote:

> When you are in a deeply-nested directory structure, and just want
> to reference a blob in a past revision, it can be pretty slow to
> type out "HEAD~29:/bla/blub/.../that-file".
> 
> This patch makes "HEAD~29:./that-file" substitute the current prefix
> for "./".  If there is not working directory, the prefix is empty.
> 
> Note that this patch does not handle "../", and neither do I plan to.

I think this is definitely the right approach. Here's a (possibly
insane) alternative. Revert the change in get_sha1_with_mode and detect
"./" in get_tree_entry:

diff --git a/tree-walk.c b/tree-walk.c
index 8d4b673..fc54354 100644
--- a/tree-walk.c
+++ b/tree-walk.c
@@ -191,6 +191,7 @@ int get_tree_entry(const unsigned char *tree_sha1, const char *name, unsigned ch
 	unsigned long size;
 	struct tree_desc t;
 	unsigned char root[20];
+	const char *prefix;
 
 	tree = read_object_with_reference(tree_sha1, tree_type, &size, root);
 	if (!tree)
@@ -202,7 +203,11 @@ int get_tree_entry(const unsigned char *tree_sha1, const char *name, unsigned ch
 	}
 
 	init_tree_desc(&t, tree, size);
-	retval = find_tree_entry(&t, name, sha1, mode);
+	if (!prefixcmp(name, "./") && (prefix = get_current_prefix()))
+		retval = find_tree_entry(&t, mkpath("%s%s", prefix, name + 2),
+				sha1, mode);
+	else
+		retval = find_tree_entry(&t, name, sha1, mode);
 	free(tree);
 	return retval;
 }


This means that the directory '.' becomes a token replacement for "my
current path" in tree paths. So if you are in "foo/bar", and you are
looking at a distance commit where the same content was in
"baz/foo/bar", you can do:

  git show distant:baz/./file

This is probably insane because:
  - this is a fairly unlikely use case
  - get_tree_entry gets called in a lot of places, and I have no idea if
    there will be some crazy fallouts.

So it is probably not worth pursuing, but maybe somebody else can think
of a good use.

-Peff

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

* Re: log/show: relative pathnames do not work in rev:path
  2007-12-19 11:23                 ` Jakub Narebski
@ 2007-12-19 17:21                   ` Dana How
  2007-12-19 18:47                     ` Jakub Narebski
  0 siblings, 1 reply; 43+ messages in thread
From: Dana How @ 2007-12-19 17:21 UTC (permalink / raw
  To: Jakub Narebski
  Cc: Linus Torvalds, Johannes Schindelin, Alex Riesen, git, danahow

On Dec 19, 2007 3:23 AM, Jakub Narebski <jnareb@gmail.com> wrote:
> On Wed, 19 Dec 2007, Dana How wrote:
> > I'd like to move some stuff currently in a p4 repository into git.
> > The directory structure within the repo is 13 levels deep;
> > I didn't design it nor can I change it.
> >
> > ...  The
> > basic commit:file syntax doesn't accept relative paths.  I am not
> > specifically hung up on the commit:./path syntax;  I just want some
> > notation that will get those 13 directories from $cwd instead of
> > making me type them again.
>
> I think new feature like this should be postponed after 1.5.4 is out;
> we are now in feature freeze (only bugfixes are accepted).
OK.  This is all the conversation that resulted from Alex's RFC.

> That said, does git-showrel solution proposed by  Johannes Schindelin
> in
>   Message-ID: <Pine.LNX.4.64.0712182250040.23902@racer.site>
>   http://permalink.gmane.org/gmane.comp.version-control.git/68840
> work for you?
>
> Below version of git-showrel script which uses proposed 'commit:./relpath'
> syntax (it could be improved, of course):
>
> cat > git-showrel <<\EOF
> #!/bin/sh
>
> rel=$(git rev-parse --show-prefix 2>/dev/null)
> git show $(echo "$@" | sed -e "s!:./!:${rel}!")
>
> EOF

It's definitely true I could use this for now.  In the long run
(meaning after the feature freeze) I don't view this as adequate
for 2 reasons:
(1) I would like a consistent interpretation of commit:path
wherever it is accepted; and
(2) If a novice types bad arguments to git-showrel ,  they
are probably going to be very confused by its error messages
which are a response to a munged version of their command line.

Thanks,
-- 
Dana L. How  danahow@gmail.com  +1 650 804 5991 cell

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

* Re: [PATCH v0] sha1_name: grok <revision>:./<relative-path>
  2007-12-19 15:05                   ` Jeff King
@ 2007-12-19 17:40                     ` Dana How
  2007-12-19 18:09                       ` Alex Riesen
  0 siblings, 1 reply; 43+ messages in thread
From: Dana How @ 2007-12-19 17:40 UTC (permalink / raw
  To: Jeff King
  Cc: Johannes Schindelin, Linus Torvalds, Alex Riesen, Jakub Narebski,
	git, danahow

On Dec 19, 2007 7:05 AM, Jeff King <peff@peff.net> wrote:
> On Wed, Dec 19, 2007 at 01:40:27PM +0000, Johannes Schindelin wrote:
> > When you are in a deeply-nested directory structure, and just want
> > to reference a blob in a past revision, it can be pretty slow to
> > type out "HEAD~29:/bla/blub/.../that-file".
> >
> > This patch makes "HEAD~29:./that-file" substitute the current prefix
> > for "./".  If there is not working directory, the prefix is empty.
>
> I think this is definitely the right approach. Here's a (possibly
> insane) alternative. Revert the change in get_sha1_with_mode and detect
> "./" in get_tree_entry:
>
> [..]
>
> This means that the directory '.' becomes a token replacement for "my
> current path" in tree paths. So if you are in "foo/bar", and you are
> looking at a distance commit where the same content was in
> "baz/foo/bar", you can do:
>
>   git show distant:baz/./file
>
> This is probably insane because:
>   - this is a fairly unlikely use case
>   - get_tree_entry gets called in a lot of places, and I have no idea if
>     there will be some crazy fallouts.
>
> So it is probably not worth pursuing, but maybe somebody else can think
> of a good use.

For me,  I was only interested in the recognition of ./ at the beginning
of a path just after : (causing a cwd suffix to be inserted there).

If there were additional /./ or /../ patterns in the result,  I think it
would be more useful (e.g. for script writers who forgot to run
their file arguments thru something like "readlink -f") for them
to be squashed out (e.g. in Perl:
  s#/(\./)+#/#g;
  s#/([^/]*[^./][^/]*/\.\./)+#/#g;
).  But this is something that could be added later if desired to
the interpretation of all paths,  and so seems like a different issue.

Thanks,
-- 
Dana L. How  danahow@gmail.com  +1 650 804 5991 cell

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

* Re: [PATCH v0] sha1_name: grok <revision>:./<relative-path>
  2007-12-19 17:40                     ` Dana How
@ 2007-12-19 18:09                       ` Alex Riesen
  0 siblings, 0 replies; 43+ messages in thread
From: Alex Riesen @ 2007-12-19 18:09 UTC (permalink / raw
  To: Dana How
  Cc: Jeff King, Johannes Schindelin, Linus Torvalds, Jakub Narebski,
	git

Dana How, Wed, Dec 19, 2007 18:40:04 +0100:
> If there were additional /./ or /../ patterns in the result,  I think it
> would be more useful (e.g. for script writers who forgot to run
> their file arguments thru something like "readlink -f") for them
> to be squashed out (e.g. in Perl:
>   s#/(\./)+#/#g;
>   s#/([^/]*[^./][^/]*/\.\./)+#/#g;
> ).  But this is something that could be added later if desired to
> the interpretation of all paths,  and so seems like a different issue.

This is what the pathexpand in pathexpand-patch does.

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

* Re: log/show: relative pathnames do not work in rev:path
  2007-12-19 17:21                   ` Dana How
@ 2007-12-19 18:47                     ` Jakub Narebski
  0 siblings, 0 replies; 43+ messages in thread
From: Jakub Narebski @ 2007-12-19 18:47 UTC (permalink / raw
  To: Dana How; +Cc: Linus Torvalds, Johannes Schindelin, Alex Riesen, git

On Wednesday, 19 December 2007, Dana How wrote:
> On Dec 19, 2007 3:23 AM, Jakub Narebski <jnareb@gmail.com> wrote:
>> 
>> That said, does git-showrel solution proposed by  Johannes Schindelin
>> in
>>   Message-ID: <Pine.LNX.4.64.0712182250040.23902@racer.site>
>>   http://permalink.gmane.org/gmane.comp.version-control.git/68840
>> work for you?
>>
>> Below version of git-showrel script which uses proposed
>> 'commit:./relpath' syntax (it could be improved, of course):
>>
>> cat> git-showrel <<\EOF
>> #!/bin/sh
>>
>> rel=$(git rev-parse --show-prefix 2>/dev/null)
>> git show $(echo "$@" | sed -e "s!:./!:${rel}!")
>>
>> EOF
> 
> It's definitely true I could use this for now.  In the long run
> (meaning after the feature freeze) I don't view this as adequate
> for 2 reasons:
> (1) I would like a consistent interpretation of commit:path
> wherever it is accepted; and

Of course this is only interim solution, after 1.5.4 is out, we are out 
of feature freeze, and <path>:./<relpath> is in.

> (2) If a novice types bad arguments to git-showrel ,  they
> are probably going to be very confused by its error messages
> which are a response to a munged version of their command line.

Actually git-showrel should change only the _last_ argument, passing all 
other unchanged to git-show. But this requires something more than 
simplest script as above...

Unfortunately my shell script hackery is not up to the task ;-(
-- 
Jakub Narebski
Poland

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

* Re: log/show: relative pathnames do not work in rev:path
  2007-12-18 22:30           ` Dana How
  2007-12-18 23:02             ` Johannes Schindelin
@ 2007-12-19 20:45             ` Junio C Hamano
  1 sibling, 0 replies; 43+ messages in thread
From: Junio C Hamano @ 2007-12-19 20:45 UTC (permalink / raw
  To: Dana How
  Cc: Junio C Hamano, Linus Torvalds, Jakub Narebski, Alex Riesen, git,
	Johannes Schindelin

"Dana How" <danahow@gmail.com> writes:

> How about this:
> <tree-ish>:./path -> NEW: relative

I think making "<tree>:./" mean "replace ./ with the current prefix and
retry the usual expansion" is relatively confusion free.  You have to
work hard to confuse yourself:

	d=$(git rev-parse --verify HEAD:Documentation)
        git rev-parse "$d":./howto ;# would not work
	cd Documentation && git rev-parse "$d":./howto ;# would work

> <tree-ish>:../path -> NEW: relative

I would rather avoid up (../) processing if we can, but making "<tree>:"
immediately followed by 1 or more "../" mean "take the current prefix,
strip away the same number of trailing directory components as we have
"../" there, and tuck the remainder in front of the path before trying
the usual expansion" would be a natural and relatively confusion free
extension of the above.  I think I can live with that, too.

> <tree-ish>:?pattern -> NEW: same as next (current :/ )

I'd prefer keeping :? (or some other unlikely-in-path letter other than
'?') as a special extension introducer character, i.e. leaving the door
open to:

	<tree>:?(magic)parameter

whose semantics is to be defined later, depending on "magic".

Similarly, we could do the same for

	:?(magic)parameter

> <tree-ish>:/pattern -> unchanged (sha1_name_oneline IIRC)

I do not think this is oneline.  "<commit>:/pattern" could be a natural
extension to the current ":/pattern" that instructs "dig from only this
commit, not all refs, and find a commit with the oneline," but I do not
think it is a good idea.  It is too similar to "locate this tree entry
from the given tree" syntax.

> <tree-ish>:path -> unchanged: absolute

Absolutely ;-)

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

* Re: [PATCH v0] sha1_name: grok <revision>:./<relative-path>
  2007-12-19 13:40                 ` [PATCH v0] sha1_name: grok <revision>:./<relative-path> Johannes Schindelin
  2007-12-19 15:05                   ` Jeff King
@ 2007-12-20  1:07                   ` Junio C Hamano
  2007-12-20 10:51                     ` Johannes Schindelin
  2007-12-21 14:17                   ` Nguyen Thai Ngoc Duy
  2 siblings, 1 reply; 43+ messages in thread
From: Junio C Hamano @ 2007-12-20  1:07 UTC (permalink / raw
  To: Johannes Schindelin
  Cc: Dana How, Linus Torvalds, Alex Riesen, Jakub Narebski, git

Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:

> diff --git a/cache.h b/cache.h
> index 39331c2..83a2c31 100644
> --- a/cache.h
> +++ b/cache.h
> @@ -225,6 +225,7 @@ extern char *get_index_file(void);
>  extern char *get_graft_file(void);
>  extern int set_git_dir(const char *path);
>  extern const char *get_git_work_tree(void);
> +extern const char *get_current_prefix(void);
>  
>  #define ALTERNATE_DB_ENVIRONMENT "GIT_ALTERNATE_OBJECT_DIRECTORIES"
>  
> diff --git a/setup.c b/setup.c
> index b59dbe7..fb9b680 100644
> --- a/setup.c
> +++ b/setup.c
> @@ -3,6 +3,12 @@
>  
>  static int inside_git_dir = -1;
>  static int inside_work_tree = -1;
> +static const char *current_prefix;
> +
> +const char *get_current_prefix()
> +{
> +	return current_prefix;
> +}

Didn't you just make libification harder?

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

* Re: [PATCH v0] sha1_name: grok <revision>:./<relative-path>
  2007-12-20  1:07                   ` Junio C Hamano
@ 2007-12-20 10:51                     ` Johannes Schindelin
  0 siblings, 0 replies; 43+ messages in thread
From: Johannes Schindelin @ 2007-12-20 10:51 UTC (permalink / raw
  To: Junio C Hamano; +Cc: Dana How, Linus Torvalds, Alex Riesen, Jakub Narebski, git

Hi,

On Wed, 19 Dec 2007, Junio C Hamano wrote:

> Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:
> 
> > diff --git a/cache.h b/cache.h
> > index 39331c2..83a2c31 100644
> > --- a/cache.h
> > +++ b/cache.h
> > @@ -225,6 +225,7 @@ extern char *get_index_file(void);
> >  extern char *get_graft_file(void);
> >  extern int set_git_dir(const char *path);
> >  extern const char *get_git_work_tree(void);
> > +extern const char *get_current_prefix(void);
> >  
> >  #define ALTERNATE_DB_ENVIRONMENT "GIT_ALTERNATE_OBJECT_DIRECTORIES"
> >  
> > diff --git a/setup.c b/setup.c
> > index b59dbe7..fb9b680 100644
> > --- a/setup.c
> > +++ b/setup.c
> > @@ -3,6 +3,12 @@
> >  
> >  static int inside_git_dir = -1;
> >  static int inside_work_tree = -1;
> > +static const char *current_prefix;
> > +
> > +const char *get_current_prefix()
> > +{
> > +	return current_prefix;
> > +}
> 
> Didn't you just make libification harder?

Well, yes.

Actually, no:

	- I marked this explicitely not ready for application,
	- it is not entirely clear if a libgit.a user would not want to 
	  set a default prefix, and
	- I decided that I will not be the only one who tries to make 
		  libification easy. ;-)

Ciao,
Dscho

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

* Re: [PATCH v0] sha1_name: grok <revision>:./<relative-path>
  2007-12-19 13:40                 ` [PATCH v0] sha1_name: grok <revision>:./<relative-path> Johannes Schindelin
  2007-12-19 15:05                   ` Jeff King
  2007-12-20  1:07                   ` Junio C Hamano
@ 2007-12-21 14:17                   ` Nguyen Thai Ngoc Duy
  2007-12-21 17:50                     ` Junio C Hamano
  2007-12-22 14:33                     ` Johannes Schindelin
  2 siblings, 2 replies; 43+ messages in thread
From: Nguyen Thai Ngoc Duy @ 2007-12-21 14:17 UTC (permalink / raw
  To: Johannes Schindelin
  Cc: Dana How, Linus Torvalds, Alex Riesen, Jakub Narebski, git

On Dec 19, 2007 8:40 PM, Johannes Schindelin <Johannes.Schindelin@gmx.de> wrote:
>
> When you are in a deeply-nested directory structure, and just want
> to reference a blob in a past revision, it can be pretty slow to
> type out "HEAD~29:/bla/blub/.../that-file".
>
> This patch makes "HEAD~29:./that-file" substitute the current prefix
> for "./".  If there is not working directory, the prefix is empty.
>
> Note that this patch does not handle "../", and neither do I plan to.

Junio's rc1 announcement got me to read this. It would be indeed
useful as I usually work in deep subdirs. However, from my user
perspective, the right approach is to make <treeish>:path always be
relative to current directory. If you want absolute path, use
<treeish>:/path. More intuitive but it breaks current behavior. Can we
slowly migrate from current absolute-path-by-default behavior to
relative-pat- by-default one? (I don't know how to make such migration
smoothly though)

> Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
> ---
>
>         On Tue, 18 Dec 2007, Dana How wrote:
>
>         > On Dec 18, 2007 5:16 PM, Linus Torvalds
>         >                       <torvalds@linux-foundation.org> wrote:
>         > > On Tue, 18 Dec 2007, Dana How wrote:
>         > >
>         > > > The cases we are talking about are all subtrees of the
>         > > > working tree. There is a useful cwd suffix.
>         > >
>         > > No.
>         > >
>         > > The cases we're talking of are *not* subtrees of the working
>         > > tree.
>         > >
>         > > The SHA1 of a commit may well be a totally disjoint tree. Try
>         > > it in the git repository with something like
>         >
>         > Agreed,  but note you wrote *may*.
>
>         Okay, this is a proposed patch.  It leaves the existing
>         "HEAD:<path>" handling alone, and only touches "HEAD:./<path>",
>         which would have been invalid anyway (except if you hacked your
>         objects database to include a tree named ".").
>
>         Note: this patch is not meant for application directly.  It should
>         be split into get_current_prefix() as one patch, and the
>         sha1_name.c stuff as the second.  (Not only to boost my ohloh
>         statistics, but because they are logically two separate things.)
>
>         Note, too: this is a quick and little-bit-dirty patch, not well
>         tested.  Particularly, I was unable to trigger the "No <path> in
>         <rev>" error path, so I am not confident that this handling is
>         correct.
>
>         Note also: in contrast to Alex' approach, this will not only work
>         for git-show, but for all callers of get_sha1().
>
>  cache.h     |    1 +
>  setup.c     |   16 +++++++++++++---
>  sha1_name.c |   17 ++++++++++++++---
>  3 files changed, 28 insertions(+), 6 deletions(-)
>
> diff --git a/cache.h b/cache.h
> index 39331c2..83a2c31 100644
> --- a/cache.h
> +++ b/cache.h
> @@ -225,6 +225,7 @@ extern char *get_index_file(void);
>  extern char *get_graft_file(void);
>  extern int set_git_dir(const char *path);
>  extern const char *get_git_work_tree(void);
> +extern const char *get_current_prefix(void);
>
>  #define ALTERNATE_DB_ENVIRONMENT "GIT_ALTERNATE_OBJECT_DIRECTORIES"
>
> diff --git a/setup.c b/setup.c
> index b59dbe7..fb9b680 100644
> --- a/setup.c
> +++ b/setup.c
> @@ -3,6 +3,12 @@
>
>  static int inside_git_dir = -1;
>  static int inside_work_tree = -1;
> +static const char *current_prefix;
> +
> +const char *get_current_prefix()
> +{
> +       return current_prefix;
> +}
>
>  const char *prefix_path(const char *prefix, int len, const char *path)
>  {
> @@ -267,6 +273,7 @@ const char *setup_git_directory_gently(int *nongit_ok)
>                                 /* config may override worktree */
>                                 if (check_repository_format_gently(nongit_ok))
>                                         return NULL;
> +                               current_prefix = retval;
>                                 return retval;
>                         }
>                         if (check_repository_format_gently(nongit_ok))
> @@ -279,7 +286,8 @@ const char *setup_git_directory_gently(int *nongit_ok)
>                         if (chdir(work_tree_env) < 0)
>                                 die ("Could not chdir to %s", work_tree_env);
>                         strcat(buffer, "/");
> -                       return retval;
> +                       current_prefix = retval;
> +                       return current_prefix;
>                 }
>                 if (nongit_ok) {
>                         *nongit_ok = 1;
> @@ -339,7 +347,8 @@ const char *setup_git_directory_gently(int *nongit_ok)
>         offset++;
>         cwd[len++] = '/';
>         cwd[len] = 0;
> -       return cwd + offset;
> +       current_prefix = cwd + offset;
> +       return current_prefix;
>  }
>
>  int git_config_perm(const char *var, const char *value)
> @@ -396,7 +405,8 @@ const char *setup_git_directory(void)
>                 if (retval && chdir(retval))
>                         die ("Could not jump back into original cwd");
>                 rel = get_relative_cwd(buffer, PATH_MAX, get_git_work_tree());
> -               return rel && *rel ? strcat(rel, "/") : NULL;
> +               current_prefix = rel && *rel ? strcat(rel, "/") : NULL;
> +               return current_prefix;
>         }
>
>         return retval;
> diff --git a/sha1_name.c b/sha1_name.c
> index 13e1164..6f61d26 100644
> --- a/sha1_name.c
> +++ b/sha1_name.c
> @@ -712,9 +712,20 @@ int get_sha1_with_mode(const char *name, unsigned char *sha1, unsigned *mode)
>         }
>         if (*cp == ':') {
>                 unsigned char tree_sha1[20];
> -               if (!get_sha1_1(name, cp-name, tree_sha1))
> -                       return get_tree_entry(tree_sha1, cp+1, sha1,
> -                                             mode);
> +               if (!get_sha1_1(name, cp-name, tree_sha1)) {
> +                       const char *prefix;
> +                       if (!prefixcmp(cp + 1, "./") &&
> +                                       (prefix = get_current_prefix())) {
> +                               unsigned char subtree_sha1[20];
> +                               if (get_tree_entry(tree_sha1, prefix,
> +                                                       subtree_sha1, mode))
> +                                       return error("No '%s' in '%.*s'",
> +                                                       prefix, cp-name, name);
> +                               memcpy(tree_sha1, subtree_sha1, 20);
> +                               cp += 2;
> +                       }
> +                       return get_tree_entry(tree_sha1, cp+1, sha1, mode);
> +               }
>         }
>         return ret;
>  }
> --
> 1.5.4.rc0.72.g536e9
>
> -
> To unsubscribe from this list: send the line "unsubscribe git" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>



-- 
Duy

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

* Re: [PATCH v0] sha1_name: grok <revision>:./<relative-path>
  2007-12-21 14:17                   ` Nguyen Thai Ngoc Duy
@ 2007-12-21 17:50                     ` Junio C Hamano
  2007-12-21 20:15                       ` Nguyen Thai Ngoc Duy
  2007-12-22 14:33                     ` Johannes Schindelin
  1 sibling, 1 reply; 43+ messages in thread
From: Junio C Hamano @ 2007-12-21 17:50 UTC (permalink / raw
  To: Nguyen Thai Ngoc Duy
  Cc: Johannes Schindelin, Dana How, Linus Torvalds, Alex Riesen,
	Jakub Narebski, git

"Nguyen Thai Ngoc Duy" <pclouds@gmail.com> writes:

>> Note that this patch does not handle "../", and neither do I plan to.
>
> Junio's rc1 announcement got me to read this. It would be indeed
> useful as I usually work in deep subdirs. However, from my user
> perspective, the right approach is to make <treeish>:path always be
> relative to current directory. If you want absolute path, use
> <treeish>:/path. More intuitive but it breaks current behavior.

I do not know if you followed the discussion thread, but the
<treeish>:relative-path has been shown to be broken semantics,
so even if it may be "intuitive", it is intuitive only to people
who do not understand the brokenness.  Please read the one that
Dscho talks about windows drive letter and Linus agrees that is
a good analogy.

It might be possible to do <commit>:relative and apply that only
to direct user input, but I do not think it is worth the
compatibility and complexity hassle.

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

* Re: [PATCH v0] sha1_name: grok <revision>:./<relative-path>
  2007-12-21 17:50                     ` Junio C Hamano
@ 2007-12-21 20:15                       ` Nguyen Thai Ngoc Duy
  0 siblings, 0 replies; 43+ messages in thread
From: Nguyen Thai Ngoc Duy @ 2007-12-21 20:15 UTC (permalink / raw
  To: Junio C Hamano
  Cc: Johannes Schindelin, Dana How, Linus Torvalds, Alex Riesen,
	Jakub Narebski, git

On Dec 22, 2007 12:50 AM, Junio C Hamano <gitster@pobox.com> wrote:
> "Nguyen Thai Ngoc Duy" <pclouds@gmail.com> writes:
>
> >> Note that this patch does not handle "../", and neither do I plan to.
> >
> > Junio's rc1 announcement got me to read this. It would be indeed
> > useful as I usually work in deep subdirs. However, from my user
> > perspective, the right approach is to make <treeish>:path always be
> > relative to current directory. If you want absolute path, use
> > <treeish>:/path. More intuitive but it breaks current behavior.
>
> I do not know if you followed the discussion thread, but the
> <treeish>:relative-path has been shown to be broken semantics,
> so even if it may be "intuitive", it is intuitive only to people
> who do not understand the brokenness.  Please read the one that
> Dscho talks about windows drive letter and Linus agrees that is
> a good analogy.
>
> It might be possible to do <commit>:relative and apply that only
> to direct user input, but I do not think it is worth the
> compatibility and complexity hassle.

Argh! I missed that thread. Will shut up now :-X Thanks for the pointer.
-- 
Duy

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

* Re: [PATCH v0] sha1_name: grok <revision>:./<relative-path>
  2007-12-21 14:17                   ` Nguyen Thai Ngoc Duy
  2007-12-21 17:50                     ` Junio C Hamano
@ 2007-12-22 14:33                     ` Johannes Schindelin
  1 sibling, 0 replies; 43+ messages in thread
From: Johannes Schindelin @ 2007-12-22 14:33 UTC (permalink / raw
  To: Nguyen Thai Ngoc Duy; +Cc: git

Hi,

On Fri, 21 Dec 2007, Nguyen Thai Ngoc Duy wrote:

> [...] from my user perspective, the right approach is to make 
> <treeish>:path always be relative to current directory.

As said by Junio, this would be a bad decision.

BTW please do not quote parts of the email that you do not comment on; it 
takes half a minute of _everybody_ who tries to read your mail, only to 
realise that it was time wasted.

Ciao,
Dscho

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

end of thread, other threads:[~2007-12-22 14:33 UTC | newest]

Thread overview: 43+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-12-18 17:33 log/show: relative pathnames do not work in rev:path Alex Riesen
2007-12-18 17:50 ` Jakub Narebski
2007-12-18 20:46   ` Alex Riesen
2007-12-18 20:47     ` [PATCH] Simple support for tree entry specification with relative pathnames Alex Riesen
2007-12-18 20:49       ` [PATCH] Introduce pathexpand: syntax-level chdir into the given cwd Alex Riesen
2007-12-18 20:52         ` [PATCH] Use pathexpand to preparse the relative pathnames in blob references Alex Riesen
2007-12-18 21:06           ` Dana How
2007-12-19 14:37           ` Jeff King
2007-12-18 21:03       ` [PATCH] Simple support for tree entry specification with relative pathnames Dana How
2007-12-18 21:17         ` Alex Riesen
     [not found]           ` <56b7f5510712181539g27bd4fc9y632ebe74d91b8e82@mail.gmail.com>
2007-12-19  7:36             ` Alex Riesen
2007-12-18 21:24     ` log/show: relative pathnames do not work in rev:path Jakub Narebski
2007-12-18 21:53       ` Linus Torvalds
2007-12-18 22:08         ` Dana How
2007-12-18 22:29           ` Alex Riesen
2007-12-18 22:20         ` Junio C Hamano
2007-12-18 22:30           ` Dana How
2007-12-18 23:02             ` Johannes Schindelin
2007-12-19 20:45             ` Junio C Hamano
2007-12-18 22:20       ` Alex Riesen
2007-12-18 22:43         ` Johannes Schindelin
2007-12-18 23:03           ` Dana How
2007-12-18 23:26             ` Johannes Schindelin
2007-12-19  1:16             ` Linus Torvalds
2007-12-19  1:52               ` Dana How
2007-12-19  7:42                 ` Alex Riesen
2007-12-19 11:23                 ` Jakub Narebski
2007-12-19 17:21                   ` Dana How
2007-12-19 18:47                     ` Jakub Narebski
2007-12-19 13:40                 ` [PATCH v0] sha1_name: grok <revision>:./<relative-path> Johannes Schindelin
2007-12-19 15:05                   ` Jeff King
2007-12-19 17:40                     ` Dana How
2007-12-19 18:09                       ` Alex Riesen
2007-12-20  1:07                   ` Junio C Hamano
2007-12-20 10:51                     ` Johannes Schindelin
2007-12-21 14:17                   ` Nguyen Thai Ngoc Duy
2007-12-21 17:50                     ` Junio C Hamano
2007-12-21 20:15                       ` Nguyen Thai Ngoc Duy
2007-12-22 14:33                     ` Johannes Schindelin
2007-12-18 23:11           ` log/show: relative pathnames do not work in rev:path Jakub Narebski
2007-12-18 23:15             ` Dana How
2007-12-18 23:18           ` Junio C Hamano
2007-12-18 23:05         ` Jakub Narebski

Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

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 read-only IMAP folder(s) and NNTP newsgroup(s).