RFR: Add git-sync command

Erik Helin ehelin at openjdk.org
Tue Sep 24 09:38:45 UTC 2019

Hi all,

this commits adds the new `git sync` command which is useful for syncing a personal fork with its upstream repository. `git sync` supports both a remote and URL as a argument, for example:

$ git sync upstream
Syncing upstream/master with origin/master... done

$ git sync https://github.com/openjdk/skara
Syncing https://github.com/openjdk/skara/master with origin/master... done

The remote can also be configured in `.git/config` (or `~/.gitconfig`) as in:

       remote = upstream

I also added two options, `--pull` and `--fetch`, that will pull and/or fetch the current branch. This is a shorthand for `git sync && git pull`. Since `git fork` sets the `sync.remote` in `.git/config` (local for the repository) a user now only has to write to fork an upstream repository, sync the branches and update their local copy:

$ git fork https://github.com/openjdk/skara
$ cd skara
$ git sync --pull

The syncing leaves no trace in the local repository, I'm only using `FETCH_HEAD` in the refspec when pushing to the personal fork.

## Testing
- [x] `sh gradlew test` passes on Linux x86_64
- [x] `sh gradlew reproduce` passes on Linux x86_64
- [x] Added two new unit tests
- [x] Manual testing of `git sync`



 - 62268c27: Set sync configuration with git-fork
 - b4add8cc: Add --fetch and --pull options, also allow remote to be configured
 - c3692ab8: Add sync to GitSkara as well
 - 6d751a06: Add alias for git-sync in skara.gitconfig
 - 9a77ebc5: Add git-sync command

Changes: https://git.openjdk.java.net/skara/pull/153/files
 Webrev: https://webrevs.openjdk.java.net/skara/153/webrev.00
  Stats: 508 lines in 14 files changed: 465 ins; 40 del; 3 mod
  Patch: https://git.openjdk.java.net/skara/pull/153.diff
  Fetch: git fetch https://git.openjdk.java.net/skara pull/153/head:pull/153

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

More information about the skara-dev mailing list