{"thread":{"id":"3024","subject":"[PATCH] GIT-VERSION-GEN: allow overriding from Makefile","startedAt":"2006-01-09T23:01:04Z","lastAt":"2006-01-10T02:07:01Z","messageCount":2,"participants":["Junio C Hamano","H. Peter Anvin"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"14370","messageId":"7vpsn1f1lb.fsf@assigned-by-dhcp.cox.net","threadId":"3024","inReplyTo":null,"subject":"[PATCH] GIT-VERSION-GEN: allow overriding from Makefile","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2006-01-09T23:01:04Z","receivedAt":"2006-01-09T23:01:04Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"The RPM building procedure relied on being able to build from a\nfreshly untarred tarball, so there is no way \"git describe\"\ncould figure out from which commit it is building (there was no\nHEAD).\n\nThis still does not allow you to build RPM binary package from\nan untagged interim version because RPM does not like '-' in\nversion number, but that probably is a blessing.\n\nSigned-off-by: Junio C Hamano <junkio@cox.net>\n\n---\n\n * For 1.1.1; the binary in 1.1.0 RPM was affected with this bug.\n\n GIT-VERSION-GEN |   13 +++++++++----\n Makefile        |    2 +-\n 2 files changed, 10 insertions(+), 5 deletions(-)\n\n1900d64cbecf46844dd7910d78676e0cace7139e\ndiff --git a/GIT-VERSION-GEN b/GIT-VERSION-GEN\nindex 845b9dc..c878819 100755\n--- a/GIT-VERSION-GEN\n+++ b/GIT-VERSION-GEN\n@@ -2,8 +2,15 @@\n \n GVF=GIT-VERSION-FILE\n \n-VN=$(git-describe --abbrev=4 HEAD 2>/dev/null) || VN=v1.0.GIT\n-VN=$(expr \"$VN\" : v'\\(.*\\)')\n+case \"${VN+set}\" in\n+set)\n+\t;;\n+*)\n+\tVN=$(git-describe --abbrev=4 HEAD 2>/dev/null) || VN=v1.0.GIT\n+\tVN=$(expr \"$VN\" : v'\\(.*\\)')\n+\t;;\n+esac\n+\n if test -r $GVF\n then\n \tVC=$(sed -e 's/^GIT_VERSION = //' <$GVF)\n@@ -14,5 +21,3 @@ test \"$VN\" = \"$VC\" || {\n \techo >&2 \"GIT_VERSION = $VN\"\n \techo \"GIT_VERSION = $VN\" >$GVF\n }\n-\n-\ndiff --git a/Makefile b/Makefile\nindex c9c15b5..0bbb5b8 100644\n--- a/Makefile\n+++ b/Makefile\n@@ -494,7 +494,7 @@ dist: git.spec git-tar-tree\n \tgzip -f -9 $(GIT_TARNAME).tar\n \n rpm: dist\n-\t$(RPMBUILD) -ta $(GIT_TARNAME).tar.gz\n+\tVN=$(GIT_VERSION) $(RPMBUILD) -ta $(GIT_TARNAME).tar.gz\n \n ### Cleaning rules\n \n-- \n1.1.0\n"},{"id":"14383","messageId":"43C316C5.9060007@zytor.com","threadId":"3024","inReplyTo":"7vpsn1f1lb.fsf@assigned-by-dhcp.cox.net","subject":"[PATCH] For release tarballs, include the proper version","fromName":"H. Peter Anvin","fromEmail":"hpa@zytor.com","sentAt":"2006-01-10T02:07:01Z","receivedAt":"2006-01-10T02:07:01Z","isPatch":true,"sender":{"key":"hpa@zytor.com","avatar":null},"body":"When producing a release tarball, include a \"version\" file, which \nGIT-VERSION-GEN can then use to do the right thing when building from a \ntarball.\n\nSigned-off-by: H. Peter Anvin <hpa@zytor.com>\n\n\ndiff --git a/GIT-VERSION-GEN b/GIT-VERSION-GEN\nindex 845b9dc..7763639 100755\n--- a/GIT-VERSION-GEN\n+++ b/GIT-VERSION-GEN\n@@ -1,9 +1,15 @@\n #!/bin/sh\n \n GVF=GIT-VERSION-FILE\n+DEF_VER=v1.1.GIT\n \n-VN=$(git-describe --abbrev=4 HEAD 2>/dev/null) || VN=v1.0.GIT\n-VN=$(expr \"$VN\" : v'\\(.*\\)')\n+# First try git-describe, then see if there is a version file\n+# (included in release tarballs), then default\n+VN=$(git-describe --abbrev=4 HEAD 2>/dev/null) ||\n+VN=$(cat version) ||\n+VN=\"$DEF_VER\"\n+\n+VN=$(expr \"$VN\" : v*'\\(.*\\)')\n if test -r $GVF\n then\n \tVC=$(sed -e 's/^GIT_VERSION = //' <$GVF)\ndiff --git a/Makefile b/Makefile\nindex c9c15b5..fa0cd83 100644\n--- a/Makefile\n+++ b/Makefile\n@@ -489,7 +489,9 @@ dist: git.spec git-tar-tree\n \t./git-tar-tree HEAD $(GIT_TARNAME) > $(GIT_TARNAME).tar\n \t@mkdir -p $(GIT_TARNAME)\n \t@cp git.spec $(GIT_TARNAME)\n-\t$(TAR) rf $(GIT_TARNAME).tar $(GIT_TARNAME)/git.spec\n+\t@echo $(GIT_VERSION) > $(GIT_TARNAME)/version\n+\t$(TAR) rf $(GIT_TARNAME).tar \\\n+\t\t$(GIT_TARNAME)/git.spec $(GIT_TARNAME)/version\n \t@rm -rf $(GIT_TARNAME)\n \tgzip -f -9 $(GIT_TARNAME).tar\n \n"}]}