git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: "Ævar Arnfjörð Bjarmason" <avarab@gmail.com>
To: git@vger.kernel.org
Cc: "Junio C Hamano" <gitster@pobox.com>,
	"Johannes Sixt" <j6t@kdbg.org>,
	"Johannes Schindelin" <johannes.schindelin@gmx.de>,
	"Jonathan Nieder" <jrnieder@gmail.com>,
	"Robert Foss" <robert.foss@linaro.org>,
	"Ævar Arnfjörð Bjarmason" <avarab@gmail.com>
Subject: [PATCH 2/2] send-email: don't needlessly abs_path() the core.hooksPath
Date: Tue, 25 May 2021 01:14:25 +0200	[thread overview]
Message-ID: <patch-2.2-d097e7b0b81-20210524T231047Z-avarab@gmail.com> (raw)
In-Reply-To: <cover-0.2-00000000000-20210524T231047Z-avarab@gmail.com>

In c8243933c74 (git-send-email: Respect core.hooksPath setting,
2021-03-23) we started supporting core.hooksPath in "send-email". It's
been reported that on Windows[1] doing this by calling abs_path()
results in different canonicalizations of the absolute path.

This wasn't an issue in c8243933c74 itself, but was revealed by my
ea7811b37e0 (git-send-email: improve --validate error output,
2021-04-06) when we started emitting the path to the hook, which was
previously only internal to git-send-email.perl.

I think this change should let us have our cake and eat it too. We now
emit a relative path for the common case where the hook is in the
.git/hooks directory, but in the case it's an absolute path (there's
another test for that, not seen here) we'll prefix it with $(pwd).

I hope that unlike the current implementation that $(pwd) v.s. $PWD
difference won't matter on Windows, since now the absolute path is the
one we get from rev-parse, not the one that's been passed through
Perl's Cwd::abs_path().

1. http://lore.kernel.org/git/bb30fe2b-cd75-4782-24a6-08bb002a0367@kdbg.org

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
---
 perl/Git.pm           | 3 +--
 t/t9001-send-email.sh | 2 +-
 2 files changed, 2 insertions(+), 3 deletions(-)

diff --git a/perl/Git.pm b/perl/Git.pm
index 73ebbf80cc6..df6280ebab5 100644
--- a/perl/Git.pm
+++ b/perl/Git.pm
@@ -629,8 +629,7 @@ sub hooks_path {
 	my ($self) = @_;
 
 	my $dir = $self->command_oneline('rev-parse', '--git-path', 'hooks');
-	my $abs = abs_path($dir);
-	return $abs;
+	return $dir;
 }
 
 =item wc_path ()
diff --git a/t/t9001-send-email.sh b/t/t9001-send-email.sh
index 2acf389837c..3b7540050ca 100755
--- a/t/t9001-send-email.sh
+++ b/t/t9001-send-email.sh
@@ -539,7 +539,7 @@ test_expect_success $PREREQ "--validate respects relative core.hooksPath path" '
 	test_path_is_file my-hooks.ran &&
 	cat >expect <<-EOF &&
 	fatal: longline.patch: rejected by sendemail-validate hook
-	fatal: command '"'"'$(pwd)/my-hooks/sendemail-validate'"'"' died with exit code 1
+	fatal: command '"'"'my-hooks/sendemail-validate'"'"' died with exit code 1
 	warning: no patches were sent
 	EOF
 	test_cmp expect actual
-- 
2.32.0.rc1.385.g9db524b96f7


  parent reply	other threads:[~2021-05-24 23:14 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-24 19:38 [PATCH] t9001-send-email.sh: fix expected absolute paths on Windows Johannes Sixt
2021-05-24 20:26 ` Jonathan Nieder
2021-05-24 22:15 ` Ævar Arnfjörð Bjarmason
2021-05-24 23:15   ` Ævar Arnfjörð Bjarmason
2021-05-24 23:14 ` [PATCH 0/2] send-email: pre-release fixes for v2.32.0 Ævar Arnfjörð Bjarmason
2021-05-24 23:14   ` [PATCH 1/2] send-email: fix missing error message regression Ævar Arnfjörð Bjarmason
2021-05-24 23:14   ` Ævar Arnfjörð Bjarmason [this message]
2021-05-25  1:03     ` [PATCH 2/2] send-email: don't needlessly abs_path() the core.hooksPath Junio C Hamano
2021-05-25  5:57       ` Ævar Arnfjörð Bjarmason
2021-05-25  6:13         ` Ævar Arnfjörð Bjarmason
2021-05-25  6:21           ` Robert Foss
2021-05-25  6:21         ` Junio C Hamano
2021-05-25 12:09           ` Ævar Arnfjörð Bjarmason
2021-05-25 19:28             ` Junio C Hamano
2021-05-26 11:21               ` [PATCH v2 0/2] " Ævar Arnfjörð Bjarmason
2021-05-26 11:21                 ` [PATCH v2 1/2] " Ævar Arnfjörð Bjarmason
2021-05-26 11:21                 ` [PATCH v2 2/2] send-email: move "hooks_path" invocation to git-send-email.perl Ævar Arnfjörð Bjarmason
2021-05-26  1:22         ` [PATCH 2/2] send-email: don't needlessly abs_path() the core.hooksPath Felipe Contreras
2021-05-25  6:10       ` Robert Foss
2021-06-02 11:40 ` [PATCH] t9001-send-email.sh: fix expected absolute paths on Windows Johannes Schindelin

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=patch-2.2-d097e7b0b81-20210524T231047Z-avarab@gmail.com \
    --to=avarab@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=j6t@kdbg.org \
    --cc=johannes.schindelin@gmx.de \
    --cc=jrnieder@gmail.com \
    --cc=robert.foss@linaro.org \
    /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.
Code repositories for project(s) associated with this public inbox

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

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 read-only IMAP folder(s) and NNTP newsgroup(s).