Skip to content

Commit

Permalink
lib/sources: Fix commitIdFromGitRepo when repo is a submodule
Browse files Browse the repository at this point in the history
  • Loading branch information
talyz committed Nov 22, 2022
1 parent b29f9c3 commit 1e659be
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions lib/sources.nix
Original file line number Diff line number Diff line change
Expand Up @@ -185,12 +185,12 @@ let
# not exported, used for commitIdFromGitRepo
_commitIdFromGitRepoOrError =
let readCommitFromFile = file: path:
let fileName = path + "/${file}";
let fileName = path + ("/" + file);
packedRefsName = path + "/packed-refs";
absolutePath = base: path:
if lib.hasPrefix "/" path
then path
else toString (/. + "${base}/${path}");
else base + ("/" + path);
in if pathIsRegularFile path
# Resolve git worktrees. See gitrepository-layout(5)
then
Expand All @@ -204,7 +204,7 @@ let
else gitDir;
commonDir' = lib.removeSuffix "/" commonDir'';
commonDir = absolutePath gitDir commonDir';
refFile = lib.removePrefix "${commonDir}/" "${gitDir}/${file}";
refFile = builtins.unsafeDiscardStringContext (lib.removePrefix "${commonDir}/" "${gitDir}/${file}");
in readCommitFromFile refFile commonDir

else if pathIsRegularFile fileName
Expand Down

0 comments on commit 1e659be

Please sign in to comment.