Skip to contentSkip to conversation

git-submodule.sh: allow running in validate mode without previous update

PATCH In review Paolo Bonzini 2 participants 2 messages Jun 22, 2023 – Jun 23, 2023

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 git-submodule.sh: allow running in validate mode without previous update

The call to git-submodule.sh done in configure may happen without a previous checkout of the roms/SLOF submodule, or even without a previous run of the script.

So, handle creating a .git-submodule-status file even in validate mode. If git is absent, ensure that all passed directories exists (because you should be in a fresh untar and will not have stale arguments to git-submodule.sh) but do no other checks. If git is present, ensure that .git-submodule-status contains an entry for all submodules passed on the command line.

With this change, "ignore" mode is not needed anymore.

Fixes b11f9bd96f4 ("configure: move SLOF submodule handling to pc-bios/s390-ccw", 2023-06-06)
---
 configure                |  2 +-
 scripts/git-submodule.sh | 73 ++++++++++++++++++++++------------------
 2 files changed, 42 insertions(+), 33 deletions(-)
configure +1 -1
index 86363a7e508..2b41c49c0d1 100755
@@ -758,7 +758,7 @@ done
 
 if ! test -e "$source_path/.git"
 then
-    git_submodules_action="ignore"
+    git_submodules_action="validate"
 fi
 
 # test for any invalid configuration combinations
scripts/git-submodule.sh +41 -32

103 lines not on this page · raw message

Signature · 1 line
2.40.1
Reviewed-by Tested-by on v2 1/1
#1 lore raw
Quoted 11 lines · Paolo Bonzini

The call to git-submodule.sh done in configure may happen without a previous checkout of the roms/SLOF submodule, or even without a previous run of the script.

So, handle creating a .git-submodule-status file even in validate mode. If git is absent, ensure that all passed directories exists (because you should be in a fresh untar and will not have stale arguments to git-submodule.sh) but do no other checks. If git is present, ensure that .git-submodule-status contains an entry for all submodules passed on the command line.

Quoted 4 lines

With this change, "ignore" mode is not needed anymore.

Fixes b11f9bd96f4 ("configure: move SLOF submodule handling to pc-bios/s390-ccw", 2023-06-06)
Quoted 5 lines
---
 configure                |  2 +-
 scripts/git-submodule.sh | 73 ++++++++++++++++++++++------------------
 2 files changed, 42 insertions(+), 33 deletions(-)

[...]

scripts/git-submodule.sh check_updated() { · line 86

Quoted 9 lines

case "$command" in
status|validate)

scripts/git-submodule.sh +3 -3
-    test -f "$substat" || validate_error "$command"
-    test -z "$maybe_modules" && exit 0
     for module in $modules; do
-        check_updated $module || validate_error "$command"
+        if is_git; then
+            check_updated $module || validate_error "$command"
+        elif ! (set xyz "$module"/* && test -e "$2"); then

You could also do set -- "$module"/* and use $1, not that it matters.

Quoted 18 lines
scripts/git-submodule.sh +9 -3
+            # The directory does not exist or it contains no files
+            echo "$0: sources not available for $module and $no_git_error"
+            validate_error "$command"
+        fi
     done
-    exit 0
     ;;
+
 update)
-    test -e $substat || touch $substat
-    test -z "$maybe_modules" && exit 0
+    is_git || {
+        echo "$0: unexpectedly called with submodules but $no_git_error"
+        exit 1
+    }
 
     $GIT submodule update --init $modules 1>/dev/null
     test $? -ne 0 && update_error "failed to update modules"