When we install Git we also install a set of default templates that both
git-init(1) and git-clone(1) populate into our build directories. The
way the pristine templates are laid out in our source directory is
somewhat weird though: instead of reconstructing the actual directory
hierarchy in "templates/", we represent directory separators with "--".
The only reason I could come up with for why we have this is the
"branches/" directory, which is supposed to be empty when installing it.
And as Git famously doesn't store empty directories at all we have to
work around this limitation.
Now the thing is that the "branches/" directory is a leftover to how
branches used to be stored in the dark ages. gitrepository-layout(5)
lists this directory as "slightly deprecated", which I would claim is a
strong understatement. I have never encountered anybody using it today
and would be surprised if it even works as expected. So having the "--"
hack in place for an item that is basically unused, unmaintained and
deprecated doesn't only feel unreasonable, but installing that entry by
default may also cause confusion for users that do not know what this is
supposed to be in the first place.
Remove this directory from our templates and, now that we do not require
the workaround anymore, restructure the templates to form a proper
hierarchy. This makes it way easier for build systems to install these
templates into place.
We should likely think about removing support for "branch/" altogether,
but that is outside of the scope of this patch series.
Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Patrick Steinhardt committedDec 6, 2024 at 14:24 UTCed060aa0a35f5d0e201af45c6a32c405db4c2654
index 367ad00c24..bd1e9e30c1 100644--- a/templates/Makefile+++ b/templates/Makefile@@ -29,24 +29,35 @@ all: boilerplates.made custom # in a file direc--tory--file in the source. They will be # just copied to the destination.-bpsrc = $(filter-out %~,$(wildcard *--*))-boilerplates.made : $(bpsrc)- $(QUIET)umask 022 && ls *--* 2>/dev/null | \- while read boilerplate; \+TEMPLATES =+TEMPLATES += description+TEMPLATES += hooks/applypatch-msg.sample+TEMPLATES += hooks/commit-msg.sample+TEMPLATES += hooks/fsmonitor-watchman.sample+TEMPLATES += hooks/post-update.sample+TEMPLATES += hooks/pre-applypatch.sample+TEMPLATES += hooks/pre-commit.sample+TEMPLATES += hooks/pre-merge-commit.sample+TEMPLATES += hooks/prepare-commit-msg.sample+TEMPLATES += hooks/pre-push.sample+TEMPLATES += hooks/pre-rebase.sample+TEMPLATES += hooks/pre-receive.sample+TEMPLATES += hooks/push-to-checkout.sample+TEMPLATES += hooks/sendemail-validate.sample+TEMPLATES += hooks/update.sample+TEMPLATES += info/exclude++boilerplates.made: $(TEMPLATES)+ $(QUIET)umask 022 && for template in $(TEMPLATES); \ do \- case "$$boilerplate" in *~) continue ;; esac && \- dst=`echo "$$boilerplate" | sed -e 's|^this|.|;s|--|/|g'` && \- dir=`expr "$$dst" : '\(.*\)/'` && \+ dir=$$(dirname "$$template") && \ mkdir -p blt/$$dir && \- case "$$boilerplate" in \- *--) continue;; \- esac && \ sed -e '1s|#!.*/sh|#!$(SHELL_PATH_SQ)|' \ -e 's|@SHELL_PATH@|$(SHELL_PATH_SQ)|' \- -e 's|@PERL_PATH@|$(PERL_PATH_SQ)|g' $$boilerplate > \- blt/$$dst && \- if test -x "$$boilerplate"; then rx=rx; else rx=r; fi && \- chmod a+$$rx "blt/$$dst" || exit; \+ -e 's|@PERL_PATH@|$(PERL_PATH_SQ)|g' $$template > \+ blt/$$template && \+ if test -x "$$template"; then rx=rx; else rx=r; fi && \+ chmod a+$$rx "blt/$$template" || exit; \ done && \ date >$@
templates/branches--
-1
deleted file mode 100644index fae88709a6..0000000000--- a/templates/branches--+++ /dev/null@@ -1 +0,0 @@-: this is just to ensure the directory exists.
templates/description
similarity index 100%rename from templates/this--descriptionrename to templates/description
templates/hooks/applypatch-msg.sample
similarity index 100%rename from templates/hooks--applypatch-msg.samplerename to templates/hooks/applypatch-msg.sample
templates/hooks/commit-msg.sample
similarity index 100%rename from templates/hooks--commit-msg.samplerename to templates/hooks/commit-msg.sample
templates/hooks/fsmonitor-watchman.sample
similarity index 100%rename from templates/hooks--fsmonitor-watchman.samplerename to templates/hooks/fsmonitor-watchman.sample
templates/hooks/post-update.sample
similarity index 100%rename from templates/hooks--post-update.samplerename to templates/hooks/post-update.sample
templates/hooks/pre-applypatch.sample
similarity index 100%rename from templates/hooks--pre-applypatch.samplerename to templates/hooks/pre-applypatch.sample
templates/hooks/pre-commit.sample
similarity index 100%rename from templates/hooks--pre-commit.samplerename to templates/hooks/pre-commit.sample
templates/hooks/pre-merge-commit.sample
similarity index 100%rename from templates/hooks--pre-merge-commit.samplerename to templates/hooks/pre-merge-commit.sample
templates/hooks/pre-push.sample
similarity index 100%rename from templates/hooks--pre-push.samplerename to templates/hooks/pre-push.sample
templates/hooks/pre-rebase.sample
similarity index 100%rename from templates/hooks--pre-rebase.samplerename to templates/hooks/pre-rebase.sample
templates/hooks/pre-receive.sample
similarity index 100%rename from templates/hooks--pre-receive.samplerename to templates/hooks/pre-receive.sample
templates/hooks/prepare-commit-msg.sample
similarity index 100%rename from templates/hooks--prepare-commit-msg.samplerename to templates/hooks/prepare-commit-msg.sample
templates/hooks/push-to-checkout.sample
similarity index 100%rename from templates/hooks--push-to-checkout.samplerename to templates/hooks/push-to-checkout.sample
templates/hooks/sendemail-validate.sample
similarity index 100%rename from templates/hooks--sendemail-validate.samplerename to templates/hooks/sendemail-validate.sample
templates/hooks/update.sample
similarity index 100%rename from templates/hooks--update.samplerename to templates/hooks/update.sample
templates/info/exclude
similarity index 100%rename from templates/info--excluderename to templates/info/exclude