[git-reparent-branch] Keep empty branches when doing rebase-update.
This fixes a bit of awkward UX where you create a new branch and
immediately want to reparent it.
Previously:
```
$ git new-branch something
$ # Oops, I really wanted that to be based on other_branch
$ git reparent-branch other_branch
Reparenting something to track remove_urllib3_hack (was origin/main)
Rebasing: something
Deleted branch something (was e10e74d5).
'something' was merged with its parent, checking out 'origin/main' instead.
```
R=gavinmak@google.com
Change-Id: I60cd4da4798094476d47ff684f301bbdee1293b1
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/4680281
Commit-Queue: Gavin Mak <gavinmak@google.com>
Reviewed-by: Gavin Mak <gavinmak@google.com>
Auto-Submit: Robbie Iannucci <iannucci@chromium.org>
diff --git a/git_reparent_branch.py b/git_reparent_branch.py
index 5e686d1..9180f60 100755
--- a/git_reparent_branch.py
+++ b/git_reparent_branch.py
@@ -92,7 +92,7 @@
for branch, parent in topo_iter(branch_tree):
if parent in branches:
branches.append(branch)
- return git_rebase_update.main(['--no-fetch'] + branches)
+ return git_rebase_update.main(['--no-fetch', '--keep-empty'] + branches)
if __name__ == '__main__': # pragma: no cover