From 1de1dc5c0068c9d7e918c2cb38d6a622e00ef78b Mon Sep 17 00:00:00 2001 From: Jeff Squyres Date: Thu, 15 Sep 2022 14:27:59 -0700 Subject: [PATCH 1/2] autogen.pl: fix submodule hash check Update the git submodule check to just look at the first character in each line of "git submodule status" output: * If it's "-", then the submodule is missing (this check was already there) * If it's "+", then the locally-checked out hash is different than what is expected by the submodule, so emit a warning (this check was there, but was incorrect) Signed-off-by: Jeff Squyres (cherry picked from commit f9fc72aa14ea45ba447c9990cb3f45fa915cfc36) --- autogen.pl | 24 ++++++++---------------- 1 file changed, 8 insertions(+), 16 deletions(-) diff --git a/autogen.pl b/autogen.pl index 623c0d17677..4e4712d2048 100755 --- a/autogen.pl +++ b/autogen.pl @@ -1391,12 +1391,9 @@ sub replace_config_sub_guess { open(IN, "git submodule status|") || die "Can't run \"git submodule status\""; while () { - chomp; - $_ =~ m/^(.)(.{40}) ([^ ]+) *\(*([^\(\)]*)\)*$/; - my $status = $1; - my $local_hash = $2; - my $path = $3; - my $extra = $4; + $_ =~ m/^(.).{40} ([^ ]+) /; + my $status = $1; + my $path = $2; print("=== Submodule: $path\n"); if (index($path, "pmix") != -1 and list_contains("pmix", @disabled_3rdparty_packages)) { @@ -1419,19 +1416,14 @@ sub replace_config_sub_guess { exit(1); } - # See if the submodule is at the expected git hash - # (it may be ok if it's not -- just warn the user) - $extra =~ m/-g(.+)/; - my $remote_hash = $1; - if ($remote_hash) { - my $abbrev_local_hash = substr($local_hash, 0, length($remote_hash)); - if ($remote_hash ne $abbrev_local_hash) { + # See if the commit in the submodule is not the same as the + # commit that the git submodule thinks it should be. + elsif ($status eq "+") { print(" ==> WARNING: Submodule hash is different than upstream. If this is not intentional, you may want to run: \"git submodule update --init --recursive\"\n"); - } else { - print(" Local hash == remote hash (good!)\n"); - } + } else { + print(" Local hash is what is expected by the submodule (good!)\n"); } } } From b7b11eb66ec6f62d7b14f6d6bcbb17126b276bd9 Mon Sep 17 00:00:00 2001 From: Jeff Squyres Date: Fri, 16 Sep 2022 08:55:14 -0400 Subject: [PATCH 2/2] autogen.pl: tweak a regexp to handle more cases The output of `git submodule status` will be of the following form: ``` Xgit_hash submodule_path [(git_ref)] ``` * `X` is either a space, `+`, or `-` * `git_hash` is 40 hex digits * `submodule_path` is the path in the repo where the submodule is located * `(git_ref)` is optional, and will not be there if the submodule is missing (which the previous regexp did not handle). This commit tightens up the regexp to be a bit more robust and handle the case where the git_ref token is not present. Signed-off-by: Jeff Squyres (cherry picked from commit 5c66993c27977c1b0e31ca1e38a2cb75a5372403) --- autogen.pl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/autogen.pl b/autogen.pl index 4e4712d2048..8263fc1820a 100755 --- a/autogen.pl +++ b/autogen.pl @@ -1391,7 +1391,7 @@ sub replace_config_sub_guess { open(IN, "git submodule status|") || die "Can't run \"git submodule status\""; while () { - $_ =~ m/^(.).{40} ([^ ]+) /; + $_ =~ m/^(.)[0-9a-f]{40}\s+(\S+)/; my $status = $1; my $path = $2;