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

Re: git diff-index with relative git-dir does not work

From
Nguyen Thai Ngoc Duy <pclouds@gmail.com>
Date
Feb 11, 2010, 10:35 UTC
Message-ID
<fcaeb9bf1002110235p7fdb50a7we41715b795f76b99@mail.gmail.com>
In-Reply-To
<87wrymwo5a.wl@dns1.atmark-techno.com>

On Tue, Feb 9, 2010 at 8:10 PM, Yasushi SHOJI > In the diff-index case, it, indeed, has RUN_SETUP explicitly

> set. however, it does not have NEED_WORK_TREE set.  And, this is
> correct in the current semantics because diff-index is a tool to
> compare the index and the object store. it does not need a work tree.

Unless --cached is given, work tree is needed. I'm not saying that diff-index is bug-free. But the bug you described is not relevant to this.

> However, diff-index is used in describe which need a work tree if
> --dirty is given.  That means that diff-index might be called
> with --work-tree.
Yes. And git-describe calls git-diff-index correctly, i.e. without --cached.
Show 12 quoted lines
>> >  In that case, we must change the setup functions signature to
>> >  allow marking "not interested" or something.
>>
>> I'm not sure I get your idea.
>
> Given that in the current form of git, many built-in command is called
> by many other built-in commands. It is hard to predict what is needed
> and what's not.  Plus, --git-dir and --work-tree are options to git
> itself not built-in's.  So, I thought it might be a good idea to call,
> say, setup_work_tree_with_abs_path(), regardless of NEED_WORK_TREE, to
> explicitly setup run time environment before any other part of the
> code call, say, open_sha1_file.

The thing is not every command expect cwd to be moved to top directory. In other words, they don't care about the prefix argument being passed to it. So you would need go go through all commands before doing that.

By the way, are you working on a patch for the diff-index bug?
-- 
Duy
Previous: Yasushi SHOJI
Message 4 of 4 in “git diff-index with relative git-dir does not work”
  1. Yasushi SHOJIFeb 9, 2010
  2. Nguyen Thai Ngoc DuyFeb 9, 2010
  3. Yasushi SHOJIFeb 9, 2010
  4. Nguyen Thai Ngoc DuyFeb 11, 2010

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.