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

fetch --prune resulting in a dangling HEAD #962

Open
njalerikson opened this issue Nov 25, 2019 · 1 comment
Open

fetch --prune resulting in a dangling HEAD #962

njalerikson opened this issue Nov 25, 2019 · 1 comment

Comments

@njalerikson
Copy link
Contributor

@njalerikson njalerikson commented Nov 25, 2019

Fetch prune fails if HEAD ends up dangling. Given that the message appears more warning like in nature, as opposed to an error, should GitPython handle this/ignore it?

To reproduce with pure git:

git clone <some-repo>
# delete master branch from remote
git fetch --prune -v origin

The fetch returns something like this:

From ...
 * [new branch]      production -> origin/production
 x [deleted]         (none)     -> origin/master
   (refs/remotes/origin/HEAD has become dangling)

GitPython crashes here as it parses the FetchInfo:

GitPython/git/remote.py

Lines 290 to 292 in 85cf7e8

match = cls._re_fetch_result.match(line)
if match is None:
raise ValueError("Failed to parse line: %r" % line)

Should dangling just be ignored in general or should there be an option to ignore_dangling?

@Byron
Copy link
Member

@Byron Byron commented Dec 8, 2019

Thanks for making the issue so easy to follow!
Currently GitPython seems to be taking the stance of rejecting anything it does’t know, which seems like a dangerous choice when being dependent on another ever changing command-line program.

In order not to break code which might rely on this particular behaviour though, I would certainly prefer adding an option like ignore_dangling and default it to false even though defaulting it to true would probably be easier to use for most.

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

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.