{"thread":{"id":"56008","subject":"[PATCH] version-gen: cleanup","startedAt":"2021-06-25T21:29:42Z","lastAt":"2021-06-25T21:29:42Z","messageCount":1,"participants":["Felipe Contreras"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"428505","messageId":"20210625212933.71607-1-felipe.contreras@gmail.com","threadId":"56008","inReplyTo":null,"subject":"[PATCH] version-gen: cleanup","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2021-06-25T21:29:33Z","receivedAt":"2021-06-25T21:29:42Z","isPatch":true,"sender":{"key":"felipe.contreras@gmail.com","avatar":"https://avatars.githubusercontent.com/u/8358?v=4"},"body":"No functional changes.\n\nSigned-off-by: Felipe Contreras <felipe.contreras@gmail.com>\n---\n\nI sent this patch a long time ago and nobody saw any problem with it\nother than a minor nit of using an if instead of an early exit.\n\nhttps://lore.kernel.org/git/1381561628-20665-2-git-send-email-felipe.contreras@gmail.com/\n\n GIT-VERSION-GEN | 34 ++++++++++++++++++++--------------\n 1 file changed, 20 insertions(+), 14 deletions(-)\n\ndiff --git a/GIT-VERSION-GEN b/GIT-VERSION-GEN\nindex 9c125f298a..60e0f8c6d2 100755\n--- a/GIT-VERSION-GEN\n+++ b/GIT-VERSION-GEN\n@@ -6,22 +6,29 @@ DEF_VER=v2.32.0\n LF='\n '\n \n-# First see if there is a version file (included in release tarballs),\n-# then try git-describe, then default.\n-if test -f version\n-then\n-\tVN=$(cat version) || VN=\"$DEF_VER\"\n-elif test -d ${GIT_DIR:-.git} -o -f .git &&\n-\tVN=$(git describe --match \"v[0-9]*\" HEAD 2>/dev/null) &&\n+describe () {\n+\tVN=$(git describe --match \"v[0-9]*\" HEAD 2>/dev/null) || return 1\n \tcase \"$VN\" in\n-\t*$LF*) (exit 1) ;;\n+\t*$LF*)\n+\t\treturn 1\n+\t\t;;\n \tv[0-9]*)\n \t\tgit update-index -q --refresh\n \t\ttest -z \"$(git diff-index --name-only HEAD --)\" ||\n-\t\tVN=\"$VN-dirty\" ;;\n+\t\tVN=\"$VN-dirty\"\n+\t\treturn 0\n+\t\t;;\n \tesac\n+}\n+\n+# First see if there is a version file (included in release tarballs),\n+# then try 'git describe', then default.\n+if test -f version\n then\n-\tVN=$(echo \"$VN\" | sed -e 's/-/./g');\n+\tVN=$(cat version) || VN=\"$DEF_VER\"\n+elif test -d ${GIT_DIR:-.git} -o -f .git && describe\n+then\n+\tVN=$(echo \"$VN\" | sed -e 's/-/./g')\n else\n \tVN=\"$DEF_VER\"\n fi\n@@ -34,7 +41,6 @@ then\n else\n \tVC=unset\n fi\n-test \"$VN\" = \"$VC\" || {\n-\techo >&2 \"GIT_VERSION = $VN\"\n-\techo \"GIT_VERSION = $VN\" >$GVF\n-}\n+test \"$VN\" = \"$VC\" && exit\n+echo >&2 \"GIT_VERSION = $VN\"\n+echo \"GIT_VERSION = $VN\" >$GVF\n-- \n2.32.0\n\n"}]}