{"thread":{"id":"13164","subject":"[PATCH 4/8] Add a function to set a non-default work tree","startedAt":"2008-04-17T23:32:33Z","lastAt":"2008-04-22T03:47:36Z","messageCount":6,"participants":["Daniel Barkalow","Johan Herland","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":8},"messages":[{"id":"74696","messageId":"alpine.LNX.1.00.0804171931550.19665@iabervon.org","threadId":"13164","inReplyTo":null,"subject":"[PATCH 4/8] Add a function to set a non-default work tree","fromName":"Daniel Barkalow","fromEmail":"barkalow@iabervon.org","sentAt":"2008-04-17T23:32:33Z","receivedAt":"2008-04-17T23:32:33Z","isPatch":true,"sender":{"key":"barkalow@iabervon.org","avatar":"https://avatars.githubusercontent.com/u/55364219?v=4"},"body":"Signed-off-by: Daniel Barkalow <barkalow@iabervon.org>\n---\n cache.h       |    1 +\n environment.c |    6 ++++++\n 2 files changed, 7 insertions(+), 0 deletions(-)\n\ndiff --git a/cache.h b/cache.h\nindex 96dcb49..d88a4e2 100644\n--- a/cache.h\n+++ b/cache.h\n@@ -311,6 +311,7 @@ extern char *get_index_file(void);\n extern char *get_graft_file(void);\n extern int set_git_dir(const char *path);\n extern const char *get_git_work_tree(void);\n+extern void set_git_work_tree(const char *tree);\n \n #define ALTERNATE_DB_ENVIRONMENT \"GIT_ALTERNATE_OBJECT_DIRECTORIES\"\n \ndiff --git a/environment.c b/environment.c\nindex 6739a3f..d6c6a6b 100644\n--- a/environment.c\n+++ b/environment.c\n@@ -81,6 +81,12 @@ const char *get_git_dir(void)\n \treturn git_dir;\n }\n \n+void set_git_work_tree(const char *new_work_tree)\n+{\n+\tget_git_work_tree(); /* make sure it's initialized */\n+\twork_tree = xstrdup(make_absolute_path(new_work_tree));\n+}\n+\n const char *get_git_work_tree(void)\n {\n \tstatic int initialized = 0;\n-- \n1.5.4.3.610.gea6cd\n"},{"id":"74755","messageId":"200804191933.51303.johan@herland.net","threadId":"13164","inReplyTo":"alpine.LNX.1.00.0804171931550.19665@iabervon.org","subject":"Re: [PATCH 4/8] Add a function to set a non-default work tree","fromName":"Johan Herland","fromEmail":"johan@herland.net","sentAt":"2008-04-19T17:33:51Z","receivedAt":"2008-04-19T17:33:51Z","isPatch":true,"sender":{"key":"johan@herland.net","avatar":"https://avatars.githubusercontent.com/u/547031?v=4"},"body":"On Friday 18 April 2008, Daniel Barkalow wrote:\n> Signed-off-by: Daniel Barkalow <barkalow@iabervon.org>\n> ---\n>  cache.h       |    1 +\n>  environment.c |    6 ++++++\n>  2 files changed, 7 insertions(+), 0 deletions(-)\n> \n> diff --git a/cache.h b/cache.h\n> index 96dcb49..d88a4e2 100644\n> --- a/cache.h\n> +++ b/cache.h\n> @@ -311,6 +311,7 @@ extern char *get_index_file(void);\n>  extern char *get_graft_file(void);\n>  extern int set_git_dir(const char *path);\n>  extern const char *get_git_work_tree(void);\n> +extern void set_git_work_tree(const char *tree);\n>  \n>  #define ALTERNATE_DB_ENVIRONMENT \"GIT_ALTERNATE_OBJECT_DIRECTORIES\"\n>  \n> diff --git a/environment.c b/environment.c\n> index 6739a3f..d6c6a6b 100644\n> --- a/environment.c\n> +++ b/environment.c\n> @@ -81,6 +81,12 @@ const char *get_git_dir(void)\n>  \treturn git_dir;\n>  }\n>  \n> +void set_git_work_tree(const char *new_work_tree)\n> +{\n> +\tget_git_work_tree(); /* make sure it's initialized */\n> +\twork_tree = xstrdup(make_absolute_path(new_work_tree));\n\nShouldn't we free(work_tree) before resetting it?\n\n> +}\n> +\n>  const char *get_git_work_tree(void)\n>  {\n>  \tstatic int initialized = 0;\n\n\n...Johan\n\n-- \nJohan Herland, <johan@herland.net>\nwww.herland.net\n"},{"id":"74798","messageId":"7vprslcdxf.fsf@gitster.siamese.dyndns.org","threadId":"13164","inReplyTo":"alpine.LNX.1.00.0804171931550.19665@iabervon.org","subject":"Re: [PATCH 4/8] Add a function to set a non-default work tree","fromName":"Junio C Hamano","fromEmail":"junio@pobox.com","sentAt":"2008-04-20T05:07:08Z","receivedAt":"2008-04-20T05:07:08Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Daniel Barkalow <barkalow@iabervon.org> writes:\n\n> Signed-off-by: Daniel Barkalow <barkalow@iabervon.org>\n> ---\n>  cache.h       |    1 +\n>  environment.c |    6 ++++++\n>  2 files changed, 7 insertions(+), 0 deletions(-)\n>\n> diff --git a/cache.h b/cache.h\n> index 96dcb49..d88a4e2 100644\n> --- a/cache.h\n> +++ b/cache.h\n> @@ -311,6 +311,7 @@ extern char *get_index_file(void);\n>  extern char *get_graft_file(void);\n>  extern int set_git_dir(const char *path);\n>  extern const char *get_git_work_tree(void);\n> +extern void set_git_work_tree(const char *tree);\n>  \n>  #define ALTERNATE_DB_ENVIRONMENT \"GIT_ALTERNATE_OBJECT_DIRECTORIES\"\n>  \n> diff --git a/environment.c b/environment.c\n> index 6739a3f..d6c6a6b 100644\n> --- a/environment.c\n> +++ b/environment.c\n> @@ -81,6 +81,12 @@ const char *get_git_dir(void)\n>  \treturn git_dir;\n>  }\n>  \n> +void set_git_work_tree(const char *new_work_tree)\n> +{\n> +\tget_git_work_tree(); /* make sure it's initialized */\n> +\twork_tree = xstrdup(make_absolute_path(new_work_tree));\n> +}\n> +\n\nSomehow this feels wrong.  Maybe you would need to move that \"static int\"\nvariable inside get_git_work_tree() outside so that you can reset from\nthis new function at will?\n\nHow should the setting of new work tree from sideways using this interface\ninteract with bareness of the repository?\n\nShould it reset is_bare_repository_cfg to zero?  Should it refuse to set a\nwork tree if is_bare_repository_cfg is true already?\n"},{"id":"74829","messageId":"alpine.LNX.1.00.0804201546340.19665@iabervon.org","threadId":"13164","inReplyTo":"7vprslcdxf.fsf@gitster.siamese.dyndns.org","subject":"Re: [PATCH 4/8] Add a function to set a non-default work tree","fromName":"Daniel Barkalow","fromEmail":"barkalow@iabervon.org","sentAt":"2008-04-20T19:52:30Z","receivedAt":"2008-04-20T19:52:30Z","isPatch":true,"sender":{"key":"barkalow@iabervon.org","avatar":"https://avatars.githubusercontent.com/u/55364219?v=4"},"body":"On Sat, 19 Apr 2008, Junio C Hamano wrote:\n\n> Daniel Barkalow <barkalow@iabervon.org> writes:\n> \n> > Signed-off-by: Daniel Barkalow <barkalow@iabervon.org>\n> > ---\n> >  cache.h       |    1 +\n> >  environment.c |    6 ++++++\n> >  2 files changed, 7 insertions(+), 0 deletions(-)\n> >\n> > diff --git a/cache.h b/cache.h\n> > index 96dcb49..d88a4e2 100644\n> > --- a/cache.h\n> > +++ b/cache.h\n> > @@ -311,6 +311,7 @@ extern char *get_index_file(void);\n> >  extern char *get_graft_file(void);\n> >  extern int set_git_dir(const char *path);\n> >  extern const char *get_git_work_tree(void);\n> > +extern void set_git_work_tree(const char *tree);\n> >  \n> >  #define ALTERNATE_DB_ENVIRONMENT \"GIT_ALTERNATE_OBJECT_DIRECTORIES\"\n> >  \n> > diff --git a/environment.c b/environment.c\n> > index 6739a3f..d6c6a6b 100644\n> > --- a/environment.c\n> > +++ b/environment.c\n> > @@ -81,6 +81,12 @@ const char *get_git_dir(void)\n> >  \treturn git_dir;\n> >  }\n> >  \n> > +void set_git_work_tree(const char *new_work_tree)\n> > +{\n> > +\tget_git_work_tree(); /* make sure it's initialized */\n> > +\twork_tree = xstrdup(make_absolute_path(new_work_tree));\n> > +}\n> > +\n> \n> Somehow this feels wrong.  Maybe you would need to move that \"static int\"\n> variable inside get_git_work_tree() outside so that you can reset from\n> this new function at will?\n\nYeah, that's better.\n\n> How should the setting of new work tree from sideways using this interface\n> interact with bareness of the repository?\n\nI'm only using it before any initialization and when I'm going to force \nthe repository (which doesn't even exist yet; I haven't set git_dir let \nalone created it, let alone looked at its configuration) to be bare, so I \nhadn't considered that.\n\n> Should it reset is_bare_repository_cfg to zero?  Should it refuse to set a\n> work tree if is_bare_repository_cfg is true already?\n\nis_bare_repository_cfg starts out -1 (not yet specified); this should \nprobably set it to false and require that it not have been specified \npreviously.\n\n\t-Daniel\n*This .sig left intentionally blank*\n"},{"id":"74892","messageId":"7v3apeagxj.fsf@gitster.siamese.dyndns.org","threadId":"13164","inReplyTo":"alpine.LNX.1.00.0804201546340.19665@iabervon.org","subject":"Re: [PATCH 4/8] Add a function to set a non-default work tree","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2008-04-22T00:09:44Z","receivedAt":"2008-04-22T00:09:44Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Daniel Barkalow <barkalow@iabervon.org> writes:\n\n> On Sat, 19 Apr 2008, Junio C Hamano wrote:\n> ...\n>> How should the setting of new work tree from sideways using this interface\n>> interact with bareness of the repository?\n>\n> I'm only using it before any initialization and when I'm going to force \n> the repository (which doesn't even exist yet; I haven't set git_dir let \n> alone created it, let alone looked at its configuration) to be bare, so I \n> hadn't considered that.\n\nThat is not quite an explanation that builds confidence in a patch that\nadds a generic-sounding helper function that could be called by later\ncallers.  Doesn't it have a very tempting name for people to call?\n"},{"id":"74901","messageId":"alpine.LNX.1.00.0804212340590.19665@iabervon.org","threadId":"13164","inReplyTo":"7v3apeagxj.fsf@gitster.siamese.dyndns.org","subject":"Re: [PATCH 4/8] Add a function to set a non-default work tree","fromName":"Daniel Barkalow","fromEmail":"barkalow@iabervon.org","sentAt":"2008-04-22T03:47:36Z","receivedAt":"2008-04-22T03:47:36Z","isPatch":true,"sender":{"key":"barkalow@iabervon.org","avatar":"https://avatars.githubusercontent.com/u/55364219?v=4"},"body":"On Mon, 21 Apr 2008, Junio C Hamano wrote:\n\n> Daniel Barkalow <barkalow@iabervon.org> writes:\n> \n> > On Sat, 19 Apr 2008, Junio C Hamano wrote:\n> > ...\n> >> How should the setting of new work tree from sideways using this interface\n> >> interact with bareness of the repository?\n> >\n> > I'm only using it before any initialization and when I'm going to force \n> > the repository (which doesn't even exist yet; I haven't set git_dir let \n> > alone created it, let alone looked at its configuration) to be bare, so I \n> > hadn't considered that.\n> \n> That is not quite an explanation that builds confidence in a patch that\n> adds a generic-sounding helper function that could be called by later\n> callers.  Doesn't it have a very tempting name for people to call?\n\nMy latest version has it die() if you've gotten meaningfully far in \ninitializing the repository state. I'm also not sure there's a tempting \nuse case for it aside for in setup code where it clearly works, at least \nuntil we've got support for dealing with multiple working trees in the \nsame process or something of that sort. But, in any case, it'll now fail \nfast and obviously outside of what I've planned for.\n\n\t-Daniel\n*This .sig left intentionally blank*\n"}]}