Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tig: fix tig-completion's dependency on __git_complete #85218

Merged
merged 1 commit into from Apr 15, 2020
Merged

tig: fix tig-completion's dependency on __git_complete #85218

merged 1 commit into from Apr 15, 2020

Conversation

megheaiulian
Copy link
Contributor

@megheaiulian megheaiulian commented Apr 14, 2020

Motivation for this change

tig recently updated it's bash-completion making it depend on __git-complete from git.
Becase __git-complete is not automatically sourced tig bash completion fails.
Also this PR makes tig completion load on-demand.

Things done
  • Tested using sandboxing (nix.useSandbox on NixOS, or option sandbox in nix.conf on non-NixOS linux)
  • Built on platform(s)
    • NixOS
    • macOS
    • other Linux distributions
  • Tested via one or more NixOS test(s) if existing and applicable for the change (look inside nixos/tests)
  • Tested compilation of all pkgs that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review wip"
  • Tested execution of all binary files (usually in ./result/bin/)
  • Determined the impact on package closure size (by running nix path-info -S before and after)
  • Ensured that relevant documentation is up to date
  • Fits CONTRIBUTING.md.

Copy link
Contributor

@bjornfor bjornfor left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: please add PR info in commit message. It's valuable info!

tig recently updated it's bash-completion making it depend on __git-complete from git.
Becase __git-complete is not automatically sourced tig bash completion fails.
Also this PR makes tig completion load on-demand.
@bjornfor bjornfor merged commit f57da8e into NixOS:master Apr 15, 2020
@bjornfor
Copy link
Contributor

Thanks!

@Ma27
Copy link
Member

Ma27 commented Apr 15, 2020

Ohh thanks a lot! Since this issue also exists on release-20.03 I backported your patch as a438aed.

@Ma27 Ma27 added the 8.has: port to stable A PR already has a backport to the stable release. label Apr 15, 2020
@megheaiulian megheaiulian deleted the fix-tig branch April 16, 2020 06:40
@smancill
Copy link
Contributor

This PR didn't fix Zsh completion, which still complains with:

$ tig -- WARNING: this script is deprecated, please see git-completion.zsh
/nix/store/g92x5762p69g82fwx722gfqf15n4x0rr-tig-2.5.1/share/bash-completion/completions/tig:99: command not found: __git_complete

When using Zsh, git-completion.bash needs to be sourced by tig-completion.zsh with GIT_SOURCING_ZSH_COMPLETION=y.

A better patch would be not to source Git completion from tig-completion.bash when the shell is Zsh

+ # fixes tig-completion __git-complete dependency
+ sed -i '1s;^;[[ -z $ZSH_VERSION ]] && source ${git}/share/bash-completion/completions/git\n;' contrib/tig-completion.bash
+

And substitute git-completion.bash also in tig-completion.zsh (which this PR missed), so it can be source properly from tig-completion.zsh instead of using the patched source command at the top of tig-completion.bash.

     substituteInPlace contrib/tig-completion.zsh \
-      --replace 'e=$(dirname ''${funcsourcetrace[1]%:*})/tig-completion.bash' "e=$out/etc/bash_completion.d/tig-completion.bash"
+      --replace 'e=$(dirname ''${funcsourcetrace[1]%:*})/tig-completion.bash' "e=$out/share/bash-completion/completions/tig" \
+      --replace 'e=$(dirname ''${funcsourcetrace[1]%:*})/git-completion.bash' 'e=${git}/share/bash-completion/completions/git'

Not sure if the syntax is right (I just edited the files manually), but the point is clear I think. Both tig-completion.bash and git-completion.bash should be replaced in tig-completion.zsh.

I have no idea how to setup Nix to create and test the patch, that's why I am commenting here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
8.has: port to stable A PR already has a backport to the stable release. 10.rebuild-darwin: 1-10 10.rebuild-linux: 1-10
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants