{"thread":{"id":"50390","subject":"[PATCH v3] git-submodule.sh: shorten submodule SHA-1s using rev-parse","startedAt":"2019-02-03T21:01:14Z","lastAt":"2019-02-04T19:01:18Z","messageCount":4,"participants":["Sven van Haastregt","Eric Sunshine","Junio C Hamano"],"isPatch":true,"patchVersion":3,"patchTotal":null},"messages":[{"id":"368440","messageId":"20190203210027.13272-1-svenvh@gmail.com","threadId":"50390","inReplyTo":null,"subject":"[PATCH v3] git-submodule.sh: shorten submodule SHA-1s using rev-parse","fromName":"Sven van Haastregt","fromEmail":"svenvh@gmail.com","sentAt":"2019-02-03T21:00:27Z","receivedAt":"2019-02-03T21:01:14Z","isPatch":true,"sender":{"key":"svenvh@gmail.com","avatar":"https://avatars.githubusercontent.com/u/1358906?v=4"},"body":"Until now, `git submodule summary` was always emitting 7-character\nSHA-1s that have a higher chance of being ambiguous for larger\nrepositories.  Use `git rev-parse --short` instead, which will\ndetermine suitable short SHA-1 lengths.\n\nWe cannot always rely on successfully invoking `git rev-parse` in the\nsubmodule directory.  Keep the old method using `cut` as a fallback.\n\nSigned-off-by: Sven van Haastregt <svenvh@gmail.com>\n---\n\nDifferences since v2: Simplify code as suggested by Eric\nSunshine <sunshine@sunshineco.com> and suppress stderr.\n\n git-submodule.sh | 7 +++++--\n 1 file changed, 5 insertions(+), 2 deletions(-)\n\ndiff --git a/git-submodule.sh b/git-submodule.sh\nindex 5e608f8bad..e26146e721 100755\n--- a/git-submodule.sh\n+++ b/git-submodule.sh\n@@ -850,8 +850,11 @@ cmd_summary() {\n \t\t\t;;\n \t\tesac\n \n-\t\tsha1_abbr_src=$(echo $sha1_src | cut -c1-7)\n-\t\tsha1_abbr_dst=$(echo $sha1_dst | cut -c1-7)\n+\t\tsha1_abbr_src=$(GIT_DIR=\"$name/.git\" git rev-parse --short $sha1_src 2>/dev/null ||\n+\t\t\techo $sha1_src | cut -c1-7)\n+\t\tsha1_abbr_dst=$(GIT_DIR=\"$name/.git\" git rev-parse --short $sha1_dst 2>/dev/null ||\n+\t\t\techo $sha1_dst | cut -c1-7)\n+\n \t\tif test $status = T\n \t\tthen\n \t\t\tblob=\"$(gettext \"blob\")\"\n-- \n2.20.1.dirty\n\n"},{"id":"368441","messageId":"CAPig+cQXuzMwZjHa3n+DwRFL3E76U8uAvhiFiC5S=B23f03Vnw@mail.gmail.com","threadId":"50390","inReplyTo":"20190203210027.13272-1-svenvh@gmail.com","subject":"Re: [PATCH v3] git-submodule.sh: shorten submodule SHA-1s using rev-parse","fromName":"Eric Sunshine","fromEmail":"sunshine@sunshineco.com","sentAt":"2019-02-03T21:28:13Z","receivedAt":"2019-02-03T21:28:26Z","isPatch":true,"sender":{"key":"sunshine@sunshineco.com","avatar":"https://avatars.githubusercontent.com/u/163641?v=4"},"body":"On Sun, Feb 3, 2019 at 4:01 PM Sven van Haastregt <svenvh@gmail.com> wrote:\n> Until now, `git submodule summary` was always emitting 7-character\n> SHA-1s that have a higher chance of being ambiguous for larger\n> repositories.  Use `git rev-parse --short` instead, which will\n> determine suitable short SHA-1 lengths.\n>\n> We cannot always rely on successfully invoking `git rev-parse` in the\n> submodule directory.  Keep the old method using `cut` as a fallback.\n\nReviewers and future readers of this patch are left in the dark\nregarding the circumstances in which git-rev-parse may fail in the\nsubmodule directory. It would be helpful for the commit message to\nexplain this potential failure in enough detail for someone working in\nthis area in the future to understand any implications of changes to\nthis code.\n\n> Signed-off-by: Sven van Haastregt <svenvh@gmail.com>\n> ---\n> Differences since v2: Simplify code as suggested by Eric\n> Sunshine <sunshine@sunshineco.com> and suppress stderr.\n\nThis version looks better. Thanks.\n"},{"id":"368469","messageId":"xmqqftt3v1ah.fsf@gitster-ct.c.googlers.com","threadId":"50390","inReplyTo":"CAPig+cQXuzMwZjHa3n+DwRFL3E76U8uAvhiFiC5S=B23f03Vnw@mail.gmail.com","subject":"Re: [PATCH v3] git-submodule.sh: shorten submodule SHA-1s using rev-parse","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2019-02-04T18:47:18Z","receivedAt":"2019-02-04T18:47:25Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Eric Sunshine <sunshine@sunshineco.com> writes:\n\n> On Sun, Feb 3, 2019 at 4:01 PM Sven van Haastregt <svenvh@gmail.com> wrote:\n>> Until now, `git submodule summary` was always emitting 7-character\n>> SHA-1s that have a higher chance of being ambiguous for larger\n>> repositories.  Use `git rev-parse --short` instead, which will\n>> determine suitable short SHA-1 lengths.\n>>\n>> We cannot always rely on successfully invoking `git rev-parse` in the\n>> submodule directory.  Keep the old method using `cut` as a fallback.\n>\n> Reviewers and future readers of this patch are left in the dark\n> regarding the circumstances in which git-rev-parse may fail in the\n> submodule directory. It would be helpful for the commit message to\n> explain this potential failure in enough detail for someone working in\n> this area in the future to understand any implications of changes to\n> this code.\n\nReplace that problematic sentence with something like\n\n\tAs a submodule may not be initialized with \"submodule init\"\n\tor not cloned, `git rev-parse` may not work in it yet; as a\n\tfallback, use the original method of cutting at 7 hexdigits.\n\nperhaps?\n\n\n>\n>> Signed-off-by: Sven van Haastregt <svenvh@gmail.com>\n>> ---\n>> Differences since v2: Simplify code as suggested by Eric\n>> Sunshine <sunshine@sunshineco.com> and suppress stderr.\n>\n> This version looks better. Thanks.\n"},{"id":"368473","messageId":"CAPig+cQezC8_T=pms=XY71+9pP2WgdvdyiF9+UwarFB8sXo+Tw@mail.gmail.com","threadId":"50390","inReplyTo":"xmqqftt3v1ah.fsf@gitster-ct.c.googlers.com","subject":"Re: [PATCH v3] git-submodule.sh: shorten submodule SHA-1s using rev-parse","fromName":"Eric Sunshine","fromEmail":"sunshine@sunshineco.com","sentAt":"2019-02-04T19:01:04Z","receivedAt":"2019-02-04T19:01:18Z","isPatch":true,"sender":{"key":"sunshine@sunshineco.com","avatar":"https://avatars.githubusercontent.com/u/163641?v=4"},"body":"On Mon, Feb 4, 2019 at 1:47 PM Junio C Hamano <gitster@pobox.com> wrote:\n> Eric Sunshine <sunshine@sunshineco.com> writes:\n> > On Sun, Feb 3, 2019 at 4:01 PM Sven van Haastregt <svenvh@gmail.com> wrote:\n> >> We cannot always rely on successfully invoking `git rev-parse` in the\n> >> submodule directory.  Keep the old method using `cut` as a fallback.\n> >\n> > Reviewers and future readers of this patch are left in the dark\n> > regarding the circumstances in which git-rev-parse may fail in the\n> > submodule directory. It would be helpful for the commit message to\n> > explain this potential failure in enough detail for someone working in\n> > this area in the future to understand any implications of changes to\n> > this code.\n>\n> Replace that problematic sentence with something like\n>\n>         As a submodule may not be initialized with \"submodule init\"\n>         or not cloned, `git rev-parse` may not work in it yet; as a\n>         fallback, use the original method of cutting at 7 hexdigits.\n>\n> perhaps?\n\nThat's better.\n"}]}