submodule config lookup API
Quoted 10 lines · Junio C Hamano
Quoted 4 lines · Stefan Beller
Quoted 1 line · Junio C Hamano
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.
Quoted 4 lines
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.
Quoted 2 lines
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(-)
Signature · 1 line
2.5.0.234.gefc8a62
PATCH 1/2 Fixup hv/documentation
If you want to look up by name, use submodule_from_name instead.
--- Documentation/technical/api-submodule-config.txt | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
Documentation/technical/api-submodule-config.txt +1 -2
@@ -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)`::
Signature · 1 line
2.5.0.234.gefc8a62
PATCH 2/2 cleanup submodule_config a bit.
In reply to Stefan BellerIn 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.
--- submodule-config.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-)
submodule-config.c +5 -7
@@ -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,
Signature · 1 line
2.5.0.234.gefc8a62
Re: [PATCH 2/2] cleanup submodule_config a bit.
Quoted 16 lines · Stefan Beller
In the first hunk,
submoduleis 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 <[email protected]>--- submodule-config.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-)submodule-config.c +0
-0
submodule-config.c static const struct submodule *config_from(struct submodule_cache *cache, · line 390
Quoted 5 lines
submodule-config.c +1
-1@@ -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.
Quoted 8 lines
submodule-config.c +0
-2switch (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 ;
submodule-config.c static const struct submodule *config_from(struct submodule_cache *cache, · line 430
Quoted 10 lines
submodule-config.c +4
-4+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.
Quoted 5 lines
submodule-config.c +0
-1} static const struct submodule *config_from_path(struct submodule_cache *cache, --2.5.0.234.gefc8a62
Re: [PATCH 2/2] cleanup submodule_config a bit.
Quoted 19 lines · Eric Sunshine
Quoted 18 lines · Stefan Beller
In the first hunk,
submoduleis 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 <[email protected]>--- submodule-config.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-)submodule-config.c +0
-0@@ -387,7 +387,7 @@ static const struct submodule *config_from(struct submodule_cache *cache, }
Quoted 8 lines
submodule-config.c static const struct submodule *config_from(struct submodule_cache *cache, · line 390
Quoted 3 lines
submodule-config.c +1
-1if (!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!
Quoted 16 lines
Quoted 16 lines
submodule-config.c +4
-4switch (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 ;
Quoted 8 lines
submodule-config.c static const struct submodule *config_from(struct submodule_cache *cache, · line 430
Quoted 3 lines
submodule-config.c +0
-2} - -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.
Quoted 6 lines
Quoted 6 lines
submodule-config.c +0
-1} static const struct submodule *config_from_path(struct submodule_cache *cache, --2.5.0.234.gefc8a62
Re: [PATCH 2/2] cleanup submodule_config a bit.
Quoted 34 lines · Stefan Beller
Quoted 9 lines · Eric Sunshine
submodule-config.c static const struct submodule *config_from(struct submodule_cache *cache, · line 390
Quoted 3 lines · Stefan Beller
if (!gitmodule_sha1_from_commit(commit_sha1, sha1))submodule-config.c +1
-1-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!
Quoted 12 lines
Quoted 12 lines
submodule-config.c +4
-4@@ -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 ;Quoted 8 lines
submodule-config.c static const struct submodule *config_from(struct submodule_cache *cache, · line 430
Quoted 3 lines
submodule-config.c +0
-2} - -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.
Quoted 4 lines
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.
Quoted 3 lines · Stefan Beller
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.