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

Re: [PATCH] Add NEED_WORK_TREE for more commands

From
Mike Hommey <mh@glandium.org>
Date
Oct 27, 2007, 10:42 UTC
Message-ID
<20071027104257.GA8876@glandium.org>
In-Reply-To
<20071027101839.GA26043@laptop>
On Sat, Oct 27, 2007 at 05:18:39PM +0700, Nguyen Thai Ngoc Duy wrote:
Show 20 quoted lines
> On Sat, Oct 27, 2007 at 11:08:22AM +0200, Mike Hommey wrote:
> > On Sat, Oct 27, 2007 at 03:19:10PM +0700, Nguy???n Th??i Ng???c Duy wrote:
> > > 
> > > Signed-off-by: Nguy???n Th??i Ng???c Duy <pclouds@gmail.com>
> > > ---
> > >  git.c |   12 ++++++------
> > >  1 files changed, 6 insertions(+), 6 deletions(-)
> > > 
> > > diff --git a/git.c b/git.c
> > > index 23a430c..9db40b3 100644
> > > --- a/git.c
> > > +++ b/git.c
> > > +		{ "ls-files", cmd_ls_files, RUN_SETUP | NEED_WORK_TREE },
> > > +		{ "update-index", cmd_update_index, RUN_SETUP | NEED_WORK_TREE },
> > 
> > At least these two work very fine without a working tree (and I *do*
> > need them to work without a working tree).
> 
> How can you do that while both need index and a working directory to
> operate?

For example, ls-files -c and update-index --remove don't need more than the index, and you don't need a working tree to fiddle with the index with these commands.

By the way, git-rm has a --cached option that allows it to only work on the index, but it has a NEED_WORK_TREE which prevents its use without a working tree in such a case (though I don't know if the implementation itself relies on the working tree or not, but if it does, it shouldn't). It's sad to have to do git-ls-files -c directory | xargs -d "\n" git-update-index --remove instead of git-rm -r --cached directory when you want to remove a directory in a bare repository.

Mike
Previous: Nguyen Thai Ngoc DuyNext: Johannes Schindelin
Message 4 of 5 in “Add NEED_WORK_TREE for more commands”
  1. Add NEED_WORK_TREE for more commandsNguyễn Thái Ngọc Duy, Oct 27, 2007
  2. Mike HommeyOct 27, 2007
  3. Nguyen Thai Ngoc DuyOct 27, 2007
  4. Mike HommeyOct 27, 2007
  5. Johannes SchindelinOct 27, 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.