Subject: Re: bug#61910: [PATCH] git-download: Download a bare Git repository from SWH.

From: Ludovic Courtès <[email-masked]>
Date: Thu, 02 Mar 2023 14:15:05 +0100

Hello!

Simon Tournier <[email-masked]> skribis:

[...]

>                         (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" "[email-masked]")
> +                         (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"))))))))))

This is much better than fetching the whole repo, well done!

Should we replace (find-files …) with (file-exists? ".gitattributes")?

I wonder if we could achieve the same without creating a repo just to
delete it afterwards, either by invoking a low-level ‘git’ command it if
exists, or using Guile-Git, or doing it ourselves in Scheme.

WDYT?

Thanks,
Ludo’.