git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH 2/2] cleanup submodule_config a bit.

From
Stefan Beller <sbeller@google.com>
Date
Aug 12, 2015, 19:13 UTC
Message-ID
<1439406838-6290-3-git-send-email-sbeller@google.com>
In-Reply-To
<1439406838-6290-1-git-send-email-sbeller@google.com>

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;
 
 	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
Previous: Stefan BellerNext: Eric Sunshine
Message 3 of 7 in “Re: [PATCH v5 0/4] submodule config lookup API”
  1. Stefan BellerAug 12, 2015
  2. 1/2 Fixup hv/documentationStefan Beller, Aug 12, 2015
  3. 2/2 cleanup submodule_config a bit.Stefan Beller, Aug 12, 2015
  4. Eric SunshineAug 12, 2015
  5. Stefan BellerAug 12, 2015
  6. Eric SunshineAug 12, 2015
  7. Junio C HamanoAug 12, 2015

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.