all messages for Guix-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Simon Tournier <zimon.toutoune@gmail.com>
To: 61910@debbugs.gnu.org
Cc: "Ludovic Courtès" <ludo@gnu.org>
Subject: [bug#61910] [PATCH v2] git-download: Apply CR/LF to Git repository from SWH.
Date: Thu,  2 Mar 2023 13:05:46 +0100	[thread overview]
Message-ID: <20230302120546.1074630-1-zimon.toutoune@gmail.com> (raw)
In-Reply-To: <20230302091233.28226-1-ludo@gnu.org>

From: Ludovic Courtès <ludo@gnu.org>

Fixes a bug whereby CR/LF convention would not be applied on Git
repositories retrieved from SWH:

  https://sympa.inria.fr/sympa/arc/swh-devel/2023-03/msg00000.html

Reported by Simon Tournier <simon.tournier@inserm.fr>.
Suggested by Valentin Lorentz <valentin.lorentz@inria.fr>.
Co-authored by Simon Tournier <simon.tournier@inserm.fr>.

* guix/git-download.scm (git-fetch)[build]: Add Git operations conditioned by
.gitattributes on the result from SWH.
---
 guix/git-download.scm | 24 ++++++++++++++++++++++--
 1 file changed, 22 insertions(+), 2 deletions(-)

Hi,

This uses 'flat' as previously but applies some Git commands for fixing CR/LF
when .gitattributes is present or not.  It works on the example hidapi.

I have not tried for other examples.

WDYT?

Cheers,
simon


diff --git a/guix/git-download.scm b/guix/git-download.scm
index a1566bed4d..be0b13615c 100644
--- a/guix/git-download.scm
+++ b/guix/git-download.scm
@@ -1,8 +1,9 @@
 ;;; GNU Guix --- Functional package management for GNU
-;;; Copyright © 2014, 2015, 2016, 2017, 2018, 2019, 2020, 2021 Ludovic Courtès <ludo@gnu.org>
+;;; Copyright © 2014-2021, 2023 Ludovic Courtès <ludo@gnu.org>
 ;;; Copyright © 2017 Mathieu Lirzin <mthl@gnu.org>
 ;;; Copyright © 2017 Christopher Baines <mail@cbaines.net>
 ;;; Copyright © 2020 Jakub Kądziołka <kuba@kadziolka.net>
+;;; Copyright © 2023 Simon Tournier <zimon.toutoune@gmail.com>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -162,8 +163,27 @@ (define recursive?
                      (parameterize ((%verify-swh-certificate? #f))
                        (format (current-error-port)
                                "Trying to download from Software Heritage...~%")
+
                        (swh-download (getenv "git url") (getenv "git commit")
-                                     #$output))))))))
+                                     #$output)
+                       ;; Perform CR/LF conversion if specificied by .gitattributes
+                       (when (find-files "." ".gitattributes")
+                         (invoke #+(file-append git "/bin/git") "-C" #$output
+                                 "init")
+                         (invoke #+(file-append git "/bin/git") "-C" #$output
+                                 "config" "--local" "user.email" "you@example.org")
+                         (invoke #+(file-append git "/bin/git") "-C" #$output
+                                 "config" "--local" "user.name" "Your Name")
+                         (invoke #+(file-append git "/bin/git") "-C" #$output
+                                 "add" ".")
+                         (invoke #+(file-append git "/bin/git") "-C" #$output
+                                 "commit" "-am" "'init'")
+                         (invoke #+(file-append git "/bin/git") "-C" #$output
+                                 "read-tree" "--empty")
+                         (invoke #+(file-append git "/bin/git") "-C" #$output
+                                 "reset" "--hard")
+                         (delete-file-recursively
+                          (string-append #$output "/.git"))))))))))
 
   (mlet %store-monad ((guile (package->derivation guile system)))
     (gexp->derivation (or name "git-checkout") build

base-commit: af95f2d8f98eb2c8c64954bb2fd0b70838899174
-- 
2.38.1





  parent reply	other threads:[~2023-03-02 12:07 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-02  9:12 [bug#61910] [PATCH] git-download: Download a bare Git repository from SWH Ludovic Courtès
2023-03-02 10:30 ` Simon Tournier
2023-03-02 12:05 ` Simon Tournier [this message]
2023-03-02 13:15   ` Ludovic Courtès
2023-03-02 13:50     ` Simon Tournier
2023-03-02 17:42       ` Simon Tournier
2023-03-03 11:12       ` Ludovic Courtès
2023-03-03 13:27         ` bug#61910: " Ludovic Courtès
2023-03-03 18:52           ` [bug#61910] " Simon Tournier

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230302120546.1074630-1-zimon.toutoune@gmail.com \
    --to=zimon.toutoune@gmail.com \
    --cc=61910@debbugs.gnu.org \
    --cc=ludo@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/guix.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.