From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46854) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1elkPj-0001eR-Rf for guix-patches@gnu.org; Tue, 13 Feb 2018 18:55:08 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1elkPe-00021U-UK for guix-patches@gnu.org; Tue, 13 Feb 2018 18:55:07 -0500 Received: from debbugs.gnu.org ([208.118.235.43]:34049) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1elkPe-00021F-Qt for guix-patches@gnu.org; Tue, 13 Feb 2018 18:55:02 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1elkPe-0007f9-HL for guix-patches@gnu.org; Tue, 13 Feb 2018 18:55:02 -0500 Subject: [bug#30450] [PATCH] git-download: Fetch only the required commit, if possible. Resent-Message-ID: Received: from eggs.gnu.org ([2001:4830:134:3::10]:46700) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1elkP8-0001LC-BB for guix-patches@gnu.org; Tue, 13 Feb 2018 18:54:31 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1elkP3-0001h0-G6 for guix-patches@gnu.org; Tue, 13 Feb 2018 18:54:30 -0500 Received: from dd26836.kasserver.com ([85.13.145.193]:36120) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1elkP3-0001ft-8I for guix-patches@gnu.org; Tue, 13 Feb 2018 18:54:25 -0500 From: Danny Milosavljevic Date: Wed, 14 Feb 2018 00:54:01 +0100 Message-Id: <20180213235401.18358-1-dannym@scratchpost.org> List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+kyle=kyleam.com@gnu.org Sender: "Guix-patches" To: 30450@debbugs.gnu.org * guix/build/git.scm (git-fetch): Fetch only the required commit, if possible. --- guix/build/git.scm | 43 +++++++++++++++++++++++-------------------- 1 file changed, 23 insertions(+), 20 deletions(-) diff --git a/guix/build/git.scm b/guix/build/git.scm index c1af545a7..14d415a6f 100644 --- a/guix/build/git.scm +++ b/guix/build/git.scm @@ -37,28 +37,31 @@ recursively. Return #t on success, #f otherwise." ;; in advance anyway. (setenv "GIT_SSL_NO_VERIFY" "true") - ;; We cannot use "git clone --recursive" since the following "git checkout" - ;; effectively removes sub-module checkouts as of Git 2.6.3. - (and (zero? (system* git-command "clone" url directory)) - (with-directory-excursion directory - (system* git-command "tag" "-l") - (and (zero? (system* git-command "checkout" commit)) - (begin - (when recursive? - ;; Now is the time to fetch sub-modules. - (unless (zero? (system* git-command "submodule" "update" + (mkdir-p directory) + + (with-directory-excursion directory + (invoke git-command "init") + (invoke git-command "remote" "add" "origin" url) + (if (zero? (system* git-command "fetch" "--depth" "1" "origin" commit)) + (invoke git-command "checkout" "FETCH_HEAD") + (begin + (invoke git-command "fetch" "origin") + (invoke git-command "checkout" commit))) + (when recursive? + ;; Now is the time to fetch sub-modules. + (unless (zero? (system* git-command "submodule" "update" "--init" "--recursive")) - (error "failed to fetch sub-modules" url)) + (error "failed to fetch sub-modules" url)) - ;; In sub-modules, '.git' is a flat file, not a directory, - ;; so we can use 'find-files' here. - (for-each delete-file-recursively - (find-files directory "^\\.git$"))) + ;; In sub-modules, '.git' is a flat file, not a directory, + ;; so we can use 'find-files' here. + (for-each delete-file-recursively + (find-files directory "^\\.git$"))) - ;; The contents of '.git' vary as a function of the current - ;; status of the Git repo. Since we want a fixed output, this - ;; directory needs to be taken out. - (delete-file-recursively ".git") - #t))))) + ;; The contents of '.git' vary as a function of the current + ;; status of the Git repo. Since we want a fixed output, this + ;; directory needs to be taken out. + (delete-file-recursively ".git") + #t)) ;;; git.scm ends here