threads / patch / 40073

patch, 2 partsFixup hv/documentation

Subject: [PATCH 1/2] Fixup hv/documentation

## tl;dr

7 messages between Aug 12, 2015 and Aug 12, 2015. Diffs are folded; open one to read it.

replies: 6people: 3as markdown or json

Stefan Beller· Aug 12, 2015, 19:13 UTC · lore

Re: [PATCH v5 0/4] submodule config lookup API

On Wed, Aug 12, 2015 at 10:53 AM, Junio C Hamano <gitster@pobox.com> wrote:
Show 10 quoted lines
> Stefan Beller <sbeller@google.com> writes:
>
>> On Mon, Jun 15, 2015 at 2:48 PM, Junio C Hamano <gitster@pobox.com> wrote:
>>> Thanks.  Will replace and wait for comments from others.
>>
>> I have reviewed the patches carefully and they look good to me.
>
> OK, I recall there were a few iterations with review comments before
> this round.  Is it your impression that they have been addressed
> adequately?

I payed only little attention to the previous rounds and the review comments thereof, because round 5 was up for quite a long time and nobody commented so far.

However just as I was convinced of my review and sent out the email, I started working with it. And I found nits which I'd ask you to squash into the round or put on top.

>
> Do you prefer it to be rebased to a more recent 'master' before you
> build your work on top of it (I think the topic currently builds on
> top of v2.5.0-rc0~56)?

Looking at the reviews for the "RFC parallel fetch for submodules" I'd like to use `argv_array_pushv` which was introduced via 85b343245b (2015-06-14, argv-array: implement argv_array_pushv()) and is already in origin/next, but not origin/master. But as I first work on the submodule--helper (both the small helper functions as well as the whole "update" thereafter), I think this dependency is not a pressing issue yet.

>
> Thanks.
Stefan Beller (2):
  Fixup hv/documentation
  cleanup submodule_config a bit.
 Documentation/technical/api-submodule-config.txt |  3 +--
 submodule-config.c                               | 12 +++++-------
 2 files changed, 6 insertions(+), 9 deletions(-)
-- 
2.5.0.234.gefc8a62
Stefan Beller· Aug 12, 2015, 19:13 UTC · re: Stefan Beller · lore
If you want to look up by name, use `submodule_from_name` instead.
Signed-off-by: Stefan Beller <sbeller@google.com>
---
 Documentation/technical/api-submodule-config.txt | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
Show changes to Documentation/technical/api-submodule-config.txt +1 −2
diff --git a/Documentation/technical/api-submodule-config.txt b/Documentation/technical/api-submodule-config.txt
index 2ea520a..941fa17 100644
--- a/Documentation/technical/api-submodule-config.txt
+++ b/Documentation/technical/api-submodule-config.txt
@@ -49,8 +49,7 @@ Functions
 
 `const struct submodule *submodule_from_path(const unsigned char *commit_sha1, const char *path)`::
 
-	Lookup values for one submodule by its commit_sha1 and path or
-	name.
+	Lookup values for one submodule by its commit_sha1 and path.
 
 `const struct submodule *submodule_from_name(const unsigned char *commit_sha1, const char *name)`::
 
-- 
2.5.0.234.gefc8a62
Stefan Beller· Aug 12, 2015, 19:13 UTC · re: Stefan Beller · lore

[PATCH 2/2] cleanup submodule_config a bit.

In the first hunk, `submodule` is NULL all the time, so we can make it clearer by directly returning NULL.

In the second hunk, we can directly return the lookup values as it also makes the coder clearer.

Signed-off-by: Stefan Beller <sbeller@google.com>
---
 submodule-config.c | 12 +++++-------
 1 file changed, 5 insertions(+), 7 deletions(-)
Show changes to submodule-config.c +5 −7
diff --git a/submodule-config.c b/submodule-config.c
index 199692b..08e93cc 100644
--- a/submodule-config.c
+++ b/submodule-config.c
@@ -387,7 +387,7 @@ static const struct submodule *config_from(struct submodule_cache *cache,
 	}
 
 	if (!gitmodule_sha1_from_commit(commit_sha1, sha1))
-		return submodule;
+		return NULL;
 
 	switch (lookup_type) {
 	case lookup_name:
@@ -420,14 +420,12 @@ static const struct submodule *config_from(struct submodule_cache *cache,
 
 	switch (lookup_type) {
 	case lookup_name:
-		submodule = cache_lookup_name(cache, sha1, key);
-		break;
+		return cache_lookup_name(cache, sha1, key);
 	case lookup_path:
-		submodule = cache_lookup_path(cache, sha1, key);
-		break;
+		return cache_lookup_path(cache, sha1, key);
+	default:
+		return NULL;
 	}
-
-	return submodule;
 }
 
 static const struct submodule *config_from_path(struct submodule_cache *cache,
-- 
2.5.0.234.gefc8a62
Eric Sunshine· Aug 12, 2015, 21:13 UTC · re: Stefan Beller · lore

Re: [PATCH 2/2] cleanup submodule_config a bit.

On Wed, Aug 12, 2015 at 3:13 PM, Stefan Beller <sbeller@google.com> wrote:
Show 21 quoted lines
> In the first hunk, `submodule` is NULL all the time, so we can make it clearer
> by directly returning NULL.
>
> In the second hunk, we can directly return the lookup values as it also makes
> the coder clearer.
>
> Signed-off-by: Stefan Beller <sbeller@google.com>
> ---
>  submodule-config.c | 12 +++++-------
>  1 file changed, 5 insertions(+), 7 deletions(-)
>
> diff --git a/submodule-config.c b/submodule-config.c
> index 199692b..08e93cc 100644
> --- a/submodule-config.c
> +++ b/submodule-config.c
> @@ -387,7 +387,7 @@ static const struct submodule *config_from(struct submodule_cache *cache,
>         }
>
>         if (!gitmodule_sha1_from_commit(commit_sha1, sha1))
> -               return submodule;
> +               return NULL;

There are a couple other places which return 'submodule' when it is known to be NULL. One could rightly expect that they deserve the same treatment, otherwise, the code becomes more confusing since it's not obvious why 'return NULL' is used some places but not others.

Show 18 quoted lines
>         switch (lookup_type) {
>         case lookup_name:
> @@ -420,14 +420,12 @@ static const struct submodule *config_from(struct submodule_cache *cache,
>
>         switch (lookup_type) {
>         case lookup_name:
> -               submodule = cache_lookup_name(cache, sha1, key);
> -               break;
> +               return cache_lookup_name(cache, sha1, key);
>         case lookup_path:
> -               submodule = cache_lookup_path(cache, sha1, key);
> -               break;
> +               return cache_lookup_path(cache, sha1, key);
> +       default:
> +               return NULL;
>         }
> -
> -       return submodule;

Earlier in the function, there's effectively a clone of this logic to which you could apply the same transformation. Changing it here, while ignoring the clone, makes the code more confusing (or at least inconsistent) rather than less.

Show 5 quoted lines
>  }
>
>  static const struct submodule *config_from_path(struct submodule_cache *cache,
> --
> 2.5.0.234.gefc8a62
Stefan Beller· Aug 12, 2015, 21:34 UTC · re: Eric Sunshine · lore

Re: [PATCH 2/2] cleanup submodule_config a bit.

On Wed, Aug 12, 2015 at 2:13 PM, Eric Sunshine <sunshine@sunshineco.com> wrote:
Show 27 quoted lines
> On Wed, Aug 12, 2015 at 3:13 PM, Stefan Beller <sbeller@google.com> wrote:
>> In the first hunk, `submodule` is NULL all the time, so we can make it clearer
>> by directly returning NULL.
>>
>> In the second hunk, we can directly return the lookup values as it also makes
>> the coder clearer.
>>
>> Signed-off-by: Stefan Beller <sbeller@google.com>
>> ---
>>  submodule-config.c | 12 +++++-------
>>  1 file changed, 5 insertions(+), 7 deletions(-)
>>
>> diff --git a/submodule-config.c b/submodule-config.c
>> index 199692b..08e93cc 100644
>> --- a/submodule-config.c
>> +++ b/submodule-config.c
>> @@ -387,7 +387,7 @@ static const struct submodule *config_from(struct submodule_cache *cache,
>>         }
>>
>>         if (!gitmodule_sha1_from_commit(commit_sha1, sha1))
>> -               return submodule;
>> +               return NULL;
>
> There are a couple other places which return 'submodule' when it is
> known to be NULL. One could rightly expect that they deserve the same
> treatment, otherwise, the code becomes more confusing since it's not
> obvious why 'return NULL' is used some places but not others.
They were slightly less obvious to me, fixed now as well!
Show 24 quoted lines
>
>>         switch (lookup_type) {
>>         case lookup_name:
>> @@ -420,14 +420,12 @@ static const struct submodule *config_from(struct submodule_cache *cache,
>>
>>         switch (lookup_type) {
>>         case lookup_name:
>> -               submodule = cache_lookup_name(cache, sha1, key);
>> -               break;
>> +               return cache_lookup_name(cache, sha1, key);
>>         case lookup_path:
>> -               submodule = cache_lookup_path(cache, sha1, key);
>> -               break;
>> +               return cache_lookup_path(cache, sha1, key);
>> +       default:
>> +               return NULL;
>>         }
>> -
>> -       return submodule;
>
> Earlier in the function, there's effectively a clone of this logic to
> which you could apply the same transformation. Changing it here, while
> ignoring the clone, makes the code more confusing (or at least
> inconsistent) rather than less.

Not quite. Note the `if (submodule)` in the earlier version, so in case cache_lookup_{name, path} return NULL, we keep going. The change I propose is at the end of the function and we definitely return no matter if it is NULL or not.

Show 6 quoted lines
>
>>  }
>>
>>  static const struct submodule *config_from_path(struct submodule_cache *cache,
>> --
>> 2.5.0.234.gefc8a62
Eric Sunshine· Aug 12, 2015, 22:01 UTC · re: Stefan Beller · lore

Re: [PATCH 2/2] cleanup submodule_config a bit.

On Wed, Aug 12, 2015 at 5:34 PM, Stefan Beller <sbeller@google.com> wrote:
Show 38 quoted lines
> On Wed, Aug 12, 2015 at 2:13 PM, Eric Sunshine <sunshine@sunshineco.com> wrote:
>> On Wed, Aug 12, 2015 at 3:13 PM, Stefan Beller <sbeller@google.com> wrote:
>>>         if (!gitmodule_sha1_from_commit(commit_sha1, sha1))
>>> -               return submodule;
>>> +               return NULL;
>>
>> There are a couple other places which return 'submodule' when it is
>> known to be NULL. One could rightly expect that they deserve the same
>> treatment, otherwise, the code becomes more confusing since it's not
>> obvious why 'return NULL' is used some places but not others.
>
> They were slightly less obvious to me, fixed now as well!
>
>>> @@ -420,14 +420,12 @@ static const struct submodule *config_from(struct submodule_cache *cache,
>>>         switch (lookup_type) {
>>>         case lookup_name:
>>> -               submodule = cache_lookup_name(cache, sha1, key);
>>> -               break;
>>> +               return cache_lookup_name(cache, sha1, key);
>>>         case lookup_path:
>>> -               submodule = cache_lookup_path(cache, sha1, key);
>>> -               break;
>>> +               return cache_lookup_path(cache, sha1, key);
>>> +       default:
>>> +               return NULL;
>>>         }
>>> -
>>> -       return submodule;
>>
>> Earlier in the function, there's effectively a clone of this logic to
>> which you could apply the same transformation. Changing it here, while
>> ignoring the clone, makes the code more confusing (or at least
>> inconsistent) rather than less.
>
> Not quite. Note the `if (submodule)` in the earlier version, so in case
> cache_lookup_{name, path} return NULL, we keep going. The change I
> propose is at the end of the function and we definitely return no matter
> if it is NULL or not.

Okay, cache_lookup_{name, path}() can indeed return NULL, so the same transformation won't work. Sorry for the noise.

Junio C Hamano· Aug 12, 2015, 19:27 UTC · re: Stefan Beller · lore

Re: [PATCH v5 0/4] submodule config lookup API

Stefan Beller <sbeller@google.com> writes:
> However just as I was convinced of my review and sent out the email, I started
> working with it. And I found nits which I'd ask you to squash into the round or
> put on top.

Good ;-). I'd prefer a full reroll, as it has been quite a while since v5 was originally posted, once you get to a reasonable state where you are reasonably confident that you won't find more of such nits. Hopefully more people might have eyes on the list to review and comment this round.

Thanks.

← back to recent threads