* [PATCH] Makefile: add a knob to turn off hardlinks within same directory
@ 2011-10-12 8:38 Jonathan Nieder
2011-10-12 19:02 ` Junio C Hamano
0 siblings, 1 reply; 3+ messages in thread
From: Jonathan Nieder @ 2011-10-12 8:38 UTC (permalink / raw)
To: git; +Cc: Bastian Blank, Cedric Staniewski
The git builtins in $(gitexecdir) are implemented as hard links to a
single git binary by default, so even the overhead of symlink
resolution is not needed to run them. However, the trick can be
harmful, in two cases:
- on Windows, some tools to estimate directory size hugely
overestimate the size of git (each hardlink counts as taking up the
same amount of space as git.exe)
- various filesystems have limits on the number of hardlinks that
can be made to a particular file --- Linux's LINK_MAX is 127,
_POSIX_LINK_MAX is 8, and btrfs has a limit of 4096 /
($len_filename + 8) or so links to a given inode in a single
directory.
Normally that second case is not a problem (when ln fails, "make
install" falls back to "ln -s"), but if git is tar'ed up on one
filesystem and then extracted on a more limited one, it can result in
"Too many links" errors.
Nowadays people are encouraged to (and typically do) run builtins
using the "git" command name directly rather than those dashed forms
in scripts, making the use of hardlinks for the dashed forms a
somewhat pointless optimization. Introduce a new knob to allow people
to turn it off with a simple "make install NO_HARDLINKS=YesPlease".
Typically someone using this setting would want to set
NO_CROSS_DIRECTORY_HARDLINKS, too, but that is not enforced, so you
can make $(bindir)/git and $(gitexecdir)/git into hardlinks to the
same inode and still make sure your tarball avoids the btrfs limits if
you want.
Requested-by: Bastian Blank <waldi@debian.org>
Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
---
Hi,
See <http://bugs.debian.org/642603> for context. Sane?
Makefile | 7 +++++++
1 files changed, 7 insertions(+), 0 deletions(-)
diff --git a/Makefile b/Makefile
index 9afdcf2a..ab64ff4c 100644
--- a/Makefile
+++ b/Makefile
@@ -226,6 +226,10 @@ all::
# Define NO_CROSS_DIRECTORY_HARDLINKS if you plan to distribute the installed
# programs as a tar, where bin/ and libexec/ might be on different file systems.
#
+# Define NO_HARDLINKS if you plan to distribute the installed programs as a tar
+# that might be extracted on a filesystem like btrfs that does not cope well
+# with many links to one inode in one directory.
+#
# Define USE_NED_ALLOCATOR if you want to replace the platforms default
# memory allocators with the nedmalloc allocator written by Niall Douglas.
#
@@ -2326,12 +2330,14 @@ endif
} && \
for p in $(filter $(install_bindir_programs),$(BUILT_INS)); do \
$(RM) "$$bindir/$$p" && \
+ test -z "$(NO_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" && \
+ test -z "$(NO_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; \
@@ -2339,6 +2345,7 @@ endif
remote_curl_aliases="$(REMOTE_CURL_ALIASES)" && \
for p in $$remote_curl_aliases; do \
$(RM) "$$execdir/$$p" && \
+ test -z "$(NO_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; \
--
1.7.7
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] Makefile: add a knob to turn off hardlinks within same directory
2011-10-12 8:38 [PATCH] Makefile: add a knob to turn off hardlinks within same directory Jonathan Nieder
@ 2011-10-12 19:02 ` Junio C Hamano
2011-10-12 19:57 ` Jonathan Nieder
0 siblings, 1 reply; 3+ messages in thread
From: Junio C Hamano @ 2011-10-12 19:02 UTC (permalink / raw)
To: Jonathan Nieder; +Cc: git, Bastian Blank, Cedric Staniewski
Jonathan Nieder <jrnieder@gmail.com> writes:
> Typically someone using this setting would want to set
> NO_CROSS_DIRECTORY_HARDLINKS, too, but that is not enforced, so you
> can make $(bindir)/git and $(gitexecdir)/git into hardlinks to the
> same inode and still make sure your tarball avoids the btrfs limits if
> you want.
>
> Requested-by: Bastian Blank <waldi@debian.org>
> Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
> ---
> Hi,
>
> See <http://bugs.debian.org/642603> for context. Sane?
>
> Makefile | 7 +++++++
> 1 files changed, 7 insertions(+), 0 deletions(-)
>
> diff --git a/Makefile b/Makefile
> index 9afdcf2a..ab64ff4c 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -226,6 +226,10 @@ all::
> # Define NO_CROSS_DIRECTORY_HARDLINKS if you plan to distribute the installed
> # programs as a tar, where bin/ and libexec/ might be on different file systems.
> #
> +# Define NO_HARDLINKS if you plan to distribute the installed programs as a tar
> +# that might be extracted on a filesystem like btrfs that does not cope well
> +# with many links to one inode in one directory.
> +#
Hmm.... I would understand if the change were to eventually remove these
"git-foo" anywhere from the filesystem perhaps after a large version bump
in Git 2.0, but that is not what you are trying to do.
Wouldn't your use case be better served with
$ tar zcf dist.tar.gz --hard-dereference $list_of_files_to_tar_up
instead?
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] Makefile: add a knob to turn off hardlinks within same directory
2011-10-12 19:02 ` Junio C Hamano
@ 2011-10-12 19:57 ` Jonathan Nieder
0 siblings, 0 replies; 3+ messages in thread
From: Jonathan Nieder @ 2011-10-12 19:57 UTC (permalink / raw)
To: Junio C Hamano; +Cc: git, Bastian Blank, Cedric Staniewski
Junio C Hamano wrote:
> Wouldn't your use case be better served with
>
> $ tar zcf dist.tar.gz --hard-dereference $list_of_files_to_tar_up
>
> instead?
No, because that duplicates the files instead of making symlinks.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2011-10-12 19:57 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-10-12 8:38 [PATCH] Makefile: add a knob to turn off hardlinks within same directory Jonathan Nieder
2011-10-12 19:02 ` Junio C Hamano
2011-10-12 19:57 ` Jonathan Nieder
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 NNTP newsgroup(s).