diff --git a/master_changes.md b/master_changes.md index c481f0530db..2e4bad309b1 100644 --- a/master_changes.md +++ b/master_changes.md @@ -81,6 +81,7 @@ users) ## Sandbox ## VCS + * Check the status of git submodules when checking if a repository is up-to-date [#6132 @kit-ty-kate] ## Build * Synchronise opam-core.opam with opam-repository changes [#6043 @dra27] diff --git a/src/repository/opamGit.ml b/src/repository/opamGit.ml index c30f66a3162..7c7b080cb04 100644 --- a/src/repository/opamGit.ml +++ b/src/repository/opamGit.ml @@ -216,7 +216,19 @@ module VCS : OpamVCS.VCS = struct @ List.map OpamFilename.SubPath.to_string (OpamStd.Option.to_list subpath)) @@> function - | { OpamProcess.r_code = 0; _ } -> Done true + | { OpamProcess.r_code = 0; _ } -> + git repo_root ["submodule"; "status"; "--recursive"] @@> fun r -> + if r.r_code = 0 && + (* NOTE: We check the first character of each lines of the output + to verify that every submodules are in their expected state. + The git submodule manual states: + Each SHA-1 will possibly be prefixed with - if the submodule is + not initialized, + if the currently checked out submodule commit + does not match the SHA-1 found in the index of the containing + repository and U if the submodule has merge conflicts. *) + List.for_all (fun s -> String.length s > 0 && s.[0] = ' ') r.r_stdout + then Done true + else (OpamProcess.cleanup ~force:true r; Done false) | { OpamProcess.r_code = 1; _ } as r -> OpamProcess.cleanup ~force:true r; Done false | r -> OpamSystem.process_error r