summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVincent van Ravesteijn <vfr@lyx.org>2011-11-23 06:31:55 (GMT)
committerJunio C Hamano <gitster@pobox.com>2011-11-23 21:23:33 (GMT)
commit5cd75c7d8da8971d0d78f82d78c017e686fb5bb0 (patch)
treebf3335e4fa4b6949ee87754d9b9f2debd1a94a9d
parentb15aa973b296ca36ae39592491bcb02944ac0f7a (diff)
downloadgit-5cd75c7d8da8971d0d78f82d78c017e686fb5bb0.zip
git-5cd75c7d8da8971d0d78f82d78c017e686fb5bb0.tar.gz
git-5cd75c7d8da8971d0d78f82d78c017e686fb5bb0.tar.bz2
builtin-branch: Fix crash on invalid use of --force
The option --force should not put us in 'create branch' mode. The fact that this option is only valid in 'create branch' mode is already caught by the the next 'if' in which we assure that we are in the correct mode. Without this patch, "git branch -f" without any other argument ends up calling create_branch without any branch name. Signed-off-by: Vincent van Ravesteijn <vfr@lyx.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
-rw-r--r--builtin/branch.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/builtin/branch.c b/builtin/branch.c
index 51ca6a0..55cad76 100644
--- a/builtin/branch.c
+++ b/builtin/branch.c
@@ -705,7 +705,7 @@ int cmd_branch(int argc, const char **argv, const char *prefix)
argc = parse_options(argc, argv, prefix, options, builtin_branch_usage,
0);
- if (!delete && !rename && !force_create && argc == 0)
+ if (!delete && !rename && argc == 0)
list = 1;
if (!!delete + !!rename + !!force_create + !!list > 1)
@@ -726,7 +726,7 @@ int cmd_branch(int argc, const char **argv, const char *prefix)
rename_branch(argv[0], argv[1], rename > 1);
else
usage_with_options(builtin_branch_usage, options);
- } else if (argc <= 2) {
+ } else if (argc > 0 && argc <= 2) {
if (kinds != REF_LOCAL_BRANCH)
die(_("-a and -r options to 'git branch' do not make sense with a branch name"));
create_branch(head, argv[0], (argc == 2) ? argv[1] : head,