Skip to content

Commit e7849a9

Browse files
bmwillgitster
authored andcommitted
submodule sync: skip work for inactive submodules
Sync does some work determining what URLs should be used for a submodule but then throws this work away if the submodule isn't active. Instead perform the activity check earlier and skip inactive submodule in order to avoid doing unnecessary work. Signed-off-by: Brandon Williams <bmwill@google.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent 6dc9f01 commit e7849a9

File tree

1 file changed

+21
-17
lines changed

1 file changed

+21
-17
lines changed

git-submodule.sh

Lines changed: 21 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1090,6 +1090,13 @@ cmd_sync()
10901090
do
10911091
die_if_unmatched "$mode" "$sha1"
10921092
name=$(git submodule--helper name "$sm_path")
1093+
1094+
# skip inactive submodules
1095+
if ! git config "submodule.$name.url" >/dev/null 2>/dev/null
1096+
then
1097+
continue
1098+
fi
1099+
10931100
url=$(git config -f .gitmodules --get submodule."$name".url)
10941101

10951102
# Possibly a url relative to parent
@@ -1111,27 +1118,24 @@ cmd_sync()
11111118
;;
11121119
esac
11131120

1114-
if git config "submodule.$name.url" >/dev/null 2>/dev/null
1121+
displaypath=$(git submodule--helper relative-path "$prefix$sm_path" "$wt_prefix")
1122+
say "$(eval_gettext "Synchronizing submodule url for '\$displaypath'")"
1123+
git config submodule."$name".url "$super_config_url"
1124+
1125+
if test -e "$sm_path"/.git
11151126
then
1116-
displaypath=$(git submodule--helper relative-path "$prefix$sm_path" "$wt_prefix")
1117-
say "$(eval_gettext "Synchronizing submodule url for '\$displaypath'")"
1118-
git config submodule."$name".url "$super_config_url"
1127+
(
1128+
sanitize_submodule_env
1129+
cd "$sm_path"
1130+
remote=$(get_default_remote)
1131+
git config remote."$remote".url "$sub_origin_url"
11191132

1120-
if test -e "$sm_path"/.git
1133+
if test -n "$recursive"
11211134
then
1122-
(
1123-
sanitize_submodule_env
1124-
cd "$sm_path"
1125-
remote=$(get_default_remote)
1126-
git config remote."$remote".url "$sub_origin_url"
1127-
1128-
if test -n "$recursive"
1129-
then
1130-
prefix="$prefix$sm_path/"
1131-
eval cmd_sync
1132-
fi
1133-
)
1135+
prefix="$prefix$sm_path/"
1136+
eval cmd_sync
11341137
fi
1138+
)
11351139
fi
11361140
done
11371141
}

0 commit comments

Comments
 (0)