Staging instance, all changes can be removed at any time

Skip to content

nar: Ensure VCS directories are recursively excluded

Previously only top level VCS directories were excluded but that behavior does not match the one from the guix hash -x -S nar command who recursively excludes those directories when computing a nar hash.

So ensure to have the same behavior to avoid hash mismatch issues when using a directory loader.

We can check that behavior using the following git repository from the guix sources file where submodules are included.

{
      "type": "git",
      "git_url": "https://github.com/dimkr/loksh",
      "integrity": "sha256-djjJH+mknmOfleVJhSkCLqCIaELh2gjZZE/xdNZuPtY=",
      "outputHashAlgo": "sha256",
      "outputHashMode": "recursive",
      "git_ref": "7.3"
}

When a submodule is exported, git creates a .git file containing the path to the submodule git data folder. We can check that the nar hash computed by guix by excluding VCS directories is the right one.

anlambert@carnavalet:/tmp$ git clone https://github.com/dimkr/loksh
Cloning into 'loksh'...
remote: Enumerating objects: 817, done.
remote: Counting objects: 100% (116/116), done.
remote: Compressing objects: 100% (61/61), done.
remote: Total 817 (delta 53), reused 98 (delta 38), pack-reused 701
Receiving objects: 100% (817/817), 771.04 KiB | 967.00 KiB/s, done.
Resolving deltas: 100% (531/531), done.

anlambert@carnavalet:/tmp$ cd loksh/

(swh) ✔ /tmp/loksh [master|✔] 
17:33 $ git checkout 7.3 
Note: switching to '7.3'.

(swh) ✔ /tmp/loksh [7.3|✔] 
17:33 $ git submodule init
Submodule 'subprojects/lolibc' (https://github.com/dimkr/lolibc) registered for path 'subprojects/lolibc'

(swh) ✔ /tmp/loksh [7.3|✔] 
17:33 $ git submodule update
Cloning into '/tmp/loksh/subprojects/lolibc'...
Submodule path 'subprojects/lolibc': checked out 'f6e9da78ba0ca66a8711a7e8cc64e418e68eaa00'

(swh) ✔ /tmp/loksh [7.3|✔] 
17:34 $ cat subprojects/lolibc/.git
gitdir: ../../.git/modules/subprojects/lolibc

(swh) ✔ /tmp/loksh [7.3|✔] 
17:33 $ guix hash -x -S nar -f base64 .
djjJH+mknmOfleVJhSkCLqCIaELh2gjZZE/xdNZuPtY=

Prior that MR, the swh nar command was not returning the same hash.

(swh) ✔ /tmp/loksh [7.3|✔] 
17:49 $ swh nar -x -f base64 .
/xgb/b9yzktnwfolnsunczevnoija+ovs5s1hhrlygg=

After that MR, the computed hash matches the one computed by guix.

(swh) ✔ /tmp/loksh [7.3|✔] 
17:53 $ swh nar -x -f base64 .
djjJH+mknmOfleVJhSkCLqCIaELh2gjZZE/xdNZuPtY=

Related to swh-loader-git#4751.

Merge request reports

Loading