{"thread":{"id":"10481","subject":"[PATCH] Add NEED_WORK_TREE for more commands","startedAt":"2007-10-27T08:19:10Z","lastAt":"2007-10-27T12:42:16Z","messageCount":5,"participants":["Nguyễn Thái Ngọc Duy","Mike Hommey","Nguyen Thai Ngoc Duy","Johannes Schindelin"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"57333","messageId":"20071027081910.GA23381@laptop","threadId":"10481","inReplyTo":null,"subject":"[PATCH] Add NEED_WORK_TREE for more commands","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2007-10-27T08:19:10Z","receivedAt":"2007-10-27T08:19:10Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"\nSigned-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n---\n git.c |   12 ++++++------\n 1 files changed, 6 insertions(+), 6 deletions(-)\n\ndiff --git a/git.c b/git.c\nindex 23a430c..9db40b3 100644\n--- a/git.c\n+++ b/git.c\n@@ -307,10 +307,10 @@ static void handle_internal_command(int argc, const char **argv)\n \tconst char *cmd = argv[0];\n \tstatic struct cmd_struct commands[] = {\n \t\t{ \"add\", cmd_add, RUN_SETUP | NEED_WORK_TREE },\n-\t\t{ \"annotate\", cmd_annotate, RUN_SETUP },\n+\t\t{ \"annotate\", cmd_annotate, RUN_SETUP | NEED_WORK_TREE },\n \t\t{ \"apply\", cmd_apply },\n \t\t{ \"archive\", cmd_archive },\n-\t\t{ \"blame\", cmd_blame, RUN_SETUP },\n+\t\t{ \"blame\", cmd_blame, RUN_SETUP | NEED_WORK_TREE },\n \t\t{ \"branch\", cmd_branch, RUN_SETUP },\n \t\t{ \"bundle\", cmd_bundle },\n \t\t{ \"cat-file\", cmd_cat_file, RUN_SETUP },\n@@ -333,7 +333,7 @@ static void handle_internal_command(int argc, const char **argv)\n \t\t{ \"fetch--tool\", cmd_fetch__tool, RUN_SETUP },\n \t\t{ \"fmt-merge-msg\", cmd_fmt_merge_msg, RUN_SETUP },\n \t\t{ \"for-each-ref\", cmd_for_each_ref, RUN_SETUP },\n-\t\t{ \"format-patch\", cmd_format_patch, RUN_SETUP },\n+\t\t{ \"format-patch\", cmd_format_patch, RUN_SETUP | NEED_WORK_TREE },\n \t\t{ \"fsck\", cmd_fsck, RUN_SETUP },\n \t\t{ \"fsck-objects\", cmd_fsck, RUN_SETUP },\n \t\t{ \"gc\", cmd_gc, RUN_SETUP },\n@@ -346,7 +346,7 @@ static void handle_internal_command(int argc, const char **argv)\n \t\t{ \"init\", cmd_init_db },\n \t\t{ \"init-db\", cmd_init_db },\n \t\t{ \"log\", cmd_log, RUN_SETUP | USE_PAGER },\n-\t\t{ \"ls-files\", cmd_ls_files, RUN_SETUP },\n+\t\t{ \"ls-files\", cmd_ls_files, RUN_SETUP | NEED_WORK_TREE },\n \t\t{ \"ls-tree\", cmd_ls_tree, RUN_SETUP },\n \t\t{ \"mailinfo\", cmd_mailinfo },\n \t\t{ \"mailsplit\", cmd_mailsplit },\n@@ -363,7 +363,7 @@ static void handle_internal_command(int argc, const char **argv)\n \t\t{ \"reflog\", cmd_reflog, RUN_SETUP },\n \t\t{ \"repo-config\", cmd_config },\n \t\t{ \"rerere\", cmd_rerere, RUN_SETUP },\n-\t\t{ \"reset\", cmd_reset, RUN_SETUP },\n+\t\t{ \"reset\", cmd_reset, RUN_SETUP | NEED_WORK_TREE },\n \t\t{ \"rev-list\", cmd_rev_list, RUN_SETUP },\n \t\t{ \"rev-parse\", cmd_rev_parse, RUN_SETUP },\n \t\t{ \"revert\", cmd_revert, RUN_SETUP | NEED_WORK_TREE },\n@@ -377,7 +377,7 @@ static void handle_internal_command(int argc, const char **argv)\n \t\t{ \"tag\", cmd_tag, RUN_SETUP },\n \t\t{ \"tar-tree\", cmd_tar_tree },\n \t\t{ \"unpack-objects\", cmd_unpack_objects, RUN_SETUP },\n-\t\t{ \"update-index\", cmd_update_index, RUN_SETUP },\n+\t\t{ \"update-index\", cmd_update_index, RUN_SETUP | NEED_WORK_TREE },\n \t\t{ \"update-ref\", cmd_update_ref, RUN_SETUP },\n \t\t{ \"upload-archive\", cmd_upload_archive },\n \t\t{ \"verify-tag\", cmd_verify_tag, RUN_SETUP },\n-- \n1.5.3.rc4.3.gab089\n"},{"id":"57343","messageId":"20071027090822.GA6789@glandium.org","threadId":"10481","inReplyTo":"20071027081910.GA23381@laptop","subject":"Re: [PATCH] Add NEED_WORK_TREE for more commands","fromName":"Mike Hommey","fromEmail":"mh@glandium.org","sentAt":"2007-10-27T09:08:22Z","receivedAt":"2007-10-27T09:08:22Z","isPatch":true,"sender":{"key":"mh@glandium.org","avatar":"https://avatars.githubusercontent.com/u/1038527?v=4"},"body":"On Sat, Oct 27, 2007 at 03:19:10PM +0700, Nguyễn Thái Ngọc Duy wrote:\n> \n> Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n> ---\n>  git.c |   12 ++++++------\n>  1 files changed, 6 insertions(+), 6 deletions(-)\n> \n> diff --git a/git.c b/git.c\n> index 23a430c..9db40b3 100644\n> --- a/git.c\n> +++ b/git.c\n> +\t\t{ \"ls-files\", cmd_ls_files, RUN_SETUP | NEED_WORK_TREE },\n> +\t\t{ \"update-index\", cmd_update_index, RUN_SETUP | NEED_WORK_TREE },\n\nAt least these two work very fine without a working tree (and I *do*\nneed them to work without a working tree).\n\nMike\n"},{"id":"57347","messageId":"20071027101839.GA26043@laptop","threadId":"10481","inReplyTo":"20071027090822.GA6789@glandium.org","subject":"Re: [PATCH] Add NEED_WORK_TREE for more commands","fromName":"Nguyen Thai Ngoc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2007-10-27T10:18:39Z","receivedAt":"2007-10-27T10:18:39Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"On Sat, Oct 27, 2007 at 11:08:22AM +0200, Mike Hommey wrote:\n> On Sat, Oct 27, 2007 at 03:19:10PM +0700, Nguy???n Th??i Ng???c Duy wrote:\n> > \n> > Signed-off-by: Nguy???n Th??i Ng???c Duy <pclouds@gmail.com>\n> > ---\n> >  git.c |   12 ++++++------\n> >  1 files changed, 6 insertions(+), 6 deletions(-)\n> > \n> > diff --git a/git.c b/git.c\n> > index 23a430c..9db40b3 100644\n> > --- a/git.c\n> > +++ b/git.c\n> > +\t\t{ \"ls-files\", cmd_ls_files, RUN_SETUP | NEED_WORK_TREE },\n> > +\t\t{ \"update-index\", cmd_update_index, RUN_SETUP | NEED_WORK_TREE },\n> \n> At least these two work very fine without a working tree (and I *do*\n> need them to work without a working tree).\n\nHow can you do that while both need index and a working directory to\noperate?\n\n> Mike\n\n-- \nDuy\n"},{"id":"57348","messageId":"20071027104257.GA8876@glandium.org","threadId":"10481","inReplyTo":"20071027101839.GA26043@laptop","subject":"Re: [PATCH] Add NEED_WORK_TREE for more commands","fromName":"Mike Hommey","fromEmail":"mh@glandium.org","sentAt":"2007-10-27T10:42:57Z","receivedAt":"2007-10-27T10:42:57Z","isPatch":true,"sender":{"key":"mh@glandium.org","avatar":"https://avatars.githubusercontent.com/u/1038527?v=4"},"body":"On Sat, Oct 27, 2007 at 05:18:39PM +0700, Nguyen Thai Ngoc Duy wrote:\n> On Sat, Oct 27, 2007 at 11:08:22AM +0200, Mike Hommey wrote:\n> > On Sat, Oct 27, 2007 at 03:19:10PM +0700, Nguy???n Th??i Ng???c Duy wrote:\n> > > \n> > > Signed-off-by: Nguy???n Th??i Ng???c Duy <pclouds@gmail.com>\n> > > ---\n> > >  git.c |   12 ++++++------\n> > >  1 files changed, 6 insertions(+), 6 deletions(-)\n> > > \n> > > diff --git a/git.c b/git.c\n> > > index 23a430c..9db40b3 100644\n> > > --- a/git.c\n> > > +++ b/git.c\n> > > +\t\t{ \"ls-files\", cmd_ls_files, RUN_SETUP | NEED_WORK_TREE },\n> > > +\t\t{ \"update-index\", cmd_update_index, RUN_SETUP | NEED_WORK_TREE },\n> > \n> > At least these two work very fine without a working tree (and I *do*\n> > need them to work without a working tree).\n> \n> How can you do that while both need index and a working directory to\n> operate?\n\nFor example, ls-files -c and update-index --remove don't need more than\nthe index, and you don't need a working tree to fiddle with the index\nwith these commands.\n\nBy the way, git-rm has a --cached option that allows it to only work on\nthe index, but it has a NEED_WORK_TREE which prevents its use without a\nworking tree in such a case (though I don't know if the implementation\nitself relies on the working tree or not, but if it does, it shouldn't).\nIt's sad to have to do \ngit-ls-files -c directory | xargs -d \"\\n\" git-update-index --remove\ninstead of\ngit-rm -r --cached directory\nwhen you want to remove a directory in a bare repository.\n\nMike\n"},{"id":"57351","messageId":"Pine.LNX.4.64.0710271335190.4362@racer.site","threadId":"10481","inReplyTo":"20071027081910.GA23381@laptop","subject":"Re: [PATCH] Add NEED_WORK_TREE for more commands","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2007-10-27T12:42:16Z","receivedAt":"2007-10-27T12:42:16Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Sat, 27 Oct 2007, Nguyễn Thái Ngọc Duy wrote:\n\n> +\t\t{ \"annotate\", cmd_annotate, RUN_SETUP | NEED_WORK_TREE },\n> +\t\t{ \"blame\", cmd_blame, RUN_SETUP | NEED_WORK_TREE },\n\nBoth can be sensibly run without a work tree: \"git blame <commit> <file>\"\n\n> +\t\t{ \"format-patch\", cmd_format_patch, RUN_SETUP | NEED_WORK_TREE },\n\nThis can be run without work tree in any case, methinks.  AFAICT \nformat-patch only ever uses information from the object database.\n\n> +\t\t{ \"ls-files\", cmd_ls_files, RUN_SETUP | NEED_WORK_TREE },\n\nThat has already been commented on.\n\n> +\t\t{ \"reset\", cmd_reset, RUN_SETUP | NEED_WORK_TREE },\n\n\"git reset --soft HEAD <commit>\" makes sense in a bare repository.\n\n> +\t\t{ \"update-index\", cmd_update_index, RUN_SETUP | NEED_WORK_TREE },\n\nThat has been coommented on, too.\n\nI agree that there are modes for these commands (except format-patch), in \nwhich they want a work-tree, but they have other modes, too, so IMHO it \nshould be solved a la 6d9ba67b(Commands requiring a work tree must not run \nin GIT_DIR).  You'll see that ls-files already has some special handling \nhere, and this could be refactorised to requires_work_tree(), which should \nmake the code much more elegant.\n\nCiao,\nDscho\n"}]}