git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] sha1_name(): accept ':directory/' to get at the cache_tree

From
Johannes Schindelin <johannes.schindelin@gmx.de>
Date
Jan 10, 2007, 00:54 UTC
Message-ID
<Pine.LNX.4.63.0701100151230.22628@wbgn013.biozentrum.uni-wuerzburg.de>
In-Reply-To
<7vtzyzhg47.fsf@assigned-by-dhcp.cox.net>
Hi,
On Tue, 9 Jan 2007, Junio C Hamano wrote:
Show 17 quoted lines
> 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.

Show 18 quoted lines
> >> > +			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.

Show 10 quoted lines
> > 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

Previous: Junio C Hamano
Message 6 of 6 in “sha1_name(): accept ':directory/' to get at the cache_tree”
  1. sha1_name(): accept ':directory/' to get at the cache_treeJohannes Schindelin, Jan 9, 2007
  2. Alex RiesenJan 9, 2007
  3. Junio C HamanoJan 9, 2007
  4. Johannes SchindelinJan 10, 2007
  5. Junio C HamanoJan 10, 2007
  6. Johannes SchindelinJan 10, 2007

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.