[Approved] RFR: 92: GitRepository::currentBranch fails when on a detached HEAD

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


On Fri, 29 Nov 2019 09:14:12 GMT, Robin Westberg <rwestberg at openjdk.org> wrote:

> 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
> 
> Looks good! Perhaps the error message could be made a bit more helpful, but not sure what it should say. :)
> 
> cli/src/main/java/org/openjdk/skara/cli/GitPr.java line 523:
> 
>> 522:             var currentBranch = repo.currentBranch().orElseGet(() -> {
>> 523:                     System.err.println("error: the repository is in a detached HEAD state");
>> 524:                     System.exit(1);
> 
> Suggestion:
> 
>                     System.err.println("error: the repository is in a detached HEAD state. check out a branch to continue.. or something");
> 
> ----------------
> 
> Approved by rwestberg (Reviewer).

Sounds good!

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


More information about the skara-dev mailing list