git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH 4/8] Add a function to set a non-default work tree

From
Daniel Barkalow <barkalow@iabervon.org>
Date
Apr 20, 2008, 19:52 UTC
Message-ID
<alpine.LNX.1.00.0804201546340.19665@iabervon.org>
In-Reply-To
<7vprslcdxf.fsf@gitster.siamese.dyndns.org>
On Sat, 19 Apr 2008, Junio C Hamano wrote:
Show 38 quoted lines
> Daniel Barkalow <barkalow@iabervon.org> writes:
> 
> > Signed-off-by: Daniel Barkalow <barkalow@iabervon.org>
> > ---
> >  cache.h       |    1 +
> >  environment.c |    6 ++++++
> >  2 files changed, 7 insertions(+), 0 deletions(-)
> >
> > diff --git a/cache.h b/cache.h
> > index 96dcb49..d88a4e2 100644
> > --- a/cache.h
> > +++ b/cache.h
> > @@ -311,6 +311,7 @@ extern char *get_index_file(void);
> >  extern char *get_graft_file(void);
> >  extern int set_git_dir(const char *path);
> >  extern const char *get_git_work_tree(void);
> > +extern void set_git_work_tree(const char *tree);
> >  
> >  #define ALTERNATE_DB_ENVIRONMENT "GIT_ALTERNATE_OBJECT_DIRECTORIES"
> >  
> > diff --git a/environment.c b/environment.c
> > index 6739a3f..d6c6a6b 100644
> > --- a/environment.c
> > +++ b/environment.c
> > @@ -81,6 +81,12 @@ const char *get_git_dir(void)
> >  	return git_dir;
> >  }
> >  
> > +void set_git_work_tree(const char *new_work_tree)
> > +{
> > +	get_git_work_tree(); /* make sure it's initialized */
> > +	work_tree = xstrdup(make_absolute_path(new_work_tree));
> > +}
> > +
> 
> Somehow this feels wrong.  Maybe you would need to move that "static int"
> variable inside get_git_work_tree() outside so that you can reset from
> this new function at will?
Yeah, that's better.
> How should the setting of new work tree from sideways using this interface
> interact with bareness of the repository?

I'm only using it before any initialization and when I'm going to force the repository (which doesn't even exist yet; I haven't set git_dir let alone created it, let alone looked at its configuration) to be bare, so I hadn't considered that.

> Should it reset is_bare_repository_cfg to zero?  Should it refuse to set a
> work tree if is_bare_repository_cfg is true already?

is_bare_repository_cfg starts out -1 (not yet specified); this should probably set it to false and require that it not have been specified previously.

	-Daniel
*This .sig left intentionally blank*
Previous: Junio C HamanoNext: Junio C Hamano
Message 4 of 6 in “Add a function to set a non-default work tree”
  1. 4/8 Add a function to set a non-default work treeDaniel Barkalow, Apr 17, 2008
  2. Johan HerlandApr 19, 2008
  3. Junio C HamanoApr 20, 2008
  4. Daniel BarkalowApr 20, 2008
  5. Junio C HamanoApr 22, 2008
  6. Daniel BarkalowApr 22, 2008

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.