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

[PATCH v2 0/2] send-email: don't needlessly abs_path() the core.hooksPath

From
Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Date
May 26, 2021, 11:21 UTC
Message-ID
<cover-0.2-00000000000-20210526T111558Z-avarab@gmail.com>
In-Reply-To
<xmqq5yz6ehpk.fsf@gitster.g>
On Wed, May 26 2021, Junio C Hamano wrote:
Show 7 quoted lines
> Ævar Arnfjörð Bjarmason <avarab@gmail.com> writes:
>
>> But I'll leave it to you, if you are convinced and do want to take this
>> 2/2 after all I'll submit another trivial patch on top to remove the new
>> (then unused) repo_path function, which we expect to go away anyway.
>
> Sounds good.

Here that is, now on top of the new "master" which has the t9001-send-email.sh changes you'd already merged down.

Ævar Arnfjörð Bjarmason (2):
  send-email: don't needlessly abs_path() the core.hooksPath
  send-email: move "hooks_path" invocation to git-send-email.perl
 git-send-email.perl   |  3 ++-
 perl/Git.pm           | 13 -------------
 t/t9001-send-email.sh |  7 ++++---
 3 files changed, 6 insertions(+), 17 deletions(-)
Range-diff against v1:
1:  df3a2b8562d < -:  ----------- send-email: fix missing error message regression
2:  d097e7b0b81 ! 1:  ff01d4619ea send-email: don't needlessly abs_path() the core.hooksPath
    @@ Commit message
         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).
    +    The just-landed 53753a37d09 (t9001-send-email.sh: fix expected
    +    absolute paths on Windows, 2021-05-24) narrowly fixed this issue, but
    +    I believe we can do better here. We should not be relying on whatever
    +    changes Perl's abs_path() makes to the path "rev-parse --git-path
    +    hooks" hands to us. Let's instead trust it, and hand it to Perl's
    +    system() in git-send-email.perl. It will handle either a relative or
    +    absolute path.
     
    -    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().
    +    So let's revert most of 53753a37d09 and just have "hooks_path" return
    +    what we get from "rev-parse" directly without modification. This has
    +    the added benefit of making the error message friendlier in the common
    +    case, we'll no longer print an absolute path for repository-local hook
    +    errors.
     
         1. http://lore.kernel.org/git/bb30fe2b-cd75-4782-24a6-08bb002a0367@kdbg.org
     
    @@ t/t9001-send-email.sh: test_expect_success $PREREQ "--validate respects relative
      	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 '"'"'$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
    + '
    + 
    + test_expect_success $PREREQ "--validate respects absolute core.hooksPath path" '
    +-	test_config core.hooksPath "$(pwd)/my-hooks" &&
    ++	hooks_path="$(pwd)/my-hooks" &&
    ++	test_config core.hooksPath "$hooks_path" &&
    + 	test_when_finished "rm my-hooks.ran" &&
    + 	test_must_fail git send-email \
    + 		--from="Example <nobody@example.com>" \
    +@@ t/t9001-send-email.sh: test_expect_success $PREREQ "--validate respects absolute 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 '"'"'$hooks_path/sendemail-validate'"'"' died with exit code 1
    + 	warning: no patches were sent
    + 	EOF
    + 	test_cmp expect actual
-:  ----------- > 2:  cda41c36772 send-email: move "hooks_path" invocation to git-send-email.perl
-- 
2.32.0.rc1.400.g0a5a93401d3
Previous: Junio C HamanoNext: Ævar Arnfjörð Bjarmason
Message 16 of 20 in “t9001-send-email.sh: fix expected absolute paths on Windows”
  1. t9001-send-email.sh: fix expected absolute paths on WindowsJohannes Sixt, May 24, 2021
  2. Jonathan NiederMay 24, 2021
  3. Ævar Arnfjörð BjarmasonMay 24, 2021
  4. Ævar Arnfjörð BjarmasonMay 24, 2021
  5. 0/2 send-email: pre-release fixes for v2.32.0Ævar Arnfjörð Bjarmason, May 24, 2021
  6. 1/2 send-email: fix missing error message regressionÆvar Arnfjörð Bjarmason, May 24, 2021
  7. 2/2 send-email: don't needlessly abs_path() the core.hooksPathÆvar Arnfjörð Bjarmason, May 24, 2021
  8. Junio C HamanoMay 25, 2021
  9. Robert FossMay 25, 2021
  10. Ævar Arnfjörð BjarmasonMay 25, 2021
  11. Ævar Arnfjörð BjarmasonMay 25, 2021
  12. Robert FossMay 25, 2021
  13. Junio C HamanoMay 25, 2021
  14. Ævar Arnfjörð BjarmasonMay 25, 2021
  15. Junio C HamanoMay 25, 2021
  16. 0/2 send-email: don't needlessly abs_path() the core.hooksPathÆvar Arnfjörð Bjarmason, May 26, 2021
  17. 1/2 send-email: don't needlessly abs_path() the core.hooksPathÆvar Arnfjörð Bjarmason, May 26, 2021
  18. 2/2 send-email: move "hooks_path" invocation to git-send-email.perlÆvar Arnfjörð Bjarmason, May 26, 2021
  19. Felipe ContrerasMay 26, 2021
  20. Johannes SchindelinJun 2, 2021

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.