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

Fails when force pushing unrelated histories #2002

Closed
bogusfocused opened this issue Aug 8, 2021 · 5 comments · Fixed by #2005
Closed

Fails when force pushing unrelated histories #2002

bogusfocused opened this issue Aug 8, 2021 · 5 comments · Fixed by #2005
Labels

Comments

@bogusfocused
Copy link

@bogusfocused bogusfocused commented Aug 8, 2021

pre-commit looks to find difference between remote and local branches as pre-commit wants to know the files changed. But in case of force, git correctly fails to generate diff.

Expected: pre-commit can run all the hooks that has pass-filename=false as they do not require diffs.

Thanks for the awesome stuff!

@asottile
Copy link
Member

@asottile asottile commented Aug 8, 2021

I can't reproduce, please provide an example as force pushing is working fine for me

@bogusfocused
Copy link
Author

@bogusfocused bogusfocused commented Aug 9, 2021

The forced push is on unrelated heads and so git cannot get the difference. Below is my output...

git.exe push -v --progress --force "github" master:main
Pushing to https://github.com/bogusfocused/ha_lan_smartthings.git
An unexpected error has occurred: CalledProcessError: command: ('C:\\Program Files\\Git\\mingw64\\libexec\\git-core
\\git.EXE', 'diff', '--name-only', '--no-ext-diff', '-z', 
'8e9e6537d911cbfa8a88aa608c3afa893a340f8c...ced7786cd5098f321b48e9a1027cce4e8938cbbf')
return code: 128
expected return code: 0
stdout: (none)
stderr:
fatal: 8e9e6537d911cbfa8a88aa608c3afa893a340f8c...ced7786cd5098f321b48e9a1027cce4e8938cbbf: no merge base

Check the log at C:\Users\Rohit\.cache\pre-commit\pre-commit.log
error: failed to push some refs to 'https://github.com/bogusfocused/ha_lan_smartthings.git'


git did not exit cleanly (exit code 1) (1672 ms @ 8/9/2021 12:48:56 PM)

@asottile
Copy link
Member

@asottile asottile commented Aug 9, 2021

ah yeah if you're force pushing unrelated histories then that'll happen -- I'm not sure there's much that could be done in that case since it's really "push everything"

@asottile asottile changed the title Fails when forced push Fails when force pushing unrelated histories Aug 9, 2021
@asottile
Copy link
Member

@asottile asottile commented Aug 9, 2021

hmmm actually I still can't reproduce -- what version of git are you using?

@bogusfocused
Copy link
Author

@bogusfocused bogusfocused commented Aug 10, 2021

Thanks. The fix works for me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Linked pull requests

Successfully merging a pull request may close this issue.

2 participants