From e3d6539d58238f046ff955330f6e10c447150164 Mon Sep 17 00:00:00 2001 From: Denton Liu Date: Sat, 27 Apr 2019 05:02:22 -0700 Subject: branch: make create_branch accept a merge base rev When we ran something like $ git checkout -b test master... it would fail with the message fatal: Not a valid object name: 'master...'. This was caused by the call to `create_branch` where `start_name` is expected to be a valid rev. However, git-checkout allows the branch to be a valid _merge base_ rev (i.e. with a "...") so it was possible for an invalid rev to be passed in. Make `create_branch` accept a merge base rev so that this case does not error out. As a side-effect, teach git-branch how to handle merge base revs as well. Helped-by: Junio C Hamano Signed-off-by: Denton Liu Signed-off-by: Junio C Hamano --- Documentation/git-branch.txt | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'Documentation/git-branch.txt') diff --git a/Documentation/git-branch.txt b/Documentation/git-branch.txt index 3bd83a7cbd..8719e4cab9 100644 --- a/Documentation/git-branch.txt +++ b/Documentation/git-branch.txt @@ -45,7 +45,11 @@ argument is missing it defaults to `HEAD` (i.e. the tip of the current branch). The command's second form creates a new branch head named -which points to the current `HEAD`, or if given. +which points to the current `HEAD`, or if given. As a +special case, for , you may use `"A...B"` as a shortcut for +the merge base of `A` and `B` if there is exactly one merge base. You +can leave out at most one of `A` and `B`, in which case it defaults to +`HEAD`. Note that this will create the new branch, but it will not switch the working tree to it; use "git checkout " to switch to the -- cgit v1.2.3