Browse Source

[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>
Robert Iannucci 2 years ago
parent
commit
7c59d27873
1 changed files with 1 additions and 1 deletions
  1. 1 1
      git_reparent_branch.py

+ 1 - 1
git_reparent_branch.py

@@ -92,7 +92,7 @@ def main(args):
   for branch, parent in topo_iter(branch_tree):
   for branch, parent in topo_iter(branch_tree):
     if parent in branches:
     if parent in branches:
       branches.append(branch)
       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
 if __name__ == '__main__':  # pragma: no cover