* [PATCH] Add NEED_WORK_TREE for more commands
@ 2007-10-27 8:19 Nguyễn Thái Ngọc Duy
2007-10-27 9:08 ` Mike Hommey
2007-10-27 12:42 ` Johannes Schindelin
0 siblings, 2 replies; 5+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2007-10-27 8:19 UTC (permalink / raw)
To: git
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
@@ -307,10 +307,10 @@ static void handle_internal_command(int argc, const char **argv)
const char *cmd = argv[0];
static struct cmd_struct commands[] = {
{ "add", cmd_add, RUN_SETUP | NEED_WORK_TREE },
- { "annotate", cmd_annotate, RUN_SETUP },
+ { "annotate", cmd_annotate, RUN_SETUP | NEED_WORK_TREE },
{ "apply", cmd_apply },
{ "archive", cmd_archive },
- { "blame", cmd_blame, RUN_SETUP },
+ { "blame", cmd_blame, RUN_SETUP | NEED_WORK_TREE },
{ "branch", cmd_branch, RUN_SETUP },
{ "bundle", cmd_bundle },
{ "cat-file", cmd_cat_file, RUN_SETUP },
@@ -333,7 +333,7 @@ static void handle_internal_command(int argc, const char **argv)
{ "fetch--tool", cmd_fetch__tool, RUN_SETUP },
{ "fmt-merge-msg", cmd_fmt_merge_msg, RUN_SETUP },
{ "for-each-ref", cmd_for_each_ref, RUN_SETUP },
- { "format-patch", cmd_format_patch, RUN_SETUP },
+ { "format-patch", cmd_format_patch, RUN_SETUP | NEED_WORK_TREE },
{ "fsck", cmd_fsck, RUN_SETUP },
{ "fsck-objects", cmd_fsck, RUN_SETUP },
{ "gc", cmd_gc, RUN_SETUP },
@@ -346,7 +346,7 @@ static void handle_internal_command(int argc, const char **argv)
{ "init", cmd_init_db },
{ "init-db", cmd_init_db },
{ "log", cmd_log, RUN_SETUP | USE_PAGER },
- { "ls-files", cmd_ls_files, RUN_SETUP },
+ { "ls-files", cmd_ls_files, RUN_SETUP | NEED_WORK_TREE },
{ "ls-tree", cmd_ls_tree, RUN_SETUP },
{ "mailinfo", cmd_mailinfo },
{ "mailsplit", cmd_mailsplit },
@@ -363,7 +363,7 @@ static void handle_internal_command(int argc, const char **argv)
{ "reflog", cmd_reflog, RUN_SETUP },
{ "repo-config", cmd_config },
{ "rerere", cmd_rerere, RUN_SETUP },
- { "reset", cmd_reset, RUN_SETUP },
+ { "reset", cmd_reset, RUN_SETUP | NEED_WORK_TREE },
{ "rev-list", cmd_rev_list, RUN_SETUP },
{ "rev-parse", cmd_rev_parse, RUN_SETUP },
{ "revert", cmd_revert, RUN_SETUP | NEED_WORK_TREE },
@@ -377,7 +377,7 @@ static void handle_internal_command(int argc, const char **argv)
{ "tag", cmd_tag, RUN_SETUP },
{ "tar-tree", cmd_tar_tree },
{ "unpack-objects", cmd_unpack_objects, RUN_SETUP },
- { "update-index", cmd_update_index, RUN_SETUP },
+ { "update-index", cmd_update_index, RUN_SETUP | NEED_WORK_TREE },
{ "update-ref", cmd_update_ref, RUN_SETUP },
{ "upload-archive", cmd_upload_archive },
{ "verify-tag", cmd_verify_tag, RUN_SETUP },
--
1.5.3.rc4.3.gab089
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] Add NEED_WORK_TREE for more commands
2007-10-27 8:19 [PATCH] Add NEED_WORK_TREE for more commands Nguyễn Thái Ngọc Duy
@ 2007-10-27 9:08 ` Mike Hommey
2007-10-27 10:18 ` Nguyen Thai Ngoc Duy
2007-10-27 12:42 ` Johannes Schindelin
1 sibling, 1 reply; 5+ messages in thread
From: Mike Hommey @ 2007-10-27 9:08 UTC (permalink / raw)
To: Nguyễn Thái Ngọc Duy; +Cc: git
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).
Mike
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] Add NEED_WORK_TREE for more commands
2007-10-27 9:08 ` Mike Hommey
@ 2007-10-27 10:18 ` Nguyen Thai Ngoc Duy
2007-10-27 10:42 ` Mike Hommey
0 siblings, 1 reply; 5+ messages in thread
From: Nguyen Thai Ngoc Duy @ 2007-10-27 10:18 UTC (permalink / raw)
To: Mike Hommey; +Cc: git
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?
> Mike
--
Duy
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] Add NEED_WORK_TREE for more commands
2007-10-27 10:18 ` Nguyen Thai Ngoc Duy
@ 2007-10-27 10:42 ` Mike Hommey
0 siblings, 0 replies; 5+ messages in thread
From: Mike Hommey @ 2007-10-27 10:42 UTC (permalink / raw)
To: Nguyen Thai Ngoc Duy; +Cc: git
On Sat, Oct 27, 2007 at 05:18:39PM +0700, Nguyen Thai Ngoc Duy wrote:
> 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
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] Add NEED_WORK_TREE for more commands
2007-10-27 8:19 [PATCH] Add NEED_WORK_TREE for more commands Nguyễn Thái Ngọc Duy
2007-10-27 9:08 ` Mike Hommey
@ 2007-10-27 12:42 ` Johannes Schindelin
1 sibling, 0 replies; 5+ messages in thread
From: Johannes Schindelin @ 2007-10-27 12:42 UTC (permalink / raw)
To: Nguyễn Thái Ngọc Duy; +Cc: git
[-- Attachment #1: Type: TEXT/PLAIN, Size: 1215 bytes --]
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
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2007-10-27 12:43 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-10-27 8:19 [PATCH] Add NEED_WORK_TREE for more commands Nguyễn Thái Ngọc Duy
2007-10-27 9:08 ` Mike Hommey
2007-10-27 10:18 ` Nguyen Thai Ngoc Duy
2007-10-27 10:42 ` Mike Hommey
2007-10-27 12:42 ` Johannes Schindelin
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).