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