|
51 | 51 | s;
|
52 | 52 |
|
53 | 53 | lines = s: filter (x : x != [] && x != "") (split "\n" s);
|
| 54 | + |
| 55 | + origSrcSubDir = toString (src.origSrcSubDir or src); |
54 | 56 | in
|
55 | 57 |
|
56 |
| -if builtins.pathExists (toString src + "/.git") |
| 58 | +if builtins.pathExists (origSrcSubDir + "/.git") |
57 | 59 | then
|
58 | 60 | let
|
59 |
| - hasIndex = builtins.pathExists (toString src + "/.git/index"); |
60 |
| - isWorktree = (builtins.readDir (toString src)).".git" == "regular"; |
| 61 | + hasIndex = builtins.pathExists (origSrcSubDir + "/.git/index"); |
| 62 | + isWorktree = (builtins.readDir origSrcSubDir).".git" == "regular"; |
61 | 63 |
|
62 | 64 | # Identify the .git directory and filter just the files that we need.
|
63 | 65 | gitDir = cleanSourceWith ({
|
|
74 | 76 | if hasIndex
|
75 | 77 | then { inherit src; subDir = ".git"; }
|
76 | 78 | else if !isWorktree
|
77 |
| - then abort "cleanGit: ${toString src + "/.git"} has no index file" |
| 79 | + then abort "cleanGit: ${origSrcSubDir + "/.git"} has no index file" |
78 | 80 | else {
|
79 | 81 | # likely a git worktree, so follow the indirection
|
80 | 82 | src =
|
81 | 83 | let
|
82 |
| - git_content = lines (readFile (toString src + "/.git")); |
| 84 | + git_content = lines (readFile (origSrcSubDir + "/.git")); |
83 | 85 | first_line = head git_content;
|
84 | 86 | prefix = "gitdir: ";
|
85 | 87 | ok = length git_content == 1 && has_prefix prefix first_line;
|
86 | 88 | in
|
87 | 89 | if ok
|
88 | 90 | then /. + remove_prefix prefix first_line
|
89 |
| - else abort "gitSource.nix: Cannot parse ${toString src + "/.git"}"; |
| 91 | + else abort "gitSource.nix: Cannot parse ${origSrcSubDir + "/.git"}"; |
90 | 92 | }));
|
91 | 93 |
|
92 | 94 | # Worktrees have a commondir pointing to the common `.git` dir. We need the
|
|
102 | 104 | else gitDir + "/config";
|
103 | 105 |
|
104 | 106 | # We need the .gitmodules file for submoules to work.
|
105 |
| - gitModulesStr = toString src + "/.gitmodules"; |
| 107 | + gitModulesStr = origSrcSubDir + "/.gitmodules"; |
106 | 108 | gitModules = builtins.path { name = "gitmodules"; path = gitModulesStr; };
|
107 | 109 |
|
108 | 110 | gitSubmoduleFiles = cleanSourceWith {
|
|
154 | 156 | }
|
155 | 157 |
|
156 | 158 | else
|
157 |
| - trace "gitSource.nix: ${toString src} does not seem to be a git repository,\nassuming it is a clean checkout." ( |
| 159 | + trace "gitSource.nix: ${origSrcSubDir} does not seem to be a git repository,\nassuming it is a clean checkout." ( |
158 | 160 | cleanSourceWith {
|
159 | 161 | caller = "cleanGit";
|
160 | 162 | inherit name src subDir;
|
|
0 commit comments