From 85d8b016600925791cbf970f69873dfac1f781cb Mon Sep 17 00:00:00 2001
From: Eric Sagnes <eric.sagnes@gmail.com>
Date: Sun, 31 Jul 2016 21:58:54 +0900
Subject: [PATCH] lib: refactor commitIdFromGitRepo with fileContents

---
 lib/sources.nix | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/lib/sources.nix b/lib/sources.nix
index 535b04523b57..c1ec02b9c26c 100644
--- a/lib/sources.nix
+++ b/lib/sources.nix
@@ -44,12 +44,12 @@ rec {
             packedRefsName = toString path + "/packed-refs";
         in if lib.pathExists fileName
            then
-             let fileContent = readFile fileName;
+             let fileContent = lib.fileContents fileName;
                  # Sometimes git stores the commitId directly in the file but
                  # sometimes it stores something like: «ref: refs/heads/branch-name»
-                 matchRef    = match "^ref: (.*)\n$" fileContent;
+                 matchRef    = match "^ref: (.*)$" fileContent;
              in if   isNull matchRef
-                then lib.removeSuffix "\n" fileContent
+                then fileContent
                 else readCommitFromFile path (lib.head matchRef)
            # Sometimes, the file isn't there at all and has been packed away in the
            # packed-refs file, so we have to grep through it: