Skip to content

fetch --prune resulting in a dangling HEAD #962

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

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

fetch --prune resulting in a dangling HEAD #962

kenodegard opened this issue Nov 25, 2019 · 1 comment

Comments

@kenodegard
Copy link
Contributor

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 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.

simu added a commit to projectsyn/commodore that referenced this issue Jul 14, 2022
…es necessary

GitPython's fetch-info parsing chokes on lines like

```
   (refs/remotes/origin/HEAD has become dangling)"
```

We handle this case by simply performing a second fetch which should
return fetch-infos with flags = 4 (HEAD_UPTODATE).

See also gitpython-developers/GitPython#962.
simu added a commit to projectsyn/commodore that referenced this issue Jul 15, 2022
…es necessary

GitPython's fetch-info parsing chokes on lines like

```
   (refs/remotes/origin/HEAD has become dangling)"
```

We handle this case by simply performing a second fetch which should
return fetch-infos with flags = 4 (HEAD_UPTODATE).

See also gitpython-developers/GitPython#962.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

2 participants