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

Occasionally can't git pull when switching branches #283

Closed
1 of 2 tasks
Hilzu opened this issue Feb 3, 2017 · 5 comments
Closed
1 of 2 tasks

Occasionally can't git pull when switching branches #283

Hilzu opened this issue Feb 3, 2017 · 5 comments

Comments

@Hilzu
Copy link

Hilzu commented Feb 3, 2017

General information

  • Pure version: 1.5.0
  • ZSH version: 5.3.1 (x86_64-apple-darwin16.3.0)
  • Terminal program & version: iTerm2 3.0.13
  • Operating system: macOS Sierra 10.12.3
  • ZSH framework: none

I have:

  • Tested with another terminal program and can reproduce the issue: Terminal.app
  • Followed the Integration instructions for my framework

Problem description

Occasionally when switching branches and immediately trying to git pull the command fails. It's most likely caused by the async git functionality trying to fetch changes at the same time.

Reproduction steps

~/code/stuff branch*
❯ g co master
Switched to branch 'master'
Your branch is behind 'origin/master' by 3 commits, and can be fast-forwarded.
  (use "git pull" to update your local branch)

~/code/stuff master* ⇣
❯ g pl
fatal: Cannot rebase onto multiple branches.

~/code/stuff master* ⇣
❯ g pl
First, rewinding head to replay your work on top of it...
Fast-forwarded master to ed79db49234bda7334cfcd6a2c1dc1c4983b502e.

My .zshrc:

autoload -U promptinit; promptinit
prompt pure

alias g=git
@mafredri
Copy link
Collaborator

mafredri commented Feb 3, 2017

Yikes, that's annoying. Is there any more information you can provide me, e.g. related git configuration (pull.rebase comes to mind, perhaps others?), repository size, etc?

I've not encountered this myself, but I'll see if I can reproduce.

@Hilzu
Copy link
Author

Hilzu commented Feb 3, 2017

In git I have pull.rebase and rebase.autostash enabled. co is a git alias for checkout and pl is pull. git version is 2.11.0.

The repository where I keep getting that isn't huge. The folder is 156M with 1080 commits.

@mafredri
Copy link
Collaborator

mafredri commented Feb 4, 2017

Thanks for the extra info, now, I haven't gotten around to reproducing this yet, but I have an idea as to what might be the cause.

In pure.zsh#L84 we check if the user executed git pull or fetch (explicitly) and cancel async tasks if the command matches one of those.

At this point the zsh alias is already expanded (so we know g = git), however pure does not know of git aliases (e.g. pl =pull).

Can you still reproduce if you change (pull|fetch) to (pl|pull|fetch)?

@Hilzu
Copy link
Author

Hilzu commented Feb 9, 2017

After testing it for a while the change seems to fix the problem.

I guess the easiest fix for me would be to define pl as a zsh alias instead of a git alias. Too bad there doesn't seem to be a way to define g pl as the alias (with the space) for symmetry with the rest of my git aliases.

@mafredri
Copy link
Collaborator

mafredri commented Feb 9, 2017

Thanks for confirming, @Hilzu. I actually have an idea on how we can fix this issue for you and anyone else in your situation.

The fix involves us parsing the git aliases once whenever we enter a new git directory via git config --get-regexp "^alias\." and looking for pull/fetch aliases. From this we could then construct a custom pattern instead of just (pull|fetch).

mafredri added a commit that referenced this issue Feb 10, 2017
sindresorhus pushed a commit that referenced this issue Feb 17, 2017
* Parse git aliases for better pull/fetch detection

Fixes #283.

* Only perform check when pattern is valid

If `prompt_pure_git_fetch_pattern` is unset, the pattern is invalid.
This did not produce errors on my machine, even when not guarding
against this case, but better safe than sorry.
kutsan pushed a commit to kutsan/pure that referenced this issue Jun 19, 2023
* Parse git aliases for better pull/fetch detection

Fixes sindresorhus#283.

* Only perform check when pattern is valid

If `prompt_pure_git_fetch_pattern` is unset, the pattern is invalid.
This did not produce errors on my machine, even when not guarding
against this case, but better safe than sorry.
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

No branches or pull requests

2 participants