Skip to contentSkip to conversation

submodule: do no re-read name in shell script

PATCH In review Stefan Beller 2 participants 3 messages Jul 21, 2016

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 submodule: do no re-read name in shell script

Instead of making another call to a submodule helper (name), just propagate the value when we know it (in the update-clone helper) already.

---
 builtin/submodule--helper.c | 4 ++--
 git-submodule.sh            | 3 +--
 2 files changed, 3 insertions(+), 4 deletions(-)
builtin/submodule--helper.c +2 -2
index b22352b..494e088 100644
@@ -683,9 +683,9 @@ static int prepare_to_clone_next_submodule(const struct cache_entry *ce,
 	needs_cloning = !file_exists(sb.buf);
 
 	strbuf_reset(&sb);
-	strbuf_addf(&sb, "%06o %s %d %d\t%s\n", ce->ce_mode,
+	strbuf_addf(&sb, "%06o %s %d %d %s\t%s\n", ce->ce_mode,
 			sha1_to_hex(ce->sha1), ce_stage(ce),
-			needs_cloning, ce->name);
+			needs_cloning, sub->name, sub->path);
 	string_list_append(&suc->projectlines, sb.buf);
 
 	if (!needs_cloning)
git-submodule.sh +1 -2
index 4ec7546..e23aada 100755
@@ -584,11 +584,10 @@ cmd_update()
 		"$@" || echo "#unmatched"
 	} | {
 	err=
-	while read mode sha1 stage just_cloned sm_path
+	while read mode sha1 stage just_cloned name sm_path
 	do
 		die_if_unmatched "$mode"
 
-		name=$(git submodule--helper name "$sm_path") || exit
 		url=$(git config submodule."$name".url)
 		branch=$(get_submodule_config "$name" branch master)
 		if ! test -z "$update"
Signature · 1 line
2.9.2.369.g0e67330
#1 lore raw
Quoted 14 lines · Stefan Beller

Instead of making another call to a submodule helper (name), just propagate the value when we know it (in the update-clone helper) already.

---
 builtin/submodule--helper.c | 4 ++--
 git-submodule.sh            | 3 +--
 2 files changed, 3 insertions(+), 4 deletions(-)
builtin/submodule--helper.c +0 -0
index b22352b..494e088 100644

builtin/submodule--helper.c static int prepare_to_clone_next_submodule(const struct cache_entry *ce, · line 688

Quoted 8 lines
builtin/submodule--helper.c +2 -2
@@ -683,9 +683,9 @@ static int prepare_to_clone_next_submodule(const struct cache_entry *ce,
 	needs_cloning = !file_exists(sb.buf);
 
 	strbuf_reset(&sb);
-	strbuf_addf(&sb, "%06o %s %d %d\t%s\n", ce->ce_mode,
+	strbuf_addf(&sb, "%06o %s %d %d %s\t%s\n", ce->ce_mode,
 			sha1_to_hex(ce->sha1), ce_stage(ce),
-			needs_cloning, ce->name);
+			needs_cloning, sub->name, sub->path);

Are there any restrictions on what characters a submodule name can contain? Does this need e.g. to be quoted with sq_quote?

Thanks,
Jonathan

#2 lore raw
Quoted 5 lines · Jonathan Nieder

builtin/submodule--helper.c static int prepare_to_clone_next_submodule(const struct cache_entry *ce, · line 688

Quoted 2 lines
builtin/submodule--helper.c +1 -1
-                     needs_cloning, ce->name);
+                     needs_cloning, sub->name, sub->path);

Are there any restrictions on what characters a submodule name can contain? Does this need e.g. to be quoted with sq_quote?

Oh good point, this ought to fail with weird names. So instead of quoting it, let's just drop this patch.

Quoted 3 lines

Thanks,
Jonathan