diff options
author | Theodore Dubois <tbodt@google.com> | 2019-07-30 12:14:25 -0700 |
---|---|---|
committer | Mike Frysinger <vapier@google.com> | 2019-09-04 04:34:50 +0000 |
commit | 60fdc5cad126fb5664ee957b91edd1c304bfc513 (patch) | |
tree | 0fff7d8a99ee6e25189147610b26acf2707989dc /project.py | |
parent | 46702eddc7b5f38391e121e47f0ab4dbd6fbdf58 (diff) | |
download | git-repo-60fdc5cad126fb5664ee957b91edd1c304bfc513.tar.gz |
Add repo start option to create the branch based off HEAD
This makes it way easier to recover from forgetting to run repo start
before committing: just run `repo start -b new-branch`, instead of
all that tedious mucking around with reflogs.
Change-Id: I56d49dce5d027e28fbba0507ac10cd763ccfc36d
Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/232712
Reviewed-by: Mike Frysinger <vapier@google.com>
Reviewed-by: David Pursehouse <dpursehouse@collab.net>
Tested-by: Mike Frysinger <vapier@google.com>
Diffstat (limited to 'project.py')
-rwxr-xr-x | project.py | 8 |
1 files changed, 6 insertions, 2 deletions
@@ -1697,7 +1697,7 @@ class Project(object): | |||
1697 | 1697 | ||
1698 | # Branch Management ## | 1698 | # Branch Management ## |
1699 | 1699 | ||
1700 | def StartBranch(self, name, branch_merge=''): | 1700 | def StartBranch(self, name, branch_merge='', revision=None): |
1701 | """Create a new branch off the manifest's revision. | 1701 | """Create a new branch off the manifest's revision. |
1702 | """ | 1702 | """ |
1703 | if not branch_merge: | 1703 | if not branch_merge: |
@@ -1718,7 +1718,11 @@ class Project(object): | |||
1718 | branch.merge = branch_merge | 1718 | branch.merge = branch_merge |
1719 | if not branch.merge.startswith('refs/') and not ID_RE.match(branch_merge): | 1719 | if not branch.merge.startswith('refs/') and not ID_RE.match(branch_merge): |
1720 | branch.merge = R_HEADS + branch_merge | 1720 | branch.merge = R_HEADS + branch_merge |
1721 | revid = self.GetRevisionId(all_refs) | 1721 | |
1722 | if revision is None: | ||
1723 | revid = self.GetRevisionId(all_refs) | ||
1724 | else: | ||
1725 | revid = self.work_git.rev_parse(revision) | ||
1722 | 1726 | ||
1723 | if head.startswith(R_HEADS): | 1727 | if head.startswith(R_HEADS): |
1724 | try: | 1728 | try: |