From 0667fcfb6271e9e1ea032a0e3a7d74c9d6a5fa8a Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Sat, 16 Dec 2006 15:14:14 +0100 Subject: add a function to rename sections in the config Given a config like this: # A config [very.interesting.section] not The command $ git repo-config --rename-section very.interesting.section bla.1 will lead to this config: # A config [bla "1"] not Signed-off-by: Johannes Schindelin Signed-off-by: Junio C Hamano --- t/t1300-repo-config.sh | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) (limited to 't') diff --git a/t/t1300-repo-config.sh b/t/t1300-repo-config.sh index 16cd642610..e48a4ecdcf 100755 --- a/t/t1300-repo-config.sh +++ b/t/t1300-repo-config.sh @@ -343,5 +343,53 @@ EOF test_expect_success '--set in alternative GIT_CONFIG' 'cmp other-config expect' +cat > .git/config << EOF +# Hallo + #Bello +[branch "eins"] + x = 1 +[branch.eins] + y = 1 + [branch "1 234 blabl/a"] +weird +EOF + +test_expect_success "rename section" \ + "git-repo-config --rename-section branch.eins branch.zwei" + +cat > expect << EOF +# Hallo + #Bello +[branch "zwei"] + x = 1 +[branch "zwei"] + y = 1 + [branch "1 234 blabl/a"] +weird +EOF + +test_expect_success "rename succeeded" "diff -u expect .git/config" + +test_expect_failure "rename non-existing section" \ + 'git-repo-config --rename-section branch."world domination" branch.drei' + +test_expect_success "rename succeeded" "diff -u expect .git/config" + +test_expect_success "rename another section" \ + 'git-repo-config --rename-section branch."1 234 blabl/a" branch.drei' + +cat > expect << EOF +# Hallo + #Bello +[branch "zwei"] + x = 1 +[branch "zwei"] + y = 1 +[branch "drei"] +weird +EOF + +test_expect_success "rename succeeded" "diff -u expect .git/config" + test_done -- cgit v1.2.3