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

Re: [PATCH] Add NEED_WORK_TREE for more commands

From
Johannes Schindelin <johannes.schindelin@gmx.de>
Date
Oct 27, 2007, 12:42 UTC
Message-ID
<Pine.LNX.4.64.0710271335190.4362@racer.site>
In-Reply-To
<20071027081910.GA23381@laptop>
Hi,
On Sat, 27 Oct 2007, Nguyễn Thái Ngọc Duy wrote:
> +		{ "annotate", cmd_annotate, RUN_SETUP | NEED_WORK_TREE },
> +		{ "blame", cmd_blame, RUN_SETUP | NEED_WORK_TREE },
Both can be sensibly run without a work tree: "git blame <commit> <file>"
> +		{ "format-patch", cmd_format_patch, RUN_SETUP | NEED_WORK_TREE },

This can be run without work tree in any case, methinks. AFAICT format-patch only ever uses information from the object database.

> +		{ "ls-files", cmd_ls_files, RUN_SETUP | NEED_WORK_TREE },
That has already been commented on.
> +		{ "reset", cmd_reset, RUN_SETUP | NEED_WORK_TREE },
"git reset --soft HEAD <commit>" makes sense in a bare repository.
> +		{ "update-index", cmd_update_index, RUN_SETUP | NEED_WORK_TREE },
That has been coommented on, too.

I agree that there are modes for these commands (except format-patch), in which they want a work-tree, but they have other modes, too, so IMHO it should be solved a la 6d9ba67b(Commands requiring a work tree must not run in GIT_DIR). You'll see that ls-files already has some special handling here, and this could be refactorised to requires_work_tree(), which should make the code much more elegant.

Ciao, Dscho

Previous: Mike Hommey
Message 5 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.