[bug#66171,v2] gnu: git: Install shell completions.
Commit Message
* 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
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.
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
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.
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.
@@ -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"))