From f9fc72aa14ea45ba447c9990cb3f45fa915cfc36 Mon Sep 17 00:00:00 2001 From: Jeff Squyres Date: Thu, 15 Sep 2022 14:27:59 -0700 Subject: [PATCH] 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 --- autogen.pl | 24 ++++++++---------------- 1 file changed, 8 insertions(+), 16 deletions(-) diff --git a/autogen.pl b/autogen.pl index 6df11cdaad3..4aa7a0f65fd 100755 --- a/autogen.pl +++ b/autogen.pl @@ -1409,12 +1409,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)) { @@ -1437,19 +1434,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"); } } }