{"thread":{"id":"46474","subject":"[PATCH] submodule: correct error message for missing commits.","startedAt":"2017-07-26T20:08:42Z","lastAt":"2017-07-26T21:10:27Z","messageCount":4,"participants":["Stefan Beller","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"325146","messageId":"20170726200832.28522-1-sbeller@google.com","threadId":"46474","inReplyTo":null,"subject":"[PATCH] submodule: correct error message for missing commits.","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2017-07-26T20:08:32Z","receivedAt":"2017-07-26T20:08:42Z","isPatch":true,"sender":{"key":"stefanbeller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/455868?v=4"},"body":"When a submodule diff should be displayed we currently just add the\nsubmodule objects to the main object store and then e.g. walk the\nrevision graph and create a summary for that submodule.\n\nIt is possible that we are missing the submodule either completely or\npartially, which we currently differentiate with different error messages\ndepending on whether (1) the whole submodule object store is missing or\n(2) just the needed for this particular diff. (1) is reported as\n\"not initialized\", and (2) is reported as \"commits not present\".\n\nIf a submodule is deinit'ed its repository data is still around inside\nthe superproject, such that the diff can still be produced. In that way\nthe error message (1) is misleading as we can have a diff despite the\nsubmodule being not initialized.\n\nDowngrade the error message (1) to be the same as (2) and just say\nthe commits are not present, as that is the true reason why the diff\ncannot be shown.\n\nSigned-off-by: Stefan Beller <sbeller@google.com>\n---\n\nI came across this error message in the series for the\nobject store modularisation[1], when I was trying to replace\n'add_submodule_odb' by a custom loaded object store from a\nsubmodule repo object, which got me thinking on the error\nmessage and the true cause for it.  \n\nWhile this could go in separately, I may carry it in that\nseries, as there we'd come up with more error messages\n(\"could not create submodule object store\" as well as the\n\"commits not present\", maybe even \"submodule not lookup failed\")\n\nThanks,\nStefan\n\n[1] https://public-inbox.org/git/20170706202739.6056-1-sbeller@google.com/\n  \n\n submodule.c                               | 2 +-\n t/t4059-diff-submodule-not-initialized.sh | 2 +-\n 2 files changed, 2 insertions(+), 2 deletions(-)\n\ndiff --git a/submodule.c b/submodule.c\nindex 6531c5d609..280c246477 100644\n--- a/submodule.c\n+++ b/submodule.c\n@@ -567,7 +567,7 @@ static void show_submodule_header(FILE *f, const char *path,\n \n \tif (add_submodule_odb(path)) {\n \t\tif (!message)\n-\t\t\tmessage = \"(not initialized)\";\n+\t\t\tmessage = \"(commits not present)\";\n \t\tgoto output_header;\n \t}\n \ndiff --git a/t/t4059-diff-submodule-not-initialized.sh b/t/t4059-diff-submodule-not-initialized.sh\nindex cd70fd5192..49bca7b48d 100755\n--- a/t/t4059-diff-submodule-not-initialized.sh\n+++ b/t/t4059-diff-submodule-not-initialized.sh\n@@ -95,7 +95,7 @@ test_expect_success 'submodule not initialized in new clone' '\n \tgit clone . sm3 &&\n \tgit -C sm3 diff-tree -p --no-commit-id --submodule=log HEAD >actual &&\n \tcat >expected <<-EOF &&\n-\tSubmodule sm1 $smhead1...$smhead2 (not initialized)\n+\tSubmodule sm1 $smhead1...$smhead2 (commits not present)\n \tEOF\n \ttest_cmp expected actual\n '\n-- \n2.14.0.rc0.3.g6c2e499285\n\n"},{"id":"325148","messageId":"xmqqh8xzq6td.fsf@gitster.mtv.corp.google.com","threadId":"46474","inReplyTo":"20170726200832.28522-1-sbeller@google.com","subject":"Re: [PATCH] submodule: correct error message for missing commits.","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2017-07-26T20:30:54Z","receivedAt":"2017-07-26T20:31:09Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Stefan Beller <sbeller@google.com> writes:\n\n> When a submodule diff should be displayed we currently just add the\n> submodule objects to the main object store and then e.g. walk the\n> revision graph and create a summary for that submodule.\n>\n> It is possible that we are missing the submodule either completely or\n> partially, which we currently differentiate with different error messages\n> depending on whether (1) the whole submodule object store is missing or\n> (2) just the needed for this particular diff. (1) is reported as\n> \"not initialized\", and (2) is reported as \"commits not present\".\n>\n> If a submodule is deinit'ed its repository data is still around inside\n> the superproject, such that the diff can still be produced. In that way\n> the error message (1) is misleading as we can have a diff despite the\n> submodule being not initialized.\n\nThis is confusing...  \n\nSo are you saying that if we do \"submodule init A && submodule\nupdate A\" followed by \"submodule deinit A\", we _could_ show the\ndifference for submodule A between two commits in the superproject,\nbecause we already have the necessary data for the submodule, but we\n_choose_ not to show it because the user told us explicitly that the\nsubmodule is not interesting?\n\nThat sounds like a very sensible and user-centric behaviour to me,\nand \"not initialized\" sounds like the right message to give in such\na case (as opposed to \"commits not present\"---even the user told us\nthey are not interesting, we may have them, so \"not present\" is not\njust incorrect but irrelevant because that is not the reason why we\nare not showing).\n\nOr are you saying that even the user told us that the submodule is\nnot interesting, if we had \"init\" it earlier even once, we show the\ndifference and with a wrong label?  Showing the difference sounds\nlike a bug that is more severe than using a wrong label to me.\n\nPuzzled.\n\n>\n> Downgrade the error message (1) to be the same as (2) and just say\n> the commits are not present, as that is the true reason why the diff\n> cannot be shown.\n>\n> Signed-off-by: Stefan Beller <sbeller@google.com>\n> ---\n>\n> I came across this error message in the series for the\n> object store modularisation[1], when I was trying to replace\n> 'add_submodule_odb' by a custom loaded object store from a\n> submodule repo object, which got me thinking on the error\n> message and the true cause for it.  \n>\n> While this could go in separately, I may carry it in that\n> series, as there we'd come up with more error messages\n> (\"could not create submodule object store\" as well as the\n> \"commits not present\", maybe even \"submodule not lookup failed\")\n>\n> Thanks,\n> Stefan\n>\n> [1] https://public-inbox.org/git/20170706202739.6056-1-sbeller@google.com/\n>   \n>\n>  submodule.c                               | 2 +-\n>  t/t4059-diff-submodule-not-initialized.sh | 2 +-\n>  2 files changed, 2 insertions(+), 2 deletions(-)\n>\n> diff --git a/submodule.c b/submodule.c\n> index 6531c5d609..280c246477 100644\n> --- a/submodule.c\n> +++ b/submodule.c\n> @@ -567,7 +567,7 @@ static void show_submodule_header(FILE *f, const char *path,\n>  \n>  \tif (add_submodule_odb(path)) {\n>  \t\tif (!message)\n> -\t\t\tmessage = \"(not initialized)\";\n> +\t\t\tmessage = \"(commits not present)\";\n>  \t\tgoto output_header;\n>  \t}\n>  \n> diff --git a/t/t4059-diff-submodule-not-initialized.sh b/t/t4059-diff-submodule-not-initialized.sh\n> index cd70fd5192..49bca7b48d 100755\n> --- a/t/t4059-diff-submodule-not-initialized.sh\n> +++ b/t/t4059-diff-submodule-not-initialized.sh\n> @@ -95,7 +95,7 @@ test_expect_success 'submodule not initialized in new clone' '\n>  \tgit clone . sm3 &&\n>  \tgit -C sm3 diff-tree -p --no-commit-id --submodule=log HEAD >actual &&\n>  \tcat >expected <<-EOF &&\n> -\tSubmodule sm1 $smhead1...$smhead2 (not initialized)\n> +\tSubmodule sm1 $smhead1...$smhead2 (commits not present)\n>  \tEOF\n>  \ttest_cmp expected actual\n>  '\n"},{"id":"325151","messageId":"CAGZ79kaYQ5Lzz5i_+uLt3wWtid+YvDxXSyw=isaYj3+98X7Mbg@mail.gmail.com","threadId":"46474","inReplyTo":"xmqqh8xzq6td.fsf@gitster.mtv.corp.google.com","subject":"Re: [PATCH] submodule: correct error message for missing commits.","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2017-07-26T20:56:17Z","receivedAt":"2017-07-26T20:56:27Z","isPatch":true,"sender":{"key":"stefanbeller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/455868?v=4"},"body":"On Wed, Jul 26, 2017 at 1:30 PM, Junio C Hamano <gitster@pobox.com> wrote:\n> Stefan Beller <sbeller@google.com> writes:\n>\n>> When a submodule diff should be displayed we currently just add the\n>> submodule objects to the main object store and then e.g. walk the\n>> revision graph and create a summary for that submodule.\n>>\n>> It is possible that we are missing the submodule either completely or\n>> partially, which we currently differentiate with different error messages\n>> depending on whether (1) the whole submodule object store is missing or\n>> (2) just the needed for this particular diff. (1) is reported as\n>> \"not initialized\", and (2) is reported as \"commits not present\".\n>>\n>> If a submodule is deinit'ed its repository data is still around inside\n>> the superproject, such that the diff can still be produced. In that way\n>> the error message (1) is misleading as we can have a diff despite the\n>> submodule being not initialized.\n>\n> This is confusing...\n>\n> So are you saying that if we do \"submodule init A && submodule\n> update A\" followed by \"submodule deinit A\",\n\n  $ git clone https://gerrit.googlesource.com/gerrit\n  $ git show --submodule=log bb798b00bb\n  ...\n  Submodule plugins/replication ... (not initialized)\n\n  $ git submodule update --init\n  $ # a good example of cross repo changes:\n  $ git show --submodule=log bb798b00bb\n  ...\n  Submodule plugins/replication db4aecb2b8...98b7156cee:\n  > Stop using WorkQueue#unregisterWorkQueue.\n  < PushOne: Remove redundant string concatenation\n\n  $ git submodule deinit -f --all\n  $ git show --submodule=log bb798b00bb\n  ...\n  Submodule plugins/replication db4aecb2b8...98b7156cee:\n  > Stop using WorkQueue#unregisterWorkQueue.\n  < PushOne: Remove redundant string concatenation\n\n  $ rm -rf .git/modules/*\n  $ git show --submodule=log bb798b00bb\n  ...\n  Submodule plugins/replication ... (not initialized)\n\n> we _could_ show the\n> difference for submodule A between two commits in the superproject,\n> because we already have the necessary data for the submodule, but we\n> _choose_ not to show it because the user told us explicitly that the\n> submodule is not interesting?\n\nWe _do_ show the submodule as demonstrated by the code sample above\nif we possess the objects.\n\nHence the \"not initialized\" is not quite technically correct. (After deinit it\nis not initialized, but we show nevertheless, so the user perceived\n_reason_ why we do not show the submodule is \"commits not present\".\n\n> That sounds like a very sensible and user-centric behaviour to me,\n> and \"not initialized\" sounds like the right message to give in such\n> a case (as opposed to \"commits not present\"---even the user told us\n> they are not interesting, we may have them, so \"not present\" is not\n> just incorrect but irrelevant because that is not the reason why we\n> are not showing).\n\nSo you are saying we should instead do:\n\n  if (not active)\n    message = \"not initialized\"\n  if (problems with object loading)\n    message = \"commits not present\"\n  ...\n\n> Or are you saying that even the user told us that the submodule is\n> not interesting, if we had \"init\" it earlier even once, we show the\n> difference and with a wrong label?  Showing the difference sounds\n> like a bug that is more severe than using a wrong label to me.\n\nI looked through the man pages and they never specify if submodule\nactiveness affects the superproject diff, so we'd want to change that\nso that only active submodules are diffed.\n"},{"id":"325154","messageId":"xmqqshhiq4zm.fsf@gitster.mtv.corp.google.com","threadId":"46474","inReplyTo":"CAGZ79kaYQ5Lzz5i_+uLt3wWtid+YvDxXSyw=isaYj3+98X7Mbg@mail.gmail.com","subject":"Re: [PATCH] submodule: correct error message for missing commits.","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2017-07-26T21:10:21Z","receivedAt":"2017-07-26T21:10:27Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Stefan Beller <sbeller@google.com> writes:\n\n> We _do_ show the submodule as demonstrated by the code sample above\n> if we possess the objects.\n> ...\n>> That sounds like a very sensible and user-centric behaviour to me,\n>> and \"not initialized\" sounds like the right message to give in such\n>> a case (as opposed to \"commits not present\"---even the user told us\n>> they are not interesting, we may have them, so \"not present\" is not\n>> just incorrect but irrelevant because that is not the reason why we\n>> are not showing).\n>\n> So you are saying we should instead do:\n>\n>   if (not active)\n>     message = \"not initialized\"\n>   if (problems with object loading)\n>     message = \"commits not present\"\n>   ...\n\nI think I am.\n\n>> Or are you saying that even the user told us that the submodule is\n>> not interesting, if we had \"init\" it earlier even once, we show the\n>> difference and with a wrong label?  Showing the difference sounds\n>> like a bug that is more severe than using a wrong label to me.\n>\n> I looked through the man pages and they never specify if submodule\n> activeness affects the superproject diff, so we'd want to change that\n> so that only active submodules are diffed.\n\nI would think that would match my expectation more closely; if I\nexplicitly told Git to \"deinit\", and still see the diff to distrat\nme (i.e. the current behaviour), I would probably feel that it is a\nbug.  I do not know about others who are used to the current\nbeehaviour, though.  Do people actively \"deinit\" a submodule that\nthey once \"init\"ed, and if so for what purpose?  It's not like they\nwant to release the disk resource, so I'd imagine the only reason is\nto reduce the distracting noise, but I'd prefer to hear from real\nusers rather than speculating.\n\nThanks.\n"}]}