@matheusbsbs / matheus-bagliano / commits / 6e8f993a5a
Fork 0

branch: die explicitly why when calling "git branch [-a|-r] branchname".

The -a and -r options used to be silently ignored in such a command. Signed-off-by: Matthieu Moy <Matthieu.Moy@imag.fr> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Matthieu Moy committed Dec 30, 2009 at 15:45 UTC 6e8f993a5a17f71edfd26a026bbc83cbbd3c0638
2 files changed +17 -15
builtin-branch.c
+4 -2
@@ -582,10 +582,12 @@ int cmd_branch(int argc, const char **argv, const char *prefix)
582 rename_branch(head, argv[0], rename > 1);
583 else if (rename && (argc == 2))
584 rename_branch(argv[0], argv[1], rename > 1);
585 - else if (argc <= 2)
585 + else if (argc <= 2) {
586 + if (kinds != REF_LOCAL_BRANCH)
587 + die("-a and -r options to 'git branch' do not make sense with a branch name");
588 create_branch(head, argv[0], (argc == 2) ? argv[1] : head,
589 force_create, reflog, track);
588 - else
590 + } else
591 usage_with_options(builtin_branch_usage, options);
592
593 return 0;
t/t5403-post-checkout-hook.sh
+13 -13
@@ -7,19 +7,19 @@ test_description='Test the post-checkout hook.'
7 . ./test-lib.sh
8
9 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
23 '
24
25 for clone in 1 2; do