diff options
author | Silvan Mosberger <contact@infinisil.com> | 2020-01-16 00:44:46 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-01-16 00:44:46 +0100 |
commit | 3c2e9fa53d237f20ec99508ef8856b3755a9da93 (patch) | |
tree | 8440228cba90aac92f49ef9c6c7d529458014072 | |
parent | 67373ae389842d543c66b38a51f45252850b9f28 (diff) | |
parent | 9d396d2e426b9a765de0b8999aa214f1259633e6 (diff) | |
download | nixlib-3c2e9fa53d237f20ec99508ef8856b3755a9da93.tar nixlib-3c2e9fa53d237f20ec99508ef8856b3755a9da93.tar.gz nixlib-3c2e9fa53d237f20ec99508ef8856b3755a9da93.tar.bz2 nixlib-3c2e9fa53d237f20ec99508ef8856b3755a9da93.tar.lz nixlib-3c2e9fa53d237f20ec99508ef8856b3755a9da93.tar.xz nixlib-3c2e9fa53d237f20ec99508ef8856b3755a9da93.tar.zst nixlib-3c2e9fa53d237f20ec99508ef8856b3755a9da93.zip |
Merge pull request #77704 from mayflower/also-submodules
lib.commitIdFromGitRepo: fix support for git-submodule
-rw-r--r-- | lib/sources.nix | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/lib/sources.nix b/lib/sources.nix index 0fd172c42b77..a5765c0fda5b 100644 --- a/lib/sources.nix +++ b/lib/sources.nix @@ -113,6 +113,10 @@ rec { with builtins; let fileName = toString path + "/" + file; packedRefsName = toString path + "/packed-refs"; + absolutePath = base: path: + if lib.hasPrefix "/" path + then path + else toString (/. + "${base}/${path}"); in if pathIsRegularFile path # Resolve git worktrees. See gitrepository-layout(5) then @@ -120,13 +124,11 @@ rec { in if m == null then throw ("File contains no gitdir reference: " + path) else - let gitDir = lib.head m; + let gitDir = absolutePath (dirOf path) (lib.head m); commonDir' = if pathIsRegularFile "${gitDir}/commondir" then lib.fileContents "${gitDir}/commondir" else gitDir; - commonDir = if lib.hasPrefix "/" commonDir' - then commonDir' - else toString (/. + "${gitDir}/${commonDir'}"); + commonDir = absolutePath gitDir commonDir'; refFile = lib.removePrefix "${commonDir}/" "${gitDir}/${file}"; in readCommitFromFile refFile commonDir |