git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Johannes Schindelin <Johannes.Schindelin@gmx.de>
To: "Nguyễn Thái Ngọc Duy" <pclouds@gmail.com>
Cc: git@vger.kernel.org, Junio C Hamano <gitster@pobox.com>
Subject: Re: [PATCH] setup_git_directory: Setup cwd properly if worktree is found
Date: Mon, 12 Nov 2007 11:57:23 +0000 (GMT)	[thread overview]
Message-ID: <Pine.LNX.4.64.0711121139010.4362@racer.site> (raw)
In-Reply-To: <20071112112408.GA5420@laptop>

[-- Attachment #1: Type: TEXT/PLAIN, Size: 1605 bytes --]

Hi,

On Mon, 12 Nov 2007, Nguyễn Thái Ngọc Duy wrote:

> diff --git a/setup.c b/setup.c
> index 6f8f769..d90f65e 100644
> --- a/setup.c
> +++ b/setup.c
> @@ -360,7 +360,12 @@ const char *setup_git_directory(void)
>  		if (retval && chdir(retval))
>  			die ("Could not jump back into original cwd");
>  		rel = get_relative_cwd(buffer, PATH_MAX, get_git_work_tree());
> -		return rel && *rel ? strcat(rel, "/") : NULL;
> +		if (rel && *rel) {
> +			if (chdir(get_git_work_tree()))
> +				die ("Could not chdir to %s", get_git_work_tree());
> +			return strcat(rel, "/");
> +		}
> +		return NULL;

Hmm.  Maybe this needs a bit more clarification?

When setup_git_directory() returns, the cwd is supposed to be the current 
working tree's root.  Your patch fixes that nicely when the worktree 
setting was overridden by the config (which is read in 
check_repository_format()).

But what about setup_git_directory_gently()?  If the working tree is 
overridden by the config, this function is still bogus, right?

As far as I see, setup_git_directory_gently() only works correctly when 
core.worktree is _not_ set, unless GIT_WORK_TREE is set (which is supposed 
to override the config setting).  Note: I treat GIT_WORK_TREE the same as 
--work-tree, since at that time they are identical.

Maybe the config stuff has to move into _gently()?

Ciao,
Dscho

P.S.: Thanks for picking up the ball.  At some stage I got so fed up with 
the work-tree stuff that I had to take a long break from it.  It is a 
messy concept, and the implementation is messy, partly because of it, and 
partly because I wrote it.

  reply	other threads:[~2007-11-12 11:58 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-11-12 11:24 [PATCH] setup_git_directory: Setup cwd properly if worktree is found Nguyễn Thái Ngọc Duy
2007-11-12 11:57 ` Johannes Schindelin [this message]
     [not found]   ` <fcaeb9bf0711120413w180c07e1qbf1b186753593d7@mail.gmail.com>
2007-11-12 12:31     ` Johannes Schindelin
2007-11-27 14:12       ` Nguyen Thai Ngoc Duy
2007-11-27 14:46         ` Johannes Schindelin
2007-11-12 12:53 ` Johannes Sixt

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Pine.LNX.4.64.0711121139010.4362@racer.site \
    --to=johannes.schindelin@gmx.de \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=pclouds@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).