git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* [PATCH] submodule: correct error message for missing commits.
@ 2017-07-26 20:08 Stefan Beller
  2017-07-26 20:30 ` Junio C Hamano
  0 siblings, 1 reply; 7+ messages in thread
From: Stefan Beller @ 2017-07-26 20:08 UTC (permalink / raw)
  To: jacob.keller; +Cc: git, Stefan Beller

When a submodule diff should be displayed we currently just add the
submodule objects to the main object store and then e.g. walk the
revision graph and create a summary for that submodule.

It is possible that we are missing the submodule either completely or
partially, which we currently differentiate with different error messages
depending on whether (1) the whole submodule object store is missing or
(2) just the needed for this particular diff. (1) is reported as
"not initialized", and (2) is reported as "commits not present".

If a submodule is deinit'ed its repository data is still around inside
the superproject, such that the diff can still be produced. In that way
the error message (1) is misleading as we can have a diff despite the
submodule being not initialized.

Downgrade the error message (1) to be the same as (2) and just say
the commits are not present, as that is the true reason why the diff
cannot be shown.

Signed-off-by: Stefan Beller <sbeller@google.com>
---

I came across this error message in the series for the
object store modularisation[1], when I was trying to replace
'add_submodule_odb' by a custom loaded object store from a
submodule repo object, which got me thinking on the error
message and the true cause for it.  

While this could go in separately, I may carry it in that
series, as there we'd come up with more error messages
("could not create submodule object store" as well as the
"commits not present", maybe even "submodule not lookup failed")

Thanks,
Stefan

[1] https://public-inbox.org/git/20170706202739.6056-1-sbeller@google.com/
  

 submodule.c                               | 2 +-
 t/t4059-diff-submodule-not-initialized.sh | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/submodule.c b/submodule.c
index 6531c5d609..280c246477 100644
--- a/submodule.c
+++ b/submodule.c
@@ -567,7 +567,7 @@ static void show_submodule_header(FILE *f, const char *path,
 
 	if (add_submodule_odb(path)) {
 		if (!message)
-			message = "(not initialized)";
+			message = "(commits not present)";
 		goto output_header;
 	}
 
diff --git a/t/t4059-diff-submodule-not-initialized.sh b/t/t4059-diff-submodule-not-initialized.sh
index cd70fd5192..49bca7b48d 100755
--- a/t/t4059-diff-submodule-not-initialized.sh
+++ b/t/t4059-diff-submodule-not-initialized.sh
@@ -95,7 +95,7 @@ test_expect_success 'submodule not initialized in new clone' '
 	git clone . sm3 &&
 	git -C sm3 diff-tree -p --no-commit-id --submodule=log HEAD >actual &&
 	cat >expected <<-EOF &&
-	Submodule sm1 $smhead1...$smhead2 (not initialized)
+	Submodule sm1 $smhead1...$smhead2 (commits not present)
 	EOF
 	test_cmp expected actual
 '
-- 
2.14.0.rc0.3.g6c2e499285


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH] submodule: correct error message for missing commits.
  2017-07-26 20:08 Stefan Beller
@ 2017-07-26 20:30 ` Junio C Hamano
  2017-07-26 20:56   ` Stefan Beller
  0 siblings, 1 reply; 7+ messages in thread
From: Junio C Hamano @ 2017-07-26 20:30 UTC (permalink / raw)
  To: Stefan Beller; +Cc: jacob.keller, git

Stefan Beller <sbeller@google.com> writes:

> When a submodule diff should be displayed we currently just add the
> submodule objects to the main object store and then e.g. walk the
> revision graph and create a summary for that submodule.
>
> It is possible that we are missing the submodule either completely or
> partially, which we currently differentiate with different error messages
> depending on whether (1) the whole submodule object store is missing or
> (2) just the needed for this particular diff. (1) is reported as
> "not initialized", and (2) is reported as "commits not present".
>
> If a submodule is deinit'ed its repository data is still around inside
> the superproject, such that the diff can still be produced. In that way
> the error message (1) is misleading as we can have a diff despite the
> submodule being not initialized.

This is confusing...  

So are you saying that if we do "submodule init A && submodule
update A" followed by "submodule deinit A", we _could_ show the
difference for submodule A between two commits in the superproject,
because we already have the necessary data for the submodule, but we
_choose_ not to show it because the user told us explicitly that the
submodule is not interesting?

That sounds like a very sensible and user-centric behaviour to me,
and "not initialized" sounds like the right message to give in such
a case (as opposed to "commits not present"---even the user told us
they are not interesting, we may have them, so "not present" is not
just incorrect but irrelevant because that is not the reason why we
are not showing).

Or are you saying that even the user told us that the submodule is
not interesting, if we had "init" it earlier even once, we show the
difference and with a wrong label?  Showing the difference sounds
like a bug that is more severe than using a wrong label to me.

Puzzled.

>
> Downgrade the error message (1) to be the same as (2) and just say
> the commits are not present, as that is the true reason why the diff
> cannot be shown.
>
> Signed-off-by: Stefan Beller <sbeller@google.com>
> ---
>
> I came across this error message in the series for the
> object store modularisation[1], when I was trying to replace
> 'add_submodule_odb' by a custom loaded object store from a
> submodule repo object, which got me thinking on the error
> message and the true cause for it.  
>
> While this could go in separately, I may carry it in that
> series, as there we'd come up with more error messages
> ("could not create submodule object store" as well as the
> "commits not present", maybe even "submodule not lookup failed")
>
> Thanks,
> Stefan
>
> [1] https://public-inbox.org/git/20170706202739.6056-1-sbeller@google.com/
>   
>
>  submodule.c                               | 2 +-
>  t/t4059-diff-submodule-not-initialized.sh | 2 +-
>  2 files changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/submodule.c b/submodule.c
> index 6531c5d609..280c246477 100644
> --- a/submodule.c
> +++ b/submodule.c
> @@ -567,7 +567,7 @@ static void show_submodule_header(FILE *f, const char *path,
>  
>  	if (add_submodule_odb(path)) {
>  		if (!message)
> -			message = "(not initialized)";
> +			message = "(commits not present)";
>  		goto output_header;
>  	}
>  
> diff --git a/t/t4059-diff-submodule-not-initialized.sh b/t/t4059-diff-submodule-not-initialized.sh
> index cd70fd5192..49bca7b48d 100755
> --- a/t/t4059-diff-submodule-not-initialized.sh
> +++ b/t/t4059-diff-submodule-not-initialized.sh
> @@ -95,7 +95,7 @@ test_expect_success 'submodule not initialized in new clone' '
>  	git clone . sm3 &&
>  	git -C sm3 diff-tree -p --no-commit-id --submodule=log HEAD >actual &&
>  	cat >expected <<-EOF &&
> -	Submodule sm1 $smhead1...$smhead2 (not initialized)
> +	Submodule sm1 $smhead1...$smhead2 (commits not present)
>  	EOF
>  	test_cmp expected actual
>  '

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] submodule: correct error message for missing commits.
  2017-07-26 20:30 ` Junio C Hamano
@ 2017-07-26 20:56   ` Stefan Beller
  2017-07-26 21:10     ` Junio C Hamano
  0 siblings, 1 reply; 7+ messages in thread
From: Stefan Beller @ 2017-07-26 20:56 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Jacob Keller, git@vger.kernel.org

On Wed, Jul 26, 2017 at 1:30 PM, Junio C Hamano <gitster@pobox.com> wrote:
> Stefan Beller <sbeller@google.com> writes:
>
>> When a submodule diff should be displayed we currently just add the
>> submodule objects to the main object store and then e.g. walk the
>> revision graph and create a summary for that submodule.
>>
>> It is possible that we are missing the submodule either completely or
>> partially, which we currently differentiate with different error messages
>> depending on whether (1) the whole submodule object store is missing or
>> (2) just the needed for this particular diff. (1) is reported as
>> "not initialized", and (2) is reported as "commits not present".
>>
>> If a submodule is deinit'ed its repository data is still around inside
>> the superproject, such that the diff can still be produced. In that way
>> the error message (1) is misleading as we can have a diff despite the
>> submodule being not initialized.
>
> This is confusing...
>
> So are you saying that if we do "submodule init A && submodule
> update A" followed by "submodule deinit A",

  $ git clone https://gerrit.googlesource.com/gerrit
  $ git show --submodule=log bb798b00bb
  ...
  Submodule plugins/replication ... (not initialized)

  $ git submodule update --init
  $ # a good example of cross repo changes:
  $ git show --submodule=log bb798b00bb
  ...
  Submodule plugins/replication db4aecb2b8...98b7156cee:
  > Stop using WorkQueue#unregisterWorkQueue.
  < PushOne: Remove redundant string concatenation

  $ git submodule deinit -f --all
  $ git show --submodule=log bb798b00bb
  ...
  Submodule plugins/replication db4aecb2b8...98b7156cee:
  > Stop using WorkQueue#unregisterWorkQueue.
  < PushOne: Remove redundant string concatenation

  $ rm -rf .git/modules/*
  $ git show --submodule=log bb798b00bb
  ...
  Submodule plugins/replication ... (not initialized)

> we _could_ show the
> difference for submodule A between two commits in the superproject,
> because we already have the necessary data for the submodule, but we
> _choose_ not to show it because the user told us explicitly that the
> submodule is not interesting?

We _do_ show the submodule as demonstrated by the code sample above
if we possess the objects.

Hence the "not initialized" is not quite technically correct. (After deinit it
is not initialized, but we show nevertheless, so the user perceived
_reason_ why we do not show the submodule is "commits not present".

> That sounds like a very sensible and user-centric behaviour to me,
> and "not initialized" sounds like the right message to give in such
> a case (as opposed to "commits not present"---even the user told us
> they are not interesting, we may have them, so "not present" is not
> just incorrect but irrelevant because that is not the reason why we
> are not showing).

So you are saying we should instead do:

  if (not active)
    message = "not initialized"
  if (problems with object loading)
    message = "commits not present"
  ...

> Or are you saying that even the user told us that the submodule is
> not interesting, if we had "init" it earlier even once, we show the
> difference and with a wrong label?  Showing the difference sounds
> like a bug that is more severe than using a wrong label to me.

I looked through the man pages and they never specify if submodule
activeness affects the superproject diff, so we'd want to change that
so that only active submodules are diffed.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] submodule: correct error message for missing commits.
  2017-07-26 20:56   ` Stefan Beller
@ 2017-07-26 21:10     ` Junio C Hamano
  0 siblings, 0 replies; 7+ messages in thread
From: Junio C Hamano @ 2017-07-26 21:10 UTC (permalink / raw)
  To: Stefan Beller; +Cc: Jacob Keller, git@vger.kernel.org

Stefan Beller <sbeller@google.com> writes:

> We _do_ show the submodule as demonstrated by the code sample above
> if we possess the objects.
> ...
>> That sounds like a very sensible and user-centric behaviour to me,
>> and "not initialized" sounds like the right message to give in such
>> a case (as opposed to "commits not present"---even the user told us
>> they are not interesting, we may have them, so "not present" is not
>> just incorrect but irrelevant because that is not the reason why we
>> are not showing).
>
> So you are saying we should instead do:
>
>   if (not active)
>     message = "not initialized"
>   if (problems with object loading)
>     message = "commits not present"
>   ...

I think I am.

>> Or are you saying that even the user told us that the submodule is
>> not interesting, if we had "init" it earlier even once, we show the
>> difference and with a wrong label?  Showing the difference sounds
>> like a bug that is more severe than using a wrong label to me.
>
> I looked through the man pages and they never specify if submodule
> activeness affects the superproject diff, so we'd want to change that
> so that only active submodules are diffed.

I would think that would match my expectation more closely; if I
explicitly told Git to "deinit", and still see the diff to distrat
me (i.e. the current behaviour), I would probably feel that it is a
bug.  I do not know about others who are used to the current
beehaviour, though.  Do people actively "deinit" a submodule that
they once "init"ed, and if so for what purpose?  It's not like they
want to release the disk resource, so I'd imagine the only reason is
to reduce the distracting noise, but I'd prefer to hear from real
users rather than speculating.

Thanks.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH] submodule: correct error message for missing commits.
@ 2017-09-26 18:27 Stefan Beller
  2017-09-26 23:37 ` Jacob Keller
  2017-09-27  0:52 ` Junio C Hamano
  0 siblings, 2 replies; 7+ messages in thread
From: Stefan Beller @ 2017-09-26 18:27 UTC (permalink / raw)
  To: git; +Cc: jacob.keller, Stefan Beller

When a submodule diff should be displayed we currently just add the
submodule objects to the main object store and then e.g. walk the
revision graph and create a summary for that submodule.

It is possible that we are missing the submodule either completely or
partially, which we currently differentiate with different error messages
depending on whether (1) the whole submodule object store is missing or
(2) just the needed for this particular diff. (1) is reported as
"not initialized", and (2) is reported as "commits not present".

If a submodule is deinit'ed its repository data is still around inside
the superproject, such that the diff can still be produced. In that way
the error message (1) is misleading as we can have a diff despite the
submodule being not initialized.

Downgrade the error message (1) to be the same as (2) and just say
the commits are not present, as that is the true reason why the diff
cannot be shown.

Signed-off-by: Stefan Beller <sbeller@google.com>
---
 submodule.c                               | 2 +-
 t/t4059-diff-submodule-not-initialized.sh | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/submodule.c b/submodule.c
index 6531c5d609..280c246477 100644
--- a/submodule.c
+++ b/submodule.c
@@ -567,7 +567,7 @@ static void show_submodule_header(FILE *f, const char *path,
 
 	if (add_submodule_odb(path)) {
 		if (!message)
-			message = "(not initialized)";
+			message = "(commits not present)";
 		goto output_header;
 	}
 
diff --git a/t/t4059-diff-submodule-not-initialized.sh b/t/t4059-diff-submodule-not-initialized.sh
index cd70fd5192..49bca7b48d 100755
--- a/t/t4059-diff-submodule-not-initialized.sh
+++ b/t/t4059-diff-submodule-not-initialized.sh
@@ -95,7 +95,7 @@ test_expect_success 'submodule not initialized in new clone' '
 	git clone . sm3 &&
 	git -C sm3 diff-tree -p --no-commit-id --submodule=log HEAD >actual &&
 	cat >expected <<-EOF &&
-	Submodule sm1 $smhead1...$smhead2 (not initialized)
+	Submodule sm1 $smhead1...$smhead2 (commits not present)
 	EOF
 	test_cmp expected actual
 '
-- 
2.14.0.rc0.3.g6c2e499285


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH] submodule: correct error message for missing commits.
  2017-09-26 18:27 [PATCH] submodule: correct error message for missing commits Stefan Beller
@ 2017-09-26 23:37 ` Jacob Keller
  2017-09-27  0:52 ` Junio C Hamano
  1 sibling, 0 replies; 7+ messages in thread
From: Jacob Keller @ 2017-09-26 23:37 UTC (permalink / raw)
  To: Stefan Beller; +Cc: Git mailing list

On Tue, Sep 26, 2017 at 11:27 AM, Stefan Beller <sbeller@google.com> wrote:
> When a submodule diff should be displayed we currently just add the
> submodule objects to the main object store and then e.g. walk the
> revision graph and create a summary for that submodule.
>
> It is possible that we are missing the submodule either completely or
> partially, which we currently differentiate with different error messages
> depending on whether (1) the whole submodule object store is missing or
> (2) just the needed for this particular diff. (1) is reported as
> "not initialized", and (2) is reported as "commits not present".
>
> If a submodule is deinit'ed its repository data is still around inside
> the superproject, such that the diff can still be produced. In that way
> the error message (1) is misleading as we can have a diff despite the
> submodule being not initialized.
>
> Downgrade the error message (1) to be the same as (2) and just say
> the commits are not present, as that is the true reason why the diff
> cannot be shown.
>
> Signed-off-by: Stefan Beller <sbeller@google.com>

This makes sense to me.

Thanks,
Jake

> ---
>  submodule.c                               | 2 +-
>  t/t4059-diff-submodule-not-initialized.sh | 2 +-
>  2 files changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/submodule.c b/submodule.c
> index 6531c5d609..280c246477 100644
> --- a/submodule.c
> +++ b/submodule.c
> @@ -567,7 +567,7 @@ static void show_submodule_header(FILE *f, const char *path,
>
>         if (add_submodule_odb(path)) {
>                 if (!message)
> -                       message = "(not initialized)";
> +                       message = "(commits not present)";
>                 goto output_header;
>         }
>
> diff --git a/t/t4059-diff-submodule-not-initialized.sh b/t/t4059-diff-submodule-not-initialized.sh
> index cd70fd5192..49bca7b48d 100755
> --- a/t/t4059-diff-submodule-not-initialized.sh
> +++ b/t/t4059-diff-submodule-not-initialized.sh
> @@ -95,7 +95,7 @@ test_expect_success 'submodule not initialized in new clone' '
>         git clone . sm3 &&
>         git -C sm3 diff-tree -p --no-commit-id --submodule=log HEAD >actual &&
>         cat >expected <<-EOF &&
> -       Submodule sm1 $smhead1...$smhead2 (not initialized)
> +       Submodule sm1 $smhead1...$smhead2 (commits not present)
>         EOF
>         test_cmp expected actual
>  '
> --
> 2.14.0.rc0.3.g6c2e499285
>

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] submodule: correct error message for missing commits.
  2017-09-26 18:27 [PATCH] submodule: correct error message for missing commits Stefan Beller
  2017-09-26 23:37 ` Jacob Keller
@ 2017-09-27  0:52 ` Junio C Hamano
  1 sibling, 0 replies; 7+ messages in thread
From: Junio C Hamano @ 2017-09-27  0:52 UTC (permalink / raw)
  To: Stefan Beller; +Cc: git, jacob.keller

Stefan Beller <sbeller@google.com> writes:

> When a submodule diff should be displayed we currently just add the
> submodule objects to the main object store and then e.g. walk the
> revision graph and create a summary for that submodule.
>
> It is possible that we are missing the submodule either completely or
> partially, which we currently differentiate with different error messages
> depending on whether (1) the whole submodule object store is missing or
> (2) just the needed for this particular diff. (1) is reported as
> "not initialized", and (2) is reported as "commits not present".
>
> If a submodule is deinit'ed its repository data is still around inside
> the superproject, such that the diff can still be produced. In that way
> the error message (1) is misleading as we can have a diff despite the
> submodule being not initialized.
>
> Downgrade the error message (1) to be the same as (2) and just say
> the commits are not present, as that is the true reason why the diff
> cannot be shown.
>
> Signed-off-by: Stefan Beller <sbeller@google.com>
> ---

Sounds good.  Thanks for working on it.


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2017-09-27  0:52 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-09-26 18:27 [PATCH] submodule: correct error message for missing commits Stefan Beller
2017-09-26 23:37 ` Jacob Keller
2017-09-27  0:52 ` Junio C Hamano
  -- strict thread matches above, loose matches on Subject: below --
2017-07-26 20:08 Stefan Beller
2017-07-26 20:30 ` Junio C Hamano
2017-07-26 20:56   ` Stefan Beller
2017-07-26 21:10     ` Junio C Hamano

Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).