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

Shell gets stuck in a loop if private git repo and using https without authentication #76

Closed
pgilad opened this issue Jun 23, 2014 · 21 comments
Labels

Comments

@pgilad
Copy link

pgilad commented Jun 23, 2014

Steps to reproduce:

  1. Use a git with https and no authentication (or cache of authentication)
  2. Be in a private git repo. (where authentication is required for read)

Shell then asks for git username, but anything you enter is evaluated as a zsh command, meaning you can't even try to actually login.

I think that the solution would be to detect if user doesn't have read permissions in a git repo - and then don't try to async evaluate remote git status (for git pull/push).

Hope that makes sense... Ran into this issue in several colleagues workspace where they used https in private repos.

@pgilad pgilad changed the title Shell gets stuck in a loop if in a git repo and using https without authentication Shell gets stuck in a loop if private git repo and using https without authentication Jun 23, 2014
@sindresorhus
Copy link
Owner

Yeah, that makes sense. Any idea how to detect that?

@pgilad
Copy link
Author

pgilad commented Jun 23, 2014

I'm currently looking into it... It seems one needs to play with git ls-remote in order to detect read access to a repo. Still learning...

The problematic line is git fetch btw...

edit - just updating that I currently didn't find any workable solution for this (except for caching credentials or switching to a git:// or not using private repos)

@MoOx
Copy link
Contributor

MoOx commented Jul 23, 2014

Just got this issue as well.

What about using github api (without auth) to detect if a repo is private (cause without auth you will be able to just see public repo) & use a cache somewhere to save this ?

As a workaround, to avoid loop, when username is prompted I just use a git pull to get an real prompt.

@stephen304
Copy link

Using github api would only work when the repo is github. I have lots of repos scattered about on bitbucket, gitlab, and my uni's enterprise github. This serverfault question suggests redirectiong the stdout somehow, not sure if it helps:

http://serverfault.com/questions/544156/git-clone-fail-instead-of-prompting-for-credentials

@fregante
Copy link

I'm not sure if it's the same issue, but when git expects input, I get a prompt I can't answer:

screen shot 2015-01-23 at 16 28 52

screen shot 2015-01-23 at 16 29 52

Anything you type is considered a normal command, it doesn't answer the prompt.

I solved the issues by causing those prompts separately (e.g. git pull) but it was confusing for a bit

@sindresorhus
Copy link
Owner

Not going to make it GitHub specific.

Pure is already running non-interactively so nothing should be prompted. Happy to receive a PR with a fix but I have no idea how to fix this.

@MoOx
Copy link
Contributor

MoOx commented Jan 26, 2015

Maybe a comment in a FAQ section in the README is a start :) (quick fix: type git pull to auth)

@sindresorhus
Copy link
Owner

@MoOx Sure, if you care enough to do a PR.

@sindresorhus
Copy link
Owner

This has been fixed in git 2.3 :D

See: f43ab97

@MoOx
Copy link
Contributor

MoOx commented Feb 6, 2015

Very nice.

@fkirkholt
Copy link

I still get this error on my Mac with git version 2.3.5.

@madeleinedaly
Copy link

Same here, running pure prompt 0.5.1 on Yosemite with git 2.3.5.

@mafredri
Copy link
Collaborator

mafredri commented May 5, 2015

@fkirkholt @dalymatthew are you sure you aren't resetting the GIT_TERMINAL_PROMPT environment variable after pure has been initialized? Mind checking

echo $GIT_TERMINAL_PROMPT

?

@madeleinedaly
Copy link

~
λ echo $GIT_TERMINAL_PROMPT
0

My ~/.zshrc and ~/.zshrc.local are just stock grml, apart from the following in the latter:

autoload -U promptinit && promptinit
PURE_PROMPT_SYMBOL=λ
prompt pure

I double-checked and GIT_TERMINAL_PROMPT isn't getting reset anywhere.

@mafredri
Copy link
Collaborator

mafredri commented May 5, 2015

Well, then I'm out of ideas. Unable to reproduce.

@neonstalwart
Copy link

by running the commands in pure.zsh one at a time i found this one to be the one which prompts:

> command git -c gc.auto=0 fetch &>/dev/null

is it a git bug?

@mafredri
Copy link
Collaborator

mafredri commented May 5, 2015

@neonstalwart either command git --version is < 2.3 or GIT_TERMINAL_PROMPT is not set to zero. Besides that, &>/dev/null is supposed to swallow all output, so no clue.

@neonstalwart
Copy link

@mafredri git version is 2.4 and GIT_TERMINAL_PROMPT is 0 - with that exact command above i see a prompt for a password. i'm trying to make sense of it.

@mafredri
Copy link
Collaborator

mafredri commented May 5, 2015

Tried upgrading to 2.4.0, still cannot reproduce:

❯ GIT_TERMINAL_PROMPT=0 command git -c gc.auto=0 fetch
fatal: could not read Password for 'https://[email protected]': terminal prompts disabled

@neonstalwart
Copy link

so, in my case it was ssh which was prompting for the password. my remote is actually [email protected]:path/to/repo.git

> GIT_TRACE=true GIT_TERMINAL_PROMPT=0 command git -c gc.auto=0 fetch
11:54:32.597755 git.c:348               trace: built-in: git 'fetch'
11:54:32.600003 run-command.c:347       trace: run_command: 'ssh' '[email protected]' 'git-upload-pack '\''path/to/repo.git'\'''
Password:

updated ~/.ssh/config with the following and it stops prompting now

Host git.XXXXX.com
    KbdInteractiveAuthentication no
    ChallengeResponseAuthentication no
    PasswordAuthentication no

@ghost
Copy link

ghost commented Mar 14, 2016

I am not sure if this is exactly the same issue (or whether this is even fixed for everyone), but I was having a similar problem while running a git clone. This is how I fixed it:

set -x GIT_ASKPASS /bin/echo

which translated to bash gives

export GIT_ASKPASS=/bin/echo

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

No branches or pull requests

9 participants