RFR: 316: git-webrev does not work without origin remote

Erik Helin ehelin at openjdk.java.net
Thu Mar 19 08:34:19 UTC 2020


On Thu, 19 Mar 2020 05:25:20 GMT, Robin Westberg <rwestberg at openjdk.org> wrote:

>> Hi all,
>> 
>> please review this patch that updates `git-webrev` to work with repositories
>> with slightly more unusual configurations by default. `git-webrev` will now by
>> default work with many more repositories that for example have multiple remotes,
>> repositories missing a remote named "origin", etc. For the most complicated
>> scenarios the user can now also specify `--remote` to pick the remote that
>> should be used for calculating outgoing changes.
>> 
>> Testing:
>> - Manual testing of `git-webrev` on Linux x64 with some more exotic repository
>>   configurations
>> 
>> Thanks,
>> Erik
>
> cli/src/main/java/org/openjdk/skara/cli/GitWebrev.java line 166:
> 
>> 165:         var cwd = Paths.get("").toAbsolutePath();
>> 166:         var repository = Repository.get(cwd);
>> 167:         if (!repository.isPresent()) {
> 
> What non-read-only method did you need? Can't spot it. :)

To figure out the outgoing commits I need to find the closest merge-base with regards to all upstream branches. Since
it is not certain that all upstream branches exists locally, I need to fetch the upstream branch to `FETCH_HEAD`. This
is not a destructive operation for the local repository, it only mutates `FETCH_HEAD` which you shouldn't rely on
anyhow staying the same.

The `fetch` method is only available on `Repository`, so I had to use `Repository` instead of `ReadOnlyRepository`.

-------------

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


More information about the skara-dev mailing list