diff options
author | Will Dietz <w@wdtz.org> | 2018-01-24 09:02:55 -0600 |
---|---|---|
committer | Tuomas Tynkkynen <tuomas.tynkkynen@iki.fi> | 2018-01-24 20:18:59 +0200 |
commit | 0e95bed017fa61e04e516974e177f5056a45b19f (patch) | |
tree | 9d1a3af1b57fcc2c252c831775df7c911d34a643 /pkgs | |
parent | bb7e2445316aa585a2d8f71f0c64bc900f51ca0c (diff) |
nix-prefetch-git: fix extraction of submodule hashes on latest git
Summary:
According to git-submodule manpage,
"git submodule status" prefixes the hash with a '-' if it is not
initialized, and other chars in other circumstances.
(this is consistent on the various git versions tested)
nix-prefetch-git runs "git submodule init" which does you'd think,
but apparently despite this earlier versions of git before 2.16
would still give the hash the '-' suffix.
In particular this is the behavior when using 2.15 and 2.14.1
from the nixos-17.09 and nixos-17.03 channels respectively.
The script then used awk to drop the first char of the first field
which does the wrong thing when there is no prefix emitted:
while there is a space character before the hash, this is not
part of the field and so we ended up eating the first character
of the hash.
To fix this in a way that also works with the previous behavior,
this commit instead uses awk to grab the hash field
and uses tr to delete any '-' chars should they be present.
This seems to work in my testing, and for example can now
successfully fetch the source for "nginxModules.brotli"
where previously it would generate an error:
fatal: '22564a95d9ab58865a096b8d9f7324ea5f2e03e' is not a commit and a branch 'fetchgit' cannot be created from it
(we dropped a '2' from the beginning of the hash)
Diffstat (limited to 'pkgs')
-rwxr-xr-x | pkgs/build-support/fetchgit/nix-prefetch-git | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/pkgs/build-support/fetchgit/nix-prefetch-git b/pkgs/build-support/fetchgit/nix-prefetch-git index 17962d08acc3..2441da156d1a 100755 --- a/pkgs/build-support/fetchgit/nix-prefetch-git +++ b/pkgs/build-support/fetchgit/nix-prefetch-git @@ -184,7 +184,7 @@ init_submodules(){ local url # checkout each submodule - hash=$(echo "$l" | awk '{print substr($1,2)}') + hash=$(echo "$l" | awk '{print $1}' | tr -d '-') dir=$(echo "$l" | awk '{print $2}') name=$( git config -f .gitmodules --get-regexp submodule\..*\.path | |