{"thread":{"id":"9385","subject":"[PATCH] checkout-index needs a working tree","startedAt":"2007-08-04T22:20:07Z","lastAt":"2007-08-11T18:15:19Z","messageCount":12,"participants":["Johannes Schindelin","Junio C Hamano","Uwe Kleine-König"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"49786","messageId":"Pine.LNX.4.64.0708042319470.14781@racer.site","threadId":"9385","inReplyTo":null,"subject":"[PATCH] checkout-index needs a working tree","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2007-08-04T22:20:07Z","receivedAt":"2007-08-04T22:20:07Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"\nSigned-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>\n---\n\n\tThis fixes \"git --work-tree=/some/where/else checkout-index\".\n\n git.c |    3 ++-\n 1 files changed, 2 insertions(+), 1 deletions(-)\n\ndiff --git a/git.c b/git.c\nindex 25b8274..f8c4545 100644\n--- a/git.c\n+++ b/git.c\n@@ -315,7 +315,8 @@ static void handle_internal_command(int argc, const char **argv)\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-\t\t{ \"checkout-index\", cmd_checkout_index, RUN_SETUP },\n+\t\t{ \"checkout-index\", cmd_checkout_index,\n+\t\t\tRUN_SETUP | NEED_WORK_TREE},\n \t\t{ \"check-ref-format\", cmd_check_ref_format },\n \t\t{ \"check-attr\", cmd_check_attr, RUN_SETUP | NEED_WORK_TREE },\n \t\t{ \"cherry\", cmd_cherry, RUN_SETUP },\n-- \n1.5.3.rc4.1.g7805\n"},{"id":"49789","messageId":"7vvebuj4nw.fsf@assigned-by-dhcp.cox.net","threadId":"9385","inReplyTo":"Pine.LNX.4.64.0708042319470.14781@racer.site","subject":"Re: [PATCH] checkout-index needs a working tree","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2007-08-04T22:50:11Z","receivedAt":"2007-08-04T22:50:11Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Hmmph.  I was trying to come up with a better commit log message\nfor this change.\n\n\tPaths given from the command line of checkout-index name\n\tfiles relative to the cwd, whose implication is that it\n\tis relative to where you are in relation with the top of\n\tthe working tree.  For doing that, you need to have the\n\twork tree to begin with.\n\nDoes this mean that any command that uses its prefix parameter\nto cmd_xxx() needs NEED_WORK_TREE?\n\nI wonder if it would help us to catch similar breakages if we\nchange git.c::run_command() so that we do not pass prefix (or\npass a bogus pointer ((const char *)1)) for commands that do not\nask for NEED_WORK_TREE.\n"},{"id":"49795","messageId":"Pine.LNX.4.64.0708050229200.14781@racer.site","threadId":"9385","inReplyTo":"7vvebuj4nw.fsf@assigned-by-dhcp.cox.net","subject":"Re: [PATCH] checkout-index needs a working tree","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2007-08-05T01:33:09Z","receivedAt":"2007-08-05T01:33:09Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Sat, 4 Aug 2007, Junio C Hamano wrote:\n\n> I wonder if it would help us to catch similar breakages if we change \n> git.c::run_command() so that we do not pass prefix (or pass a bogus \n> pointer ((const char *)1)) for commands that do not ask for \n> NEED_WORK_TREE.\n\nI tried that, but we have some places where we ask \"if (prefix && \n*prefix)\", for example in ls-tree.  It does not _require_ a work tree, but \nit certainly uses it when it is available -- which is fine.\n\nOther users are more tricky, such as ls-files and update-index, which need \na working tree only in some cases.\n\nI'll probably write a patch on Monday (if nobody else is faster) to \nprovide a function \"require_work_tree()\" in environment.c, which does the \nobvious (with caching).  Then comes the tedious part: identifying all \nthose options that need a working tree...\n\nCiao,\nDscho\n"},{"id":"50352","messageId":"20070809223530.GA29680@cassiopeia","threadId":"9385","inReplyTo":"Pine.LNX.4.64.0708042319470.14781@racer.site","subject":"Re: [PATCH] checkout-index needs a working tree","fromName":"Uwe Kleine-König","fromEmail":"ukleinek@informatik.uni-freiburg.de","sentAt":"2007-08-09T22:35:30Z","receivedAt":"2007-08-09T22:35:30Z","isPatch":true,"sender":{"key":"u.kleine-koenig@pengutronix.de","avatar":"https://gravatar.com/avatar/354b5e3ceb2806a2f1e1e382ac29ddbdad18288654da62b61eb13583a857eee7?d=mp&s=160"},"body":"Johannes Schindelin wrote:\n> \n> Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>\n> ---\n> \n> \tThis fixes \"git --work-tree=/some/where/else checkout-index\".\n> \n>  git.c |    3 ++-\n>  1 files changed, 2 insertions(+), 1 deletions(-)\n> \n> diff --git a/git.c b/git.c\n> index 25b8274..f8c4545 100644\n> --- a/git.c\n> +++ b/git.c\n> @@ -315,7 +315,8 @@ static void handle_internal_command(int argc, const char **argv)\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> -\t\t{ \"checkout-index\", cmd_checkout_index, RUN_SETUP },\n> +\t\t{ \"checkout-index\", cmd_checkout_index,\n> +\t\t\tRUN_SETUP | NEED_WORK_TREE},\n>  \t\t{ \"check-ref-format\", cmd_check_ref_format },\n>  \t\t{ \"check-attr\", cmd_check_attr, RUN_SETUP | NEED_WORK_TREE },\n>  \t\t{ \"cherry\", cmd_cherry, RUN_SETUP },\nWith this patch I'm not able to do\n\n\tgit checkout-index --prefix=/tmp/exportdir -a\n\nto export an entire tree as described in git-checkout-index(1) in a bare\nrepo.\n\n(Not that I need it, but I claimed on #git that it works, ... )\n\nBTW: I didn't try if reverting this patch helps, but probably it does.\n\nBest regards\nUwe\n\n-- \nUwe Kleine-König\n\nhttp://www.google.com/search?q=72+PS+point+in+inch\n"},{"id":"50362","messageId":"Pine.LNX.4.64.0708100129200.21857@racer.site","threadId":"9385","inReplyTo":"20070809223530.GA29680@cassiopeia","subject":"Re: [PATCH] checkout-index needs a working tree","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2007-08-10T00:31:06Z","receivedAt":"2007-08-10T00:31:06Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Fri, 10 Aug 2007, Uwe Kleine-K?nig wrote:\n\n> Johannes Schindelin wrote:\n> > \n> > Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>\n> > ---\n> > \n> > \tThis fixes \"git --work-tree=/some/where/else checkout-index\".\n> > \n> >  git.c |    3 ++-\n> >  1 files changed, 2 insertions(+), 1 deletions(-)\n> > \n> > diff --git a/git.c b/git.c\n> > index 25b8274..f8c4545 100644\n> > --- a/git.c\n> > +++ b/git.c\n> > @@ -315,7 +315,8 @@ static void handle_internal_command(int argc, const char **argv)\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> > -\t\t{ \"checkout-index\", cmd_checkout_index, RUN_SETUP },\n> > +\t\t{ \"checkout-index\", cmd_checkout_index,\n> > +\t\t\tRUN_SETUP | NEED_WORK_TREE},\n> >  \t\t{ \"check-ref-format\", cmd_check_ref_format },\n> >  \t\t{ \"check-attr\", cmd_check_attr, RUN_SETUP | NEED_WORK_TREE },\n> >  \t\t{ \"cherry\", cmd_cherry, RUN_SETUP },\n> With this patch I'm not able to do\n> \n> \tgit checkout-index --prefix=/tmp/exportdir -a\n> \n> to export an entire tree as described in git-checkout-index(1) in a bare\n> repo.\n\nThat is _completely_ expected.  If it is a bare repository, you can _only_ \noverride that check by GIT_WORK_TREE or --work-tree.\n\nBut I have to wonder: if you want to use git checkout-index, which is a \nwork-tree operation, why did you mark it as bare to begin with?\n\nCiao,\nDscho\n"},{"id":"50365","messageId":"7vd4xww6mr.fsf@assigned-by-dhcp.cox.net","threadId":"9385","inReplyTo":"Pine.LNX.4.64.0708100129200.21857@racer.site","subject":"Re: [PATCH] checkout-index needs a working tree","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2007-08-10T00:55:08Z","receivedAt":"2007-08-10T00:55:08Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:\n\n> That is _completely_ expected.  If it is a bare repository, you can _only_ \n> override that check by GIT_WORK_TREE or --work-tree.\n>\n> But I have to wonder: if you want to use git checkout-index, which is a \n> work-tree operation, why did you mark it as bare to begin with?\n\nI do not necessarily think --prefix=untar/it/here/ is a work\ntree operation.\n\nPerhaps we probably are better off if we add something that says\nspecifying GIT_DIR alone means you are at the top of work tree\n(to resurrect the traditional behaviour), to alleviate fallouts\nlike this and the other cvsserver one?  If one does not like\nthat traditional behaviour, the new GIT_WORK_TREE support can\nbe used override it.\n"},{"id":"50367","messageId":"Pine.LNX.4.64.0708100210280.21857@racer.site","threadId":"9385","inReplyTo":"7vd4xww6mr.fsf@assigned-by-dhcp.cox.net","subject":"Re: [PATCH] checkout-index needs a working tree","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2007-08-10T01:11:11Z","receivedAt":"2007-08-10T01:11:11Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Thu, 9 Aug 2007, Junio C Hamano wrote:\n\n> Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:\n> \n> > That is _completely_ expected.  If it is a bare repository, you can _only_ \n> > override that check by GIT_WORK_TREE or --work-tree.\n> >\n> > But I have to wonder: if you want to use git checkout-index, which is a \n> > work-tree operation, why did you mark it as bare to begin with?\n> \n> I do not necessarily think --prefix=untar/it/here/ is a work\n> tree operation.\n> \n> Perhaps we probably are better off if we add something that says\n> specifying GIT_DIR alone means you are at the top of work tree\n> (to resurrect the traditional behaviour), to alleviate fallouts\n> like this and the other cvsserver one?  If one does not like\n> that traditional behaviour, the new GIT_WORK_TREE support can\n> be used override it.\n\nI think I sent a patch for that, but was negative about it, even if I \npromised not to question your decision.\n\nCiao,\nDscho\n"},{"id":"50390","messageId":"7vr6mbu8iv.fsf_-_@assigned-by-dhcp.cox.net","threadId":"9385","inReplyTo":"Pine.LNX.4.64.0708100210280.21857@racer.site","subject":"[PATCH] Reinstate the old behaviour when GIT_DIR is set and GIT_WORK_TREE is unset","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2007-08-10T07:57:12Z","receivedAt":"2007-08-10T07:57:12Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"From: Johannes Schindelin <Johannes.Schindelin@gmx.de>\nDate: Sun, 5 Aug 2007 14:12:53 +0100\n\nThe old behaviour was to unilaterally default to the cwd is the work tree\nwhen GIT_DIR was set, but GIT_WORK_TREE wasn't, no matter if we are inside\nthe GIT_DIR, or if GIT_DIR is actually something like ../../../.git.\n\nSigned-off-by: Johannes Schindelin <Johannes.Schindelin@gmx.de>\nSigned-off-by: Junio C Hamano <gitster@pobox.com>\n---\n\n Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:\n\n > I think I sent a patch for that, but was negative about it, even if I \n > promised not to question your decision.\n\n Yes you did.  Here is a refresher with an affected test\n adjusted.\n\n We already have a few changes that worked around the semantics\n change by either setting GIT_WORK_TREE or cd'ing up, but I\n think they should not need to be reverted.\n\n It makes more sense to keep the old semantics -- people who use\n unusual GIT_DIR setting should know what they are doing, and\n the new GIT_WORK_TREE feature (and core.worktree) would give\n them better control.  We just should not break existing users\n that set GIT_DIR and nothing else.  Which means I need another\n rewrite on the Release Notes, and probably yet another rc\n cycle.\n\n setup.c              |   52 +++++++++----------------------------------------\n t/t1500-rev-parse.sh |    6 +++-\n 2 files changed, 14 insertions(+), 44 deletions(-)\n\ndiff --git a/setup.c b/setup.c\nindex b55b82c..06004f1 100644\n--- a/setup.c\n+++ b/setup.c\n@@ -189,53 +189,21 @@ int is_inside_work_tree(void)\n }\n \n /*\n- * If no worktree was given, and we are outside of a default work tree,\n- * now is the time to set it.\n- *\n- * In other words, if the user calls git with something like\n- *\n- *\tgit --git-dir=/some/where/else/.git bla\n- *\n- * default to /some/where/else as working directory; if the specified\n- * git-dir does not end in \"/.git\", the cwd is used as working directory.\n+ * set_work_tree() is only ever called if you set GIT_DIR explicitely.\n+ * The old behaviour (which we retain here) is to set the work tree root\n+ * to the cwd, unless overridden by the config, the command line, or\n+ * GIT_WORK_TREE.\n  */\n-const char *set_work_tree(const char *dir)\n+static const char *set_work_tree(const char *dir)\n {\n-\tchar dir_buffer[PATH_MAX], *rel = NULL;\n-\tstatic char buffer[PATH_MAX + 1];\n-\tint len, suffix_len = strlen(DEFAULT_GIT_DIR_ENVIRONMENT) + 1;\n-\n-\t/* strip the variable 'dir' of the postfix \"/.git\" if it has it */\n-\tlen = strlen(dir);\n-\tif (len > suffix_len &&\n-\t    !strcmp(dir + len - suffix_len, \"/\" DEFAULT_GIT_DIR_ENVIRONMENT)) {\n-\t\tif ((len - suffix_len) >= sizeof(dir_buffer))\n-\t\t\tdie(\"directory name too long\");\n-\t\tmemcpy(dir_buffer, dir, len - suffix_len);\n-\t\tdir_buffer[len - suffix_len] = '\\0';\n-\n-\t\t/* are we inside the default work tree? */\n-\t\trel = get_relative_cwd(buffer, sizeof(buffer), dir_buffer);\n-\t}\n+\tchar buffer[PATH_MAX + 1];\n \n-\t/* if rel is set, the cwd is _not_ the current working tree */\n-\tif (rel && *rel) {\n-\t\tif (!is_absolute_path(dir))\n-\t\t\tset_git_dir(make_absolute_path(dir));\n-\t\tdir = dir_buffer;\n-\t\tif (chdir(dir))\n-\t\t\tdie(\"cannot chdir to %s: %s\", dir, strerror(errno));\n-\t\telse\n-\t\t\tstrcat(rel, \"/\");\n-\t\tinside_git_dir = 0;\n-\t} else {\n-\t\trel = NULL;\n-\t\tdir = getcwd(buffer, sizeof(buffer));\n-\t}\n-\tgit_work_tree_cfg = xstrdup(dir);\n+\tif (!getcwd(buffer, sizeof(buffer)))\n+\t\tdie (\"Could not get the current working directory\");\n+\tgit_work_tree_cfg = xstrdup(buffer);\n \tinside_work_tree = 1;\n \n-\treturn rel;\n+\treturn NULL;\n }\n \n /*\ndiff --git a/t/t1500-rev-parse.sh b/t/t1500-rev-parse.sh\nindex bea40cb..e474b3f 100755\n--- a/t/t1500-rev-parse.sh\n+++ b/t/t1500-rev-parse.sh\n@@ -28,6 +28,8 @@ test_rev_parse() {\n \t[ $# -eq 0 ] && return\n }\n \n+# label is-bare is-inside-git is-inside-work prefix\n+\n test_rev_parse toplevel false false true ''\n \n cd .git || exit 1\n@@ -53,13 +55,13 @@ export GIT_DIR=../.git\n export GIT_CONFIG=\"$(pwd)\"/../.git/config\n \n git config core.bare false\n-test_rev_parse 'GIT_DIR=../.git, core.bare = false' false false true work/\n+test_rev_parse 'GIT_DIR=../.git, core.bare = false' false false true ''\n \n git config core.bare true\n test_rev_parse 'GIT_DIR=../.git, core.bare = true' true false false ''\n \n git config --unset core.bare\n-test_rev_parse 'GIT_DIR=../.git, core.bare undefined' false false true work/\n+test_rev_parse 'GIT_DIR=../.git, core.bare undefined' false false true ''\n \n mv ../.git ../repo.git || exit 1\n export GIT_DIR=../repo.git\n-- \n1.5.3.rc4.29.g74276\n"},{"id":"50401","messageId":"20070810112821.GA11026@informatik.uni-freiburg.de","threadId":"9385","inReplyTo":"7vr6mbu8iv.fsf_-_@assigned-by-dhcp.cox.net","subject":"Re: [PATCH] Reinstate the old behaviour when GIT_DIR is set and GIT_WORK_TREE is unset","fromName":"Uwe Kleine-König","fromEmail":"ukleinek@informatik.uni-freiburg.de","sentAt":"2007-08-10T11:28:21Z","receivedAt":"2007-08-10T11:28:21Z","isPatch":true,"sender":{"key":"u.kleine-koenig@pengutronix.de","avatar":"https://gravatar.com/avatar/354b5e3ceb2806a2f1e1e382ac29ddbdad18288654da62b61eb13583a857eee7?d=mp&s=160"},"body":"Hello Junio,\n\nJunio C Hamano wrote:\n> From: Johannes Schindelin <Johannes.Schindelin@gmx.de>\n> Date: Sun, 5 Aug 2007 14:12:53 +0100\n> \n> The old behaviour was to unilaterally default to the cwd is the work tree\n> when GIT_DIR was set, but GIT_WORK_TREE wasn't, no matter if we are inside\n> the GIT_DIR, or if GIT_DIR is actually something like ../../../.git.\n> \n> Signed-off-by: Johannes Schindelin <Johannes.Schindelin@gmx.de>\n> Signed-off-by: Junio C Hamano <gitster@pobox.com>\n> ---\n> \n>  Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:\n> \n>  > I think I sent a patch for that, but was negative about it, even if I \n>  > promised not to question your decision.\n> \n>  Yes you did.  Here is a refresher with an affected test\n>  adjusted.\n> \n>  We already have a few changes that worked around the semantics\n>  change by either setting GIT_WORK_TREE or cd'ing up, but I\n>  think they should not need to be reverted.\n> \n>  It makes more sense to keep the old semantics -- people who use\n>  unusual GIT_DIR setting should know what they are doing, and\n>  the new GIT_WORK_TREE feature (and core.worktree) would give\n>  them better control.  We just should not break existing users\n>  that set GIT_DIR and nothing else.  Which means I need another\n>  rewrite on the Release Notes, and probably yet another rc\n>  cycle.\n\nI don't know if you planed to make \n\n\tgit checkout-index --prefix=/tmp/tra -a\n\nwork (again) in a bare repo.  Probably not, so it's no surprise that it\nstill doesn't work.\n\nBest regards\nUwe\n\n-- \nUwe Kleine-König\n\ncat /*dev/null; echo 'Hello World!';\ncat > /dev/null <<*/ \n() { } int main() { printf(\"Hello World!\\n\");}\n/* */\n"},{"id":"50437","messageId":"7vk5s3ry0v.fsf@assigned-by-dhcp.cox.net","threadId":"9385","inReplyTo":"20070810112821.GA11026@informatik.uni-freiburg.de","subject":"Re: [PATCH] Reinstate the old behaviour when GIT_DIR is set and GIT_WORK_TREE is unset","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2007-08-10T19:26:56Z","receivedAt":"2007-08-10T19:26:56Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Uwe Kleine-König  <ukleinek@informatik.uni-freiburg.de> writes:\n\n> I don't know if you planed to make \n>\n> \tgit checkout-index --prefix=/tmp/tra -a\n>\n> work (again) in a bare repo.  Probably not, so it's no surprise that it\n> still doesn't work.\n\nI think it is now safe to revert that NEED_WORK_TREE change\nin git.c for checkout-index.\n"},{"id":"50457","messageId":"7vhcn6ps4j.fsf@assigned-by-dhcp.cox.net","threadId":"9385","inReplyTo":"7vk5s3ry0v.fsf@assigned-by-dhcp.cox.net","subject":"Re: [PATCH] Reinstate the old behaviour when GIT_DIR is set and GIT_WORK_TREE is unset","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2007-08-11T05:17:16Z","receivedAt":"2007-08-11T05:17:16Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Subject: [PATCH] Revert 4465f410 and add tests\n\ncheckout-index --prefix=<path> does not need a working tree,\neven when run from inside a bare repository.\n\nSigned-off-by: Junio C Hamano <gitster@pobox.com>\n---\n\n Junio C Hamano <gitster@pobox.com> writes:\n\n > Uwe Kleine-König  <ukleinek@informatik.uni-freiburg.de> writes:\n >\n >> I don't know if you planed to make \n >>\n >> \tgit checkout-index --prefix=/tmp/tra -a\n >>\n >> work (again) in a bare repo.  Probably not, so it's no surprise that it\n >> still doesn't work.\n >\n > I think it is now safe to revert that NEED_WORK_TREE change\n > in git.c for checkout-index.\n\n How does this look?  I think the second test (no GIT_DIR, just\n being in a bare repository and specifying --prefix to redirect\n the output elsewhere) never worked even before the current\n work-tree feature was started (none of v1.4.4.4, v1.5.0, nor\n v1.5.2 worked that way), so this is not even \"work again\", but\n more like \"now works\".  Later tests with exported GIT_DIR would\n work with or without reverting the NEED_WORK_TREE change in\n git.c, so in that sense reverting is probably not such a good\n idea to begin with.  I dunno.\n\n git.c                            |    3 +-\n t/t2008-checkout-index-prefix.sh |   78 ++++++++++++++++++++++++++++++++++++++\n 2 files changed, 79 insertions(+), 2 deletions(-)\n create mode 100755 t/t2008-checkout-index-prefix.sh\n\ndiff --git a/git.c b/git.c\nindex f8c4545..bafbb4b 100644\n--- a/git.c\n+++ b/git.c\n@@ -315,8 +315,7 @@ static void handle_internal_command(int argc, const char **argv)\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-\t\t{ \"checkout-index\", cmd_checkout_index,\n-\t\t\tRUN_SETUP | NEED_WORK_TREE},\n+\t\t{ \"checkout-index\", cmd_checkout_index, RUN_SETUP},\n \t\t{ \"check-ref-format\", cmd_check_ref_format },\n \t\t{ \"check-attr\", cmd_check_attr, RUN_SETUP | NEED_WORK_TREE },\n \t\t{ \"cherry\", cmd_cherry, RUN_SETUP },\ndiff --git a/t/t2008-checkout-index-prefix.sh b/t/t2008-checkout-index-prefix.sh\nnew file mode 100755\nindex 0000000..7727f07\n--- /dev/null\n+++ b/t/t2008-checkout-index-prefix.sh\n@@ -0,0 +1,78 @@\n+#!/bin/sh\n+\n+test_description='checkout-index --prefix=foo/'\n+\n+. ./test-lib.sh\n+\n+test_expect_success setup '\n+\n+\tmkdir filfre &&\n+\t>frotz &&\n+\t>filfre/nitfol &&\n+\tgit update-index --add frotz filfre/nitfol\n+\n+'\n+\n+rm -fr f*\n+\n+mv .git repo.git || exit ;# very bad\n+GIT_DIR=\"$(pwd)/repo.git\"\n+GIT_CONFIG=\"$GIT_DIR/config\" git config core.bare true\n+\n+test_expect_success 'checkout with --prefix' '\n+\n+\t(\n+\t\tcd repo.git &&\n+\t\tgit checkout-index --prefix=../f- -a\n+\t) &&\n+\ttest -f f-frotz &&\n+\ttest -d f-filfre &&\n+\ttest -f f-filfre/nitfol\n+\n+'\n+\n+export GIT_DIR\n+\n+rm -fr f*\n+\n+test_expect_success 'checkout with --prefix and GIT_DIR (0)' '\n+\n+\t(\n+\t\tcd repo.git &&\n+\t\tgit checkout-index --prefix=../f/ -a\n+\t) &&\n+\ttest -d f &&\n+\ttest -f f/frotz &&\n+\ttest -d f/filfre &&\n+\ttest -f f/filfre/nitfol\n+\n+'\n+\n+rm -fr f*\n+\n+test_expect_success 'checkout with --prefix and GIT_DIR (1)' '\n+\n+\tgit checkout-index --prefix=f/ -a &&\n+\ttest -d f &&\n+\ttest -f f/frotz &&\n+\ttest -d f/filfre &&\n+\ttest -f f/filfre/nitfol\n+\n+'\n+\n+rm -fr f*\n+\n+test_expect_success 'checkout with --prefix and GIT_DIR (2)' '\n+\n+\tmkdir f &&\n+\t(\n+\t\tcd f && git checkout-index --prefix=../f1/ -a\n+\t) &&\n+\ttest -d f1 &&\n+\ttest -f f1/frotz &&\n+\ttest -d f1/filfre &&\n+\ttest -f f1/filfre/nitfol\n+\n+'\n+\n+test_done\n"},{"id":"50489","messageId":"1186856119985-git-send-email-ukleinek@informatik.uni-freiburg.de","threadId":"9385","inReplyTo":"7vhcn6ps4j.fsf@assigned-by-dhcp.cox.net","subject":"[PATCH] checkout-index doc: use --work-dir in the export example","fromName":"Uwe Kleine-König","fromEmail":"ukleinek@informatik.uni-freiburg.de","sentAt":"2007-08-11T18:15:19Z","receivedAt":"2007-08-11T18:15:19Z","isPatch":true,"sender":{"key":"u.kleine-koenig@pengutronix.de","avatar":"https://gravatar.com/avatar/354b5e3ceb2806a2f1e1e382ac29ddbdad18288654da62b61eb13583a857eee7?d=mp&s=160"},"body":"The old example used --prefix=.../ to teach the reader that the trailing\nslash is important.  This lesson just moved down to the next example,\nwithout a real example though.\n\nSigned-off-by: Uwe Kleine-König <ukleinek@informatik.uni-freiburg.de>\n---\nHello Junio,\n\neven if you revert 4465f410 (and add the tests) I'd prefer using\n--work-tree.\n\nBest regards\nUwe\n\n Documentation/git-checkout-index.txt |   15 ++++++---------\n 1 files changed, 6 insertions(+), 9 deletions(-)\n\ndiff --git a/Documentation/git-checkout-index.txt b/Documentation/git-checkout-index.txt\nindex b1a8ce1..7c19351 100644\n--- a/Documentation/git-checkout-index.txt\n+++ b/Documentation/git-checkout-index.txt\n@@ -143,21 +143,16 @@ $ git-checkout-index -n -f -a && git-update-index --ignore-missing --refresh\n ----------------\n \n Using `git-checkout-index` to \"export an entire tree\"::\n-\tThe prefix ability basically makes it trivial to use\n-\t`git-checkout-index` as an \"export as tree\" function.\n-\tJust read the desired tree into the index, and do:\n+\tJust read the desired tree into the index, make sure\n+\tgit-export-dir exists, and do:\n +\n ----------------\n-$ git-checkout-index --prefix=git-export-dir/ -a\n+$ git --work-dir=git-export-dir checkout-index -a\n ----------------\n +\n `git-checkout-index` will \"export\" the index into the specified\n directory.\n +\n-The final \"/\" is important. The exported name is literally just\n-prefixed with the specified string.  Contrast this with the\n-following example.\n-\n Export files with a prefix::\n +\n ----------------\n@@ -165,7 +160,9 @@ $ git-checkout-index --prefix=.merged- Makefile\n ----------------\n +\n This will check out the currently cached copy of `Makefile`\n-into the file `.merged-Makefile`.\n+into the file `.merged-Makefile`.  The argument of --prefix is\n+literally just prefixed with the specified string, so if you want to\n+export to a directory you must end the prefix with a slash.\n \n \n Author\n-- \n1.5.3.rc4.857.ge22ff\n"}]}