{"thread":{"id":"8752","subject":"[PATCH] git-submodule: Try harder to describe the status of a submodule","startedAt":"2007-06-27T19:13:21Z","lastAt":"2007-07-02T15:44:09Z","messageCount":4,"participants":["Emil Medve","Junio C Hamano","Medve Emilian-EMMEDVE1"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"45934","messageId":"118297160163-git-send-email-Emilian.Medve@Freescale.com","threadId":"8752","inReplyTo":null,"subject":"[PATCH] git-submodule: Try harder to describe the status of a submodule","fromName":"Emil Medve","fromEmail":"emilian.medve@freescale.com","sentAt":"2007-06-27T19:13:21Z","receivedAt":"2007-06-27T19:13:21Z","isPatch":true,"sender":{"key":"emilian.medve@freescale.com","avatar":null},"body":"Some repositories might not use/have annotated tags (for example repositories created with\ngit-cvsimport) or might not have tags at all and could cause git-submodule status to fail because\ngit-describe might fail.\n\nThis change makes git-submodule status try harder in displaying the status of a module by\nconsidering lightweight tags, subsequent tags and branches.\n\nSigned-off-by: Emil Medve <Emilian.Medve@Freescale.com>\n---\n git-submodule.sh |   23 +++++++++++++++++++++--\n 1 files changed, 21 insertions(+), 2 deletions(-)\n\ndiff --git a/git-submodule.sh b/git-submodule.sh\nindex 89a3885..7429ce3 100755\n--- a/git-submodule.sh\n+++ b/git-submodule.sh\n@@ -134,6 +134,25 @@ modules_update()\n }\n \n #\n+# Identify and display the most specific name describing an object specified by a SHA1 key\n+#\n+# First try to locate a tag that predates the commit. If that fails try to locate a tag that comes\n+# after the commit. If that fails too (e.g. undefined), try to locate the branch of the commit. If\n+# that fails too just display \"undefined\"\n+#\n+get_revname()\n+{\n+\t_revname=$(git-describe --tags \"$1\" 2>/dev/null || git-describe --contains \"$1\" 2>/dev/null)\n+\tif test -z \"$_revname\" -o \"$_revname\" = \"undefined\"\n+\tthen\n+\t\t_revname=$(git-describe --all \"$1\" 2>/dev/null | cut -d / -f2-)\n+\t\ttest -z \"$_revname\" && _revname=undefined\n+\tfi\n+\techo $_revname\n+\tunset _revname\n+}\n+\n+#\n # List all submodules, prefixed with:\n #  - submodule not initialized\n #  + different revision checked out\n@@ -155,7 +174,7 @@ modules_list()\n \t\t\tsay \"-$sha1 $path\"\n \t\t\tcontinue;\n \t\tfi\n-\t\trevname=$(unset GIT_DIR && cd \"$path\" && git-describe $sha1)\n+\t\trevname=$(unset GIT_DIR && cd \"$path\" && get_revname $sha1)\n \t\tif git diff-files --quiet -- \"$path\"\n \t\tthen\n \t\t\tsay \" $sha1 $path ($revname)\"\n@@ -163,7 +182,7 @@ modules_list()\n \t\t\tif test -z \"$cached\"\n \t\t\tthen\n \t\t\t\tsha1=$(unset GIT_DIR && cd \"$path\" && git-rev-parse --verify HEAD)\n-\t\t\t\trevname=$(unset GIT_DIR && cd \"$path\" && git-describe $sha1)\n+\t\t\t\trevname=$(unset GIT_DIR && cd \"$path\" && get_revname $sha1)\n \t\t\tfi\n \t\t\tsay \"+$sha1 $path ($revname)\"\n \t\tfi\n-- \n1.5.2.2.549.gaeb59\n"},{"id":"45950","messageId":"7v1wfwpuy2.fsf@assigned-by-dhcp.pobox.com","threadId":"8752","inReplyTo":"118297160163-git-send-email-Emilian.Medve@Freescale.com","subject":"Re: [PATCH] git-submodule: Try harder to describe the status of a submodule","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2007-06-28T04:24:53Z","receivedAt":"2007-06-28T04:24:53Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Emil Medve <Emilian.Medve@Freescale.com> writes:\n\n> Some repositories might not use/have annotated tags (for example repositories created with\n> git-cvsimport) or might not have tags at all and could cause git-submodule status to fail because\n> git-describe might fail.\n>\n> This change makes git-submodule status try harder in displaying the status of a module by\n> considering lightweight tags, subsequent tags and branches.\n\nWhy are we suddenly seeing these loooooooong lines...\n\n> +get_revname()\n> +{\n> +\t_revname=$(git-describe --tags \"$1\" 2>/dev/null || git-describe --contains \"$1\" 2>/dev/null)\n> +\tif test -z \"$_revname\" -o \"$_revname\" = \"undefined\"\n> +\tthen\n> +\t\t_revname=$(git-describe --all \"$1\" 2>/dev/null | cut -d / -f2-)\n> +\t\ttest -z \"$_revname\" && _revname=undefined\n> +\tfi\n\nI really do not think using --all is useful.  If you do not have\na tag and the rev cannot be described, what damage does it incur?\n\nWe still say \"$sha1 $path\" in the output anyway, and ($revname)\nis only \"it makes it nicer\" appendix.\n\n> @@ -155,7 +174,7 @@ modules_list()\n>  \t\t\tsay \"-$sha1 $path\"\n>  \t\t\tcontinue;\n>  \t\tfi\n> -\t\trevname=$(unset GIT_DIR && cd \"$path\" && git-describe $sha1)\n> +\t\trevname=$(unset GIT_DIR && cd \"$path\" && get_revname $sha1)\n>  \t\tif git diff-files --quiet -- \"$path\"\n>  \t\tthen\n>  \t\t\tsay \" $sha1 $path ($revname)\"\n\nIn that sense, I would prefer mine much better. If a rev is\nindescribable, your version would say:\n\n\t\" dddddddddddddddddddddddddddddddddddddddd subdir (undefined)\"\n\nwhile mine would have said:\n\n\t\" dddddddddddddddddddddddddddddddddddddddd subdir\"\n"},{"id":"45975","messageId":"598D5675D34BE349929AF5EDE9B03E27011CFFED@az33exm24.fsl.freescale.net","threadId":"8752","inReplyTo":"7v1wfwpuy2.fsf@assigned-by-dhcp.pobox.com","subject":"RE: [PATCH] git-submodule: Try harder to describe the status of a submodule","fromName":"Medve Emilian-EMMEDVE1","fromEmail":"emilian.medve@freescale.com","sentAt":"2007-06-28T13:01:29Z","receivedAt":"2007-06-28T13:01:29Z","isPatch":true,"sender":{"key":"emilian.medve@freescale.com","avatar":null},"body":"Hello Junio,\n\n\nAlright, let's go with your patch.\n\n\nCheers,\nEmil.\n\n\nThis e-mail, and any associated attachments have been classified as:\n--------------------------------------------------------------------\n[x] Public\n[ ] Freescale Semiconductor Internal Use Only\n[ ] Freescale Semiconductor Confidential Proprietary\n\n\n-----Original Message-----\nFrom: Junio C Hamano [mailto:gitster@pobox.com] \nSent: Wednesday, June 27, 2007 11:25 PM\nTo: Medve Emilian-EMMEDVE1\nCc: git@vger.kernel.org\nSubject: Re: [PATCH] git-submodule: Try harder to describe the status of\na submodule\n\nEmil Medve <Emilian.Medve@Freescale.com> writes:\n\n> Some repositories might not use/have annotated tags (for example\nrepositories created with\n> git-cvsimport) or might not have tags at all and could cause\ngit-submodule status to fail because\n> git-describe might fail.\n>\n> This change makes git-submodule status try harder in displaying the\nstatus of a module by\n> considering lightweight tags, subsequent tags and branches.\n\nWhy are we suddenly seeing these loooooooong lines...\n\n> +get_revname()\n> +{\n> +\t_revname=$(git-describe --tags \"$1\" 2>/dev/null || git-describe\n--contains \"$1\" 2>/dev/null)\n> +\tif test -z \"$_revname\" -o \"$_revname\" = \"undefined\"\n> +\tthen\n> +\t\t_revname=$(git-describe --all \"$1\" 2>/dev/null | cut -d\n/ -f2-)\n> +\t\ttest -z \"$_revname\" && _revname=undefined\n> +\tfi\n\nI really do not think using --all is useful.  If you do not have\na tag and the rev cannot be described, what damage does it incur?\n\nWe still say \"$sha1 $path\" in the output anyway, and ($revname)\nis only \"it makes it nicer\" appendix.\n\n> @@ -155,7 +174,7 @@ modules_list()\n>  \t\t\tsay \"-$sha1 $path\"\n>  \t\t\tcontinue;\n>  \t\tfi\n> -\t\trevname=$(unset GIT_DIR && cd \"$path\" && git-describe\n$sha1)\n> +\t\trevname=$(unset GIT_DIR && cd \"$path\" && get_revname\n$sha1)\n>  \t\tif git diff-files --quiet -- \"$path\"\n>  \t\tthen\n>  \t\t\tsay \" $sha1 $path ($revname)\"\n\nIn that sense, I would prefer mine much better. If a rev is\nindescribable, your version would say:\n\n\t\" dddddddddddddddddddddddddddddddddddddddd subdir (undefined)\"\n\nwhile mine would have said:\n\n\t\" dddddddddddddddddddddddddddddddddddddddd subdir\"\n"},{"id":"46248","messageId":"598D5675D34BE349929AF5EDE9B03E27011D03ED@az33exm24.fsl.freescale.net","threadId":"8752","inReplyTo":"598D5675D34BE349929AF5EDE9B03E27011CFFED@az33exm24.fsl.freescale.net","subject":"RE: [PATCH] git-submodule: Try harder to describe the status of a submodule","fromName":"Medve Emilian-EMMEDVE1","fromEmail":"emilian.medve@freescale.com","sentAt":"2007-07-02T15:44:09Z","receivedAt":"2007-07-02T15:44:09Z","isPatch":true,"sender":{"key":"emilian.medve@freescale.com","avatar":null},"body":"Hello Junio,\n\n\nI noticed the 1.5.2.3 tag and the plans for 1.5.3-rc1 and I was\nwondering when do you think you'll apply your submodule patch? Is there\nany way I can help with it?\n\n\nThanks,\nEmil.\n\n\nThis e-mail, and any associated attachments have been classified as:\n--------------------------------------------------------------------\n[x] Public\n[ ] Freescale Semiconductor Internal Use Only\n[ ] Freescale Semiconductor Confidential Proprietary\n\n\n-----Original Message-----\nFrom: git-owner@vger.kernel.org [mailto:git-owner@vger.kernel.org] On\nBehalf Of Medve Emilian-EMMEDVE1\nSent: Thursday, June 28, 2007 8:01 AM\nTo: git@vger.kernel.org\nSubject: RE: [PATCH] git-submodule: Try harder to describe the status of\na submodule\n\nHello Junio,\n\n\nAlright, let's go with your patch.\n\n\nCheers,\nEmil.\n\n\nThis e-mail, and any associated attachments have been classified as:\n--------------------------------------------------------------------\n[x] Public\n[ ] Freescale Semiconductor Internal Use Only\n[ ] Freescale Semiconductor Confidential Proprietary\n\n\n-----Original Message-----\nFrom: Junio C Hamano [mailto:gitster@pobox.com] \nSent: Wednesday, June 27, 2007 11:25 PM\nTo: Medve Emilian-EMMEDVE1\nCc: git@vger.kernel.org\nSubject: Re: [PATCH] git-submodule: Try harder to describe the status of\na submodule\n\nEmil Medve <Emilian.Medve@Freescale.com> writes:\n\n> Some repositories might not use/have annotated tags (for example\nrepositories created with\n> git-cvsimport) or might not have tags at all and could cause\ngit-submodule status to fail because\n> git-describe might fail.\n>\n> This change makes git-submodule status try harder in displaying the\nstatus of a module by\n> considering lightweight tags, subsequent tags and branches.\n\nWhy are we suddenly seeing these loooooooong lines...\n\n> +get_revname()\n> +{\n> +\t_revname=$(git-describe --tags \"$1\" 2>/dev/null || git-describe\n--contains \"$1\" 2>/dev/null)\n> +\tif test -z \"$_revname\" -o \"$_revname\" = \"undefined\"\n> +\tthen\n> +\t\t_revname=$(git-describe --all \"$1\" 2>/dev/null | cut -d\n/ -f2-)\n> +\t\ttest -z \"$_revname\" && _revname=undefined\n> +\tfi\n\nI really do not think using --all is useful.  If you do not have\na tag and the rev cannot be described, what damage does it incur?\n\nWe still say \"$sha1 $path\" in the output anyway, and ($revname)\nis only \"it makes it nicer\" appendix.\n\n> @@ -155,7 +174,7 @@ modules_list()\n>  \t\t\tsay \"-$sha1 $path\"\n>  \t\t\tcontinue;\n>  \t\tfi\n> -\t\trevname=$(unset GIT_DIR && cd \"$path\" && git-describe\n$sha1)\n> +\t\trevname=$(unset GIT_DIR && cd \"$path\" && get_revname\n$sha1)\n>  \t\tif git diff-files --quiet -- \"$path\"\n>  \t\tthen\n>  \t\t\tsay \" $sha1 $path ($revname)\"\n\nIn that sense, I would prefer mine much better. If a rev is\nindescribable, your version would say:\n\n\t\" dddddddddddddddddddddddddddddddddddddddd subdir (undefined)\"\n\nwhile mine would have said:\n\n\t\" dddddddddddddddddddddddddddddddddddddddd subdir\"\n"}]}