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

Re: [PATCH 1/6] Makefile: symlink the same way under "symlinks" and "no hardlinks"

From
Junio C Hamano <gitster@pobox.com>
Date
Mar 29, 2021, 22:17 UTC
Message-ID
<xmqq1rbxiozl.fsf@gitster.g>
In-Reply-To
<patch-1.7-39926acb0d1-20210329T162327Z-avarab@gmail.com>
Ævar Arnfjörð Bjarmason  <avarab@gmail.com> writes:
Show 21 quoted lines
> In particular INSTALL_SYMLINKS=Y will result in a link tree like:
>
>     bin/git
>     libexec/git -> ../bin/git
>     libexec/git-add -> ../bin/git
>
> Whereas NO_INSTALL_HARDLINKS=Y in cases where the "ln" would fail would result in:
>
>     bin/git
>     libexec/git
>     libexec/git-add -> git
>
> I.e. we duplicated the "git" between the bin/ and libexec/
> directories (by default they're hardlinked), and potentially had had
> e.g. "git-add" pointing at the libexec/git hardlink (or more likely if
> "ln" is failing, a copy), instead of the bin/git.
>
> Now we'll instead use the same symlinks to point to the bindir. I
> don't see any reason not to do so, and no breakage related to this has
> been reported with INSTALL_SYMLINKS in all this time. I just did it
> this way to maintain bug-for-bug compatibility at the time.

Makes sense. I do not see a reason why libexec/git-add that points at ../bin/git would cause problems, either.

> +# Define NO_INSTALL_HARDLINKS if you'd like to have programs in bin/
> +# and libexec/ either symlinked (we try with INSTALL_SYMLINKS first),
> +# or if that fails fall back on a "cp" instead of a "ln". Useful for
> +# when you don't want hardlinks at all.

So without INSTALL_SYMLINKS and with NO_INSTALL_HARDLINKS, the only remaining choice is "cp". With both set, we favour "ln -s" over "cp" and do not allow "ln". With INSTALL_SYMLINKS and without NO_INSTALL_HARDLINKS, we try "ln -s", "ln" and finally "cp". With neither, we try "ln" and fall back to "cp"?

That precedence order does make sense.
Show 6 quoted lines
> @@ -3019,33 +3020,30 @@ endif
>  	} && \
>  	for p in $(filter $(install_bindir_programs),$(BUILT_INS)); do \
>  		$(RM) "$$bindir/$$p" && \
> -		test -n "$(INSTALL_SYMLINKS)" && \
> +		test -n "$(INSTALL_SYMLINKS)" -o "$(NO_INSTALL_HARDLINKS)" && \

I had an impression that we avoid -o/-a used with "test" (instead we'd use "test && test" or "test || test")?

In either case, if we are told to favor "ln -s", or told not to use "ln", we try "ln -s"? That does not make much sense to me, though.

What do I need to do if I do not ever want symbolic links? Is it impossible now?

Show 12 quoted lines
>  		ln -s "git$X" "$$bindir/$$p" || \
>  		{ test -z "$(NO_INSTALL_HARDLINKS)" && \
>  		  ln "$$bindir/git$X" "$$bindir/$$p" 2>/dev/null || \
> -		  ln -s "git$X" "$$bindir/$$p" 2>/dev/null || \
>  		  cp "$$bindir/git$X" "$$bindir/$$p" || exit; }; \
>  	done && \
>  	for p in $(BUILT_INS); do \
>  		$(RM) "$$execdir/$$p" && \
>  		if test -z "$(SKIP_DASHED_BUILT_INS)"; \
>  		then \
> -			test -n "$(INSTALL_SYMLINKS)" && \
> +			test -n "$(INSTALL_SYMLINKS)" -o "$(NO_INSTALL_HARDLINKS)" && \
Perhaps the same comment applies here and to the next hunk, too?
Show 19 quoted lines
>  			ln -s "$$destdir_from_execdir_SQ/$(bindir_relative_SQ)/git$X" "$$execdir/$$p" || \
>  			{ test -z "$(NO_INSTALL_HARDLINKS)" && \
>  			  ln "$$execdir/git$X" "$$execdir/$$p" 2>/dev/null || \
> -			  ln -s "git$X" "$$execdir/$$p" 2>/dev/null || \
>  			  cp "$$execdir/git$X" "$$execdir/$$p" || exit; }; \
>  		fi \
>  	done && \
>  	remote_curl_aliases="$(REMOTE_CURL_ALIASES)" && \
>  	for p in $$remote_curl_aliases; do \
>  		$(RM) "$$execdir/$$p" && \
> -		test -n "$(INSTALL_SYMLINKS)" && \
> +		test -n "$(INSTALL_SYMLINKS)" -o "$(NO_INSTALL_HARDLINKS)" && \
>  		ln -s "git-remote-http$X" "$$execdir/$$p" || \
>  		{ test -z "$(NO_INSTALL_HARDLINKS)" && \
>  		  ln "$$execdir/git-remote-http$X" "$$execdir/$$p" 2>/dev/null || \
> -		  ln -s "git-remote-http$X" "$$execdir/$$p" 2>/dev/null || \
>  		  cp "$$execdir/git-remote-http$X" "$$execdir/$$p" || exit; } \
>  	done && \
>  	./check_bindir "z$$bindir" "z$$execdir" "$$bindir/git-add$X"
Previous: Ævar Arnfjörð BjarmasonNext: Ævar Arnfjörð Bjarmason
Message 31 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.