RFR: 92: GitRepository::currentBranch fails when on a detached HEAD

Robin Westberg rwestberg at openjdk.java.net
Fri Nov 29 11:27:22 UTC 2019


On Thu, 28 Nov 2019 15:10:50 GMT, Erik Helin <ehelin at openjdk.org> wrote:

> Hi all,
> 
> please review this pull request that makes `git webrev` work when the repository is in a "detached HEAD" state (i.e. there is no active branch). The main part of the change is making `ReadOnlyRepository::currentBranch` return `Optional<Branch>` instead of `Branch`.
> 
> Thanks,
> Erik
> 
> ## Testing
> - [x] `make test` on Linux x64
> - [x] Manually running `git webrev` on a repository with a detached HEAD
> 
> ----------------
> 
> Commits:
>  - 3dc4fea9: 92: GitRepository::currentBranch fails when on a detached HEAD
> 
> Changes: https://git.openjdk.java.net/skara/pull/278/files
>  Webrev: https://webrevs.openjdk.java.net/skara/278/webrev.00
>   Issue: https://bugs.openjdk.java.net/browse/SKARA-92
>   Stats: 40 lines in 8 files changed: 16 ins; 2 del; 22 mod
>   Patch: https://git.openjdk.java.net/skara/pull/278.diff
>   Fetch: git fetch https://git.openjdk.java.net/skara pull/278/head:pull/278

vcs/src/main/java/org/openjdk/skara/vcs/hg/HgRepository.java line 603:

> 602:         var current = currentBranch().orElseThrow(() ->
> 603:                 new IOException("No current branch to rebase upon")
> 604:         );

Should this mention the detached head then as well perhaps?

PR: https://git.openjdk.java.net/skara/pull/278


More information about the skara-dev mailing list