Skip to content

contrib/completion: use __git() in bash completor to avoid aliased tools #282

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

zaquestion
Copy link

@zaquestion zaquestion commented Jul 2, 2019

For users who alias git to other tools that wrap git (like lab or hub)
the existing completion script will use these aliased tools. Since
__git exists and is unlikely to be aliased, making it well suited to
ensure the completion script is actually calling git and not an aliased
tool.

For users who alias git to other tools that wrap git (like lab or hub)
the existing completion script will use these aliased tools. Since
`__git` exists and is unlikely to be aliased, making it well suited to
ensure the completion script is actually calling git and not an aliased
tool.

Signed-off-by: Zaq? Wiedmann <[email protected]>
@gitgitgadget
Copy link

gitgitgadget bot commented Jul 2, 2019

Welcome to GitGitGadget

Hi @zaquestion, and welcome to GitGitGadget, the GitHub App to send patch series to the Git mailing list from GitHub Pull Requests.

Please make sure that this Pull Request has a good description, as it will be used as cover letter.

Also, it is a good idea to review the commit messages one last time, as the Git project expects them in a quite specific form:

  • the lines should not exceed 76 columns,
  • the first line should be like a header and typically start with a prefix like "tests:" or "commit:", and
  • the commit messages' body should be describing the "why?" of the change.
  • Finally, the commit messages should end in a Signed-off-by: line matching the commits' author.

It is in general a good idea to await the automated test ("Checks") in this Pull Request before contributing the patches, e.g. to avoid trivial issues such as unportable code.

Contributing the patches

Before you can contribute the patches, your GitHub username needs to be added to the list of permitted users. Any already-permitted user can do that, by adding a PR comment of the form /allow <username>.

Once on the list of permitted usernames, you can contribute the patches to the Git mailing list by adding a PR comment /submit.

After you submit, GitGitGadget will respond with another comment that contains the link to the cover letter mail in the Git mailing list archive. Please make sure to monitor the discussion in that thread and to address comments and suggestions.

If you do not want to subscribe to the Git mailing list just to be able to respond to a mail, you can download the mbox ("raw") file corresponding to the mail you want to reply to from the Git mailing list. If you use GMail, you can upload that raw mbox file via:

curl -g --user "<EMailAddress>:<Password>" --url "imaps://imap.gmail.com/INBOX" -T /path/to/raw.txt

@dscho
Copy link
Member

dscho commented Jul 2, 2019

This seems to break t9902: https://dev.azure.com/gitgitgadget/git/_build/results?buildId=11994&view=ms.vss-test-web.build-test-results-tab

For example:

not ok 9 - __git_find_repo_path - from command line while "git -C"

 expecting success:
     echo "$ROOT/.git" >expected &&
     (
         __git_dir="$ROOT/.git" &&
         __git_C_args=(-C otherrepo) &&
         __git_find_repo_path &&
         echo "$__git_repo_path" >"$actual"
     ) &&
     test_cmp expected "$actual"

++ echo '/home/vsts/work/1/s/t/trash directory.t9902-completion/.git'
++ __git_dir='/home/vsts/work/1/s/t/trash directory.t9902-completion/.git'
++ __git_C_args=(-C otherrepo)
++ __git_find_repo_path
++ '[' -n '' ']'
++ '[' -n -C ']'
+++ __git -C otherrepo '--git-dir=/home/vsts/work/1/s/t/trash directory.t9902-completion/.git' rev-parse --absolute-git-dir
+++ git -C otherrepo '--git-dir=/home/vsts/work/1/s/t/trash directory.t9902-completion/.git' -C otherrepo '--git-dir=/home/vsts/work/1/s/t/trash directory.t9902-completion/.git' rev-parse --absolute-git-dir
++ __git_repo_path=
error: last command exited with $?=128

Any idea what is going on? Does this happen on your machine, too?

@dscho
Copy link
Member

dscho commented Jul 2, 2019

/allow zaquestion

@gitgitgadget
Copy link

gitgitgadget bot commented Jul 2, 2019

User zaquestion is now allowed to use GitGitGadget.

@zaquestion
Copy link
Author

Weird, on my machine (linux) autocomplete works correctly for the cases shown in the tests. I'll dig a little deeper into what the root cause might be.

@zaquestion
Copy link
Author

zaquestion commented Jul 9, 2019

Oh interesting, something between the version of the completion script that these changes were originally based off of ( whats in https://github.com/git/git/pull/536/files ) and the latest version of the script with this changes (this PR) breaks the completion in this case.

Originally tested with the old PR, but was able to reproduce after I sourced this one.

Should be easy enough to track down, hopefully can get that up soon.

@dscho
Copy link
Member

dscho commented Sep 17, 2019

@zaquestion gentle ping?

@zaquestion
Copy link
Author

Haven't forgotten about this, admittedly also haven't had a ton of time to really dive in, but I did a few time and have had some trouble identifying what could be causing the break. Hoping to take a closer look in the next few week now that my schedule is starting to have a bit more room (finally consistently have a day off each week 🎉 )

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants