]> git.ipfire.org Git - thirdparty/git.git/blobdiff - t/t3200-branch.sh
branch: add test for -m renaming multiple config sections
[thirdparty/git.git] / t / t3200-branch.sh
index fe62e7c775da6a8fc191ed1dc6634d5285ddbc4b..5eb752c516d74513b35c9adc92a805bf89b9e7e6 100755 (executable)
@@ -338,7 +338,48 @@ test_expect_success 'git branch -m s/s s should work when s/t is deleted' '
 
 test_expect_success 'config information was renamed, too' '
        test $(git config branch.s.dummy) = Hello &&
-       test_must_fail git config branch.s/s/dummy
+       test_must_fail git config branch.s/s.dummy
+'
+
+test_expect_success 'git branch -m correctly renames multiple config sections' '
+       test_when_finished "git checkout master" &&
+       git checkout -b source master &&
+
+       # Assert that a config file with multiple config sections has
+       # those sections preserved...
+       cat >expect <<-\EOF &&
+       branch.dest.key1=value1
+       some.gar.b=age
+       branch.dest.key2=value2
+       EOF
+       cat >config.branch <<\EOF &&
+;; Note the lack of -\EOF above & mixed indenting here. This is
+;; intentional, we are also testing that the formatting of copied
+;; sections is preserved.
+
+;; Comment for source. Tabs
+[branch "source"]
+       ;; Comment for the source value
+       key1 = value1
+;; Comment for some.gar. Spaces
+[some "gar"]
+    ;; Comment for the some.gar value
+    b = age
+;; Comment for source, again. Mixed tabs/spaces.
+[branch "source"]
+    ;; Comment for the source value, again
+       key2 = value2
+EOF
+       cat config.branch >>.git/config &&
+       git branch -m source dest &&
+       git config -f .git/config -l | grep -F -e source -e dest -e some.gar >actual &&
+       test_cmp expect actual &&
+
+       # ...and that the comments for those sections are also
+       # preserved.
+       cat config.branch | sed "s/\"source\"/\"dest\"/" >expect &&
+       sed -n -e "/Note the lack/,\$p" .git/config >actual &&
+       test_cmp expect actual
 '
 
 test_expect_success 'deleting a symref' '