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>
maint
Brandon Williams 2017-03-16 15:29:45 -07:00 committed by Junio C Hamano
parent 6dc9f01f33
commit e7849a9677
1 changed files with 21 additions and 17 deletions

View File

@ -1090,6 +1090,13 @@ cmd_sync()
do
die_if_unmatched "$mode" "$sha1"
name=$(git submodule--helper name "$sm_path")

# skip inactive submodules
if ! git config "submodule.$name.url" >/dev/null 2>/dev/null
then
continue
fi

url=$(git config -f .gitmodules --get submodule."$name".url)

# Possibly a url relative to parent
@ -1111,8 +1118,6 @@ cmd_sync()
;;
esac

if git config "submodule.$name.url" >/dev/null 2>/dev/null
then
displaypath=$(git submodule--helper relative-path "$prefix$sm_path" "$wt_prefix")
say "$(eval_gettext "Synchronizing submodule url for '\$displaypath'")"
git config submodule."$name".url "$super_config_url"
@ -1132,7 +1137,6 @@ cmd_sync()
fi
)
fi
fi
done
}