GitPython icon indicating copy to clipboard operation
GitPython copied to clipboard

fetch --prune resulting in a dangling HEAD

Open kenodegard opened this issue 6 years ago • 1 comments

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:

https://github.com/gitpython-developers/GitPython/blob/85cf7e89682d061ea86514c112dfb684af664d45/git/remote.py#L290-L292

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

kenodegard avatar Nov 25 '19 17:11 kenodegard

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.

Byron avatar Dec 08 '19 11:12 Byron