From f98bc23805c5956314f0c0359794225a2557088f Mon Sep 17 00:00:00 2001 From: Guillaume Girol Date: Thu, 22 Jul 2021 16:18:10 +0000 Subject: [PATCH] nix-gitignore: fix evaluation when .gitignore contains \# or \! (#130643) --- pkgs/build-support/nix-gitignore/default.nix | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/pkgs/build-support/nix-gitignore/default.nix b/pkgs/build-support/nix-gitignore/default.nix index 5d7b945bf1b..497dcb0660b 100644 --- a/pkgs/build-support/nix-gitignore/default.nix +++ b/pkgs/build-support/nix-gitignore/default.nix @@ -41,6 +41,9 @@ in rec { let split = match "^(!?)(.*)" l; in [(elemAt split 1) (head split == "!")]; + # regex -> regex + handleHashesBangs = replaceStrings ["\\#" "\\!"] ["#" "!"]; + # ignore -> regex substWildcards = let @@ -86,7 +89,7 @@ in rec { mapPat = f: l: [(f (head l)) (last l)]; in map (l: # `l' for "line" - mapPat (l: handleSlashSuffix (handleSlashPrefix (mapAroundCharclass substWildcards l))) + mapPat (l: handleSlashSuffix (handleSlashPrefix (handleHashesBangs (mapAroundCharclass substWildcards l)))) (computeNegation l)) (filter (l: !isList l && !isComment l) (split "\n" gitignore));