File tree Expand file tree Collapse file tree 1 file changed +21
-1
lines changed Expand file tree Collapse file tree 1 file changed +21
-1
lines changed Original file line number Diff line number Diff line change @@ -257,17 +257,37 @@ git submodule status --recursive --cached >> "$TMPLIST"
257
257
while read path; do
258
258
# git submodule does not list trailing slashes in $path. Remove it in $TREEISH search.
259
259
TREEISH=$( git ls-tree " ${TOP_TREEISH} " " ${path%/ } " | awk ' { print $3 }' )
260
+
261
+ if [ -z " $TREEISH " ]; then
262
+ # It is not top repo's direct submodule.
263
+ ppath=${path%/ } ; ppath=${ppath%/* }
264
+ pathbase=${path%/ } ; pathbase=${pathbase##*/ }
265
+ while [ -n " ${ppath} " ]; do
266
+ PARENT_TREEISH=$( sed -nr -e ' s@^[ +-]@@' -e ' s@ +\(.*\)$@@' -e ' s@([^ ]+) +' " ${ppath} " ' $@\1@ p' " $TMPLIST " | tail -n1)
267
+ if [ -n " $PARENT_TREEISH " ]; then
268
+ TREEISH=$( git -C " ${ppath} " ls-tree " ${PARENT_TREEISH} " " ${pathbase} " | awk ' { print $3 }' )
269
+ fi
270
+ if [ ${ppath} == ${ppath%/* } ]; then
271
+ break
272
+ else
273
+ pathbase=" ${ppath##*/ } /${pathbase} "
274
+ ppath=${ppath%/* }
275
+ fi
276
+ done
277
+ fi
278
+
260
279
if [ -z " $TREEISH " ]; then
261
280
if [ " $TOP_TREEISH_HASH " != " $TOP_HEAD_HASH " ]; then
262
281
echo >&2 -e " \e[33;1mWarning:\e[22m Submodule \" ${path%/ } \" hash for top repo's ${TOP_TREEISH} was not obtained. Use the commit for top repo's HEAD.\e[m"
263
282
fi
264
283
265
- TREEISH=$( sed -nr -e ' s@^[ +-]@@' -e ' s@ +\(.*\)$@@' -e ' s@([^ ]+) +' " ${path%/ } " ' $@\1@ p' " $TMPLIST " )
284
+ TREEISH=$( sed -nr -e ' s@^[ +-]@@' -e ' s@ +\(.*\)$@@' -e ' s@([^ ]+) +' " ${path%/ } " ' $@\1@ p' " $TMPLIST " | tail -n1 )
266
285
if [ -z " $TREEISH " ]; then
267
286
echo >&2 -e " \e[33;1mWarning:\e[22m Submodule \" ${path%/ } \" hash for top repo's HEAD was not obtained. Use the commit for the submodule's HEAD.\e[m"
268
287
TREEISH=HEAD
269
288
fi
270
289
fi
290
+ echo " ${TREEISH} ${path%/ } " >> " ${TMPLIST} " # Update the chosen commit
271
291
echo >&2 " Submodule \" ${path%/ } \" commit for top repo's ${TOP_TREEISH} : ${TREEISH:- HEAD} ($( git -C ${path} name-rev --name-only " ${TREEISH} " ) )"
272
292
273
293
cd " $path "
You can’t perform that action at this time.
0 commit comments