test-lib: parse options in a for loop to keep $@ intact
[gitweb.git] / t / t3200-branch.sh
index dbca665da41908e7e3014564dc8ddb901030715b..478b82cf9b513a8f45f250de59d519847227f794 100755 (executable)
@@ -1221,7 +1221,7 @@ test_expect_success 'use --edit-description' '
        EOF
        EDITOR=./editor git branch --edit-description &&
        echo "New contents" >expect &&
-       test_cmp EDITOR_OUTPUT expect
+       test_cmp expect EDITOR_OUTPUT
 '
 
 test_expect_success 'detect typo in branch name when using --edit-description' '
@@ -1305,4 +1305,50 @@ test_expect_success 'tracking with unexpected .fetch refspec' '
        )
 '
 
+test_expect_success 'configured committerdate sort' '
+       git init sort &&
+       (
+               cd sort &&
+               git config branch.sort committerdate &&
+               test_commit initial &&
+               git checkout -b a &&
+               test_commit a &&
+               git checkout -b c &&
+               test_commit c &&
+               git checkout -b b &&
+               test_commit b &&
+               git branch >actual &&
+               cat >expect <<-\EOF &&
+                 master
+                 a
+                 c
+               * b
+               EOF
+               test_cmp expect actual
+       )
+'
+
+test_expect_success 'option override configured sort' '
+       (
+               cd sort &&
+               git config branch.sort committerdate &&
+               git branch --sort=refname >actual &&
+               cat >expect <<-\EOF &&
+                 a
+               * b
+                 c
+                 master
+               EOF
+               test_cmp expect actual
+       )
+'
+
+test_expect_success 'invalid sort parameter in configuration' '
+       (
+               cd sort &&
+               git config branch.sort "v:notvalid" &&
+               test_must_fail git branch
+       )
+'
+
 test_done