Makefile: don't use a versioned temp distribution directory

The 'dist' target uses a versioned temp directory, $(GIT_TARNAME), into which it copies various files added to the distribution tarball. Should it be necessary to remove this directory in the 'clean' target, since the name depends on $(GIT_VERSION), the current HEAD must be positioned on the same commit as when 'make dist' was issued. Otherwise, the target will fail to remove that directory. Create an '.dist-tmp-dir' directory and copy the various files into this now un-versioned directory while creating the distribution tarball. Change the 'clean' target to remove the '.dist-tmp-dir' directory, instead of the version dependent $(GIT_TARNAME) directory. Signed-off-by: Ramsay Jones <ramsay@ramsayjones.plus.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Ramsay Jones committed Dec 8, 2020 at 22:36 UTC c5312033dd81771def2268d57f64e5551d9e11bf
1 file changed +8 -7
Makefile
+8 -7
@@ -3061,9 +3061,9 @@ GIT_TARNAME = git-$(GIT_VERSION)
3061 GIT_ARCHIVE_EXTRA_FILES = \
3062 --prefix=$(GIT_TARNAME)/ \
3063 --add-file=configure \
3064 - --add-file=$(GIT_TARNAME)/version \
3064 + --add-file=.dist-tmp-dir/version \
3065 --prefix=$(GIT_TARNAME)/git-gui/ \
3066 - --add-file=$(GIT_TARNAME)/git-gui/version
3066 + --add-file=.dist-tmp-dir/git-gui/version
3067 ifdef DC_SHA1_SUBMODULE
3068 GIT_ARCHIVE_EXTRA_FILES += \
3069 --prefix=$(GIT_TARNAME)/sha1collisiondetection/ \
@@ -3075,13 +3075,14 @@ GIT_ARCHIVE_EXTRA_FILES += \
3075 --add-file=sha1collisiondetection/lib/ubc_check.h
3076 endif
3077 dist: git-archive$(X) configure
3078 - @mkdir -p $(GIT_TARNAME)
3079 - @echo $(GIT_VERSION) > $(GIT_TARNAME)/version
3080 - @$(MAKE) -C git-gui TARDIR=../$(GIT_TARNAME)/git-gui dist-version
3078 + @$(RM) -r .dist-tmp-dir
3079 + @mkdir .dist-tmp-dir
3080 + @echo $(GIT_VERSION) > .dist-tmp-dir/version
3081 + @$(MAKE) -C git-gui TARDIR=../.dist-tmp-dir/git-gui dist-version
3082 ./git-archive --format=tar \
3083 $(GIT_ARCHIVE_EXTRA_FILES) \
3084 --prefix=$(GIT_TARNAME)/ HEAD^{tree} > $(GIT_TARNAME).tar
3084 - @$(RM) -r $(GIT_TARNAME)
3085 + @$(RM) -r .dist-tmp-dir
3086 gzip -f -9 $(GIT_TARNAME).tar
3087
3088 rpm::
@@ -3158,7 +3159,7 @@ clean: profile-clean coverage-clean cocciclean
3159 $(RM) -r bin-wrappers $(dep_dirs) $(compdb_dir) compile_commands.json
3160 $(RM) -r po/build/
3161 $(RM) *.pyc *.pyo */*.pyc */*.pyo $(GENERATED_H) $(ETAGS_TARGET) tags cscope*
3161 - $(RM) -r $(GIT_TARNAME) .doc-tmp-dir
3162 + $(RM) -r .dist-tmp-dir .doc-tmp-dir
3163 $(RM) $(GIT_TARNAME).tar.gz
3164 $(RM) $(htmldocs).tar.gz $(manpages).tar.gz
3165 $(MAKE) -C Documentation/ clean