git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] sha1_name(): accept ':directory/' to get at the cache_tree
@ 2006-12-22  2:19 Johannes Schindelin
  2006-12-22  4:29 ` Junio C Hamano
  2006-12-22  8:44 ` Alex Riesen
  0 siblings, 2 replies; 16+ messages in thread
From: Johannes Schindelin @ 2006-12-22  2:19 UTC (permalink / raw)
  To: git, junkio


If the cache tree is not up-to-date, it will be updated first. So, now

	$ git show :Documentation/

will in effect show what files/directories are in the index' version
of the directory Documentation. The three commands

	$ git show :./
	$ git show :.
	$ git show :

are all equivalent and show the index' idea of the root directory.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
---
 sha1_name.c |   24 +++++++++++++++++++++++-
 1 files changed, 23 insertions(+), 1 deletions(-)

diff --git a/sha1_name.c b/sha1_name.c
index 6d7cd78..e3758cc 100644
--- a/sha1_name.c
+++ b/sha1_name.c
@@ -5,6 +5,7 @@
 #include "blob.h"
 #include "tree-walk.h"
 #include "refs.h"
+#include "cache-tree.h"
 
 static int find_short_object_filename(int len, const char *name, unsigned char *sha1)
 {
@@ -532,7 +533,7 @@ int get_sha1(const char *name, unsigned char *sha1)
 	 */
 	if (name[0] == ':') {
 		int stage = 0;
-		struct cache_entry *ce;
+		struct cache_entry *ce = NULL;
 		int pos;
 		if (namelen < 3 ||
 		    name[2] != ':' ||
@@ -561,6 +562,27 @@ int get_sha1(const char *name, unsigned char *sha1)
 			}
 			pos++;
 		}
+		if (namelen > 0 && cp[namelen - 1] == '/')
+			namelen--;
+		if (namelen == 1 && cp[0] == '.') {
+			namelen = 0;
+			cp = "";
+		}
+		if (namelen == 0 || (ce && ce_namelen(ce) > namelen &&
+					ce->name[namelen] == '/' &&
+					!memcmp(ce->name, cp, namelen))) {
+			struct cache_tree *tree =
+				cache_tree_find(active_cache_tree, cp);
+			if (!cache_tree_fully_valid(tree)) {
+				ret = cache_tree_update(active_cache_tree,
+						active_cache, active_nr, 0, 0);
+				if (ret < 0)
+					return ret;
+				tree = cache_tree_find(active_cache_tree, cp);
+			}
+			hashcpy(sha1, tree->sha1);
+			return 0;
+		}
 		return -1;
 	}
 	for (cp = name, bracket_depth = 0; *cp; cp++) {
-- 
1.4.4.2.ga854-dirty

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

* Re: [PATCH] sha1_name(): accept ':directory/' to get at the cache_tree
  2006-12-22  2:19 [PATCH] sha1_name(): accept ':directory/' to get at the cache_tree Johannes Schindelin
@ 2006-12-22  4:29 ` Junio C Hamano
  2006-12-22  8:28   ` Jakub Narebski
                     ` (2 more replies)
  2006-12-22  8:44 ` Alex Riesen
  1 sibling, 3 replies; 16+ messages in thread
From: Junio C Hamano @ 2006-12-22  4:29 UTC (permalink / raw)
  To: Johannes Schindelin; +Cc: git, junkio

(1) Why is this needed?

(2) What does this do when the index is unmerged?

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

* Re: [PATCH] sha1_name(): accept ':directory/' to get at the cache_tree
  2006-12-22  4:29 ` Junio C Hamano
@ 2006-12-22  8:28   ` Jakub Narebski
  2006-12-22 12:16     ` Johannes Schindelin
  2006-12-22 12:14   ` Johannes Schindelin
  2006-12-22 19:25   ` Johannes Schindelin
  2 siblings, 1 reply; 16+ messages in thread
From: Jakub Narebski @ 2006-12-22  8:28 UTC (permalink / raw)
  To: git

Junio C Hamano wrote:

> (1) Why is this needed?

Probably for completeness.

> (2) What does this do when the index is unmerged?

I think it should show "git ls-files --unmerged --abbrev", perhaps...
-- 
Jakub Narebski
Warsaw, Poland
ShadeHawk on #git

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

* Re: [PATCH] sha1_name(): accept ':directory/' to get at the cache_tree
  2006-12-22  2:19 [PATCH] sha1_name(): accept ':directory/' to get at the cache_tree Johannes Schindelin
  2006-12-22  4:29 ` Junio C Hamano
@ 2006-12-22  8:44 ` Alex Riesen
  2006-12-22 12:18   ` Johannes Schindelin
  1 sibling, 1 reply; 16+ messages in thread
From: Alex Riesen @ 2006-12-22  8:44 UTC (permalink / raw)
  To: Johannes Schindelin; +Cc: git, junkio

Johannes Schindelin, Fri, Dec 22, 2006 03:19:21 +0100:
> 
> If the cache tree is not up-to-date, it will be updated first. So, now
> 
> 	$ git show :Documentation/
> 
> will in effect show what files/directories are in the index' version
> of the directory Documentation. The three commands
> 
> 	$ git show :./
> 	$ git show :.
> 	$ git show :
> 
> are all equivalent and show the index' idea of the root directory.

That is a bit unexpected if you're not in the root directory of
repository, but in some subdir of the working directory.
Why root? Why not the current directory relative to root?

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

* Re: [PATCH] sha1_name(): accept ':directory/' to get at the cache_tree
  2006-12-22  4:29 ` Junio C Hamano
  2006-12-22  8:28   ` Jakub Narebski
@ 2006-12-22 12:14   ` Johannes Schindelin
  2006-12-22 19:25   ` Johannes Schindelin
  2 siblings, 0 replies; 16+ messages in thread
From: Johannes Schindelin @ 2006-12-22 12:14 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git

Hi,

On Thu, 21 Dec 2006, Junio C Hamano wrote:

> (1) Why is this needed?

It was asked recently. It also serves well when you want to show the 
index.

> (2) What does this do when the index is unmerged?

I have no idea, and ATM no time to test. Will do later.

Ciao,
Dscho

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

* Re: [PATCH] sha1_name(): accept ':directory/' to get at the cache_tree
  2006-12-22  8:28   ` Jakub Narebski
@ 2006-12-22 12:16     ` Johannes Schindelin
  2006-12-22 18:05       ` Jakub Narebski
  0 siblings, 1 reply; 16+ messages in thread
From: Johannes Schindelin @ 2006-12-22 12:16 UTC (permalink / raw)
  To: Jakub Narebski; +Cc: git

Hi,

On Fri, 22 Dec 2006, Jakub Narebski wrote:

> Junio C Hamano wrote:
> 
> > (2) What does this do when the index is unmerged?
> 
> I think it should show "git ls-files --unmerged --abbrev", perhaps...

Nah. I'd rather fail out, saying that because there are unmerged entries, 
there is no valid tree in the index.

Ciao,
Dscho

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

* Re: [PATCH] sha1_name(): accept ':directory/' to get at the cache_tree
  2006-12-22  8:44 ` Alex Riesen
@ 2006-12-22 12:18   ` Johannes Schindelin
  2006-12-22 16:09     ` Alex Riesen
  0 siblings, 1 reply; 16+ messages in thread
From: Johannes Schindelin @ 2006-12-22 12:18 UTC (permalink / raw)
  To: Alex Riesen; +Cc: git, junkio

Hi,

On Fri, 22 Dec 2006, Alex Riesen wrote:

> Johannes Schindelin, Fri, Dec 22, 2006 03:19:21 +0100:
> > 
> > If the cache tree is not up-to-date, it will be updated first. So, now
> > 
> > 	$ git show :Documentation/
> > 
> > will in effect show what files/directories are in the index' version
> > of the directory Documentation. The three commands
> > 
> > 	$ git show :./
> > 	$ git show :.
> > 	$ git show :
> > 
> > are all equivalent and show the index' idea of the root directory.
> 
> That is a bit unexpected if you're not in the root directory of
> repository, but in some subdir of the working directory.
> Why root? Why not the current directory relative to root?

Why root? Because you are not asking for the working directory. Use "ls" 
for that. You are asking for the index. If you git-show a commit, you 
don't expect the output to be restricted by the subdirectory you're in, 
either, right?

CIao,
Dscho

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

* Re: [PATCH] sha1_name(): accept ':directory/' to get at the cache_tree
  2006-12-22 12:18   ` Johannes Schindelin
@ 2006-12-22 16:09     ` Alex Riesen
  0 siblings, 0 replies; 16+ messages in thread
From: Alex Riesen @ 2006-12-22 16:09 UTC (permalink / raw)
  To: Johannes Schindelin; +Cc: git, junkio

Johannes Schindelin, Fri, Dec 22, 2006 13:18:55 +0100:
> > > If the cache tree is not up-to-date, it will be updated first. So, now
> > > 
> > > 	$ git show :Documentation/
> > > 
> > > will in effect show what files/directories are in the index' version
> > > of the directory Documentation. The three commands
> > > 
> > > 	$ git show :./
> > > 	$ git show :.
> > > 	$ git show :
> > > 
> > > are all equivalent and show the index' idea of the root directory.
> > 
> > That is a bit unexpected if you're not in the root directory of
> > repository, but in some subdir of the working directory.
> > Why root? Why not the current directory relative to root?
> 
> Why root? Because you are not asking for the working directory. Use "ls" 
> for that. You are asking for the index. If you git-show a commit, you 
> don't expect the output to be restricted by the subdirectory you're in, 
> either, right?

Of course I do. You're breaking a very well-known and widely used
idiom here: the "." means current or at least somehow related to the
current directory. Why would you expect "git show :." to show
everything from root on if your current directory is "Documentation"?
Yes, it is a commit which "git show" displays, but the patches/diffs
are restricted by filenames, and that is where the old rules come into
play. And I would actually expect ":/" to filter from the root on, and
":." to mean the current directory.

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

* Re: [PATCH] sha1_name(): accept ':directory/' to get at the cache_tree
  2006-12-22 12:16     ` Johannes Schindelin
@ 2006-12-22 18:05       ` Jakub Narebski
  0 siblings, 0 replies; 16+ messages in thread
From: Jakub Narebski @ 2006-12-22 18:05 UTC (permalink / raw)
  To: Johannes Schindelin; +Cc: git

Johannes Schindelin wrote:

> On Fri, 22 Dec 2006, Jakub Narebski wrote:
> 
>> Junio C Hamano wrote:
>> 
>>> (2) What does this do when the index is unmerged?
>> 
>> I think it should show "git ls-files --unmerged --abbrev", perhaps...
> 
> Nah. I'd rather fail out, saying that because there are unmerged entries, 
> there is no valid tree in the index.

Well, 'git diff' on unmerged IIRC does 'git diff -cc', so why not 'git show :'
do 'git ls-files --unmerged --abbrev'...
-- 
Jakub Narebski
Poland

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

* Re: [PATCH] sha1_name(): accept ':directory/' to get at the cache_tree
  2006-12-22  4:29 ` Junio C Hamano
  2006-12-22  8:28   ` Jakub Narebski
  2006-12-22 12:14   ` Johannes Schindelin
@ 2006-12-22 19:25   ` Johannes Schindelin
  2 siblings, 0 replies; 16+ messages in thread
From: Johannes Schindelin @ 2006-12-22 19:25 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git

Hi,

On Thu, 21 Dec 2006, Junio C Hamano wrote:

> (2) What does this do when the index is unmerged?

	$ git show :
	a1: unmerged (f16f906ab60483c100d1241dfc39868de9ec9fcb)
	a1: unmerged (cf84443e49e1b366fac938711ddf4be2d4d1d9e9)
	a1: unmerged (fd7923529855d0b274795ae3349c5e0438333979)
	fatal: ambiguous argument ':': unknown revision or path not in the 
	working tree. Use '--' to separate paths from revisions

We could be a bit nicer, but I think the first three lines speak for 
themselves. This is all stderr BTW.

Ciao,
Dscho

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

* [PATCH] sha1_name(): accept ':directory/' to get at the cache_tree
@ 2007-01-09 14:03 Johannes Schindelin
  2007-01-09 17:25 ` Alex Riesen
  2007-01-09 23:47 ` Junio C Hamano
  0 siblings, 2 replies; 16+ messages in thread
From: Johannes Schindelin @ 2007-01-09 14:03 UTC (permalink / raw)
  To: git, junkio


If the cache tree is not up-to-date, it will be updated first. So, now

        $ git show :Documentation/

will in effect show what files/directories are in the index' version
of the directory Documentation. The commands

        $ git show :/
        $ git show :

are equivalent and show the index' idea of the root directory.

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

---

	'tis a resend of an earlier patch, but without support for the
	bogus ":." as equivalent to ":/".

	I find this feature highly convenient when I just want to see
	what files the index contains.

 sha1_name.c |   20 +++++++++++++++++++-
 1 files changed, 19 insertions(+), 1 deletions(-)

diff --git a/sha1_name.c b/sha1_name.c
index 6d7cd78..6baa7a4 100644
--- a/sha1_name.c
+++ b/sha1_name.c
@@ -5,6 +5,7 @@
 #include "blob.h"
 #include "tree-walk.h"
 #include "refs.h"
+#include "cache-tree.h"
 
 static int find_short_object_filename(int len, const char *name, unsigned char *sha1)
 {
@@ -532,7 +533,7 @@ int get_sha1(const char *name, unsigned char *sha1)
 	 */
 	if (name[0] == ':') {
 		int stage = 0;
-		struct cache_entry *ce;
+		struct cache_entry *ce = NULL;
 		int pos;
 		if (namelen < 3 ||
 		    name[2] != ':' ||
@@ -561,6 +562,23 @@ int get_sha1(const char *name, unsigned char *sha1)
 			}
 			pos++;
 		}
+		if (namelen > 0 && cp[namelen - 1] == '/')
+			namelen--;
+		if (namelen == 0 || (ce && ce_namelen(ce) > namelen &&
+					ce->name[namelen] == '/' &&
+					!memcmp(ce->name, cp, namelen))) {
+			struct cache_tree *tree =
+				cache_tree_find(active_cache_tree, cp);
+			if (!cache_tree_fully_valid(tree)) {
+				ret = cache_tree_update(active_cache_tree,
+						active_cache, active_nr, 0, 0);
+				if (ret < 0)
+					return ret;
+				tree = cache_tree_find(active_cache_tree, cp);
+			}
+			hashcpy(sha1, tree->sha1);
+			return 0;
+		}
 		return -1;
 	}
 	for (cp = name, bracket_depth = 0; *cp; cp++) {

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

* Re: [PATCH] sha1_name(): accept ':directory/' to get at the cache_tree
  2007-01-09 14:03 Johannes Schindelin
@ 2007-01-09 17:25 ` Alex Riesen
  2007-01-09 23:47 ` Junio C Hamano
  1 sibling, 0 replies; 16+ messages in thread
From: Alex Riesen @ 2007-01-09 17:25 UTC (permalink / raw)
  To: Johannes Schindelin; +Cc: git, junkio

On 1/9/07, Johannes Schindelin <Johannes.Schindelin@gmx.de> wrote:
> 	'tis a resend of an earlier patch, but without support for the
> 	bogus ":." as equivalent to ":/".

Thanks :)

> 	I find this feature highly convenient when I just want to see
> 	what files the index contains.

I find it very useful too.

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

* Re: [PATCH] sha1_name(): accept ':directory/' to get at the cache_tree
  2007-01-09 14:03 Johannes Schindelin
  2007-01-09 17:25 ` Alex Riesen
@ 2007-01-09 23:47 ` Junio C Hamano
  2007-01-10  0:22   ` Johannes Schindelin
  1 sibling, 1 reply; 16+ messages in thread
From: Junio C Hamano @ 2007-01-09 23:47 UTC (permalink / raw)
  To: Johannes Schindelin; +Cc: git

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

> 	'tis a resend of an earlier patch, but without support for the
> 	bogus ":." as equivalent to ":/".
>
> 	I find this feature highly convenient when I just want to see
> 	what files the index contains.

I do not understand; do you mean ls-files?

In any case, I wonder if this does a sane thing if you asked
"git show :3:t/" on a fully merged index.

> @@ -561,6 +562,23 @@ int get_sha1(const char *name, unsigned char *sha1)
>  			}
>  			pos++;
>  		}
> +		if (namelen > 0 && cp[namelen - 1] == '/')
> +			namelen--;
> +		if (namelen == 0 || (ce && ce_namelen(ce) > namelen &&
> +					ce->name[namelen] == '/' &&
> +					!memcmp(ce->name, cp, namelen))) {

I may be misreading the code, but what does ce point at?  Does
this get the index sort order correctly?  For example, would
this work?

	$ echo >t- && git add t-
        $ git show :t
	$ git show :t/

> +			struct cache_tree *tree =
> +				cache_tree_find(active_cache_tree, cp);
> +			if (!cache_tree_fully_valid(tree)) {
> +				ret = cache_tree_update(active_cache_tree,
> +						active_cache, active_nr, 0, 0);
> +				if (ret < 0)
> +					return ret;

This gracefully errs out when the index is unmerged but fails to
pretend the index knows about trees, if the unmerged part of
index is outside the directory the user specified.

In short, I am not sure if it is worth it, and especially if the
motivation is to pretend as if the index contains trees, I would
be opposed to it.  The index does _not_ contain trees, and
cache-tree is a pure optimization for the next write-tree.
Nothing more.

If it (pretending as if the index contains trees) is just a
means to achieve something else worthy, I would not necessarily
oppose to that goal, but I do not see what it is, and I do not
know if the approach is right...

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

* Re: [PATCH] sha1_name(): accept ':directory/' to get at the cache_tree
  2007-01-09 23:47 ` Junio C Hamano
@ 2007-01-10  0:22   ` Johannes Schindelin
  2007-01-10  0:36     ` Junio C Hamano
  0 siblings, 1 reply; 16+ messages in thread
From: Johannes Schindelin @ 2007-01-10  0:22 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git

Hi,

On Tue, 9 Jan 2007, Junio C Hamano wrote:

> Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:
> 
> > 	'tis a resend of an earlier patch, but without support for the
> > 	bogus ":." as equivalent to ":/".
> >
> > 	I find this feature highly convenient when I just want to see
> > 	what files the index contains.
> 
> I do not understand; do you mean ls-files?

It is the same as ls-files, except "show" is shorter, is labeled as 
porcelain, easier to remember, _and_ it runs the pager automatically.

> In any case, I wonder if this does a sane thing if you asked
> "git show :3:t/" on a fully merged index.

No. That slipped through. The code will just ignore the stage (if 
specified) for trees.

> > @@ -561,6 +562,23 @@ int get_sha1(const char *name, unsigned char *sha1)
> >  			}
> >  			pos++;
> >  		}
> > +		if (namelen > 0 && cp[namelen - 1] == '/')
> > +			namelen--;
> > +		if (namelen == 0 || (ce && ce_namelen(ce) > namelen &&
> > +					ce->name[namelen] == '/' &&
> > +					!memcmp(ce->name, cp, namelen))) {
> 
> I may be misreading the code, but what does ce point at?  Does
> this get the index sort order correctly?

It is still at what cache_name_pos(cp, namelen) pointed to, or NULL if 
the entry does not exist (e.g. there is no cache entry, or all cache 
entries are lexicographically smaller).

> For example, would this work?
> 
> 	$ echo >t- && git add t-
>         $ git show :t
> 	$ git show :t/

I think so: The code explicitely checks for a trailing '/'. (See second 
last line of the hunk you quoted.)

> > +			struct cache_tree *tree =
> > +				cache_tree_find(active_cache_tree, cp);
> > +			if (!cache_tree_fully_valid(tree)) {
> > +				ret = cache_tree_update(active_cache_tree,
> > +						active_cache, active_nr, 0, 0);
> > +				if (ret < 0)
> > +					return ret;
> 
> This gracefully errs out when the index is unmerged but fails to
> pretend the index knows about trees, if the unmerged part of
> index is outside the directory the user specified.

That is correct. But in that case, we cannot sanely ask the question "what 
would the tree object look like if we committed right now?"

> In short, I am not sure if it is worth it, and especially if the 
> motivation is to pretend as if the index contains trees, I would be 
> opposed to it.  The index does _not_ contain trees, and cache-tree is a 
> pure optimization for the next write-tree. Nothing more.

Well, it _is_ the method to construct tree objects for committing them.

> If it (pretending as if the index contains trees) is just a means to 
> achieve something else worthy, I would not necessarily oppose to that 
> goal, but I do not see what it is, and I do not know if the approach is 
> right...

I wanted to have it for teaching purposes. And maybe a little bit for 
completeness.

But then it turned out that I even use it before committing, like when I 
ask "what files would be in my next revision?" It is not a question 
arising daily, but sometimes it is interesting to see _before_ committing 
them. (Note that I am not only interested in the _modified_ files.)

But if you feel strongly about that feature, don't take the patch.

Ciao,
Dscho

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

* Re: [PATCH] sha1_name(): accept ':directory/' to get at the cache_tree
  2007-01-10  0:22   ` Johannes Schindelin
@ 2007-01-10  0:36     ` Junio C Hamano
  2007-01-10  0:54       ` Johannes Schindelin
  0 siblings, 1 reply; 16+ messages in thread
From: Junio C Hamano @ 2007-01-10  0:36 UTC (permalink / raw)
  To: Johannes Schindelin; +Cc: git

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

> It is still at what cache_name_pos(cp, namelen) pointed to, or NULL if 
> the entry does not exist (e.g. there is no cache entry, or all cache 
> entries are lexicographically smaller).
>
>> For example, would this work?
>> 
>> 	$ echo >t- && git add t-
>>         $ git show :t
>> 	$ git show :t/
>
> I think so: The code explicitely checks for a trailing '/'. (See second 
> last line of the hunk you quoted.)

The comment was not about the trailing / version, but the one without.
Have you tried them?  

>> > +			struct cache_tree *tree =
>> > +				cache_tree_find(active_cache_tree, cp);
>> > +			if (!cache_tree_fully_valid(tree)) {
>> > +				ret = cache_tree_update(active_cache_tree,
>> > +						active_cache, active_nr, 0, 0);
>> > +				if (ret < 0)
>> > +					return ret;
>> 
>> This gracefully errs out when the index is unmerged but fails to
>> pretend the index knows about trees, if the unmerged part of
>> index is outside the directory the user specified.
>
> That is correct. But in that case, we cannot sanely ask the question "what 
> would the tree object look like if we committed right now?"

But that is not the question you are asking.  "git-ls-files t/"
does work even though you still have cache.h unmerged in the
index.

> But then it turned out that I even use it before committing, like when I 
> ask "what files would be in my next revision?" It is not a question 
> arising daily, but sometimes it is interesting to see _before_ committing 
> them. (Note that I am not only interested in the _modified_ files.)

So it really is about being able to say show while you mean ls-files.

I am not opposed to that goal at all.  I think it makes it
easier to type.  But I think using cache-tree is a wrong
approach.

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

* Re: [PATCH] sha1_name(): accept ':directory/' to get at the cache_tree
  2007-01-10  0:36     ` Junio C Hamano
@ 2007-01-10  0:54       ` Johannes Schindelin
  0 siblings, 0 replies; 16+ messages in thread
From: Johannes Schindelin @ 2007-01-10  0:54 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git

Hi,

On Tue, 9 Jan 2007, Junio C Hamano wrote:

> Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:
> 
> > It is still at what cache_name_pos(cp, namelen) pointed to, or NULL if 
> > the entry does not exist (e.g. there is no cache entry, or all cache 
> > entries are lexicographically smaller).
> >
> >> For example, would this work?
> >> 
> >> 	$ echo >t- && git add t-
> >>         $ git show :t
> >> 	$ git show :t/
> >
> > I think so: The code explicitely checks for a trailing '/'. (See second 
> > last line of the hunk you quoted.)
> 
> The comment was not about the trailing / version, but the one without.
> Have you tried them?

Of course not! I had the impression that cache_name_pos() just _had_ to 
find the correct spot, but of course you are right: it does not.

> >> > +			struct cache_tree *tree =
> >> > +				cache_tree_find(active_cache_tree, cp);
> >> > +			if (!cache_tree_fully_valid(tree)) {
> >> > +				ret = cache_tree_update(active_cache_tree,
> >> > +						active_cache, active_nr, 0, 0);
> >> > +				if (ret < 0)
> >> > +					return ret;
> >> 
> >> This gracefully errs out when the index is unmerged but fails to
> >> pretend the index knows about trees, if the unmerged part of
> >> index is outside the directory the user specified.
> >
> > That is correct. But in that case, we cannot sanely ask the question "what 
> > would the tree object look like if we committed right now?"
> 
> But that is not the question you are asking.  "git-ls-files t/"
> does work even though you still have cache.h unmerged in the
> index.

Ah! I retract that. I did _not_ want the recursive file list. I wanted the 
equivalent of HEAD:t/ _after_ a commit.

> > But then it turned out that I even use it before committing, like when I 
> > ask "what files would be in my next revision?" It is not a question 
> > arising daily, but sometimes it is interesting to see _before_ committing 
> > them. (Note that I am not only interested in the _modified_ files.)
> 
> So it really is about being able to say show while you mean ls-files.
> 
> I am not opposed to that goal at all.  I think it makes it
> easier to type.  But I think using cache-tree is a wrong
> approach.

Well, you are the master.

Ciao,
Dscho

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

end of thread, other threads:[~2007-01-10  0:54 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-12-22  2:19 [PATCH] sha1_name(): accept ':directory/' to get at the cache_tree Johannes Schindelin
2006-12-22  4:29 ` Junio C Hamano
2006-12-22  8:28   ` Jakub Narebski
2006-12-22 12:16     ` Johannes Schindelin
2006-12-22 18:05       ` Jakub Narebski
2006-12-22 12:14   ` Johannes Schindelin
2006-12-22 19:25   ` Johannes Schindelin
2006-12-22  8:44 ` Alex Riesen
2006-12-22 12:18   ` Johannes Schindelin
2006-12-22 16:09     ` Alex Riesen
  -- strict thread matches above, loose matches on Subject: below --
2007-01-09 14:03 Johannes Schindelin
2007-01-09 17:25 ` Alex Riesen
2007-01-09 23:47 ` Junio C Hamano
2007-01-10  0:22   ` Johannes Schindelin
2007-01-10  0:36     ` Junio C Hamano
2007-01-10  0:54       ` Johannes Schindelin

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