Merge branch 'gp/branch'
* gp/branch: git-branch: cleanup config file when deleting branches
This commit is contained in:
@ -85,6 +85,7 @@ static int delete_branches(int argc, const char **argv, int force, int kinds)
|
|||||||
unsigned char sha1[20];
|
unsigned char sha1[20];
|
||||||
char *name = NULL;
|
char *name = NULL;
|
||||||
const char *fmt, *remote;
|
const char *fmt, *remote;
|
||||||
|
char section[PATH_MAX];
|
||||||
int i;
|
int i;
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
|
||||||
@ -152,9 +153,13 @@ static int delete_branches(int argc, const char **argv, int force, int kinds)
|
|||||||
error("Error deleting %sbranch '%s'", remote,
|
error("Error deleting %sbranch '%s'", remote,
|
||||||
argv[i]);
|
argv[i]);
|
||||||
ret = 1;
|
ret = 1;
|
||||||
} else
|
} else {
|
||||||
printf("Deleted %sbranch %s.\n", remote, argv[i]);
|
printf("Deleted %sbranch %s.\n", remote, argv[i]);
|
||||||
|
snprintf(section, sizeof(section), "branch.%s",
|
||||||
|
argv[i]);
|
||||||
|
if (git_config_rename_section(section, NULL) < 0)
|
||||||
|
warning("Update of config-file failed");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (name)
|
if (name)
|
||||||
|
@ -171,6 +171,15 @@ test_expect_success 'test tracking setup via --track but deeper' \
|
|||||||
test "$(git-config branch.my7.remote)" = local &&
|
test "$(git-config branch.my7.remote)" = local &&
|
||||||
test "$(git-config branch.my7.merge)" = refs/heads/o/o'
|
test "$(git-config branch.my7.merge)" = refs/heads/o/o'
|
||||||
|
|
||||||
|
test_expect_success 'test deleting branch deletes branch config' \
|
||||||
|
'git-branch -d my7 &&
|
||||||
|
test "$(git-config branch.my7.remote)" = "" &&
|
||||||
|
test "$(git-config branch.my7.merge)" = ""'
|
||||||
|
|
||||||
|
test_expect_success 'test deleting branch without config' \
|
||||||
|
'git-branch my7 s &&
|
||||||
|
test "$(git-branch -d my7 2>&1)" = "Deleted branch my7."'
|
||||||
|
|
||||||
# Keep this test last, as it changes the current branch
|
# Keep this test last, as it changes the current branch
|
||||||
cat >expect <<EOF
|
cat >expect <<EOF
|
||||||
0000000000000000000000000000000000000000 $HEAD $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1117150200 +0000 branch: Created from master
|
0000000000000000000000000000000000000000 $HEAD $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1117150200 +0000 branch: Created from master
|
||||||
|
Reference in New Issue
Block a user