[PATCH] git-download: Fetch only the required commit, if possible.

  • Done
  • quality assurance status badge
Details
One participant
  • Danny Milosavljevic
Owner
unassigned
Submitted by
Danny Milosavljevic
Severity
normal

Debbugs page

Danny Milosavljevic wrote 7 years ago
(address . guix-patches@gnu.org)(name . Danny Milosavljevic)(address . dannym@scratchpost.org)
20180213235401.18358-1-dannym@scratchpost.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(-)

Toggle diff (56 lines)
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
Danny Milosavljevic wrote 7 years ago
(no subject)
(address . control@debbugs.gnu.org)
20180304175237.2f8a7a7a@scratchpost.org
close 30450
close 30050
-----BEGIN PGP SIGNATURE-----

iQEzBAEBCAAdFiEEds7GsXJ0tGXALbPZ5xo1VCwwuqUFAlqcJFUACgkQ5xo1VCww
uqUovAf/XUKLwDbHTLpj+CtYAaZxUHfpJDMCbEVuiCn0ORbEhD4A6RBaJMDL5tKf
SV7xK0MIGrf/VSdn4pVQAKPDMXufU949Ahu+tCXdZ5uYeUmfZZSV7I4vfazqe5f9
OVVYVAgZd0O8WcS3umDUjHW8S819otM4vkt0/QqYMbpxkLJPyBMo+Y7RHfFJOM3W
oGZEnEKljYETRnL1clZiTJ/aFh6PZTRgKdjytVFP3f+TtufUlToA1ygueEqxrRbj
pJtE5y82GIFyiYBomVUmNw6sW/gzEKHqTBko4VFlbv4847s3atfEqZAF7udndLtm
sUY3FfZdOMH249vsQbeC7waR+oP0+A==
=oDsG
-----END PGP SIGNATURE-----


?
Your comment

This issue is archived.

To comment on this conversation send an email to 30450@debbugs.gnu.org

To respond to this issue using the mumi CLI, first switch to it
mumi current 30450
Then, you may apply the latest patchset in this issue (with sign off)
mumi am -- -s
Or, compose a reply to this issue
mumi compose
Or, send patches to this issue
mumi send-email *.patch
You may also tag this issue. See list of standard tags. For example, to set the confirmed and easy tags
mumi command -t +confirmed -t +easy
Or, remove the moreinfo tag and set the help tag
mumi command -t -moreinfo -t +help