Merge branch 'master' into next

* master:
  receive-pack: do not expect object 0{40} to exist
  t3200: add test case for 'branch -m'
  branch -m: handle no arg properly

Conflicts:
	builtin/branch.c
This commit is contained in:
Junio C Hamano
2011-11-03 14:34:12 -07:00
3 changed files with 24 additions and 12 deletions

View File

@@ -771,12 +771,14 @@ int cmd_branch(int argc, const char **argv, const char *prefix)
usage_with_options(builtin_branch_usage, options);
if (edit_branch_description(branch_name))
return 1;
}
else if (rename && (argc == 1))
rename_branch(head, argv[0], rename > 1);
else if (rename && (argc == 2))
rename_branch(argv[0], argv[1], rename > 1);
else if (argc <= 2) {
} else if (rename) {
if (argc == 1)
rename_branch(head, argv[0], rename > 1);
else if (argc == 2)
rename_branch(argv[0], argv[1], rename > 1);
else
usage_with_options(builtin_branch_usage, options);
} else if (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,

View File

@@ -634,7 +634,7 @@ static int command_singleton_iterator(void *cb_data, unsigned char sha1[20])
struct command **cmd_list = cb_data;
struct command *cmd = *cmd_list;
if (!cmd)
if (!cmd || is_null_sha1(cmd->new_sha1))
return -1; /* end of list */
*cmd_list = NULL; /* this returns only one */
hashcpy(sha1, cmd->new_sha1);
@@ -659,11 +659,16 @@ static int iterate_receive_command_list(void *cb_data, unsigned char sha1[20])
struct command **cmd_list = cb_data;
struct command *cmd = *cmd_list;
if (!cmd)
return -1; /* end of list */
*cmd_list = cmd->next;
hashcpy(sha1, cmd->new_sha1);
return 0;
while (cmd) {
if (!is_null_sha1(cmd->new_sha1)) {
hashcpy(sha1, cmd->new_sha1);
*cmd_list = cmd->next;
return 0;
}
cmd = cmd->next;
}
*cmd_list = NULL;
return -1; /* end of list */
}
static void execute_commands(struct command *commands, const char *unpacker_error)

View File

@@ -74,6 +74,11 @@ test_expect_success \
git branch -d l/m &&
git branch l'
test_expect_success \
'git branch -m dumps usage' \
'test_expect_code 129 git branch -m 2>err &&
grep "[Uu]sage: git branch" err'
test_expect_success \
'git branch -m m m/m should work' \
'git branch -l m &&