Another downside to the linear Git history that I noticed today: `git branch -d review/[number]` is less likely to succeed, because the commit was probably rebased on merge, so it’s now a different commit even if the version I had previously downloaded with `git review -d [number]` was still the latest version.
Hello,
I delete them without looking by forcing the deletion: `git
branch -D`. That is because I consider them ephemeral and in
almost any case I always refetch the change from Gerrit.
`git branch -d` checks whether the branch got merged, and with
Gerrit rebasing a patch behind our hood, it get lost since the
commit might have a different sha1 as the parent might be
different.
There is another command that is used for email based workflow: git
cherry. It compares the commits based on the diff and shows
which commits have been applied and which one are yet to be
applied
Assuming your:
* local branch `review/user/num` tracks a remote branch (which
git-review -d should do)
* the remote is up-to-date (git fetch origin / git fetch --all /
git remote update)
Then when invoking `git cherry -v`, it compares the pending
patches in your local branch with the remote and print them. The
commits that have an equivalent in the remote branch are prefixed
with a `-` (they have been merged), those that did not are
prefixed with a `+`.
Example with integration/config, I had a local branch review/cmelo/T397271 which pointed to https://gerrit.wikimedia.org/r/c/integration/config/+/1163347/3.
The branch is not fully merged:
git branch -d review/cmelo/T397271
error: The branch 'review/cmelo/T397271' is not fully merged.
But the patch has been applied:
$ git checkout review/cmelo/T397271
Switched to branch 'review/cmelo/T397271'
Your branch and 'origin/master' have diverged,
and have 1 and 74 different commits each, respectively.
$ git cherry -v
- 0c481434f44b95c354bbacf11258188e8b842f59 zuul:
[mediawiki/extensions/CampaignEvents] add cldr as dependency
Or pull the branch and it is then deletable.
I am pretty sure git-review could be taught to automatically delete local review branches by using `git cherry` ;)
Antoine "hashar" Musso