git@vger.kernel.org list mirror (unofficial, one of many)
 help / color / mirror / code / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Alex Vandiver <alexmv@dropbox.com>
Cc: git@vger.kernel.org,
	Johannes Schindelin <Johannes.Schindelin@gmx.de>,
	Ben Peart <peartben@gmail.com>
Subject: Re: [PATCH 1/2] fsmonitor: Read from getcwd(), not the PWD environment variable
Date: Fri, 10 Nov 2017 14:04:45 +0900	[thread overview]
Message-ID: <xmqqzi7ug1w2.fsf@gitster.mtv.corp.google.com> (raw)
In-Reply-To: <1a8090dfa6f273bae68cfcdd62446944bedbc8a7.1510257457.git.alexmv@dropbox.com> (Alex Vandiver's message of "Thu, 9 Nov 2017 11:58:09 -0800")

Alex Vandiver <alexmv@dropbox.com> writes:

This comment is only so that I do not keep editing them while queuing..

> Subject: Re: [PATCH 1/2] fsmonitor: Read from getcwd(), not the PWD environment variable

Downcase "Read" (or any word after "<area>: " on the commit title).

> Though the process has chdir'd to the root of the working tree, the
> PWD environment variable is only guaranteed to be updated accordingly
> if a shell is involved -- which is not guaranteed to be the case.
> That is, if `/usr/bin/perl` is a binary, $ENV{PWD} is unchanged from
> whatever spawned `git` -- if `/usr/bin/perl` is a trivial shell
> wrapper to the real `perl`, `$ENV{PWD}` will have been updated to the
> root of the working copy.
>
> Update to read from the Cwd module using the `getcwd` syscall, not the
> PWD environment variable.  The Cygwin case is left unchanged, as it
> necessarily _does_ go through a shell.

Interesting observation.  Why didn't anybody else notice it, I
wonder?

Thanks, will queue.

> Signed-off-by: Alex Vandiver <alexmv@dropbox.com>
> ---
>  t/t7519/fsmonitor-watchman                 | 3 ++-
>  templates/hooks--fsmonitor-watchman.sample | 3 ++-
>  2 files changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/t/t7519/fsmonitor-watchman b/t/t7519/fsmonitor-watchman
> index a3e30bf54..5fe72cefa 100755
> --- a/t/t7519/fsmonitor-watchman
> +++ b/t/t7519/fsmonitor-watchman
> @@ -41,7 +41,8 @@ if ($system =~ m/^MSYS_NT/ || $system =~ m/^MINGW/) {
>  	$git_work_tree =~ s/[\r\n]+//g;
>  	$git_work_tree =~ s,\\,/,g;
>  } else {
> -	$git_work_tree = $ENV{'PWD'};
> +	require Cwd;
> +	$git_work_tree = Cwd::cwd();
>  }
>  
>  my $retry = 1;
> diff --git a/templates/hooks--fsmonitor-watchman.sample b/templates/hooks--fsmonitor-watchman.sample
> index 9a082f278..ba6d88c5f 100755
> --- a/templates/hooks--fsmonitor-watchman.sample
> +++ b/templates/hooks--fsmonitor-watchman.sample
> @@ -40,7 +40,8 @@ if ($system =~ m/^MSYS_NT/ || $system =~ m/^MINGW/) {
>  	$git_work_tree =~ s/[\r\n]+//g;
>  	$git_work_tree =~ s,\\,/,g;
>  } else {
> -	$git_work_tree = $ENV{'PWD'};
> +	require Cwd;
> +	$git_work_tree = Cwd::cwd();
>  }
>  
>  my $retry = 1;

  parent reply	other threads:[~2017-11-10  5:04 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-11-09 19:58 [PATCH 0/2] fsmonitor: Stop reading from PWD, write fsmonitor+split index right Alex Vandiver
2017-11-09 19:58 ` [PATCH 1/2] fsmonitor: Read from getcwd(), not the PWD environment variable Alex Vandiver
2017-11-09 19:58   ` [PATCH 2/2] fsmonitor: Store fsmonitor bitmap before splitting index Alex Vandiver
2017-11-10  5:11     ` Junio C Hamano
2017-11-13 15:28     ` Ben Peart
2017-12-16  2:02       ` Alex Vandiver
2017-11-10  5:04   ` Junio C Hamano [this message]
2017-11-10 21:03     ` [PATCH v1] fsmonitor: simplify determining the git worktree under Windows Ben Peart
2017-11-13  1:02       ` Junio C Hamano

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

  List information: http://vger.kernel.org/majordomo-info.html

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

  git send-email \
    --in-reply-to=xmqqzi7ug1w2.fsf@gitster.mtv.corp.google.com \
    --to=gitster@pobox.com \
    --cc=Johannes.Schindelin@gmx.de \
    --cc=alexmv@dropbox.com \
    --cc=git@vger.kernel.org \
    --cc=peartben@gmail.com \
    --subject='Re: [PATCH 1/2] fsmonitor: Read from getcwd(), not the PWD environment variable' \
    /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

git@vger.kernel.org list mirror (unofficial, one of many)

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://public-inbox.org/git
	git clone --mirror http://ou63pmih66umazou.onion/git
	git clone --mirror http://czquwvybam4bgbro.onion/git
	git clone --mirror http://hjrcffqmbrq6wope.onion/git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V1 git git/ https://public-inbox.org/git \
		git@vger.kernel.org
	public-inbox-index git

Example config snippet for mirrors.
Newsgroups are available over NNTP:
	nntp://news.public-inbox.org/inbox.comp.version-control.git
	nntp://7fh6tueqddpjyxjmgtdiueylzoqt6pt7hec3pukyptlmohoowvhde4yd.onion/inbox.comp.version-control.git
	nntp://ie5yzdi7fg72h7s4sdcztq5evakq23rdt33mfyfcddc5u3ndnw24ogqd.onion/inbox.comp.version-control.git
	nntp://4uok3hntl7oi7b4uf4rtfwefqeexfzil2w6kgk2jn5z2f764irre7byd.onion/inbox.comp.version-control.git
	nntp://news.gmane.io/gmane.comp.version-control.git
 note: .onion URLs require Tor: https://www.torproject.org/

code repositories for project(s) associated with this inbox:

	https://80x24.org/mirrors/git.git

AGPL code for this site: git clone https://public-inbox.org/public-inbox.git