From 0e95bed017fa61e04e516974e177f5056a45b19f Mon Sep 17 00:00:00 2001 From: Will Dietz Date: Wed, 24 Jan 2018 09:02:55 -0600 Subject: 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) --- pkgs/build-support/fetchgit/nix-prefetch-git | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'pkgs/build-support/fetchgit/nix-prefetch-git') 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 | -- cgit 1.4.1