Thread (234 messages) flat view 234 messages, 5 authors, 2017-04-07
STALE3450d

Revision rfc of 7 in this series.

Revisions (7)
  1. rfc current
  2. v2 [diff vs current]
  3. v3 [diff vs current]
  4. v4 [diff vs current]
  5. v5 [diff vs current]
  6. v6 [diff vs current]
  7. v7 [diff vs current]

[PATCH 08/11] refs.c: factor submodule code out of get_ref_store()

From: Nguyễn Thái Ngọc Duy <hidden>
Date: 2017-02-13 15:21:29
Subsystem: the rest · Maintainer: Linus Torvalds

This code is going to be expanded a bit soon. Keep it out for
better readability later.

Signed-off-by: Nguyễn Thái Ngọc Duy <redacted>
---
 refs.c | 22 ++++++++++++++--------
 1 file changed, 14 insertions(+), 8 deletions(-)
diff --git a/refs.c b/refs.c
index 2cacd934e..8ef7a52ba 100644
--- a/refs.c
+++ b/refs.c
@@ -1445,6 +1445,18 @@ static struct ref_store *lookup_ref_store(const char *submodule)
 	return entry ? entry->refs : NULL;
 }
 
+static struct ref_store *init_submodule_ref_store(const char *submodule)
+{
+	struct strbuf submodule_sb = STRBUF_INIT;
+	struct ref_store *refs = NULL;
+
+	strbuf_addstr(&submodule_sb, submodule);
+	if (is_nonbare_repository_dir(&submodule_sb))
+		refs = ref_store_init(submodule);
+	strbuf_release(&submodule_sb);
+	return refs;
+}
+
 struct ref_store *get_ref_store(const char *submodule)
 {
 	struct ref_store *refs;
@@ -1457,14 +1469,8 @@ struct ref_store *get_ref_store(const char *submodule)
 	} else {
 		refs = lookup_ref_store(submodule);
 
-		if (!refs) {
-			struct strbuf submodule_sb = STRBUF_INIT;
-
-			strbuf_addstr(&submodule_sb, submodule);
-			if (is_nonbare_repository_dir(&submodule_sb))
-				refs = ref_store_init(submodule);
-			strbuf_release(&submodule_sb);
-		}
+		if (!refs)
+			refs = init_submodule_ref_store(submodule);
 	}
 
 	return refs;
-- 
2.11.0.157.gd943d85
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help