Skip to content

Commit 9bfff3a

Browse files
committed
Merge branch 'maint-1.6.0' into maint
* maint-1.6.0: branch: die explicitly why when calling "git branch [-a|-r] branchname".
2 parents 74fbd11 + 6e8f993 commit 9bfff3a

File tree

2 files changed

+17
-15
lines changed

2 files changed

+17
-15
lines changed

builtin-branch.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -638,10 +638,12 @@ int cmd_branch(int argc, const char **argv, const char *prefix)
638638
rename_branch(head, argv[0], rename > 1);
639639
else if (rename && (argc == 2))
640640
rename_branch(argv[0], argv[1], rename > 1);
641-
else if (argc <= 2)
641+
else if (argc <= 2) {
642+
if (kinds != REF_LOCAL_BRANCH)
643+
die("-a and -r options to 'git branch' do not make sense with a branch name");
642644
create_branch(head, argv[0], (argc == 2) ? argv[1] : head,
643645
force_create, reflog, track);
644-
else
646+
} else
645647
usage_with_options(builtin_branch_usage, options);
646648

647649
return 0;

t/t5403-post-checkout-hook.sh

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,19 @@ test_description='Test the post-checkout hook.'
77
. ./test-lib.sh
88

99
test_expect_success setup '
10-
echo Data for commit0. >a &&
11-
echo Data for commit0. >b &&
12-
git update-index --add a &&
13-
git update-index --add b &&
14-
tree0=$(git write-tree) &&
15-
commit0=$(echo setup | git commit-tree $tree0) &&
16-
git update-ref refs/heads/master $commit0 &&
17-
git clone ./. clone1 &&
18-
git clone ./. clone2 &&
19-
GIT_DIR=clone2/.git git branch -a new2 &&
20-
echo Data for commit1. >clone2/b &&
21-
GIT_DIR=clone2/.git git add clone2/b &&
22-
GIT_DIR=clone2/.git git commit -m new2
10+
echo Data for commit0. >a &&
11+
echo Data for commit0. >b &&
12+
git update-index --add a &&
13+
git update-index --add b &&
14+
tree0=$(git write-tree) &&
15+
commit0=$(echo setup | git commit-tree $tree0) &&
16+
git update-ref refs/heads/master $commit0 &&
17+
git clone ./. clone1 &&
18+
git clone ./. clone2 &&
19+
GIT_DIR=clone2/.git git branch new2 &&
20+
echo Data for commit1. >clone2/b &&
21+
GIT_DIR=clone2/.git git add clone2/b &&
22+
GIT_DIR=clone2/.git git commit -m new2
2323
'
2424

2525
for clone in 1 2; do

0 commit comments

Comments
 (0)