diff mbox series

[bug#66171,v2] gnu: git: Install shell completions.

Message ID 7be0975a4d30362dec08c3115e68c992e58ab549.1695660890.git.liliana.prikler@gmail.com
State New
Headers show
Series [bug#66171,v2] gnu: git: Install shell completions. | expand

Commit Message

Liliana Marie Prikler Sept. 23, 2023, 7:43 p.m. UTC
* gnu/packages/version-control.scm (git)[outputs]: Add “completion”.
[#:phases]: Add ‘install-completion’.
(git-minimal)[#:phases]: Adjust accordingly.
---
Am Montag, dem 25.09.2023 um 13:12 +0200 schrieb Simon Tournier:
> Naive question: this also adds “completion” to git-minimal, no?  I mean,
> does the phase need to be deleted in git-minimal?
Indeed it does; updated the patch accordingly.

Cheers

 gnu/packages/version-control.scm | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)


base-commit: e134686cead6db62ea8b941b2ed7c0bd660804da

Comments

Maxim Cournoyer Sept. 25, 2023, 5:51 p.m. UTC | #1
Hello,

Liliana Marie Prikler <liliana.prikler@gmail.com> writes:

> * gnu/packages/version-control.scm (git)[outputs]: Add “completion”.
> [#:phases]: Add ‘install-completion’.
> (git-minimal)[#:phases]: Adjust accordingly.

Did something change in git?  I've always had completion in git, so I'm
not sure what this extra phase does, or when it's useful?  Does it add
*extra* completion or... ?

Also, a completion output seems a bit over the top.  I doubt its weigh
justifies the annoyance of special casing it.
Liliana Marie Prikler Sept. 25, 2023, 6:41 p.m. UTC | #2
Am Montag, dem 25.09.2023 um 13:51 -0400 schrieb Maxim Cournoyer:
> Hello,
> 
> Liliana Marie Prikler <liliana.prikler@gmail.com> writes:
> 
> > * gnu/packages/version-control.scm (git)[outputs]: Add
> > “completion”.
> > [#:phases]: Add ‘install-completion’.
> > (git-minimal)[#:phases]: Adjust accordingly.
> 
> Did something change in git?  I've always had completion in git, so
> I'm not sure what this extra phase does, or when it's useful?  Does
> it add *extra* completion or... ?
Which shell are you using?  If it's zsh, then the completion is baked
in.  If it's bash, idk, I haven't tried.  I personally use this for the
included git-prompt, which allows me to have my prompt look like the
following:

  \u@\h /path/to/guix [$branch env] ($SHLVL) \$

> Also, a completion output seems a bit over the top.  I doubt its
> weigh justifies the annoyance of special casing it.
I special-cased it because it *is* a contrib script, but also as it
might be able to conflict with whatever shell builtins you have.  Now
it isn't particularly likely to do so given that other distros include
it as part of their git-core, but I prefer safe over sorry.

That being said, I could just write it to out if you prefer that.

Cheers
Maxim Cournoyer Sept. 26, 2023, 4:36 p.m. UTC | #3
Hi,

Liliana Marie Prikler <liliana.prikler@gmail.com> writes:

> Am Montag, dem 25.09.2023 um 13:51 -0400 schrieb Maxim Cournoyer:
>> Hello,
>> 
>> Liliana Marie Prikler <liliana.prikler@gmail.com> writes:
>> 
>> > * gnu/packages/version-control.scm (git)[outputs]: Add
>> > “completion”.
>> > [#:phases]: Add ‘install-completion’.
>> > (git-minimal)[#:phases]: Adjust accordingly.
>> 
>> Did something change in git?  I've always had completion in git, so
>> I'm not sure what this extra phase does, or when it's useful?  Does
>> it add *extra* completion or... ?
> Which shell are you using?  If it's zsh, then the completion is baked
> in.  If it's bash, idk, I haven't tried.  I personally use this for the
> included git-prompt, which allows me to have my prompt look like the
> following:
>
>   \u@\h /path/to/guix [$branch env] ($SHLVL) \$

I see.  I use Bash.

>
>> Also, a completion output seems a bit over the top.  I doubt its
>> weigh justifies the annoyance of special casing it.
> I special-cased it because it *is* a contrib script, but also as it
> might be able to conflict with whatever shell builtins you have.  Now
> it isn't particularly likely to do so given that other distros include
> it as part of their git-core, but I prefer safe over sorry.

Ah, if it's just a contrib I guess a dedicated output is fine, although
i'd perhaps call such output 'contrib', as completions seem to imply
that without it there are no auto-completion support, which is clearly
not the case, at least for Bash.
Efraim Flashner Sept. 28, 2023, 2:41 p.m. UTC | #4
On Mon, Sep 25, 2023 at 08:41:05PM +0200, Liliana Marie Prikler wrote:
> Am Montag, dem 25.09.2023 um 13:51 -0400 schrieb Maxim Cournoyer:
> > Hello,
> > 
> > Liliana Marie Prikler <liliana.prikler@gmail.com> writes:
> > 
> > > * gnu/packages/version-control.scm (git)[outputs]: Add
> > > “completion”.
> > > [#:phases]: Add ‘install-completion’.
> > > (git-minimal)[#:phases]: Adjust accordingly.
> > 
> > Did something change in git?  I've always had completion in git, so
> > I'm not sure what this extra phase does, or when it's useful?  Does
> > it add *extra* completion or... ?
> Which shell are you using?  If it's zsh, then the completion is baked
> in.  If it's bash, idk, I haven't tried.  I personally use this for the
> included git-prompt, which allows me to have my prompt look like the
> following:
> 
>   \u@\h /path/to/guix [$branch env] ($SHLVL) \$

/gnu/store/p7zln1rzsccq8vgpnrm4ibz5hcgxrqd9-git-2.41.0/etc/bash_completion.d/git
It looks like there is a bash completion from git. I thought maybe it
was from the bash-completions package.
diff mbox series

Patch

diff --git a/gnu/packages/version-control.scm b/gnu/packages/version-control.scm
index 9716a6f27a..35d17d434e 100644
--- a/gnu/packages/version-control.scm
+++ b/gnu/packages/version-control.scm
@@ -303,6 +303,7 @@  (define-public git
                "credential-netrc"       ; git-credential-netrc
                "credential-libsecret"   ; git-credential-libsecret
                "subtree"                ; git-subtree
+               "completion"             ; git-completion and git-prompt
                "gui"))                  ; gitk, git gui
     (arguments
      `(#:make-flags `("V=1"             ;more verbose compilation
@@ -482,6 +483,20 @@  (define-public git
                              (string-append subtree "/bin"))
                (install-file "contrib/subtree/git-subtree.1"
                              (string-append subtree "/share/man/man1")))))
+         (add-after 'install 'install-completion
+           (lambda* (#:key outputs #:allow-other-keys)
+             (let ((completion (assoc-ref outputs "completion")))
+               (define (install-as file storename)
+                 (let ((storename (string-append completion storename)))
+                   (mkdir-p (dirname storename))
+                   (copy-file file storename)))
+               (with-directory-excursion "contrib/completion"
+                 (for-each (cut apply install-as <>)
+                           `(("git-prompt.sh" "/bin/git-prompt")
+                             ("git-completion.bash"
+                              "/share/bash-completion/completions/_git")
+                             ("git-completion.zsh"
+                              "/share/zsh/site-functions/_git")))))))
          (add-after 'install 'restore-sample-hooks-shebang
            (lambda* (#:key outputs #:allow-other-keys)
              (let* ((out (assoc-ref outputs "out"))
@@ -639,6 +654,7 @@  (define-public git-minimal
             (delete 'install-subtree)
             (delete 'install-credential-netrc)
             (delete 'install-credential-libsecret)
+            (delete 'install-completion)
             (add-after 'install 'remove-unusable-perl-commands
               (lambda* (#:key outputs #:allow-other-keys)
                 (let* ((out     (assoc-ref outputs "out"))