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

Re: [PATCH 3/6] Makefile: refactor out "ln || ln -s || cp" pattern

From
Junio C Hamano <gitster@pobox.com>
Date
Mar 29, 2021, 22:24 UTC
Message-ID
<xmqqsg4dha3i.fsf@gitster.g>
In-Reply-To
<patch-3.7-bde9de756b4-20210329T162327Z-avarab@gmail.com>
Ævar Arnfjörð Bjarmason  <avarab@gmail.com> writes:
Show 27 quoted lines
> Refactor out the hard-to-read and maintain "ln || ln -s || cp"
> pattern.
>
> This was initially added in 3e073dc5611 (Makefile: always provide a
> fallback when hardlinks fail, 2008-08-25), but since then it's become
> a lot more complex as we've added:
>
>  * 3426e34fedd (Add NO_CROSS_DIRECTORY_HARDLINKS support to the
>    Makefile, 2009-05-11)
>
>  * NO_INSTALL_HARDLINKS in 70de5e65e8c (Makefile:
>    NO_INSTALL_HARDLINKS, 2012-05-02)
>
>  * INSTALL_SYMLINKS in ad874608d8c (Makefile: optionally symlink
>    libexec/git-core binaries to bin/git, 2018-03-13)
>
>  * SKIP_DASHED_BUILT_INS 179227d6e21 (Optionally skip linking/copying
>    the built-ins, 2020-09-21)
>
> Each of those commits had to add a new special-case to this code,
> resulting in quite an unmaintainable mess for adding any sort of new
> option.
>
> Let's use the newly introduced ln-or-cp.sh script instead, note that
> we only sometimes pass the --no-cross-directory-hardlinks option, per
> the previous behavior. The target of the "ln -s" is also another
> special snowflake, but we're careful to carry that forward.

Nice. These explicit command-line options to the helper may be harder to initially write and maintain than just exporting the relevant $(MAKE) macros and using it from the helper, but once it works correctly, it is much easier to see what is going on.

And obviously, if we want to fix the "I do not ever want to see any symlinks", it is very clear that main_with_fallbacks is where the change needs to go.

Raelly nice.
Previous: Ævar Arnfjörð BjarmasonNext: Jeff King
Message 43 of 48 in “Makefile: generate 'git' as 'cc [...] -o git+ && mv git+ git'”
  1. Makefile: generate 'git' as 'cc [...] -o git+ && mv git+ git'Ævar Arnfjörð Bjarmason, Mar 7, 2021
  2. Junio C HamanoMar 7, 2021
  3. Ævar Arnfjörð BjarmasonMar 8, 2021
  4. Junio C HamanoMar 8, 2021
  5. Jeff KingMar 8, 2021
  6. 0/5 Makefile: don't die on AIX with open ./gitÆvar Arnfjörð Bjarmason, Mar 29, 2021
  7. 1/5 Makefile: rename objects in-place, don't clobberÆvar Arnfjörð Bjarmason, Mar 29, 2021
  8. Junio C HamanoMar 29, 2021
  9. Junio C HamanoMar 29, 2021
  10. Ævar Arnfjörð BjarmasonMar 29, 2021
  11. Junio C HamanoMar 30, 2021
  12. Ævar Arnfjörð BjarmasonMar 31, 2021
  13. Junio C HamanoMar 31, 2021
  14. 4/5 Makefile: add the ".DELETE_ON_ERROR" flagÆvar Arnfjörð Bjarmason, Mar 29, 2021
  15. Junio C HamanoMar 29, 2021
  16. Ævar Arnfjörð BjarmasonMar 29, 2021
  17. Junio C HamanoMar 29, 2021
  18. Jeff KingMar 30, 2021
  19. Junio C HamanoMar 30, 2021
  20. Jeff KingMar 31, 2021
  21. Junio C HamanoMar 31, 2021
  22. Johannes SchindelinMar 31, 2021
  23. 3/5 Makefile: don't needlessly "rm $@ $@+" before "mv $@+ $@"Ævar Arnfjörð Bjarmason, Mar 29, 2021
  24. Junio C HamanoMar 29, 2021
  25. 2/5 Makefile: rename scripts in-place, don't clobberÆvar Arnfjörð Bjarmason, Mar 29, 2021
  26. Junio C HamanoMar 29, 2021
  27. Ævar Arnfjörð BjarmasonMar 29, 2021
  28. 5/5 Makefile: don't "rm configure" before generating itÆvar Arnfjörð Bjarmason, Mar 29, 2021
  29. 0/6 Makefile: make non-symlink & non-hardlink install saneÆvar Arnfjörð Bjarmason, Mar 29, 2021
  30. 1/6 Makefile: symlink the same way under "symlinks" and "no hardlinks"Ævar Arnfjörð Bjarmason, Mar 29, 2021
  31. Junio C HamanoMar 29, 2021
  32. 5/6 Makefile: use "ln -f" instead of "rm && ln"Ævar Arnfjörð Bjarmason, Mar 29, 2021
  33. Junio C HamanoMar 29, 2021
  34. 4/6 Makefile: make INSTALL_SYMLINKS affect the build directoryÆvar Arnfjörð Bjarmason, Mar 29, 2021
  35. Junio C HamanoMar 29, 2021
  36. Ævar Arnfjörð BjarmasonMar 31, 2021
  37. 6/6 Makefile: add a INSTALL_FALLBACK_LN_CP modeÆvar Arnfjörð Bjarmason, Mar 29, 2021
  38. Junio C HamanoMar 29, 2021
  39. Ævar Arnfjörð BjarmasonMar 31, 2021
  40. Junio C HamanoMar 31, 2021
  41. Ævar Arnfjörð BjarmasonMar 31, 2021
  42. 3/6 Makefile: refactor out "ln || ln -s || cp" patternÆvar Arnfjörð Bjarmason, Mar 29, 2021
  43. Junio C HamanoMar 29, 2021
  44. Jeff KingMar 30, 2021
  45. Junio C HamanoMar 30, 2021
  46. 2/6 Makefile: begin refactoring out "ln || ln -s || cp" patternÆvar Arnfjörð Bjarmason, Mar 29, 2021
  47. Junio C HamanoMar 29, 2021
  48. Junio C HamanoMar 29, 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.