@@ -323,11 +323,11 @@ test_expect_success 'git branch --list -v with --abbrev' '
323
323
324
324
test_expect_success ' git branch --column' '
325
325
COLUMNS=81 git branch --column=column >actual &&
326
- cat >expected <<\EOF &&
326
+ cat >expect <<\EOF &&
327
327
a/b/c bam foo l * master mb o/o q
328
328
abc bar j/k m/m master2 n o/p r
329
329
EOF
330
- test_cmp expected actual
330
+ test_cmp expect actual
331
331
'
332
332
333
333
test_expect_success ' git branch --column with an extremely long branch name' '
@@ -336,7 +336,7 @@ test_expect_success 'git branch --column with an extremely long branch name' '
336
336
test_when_finished "git branch -d $long" &&
337
337
git branch $long &&
338
338
COLUMNS=80 git branch --column=column >actual &&
339
- cat >expected <<EOF &&
339
+ cat >expect <<EOF &&
340
340
a/b/c
341
341
abc
342
342
bam
@@ -355,7 +355,7 @@ test_expect_success 'git branch --column with an extremely long branch name' '
355
355
r
356
356
$long
357
357
EOF
358
- test_cmp expected actual
358
+ test_cmp expect actual
359
359
'
360
360
361
361
test_expect_success ' git branch with column.*' '
@@ -364,11 +364,11 @@ test_expect_success 'git branch with column.*' '
364
364
COLUMNS=80 git branch >actual &&
365
365
git config --unset column.branch &&
366
366
git config --unset column.ui &&
367
- cat >expected <<\EOF &&
367
+ cat >expect <<\EOF &&
368
368
a/b/c bam foo l * master mb o/o q
369
369
abc bar j/k m/m master2 n o/p r
370
370
EOF
371
- test_cmp expected actual
371
+ test_cmp expect actual
372
372
'
373
373
374
374
test_expect_success ' git branch --column -v should fail' '
@@ -379,7 +379,7 @@ test_expect_success 'git branch -v with column.ui ignored' '
379
379
git config column.ui column &&
380
380
COLUMNS=80 git branch -v | cut -c -10 | sed "s/ *$//" >actual &&
381
381
git config --unset column.ui &&
382
- cat >expected <<\EOF &&
382
+ cat >expect <<\EOF &&
383
383
a/b/c
384
384
abc
385
385
bam
@@ -397,7 +397,7 @@ test_expect_success 'git branch -v with column.ui ignored' '
397
397
q
398
398
r
399
399
EOF
400
- test_cmp expected actual
400
+ test_cmp expect actual
401
401
'
402
402
403
403
mv .git/config .git/config-saved
@@ -835,32 +835,42 @@ test_expect_success 'branch from tag w/--track causes failure' '
835
835
'
836
836
837
837
test_expect_success ' --set-upstream-to fails on multiple branches' '
838
- test_must_fail git branch --set-upstream-to master a b c
838
+ echo "fatal: too many arguments to set new upstream" >expect &&
839
+ test_must_fail git branch --set-upstream-to master a b c 2>err &&
840
+ test_i18ncmp expect err
839
841
'
840
842
841
843
test_expect_success ' --set-upstream-to fails on detached HEAD' '
842
844
git checkout HEAD^{} &&
843
- test_must_fail git branch --set-upstream-to master &&
844
- git checkout -
845
+ test_when_finished git checkout - &&
846
+ echo "fatal: could not set upstream of HEAD to master when it does not point to any branch." >expect &&
847
+ test_must_fail git branch --set-upstream-to master 2>err &&
848
+ test_i18ncmp expect err
845
849
'
846
850
847
851
test_expect_success ' --set-upstream-to fails on a missing dst branch' '
848
- test_must_fail git branch --set-upstream-to master does-not-exist
852
+ echo "fatal: branch ' " '" ' does-not-exist' " '" ' does not exist" >expect &&
853
+ test_must_fail git branch --set-upstream-to master does-not-exist 2>err &&
854
+ test_i18ncmp expect err
849
855
'
850
856
851
857
test_expect_success ' --set-upstream-to fails on a missing src branch' '
852
- test_must_fail git branch --set-upstream-to does-not-exist master
858
+ test_must_fail git branch --set-upstream-to does-not-exist master 2>err &&
859
+ test_i18ngrep "the requested upstream branch ' " '" ' does-not-exist' " '" ' does not exist" err
853
860
'
854
861
855
862
test_expect_success ' --set-upstream-to fails on a non-ref' '
856
- test_must_fail git branch --set-upstream-to HEAD^{}
863
+ echo "fatal: Cannot setup tracking information; starting point ' " '" ' HEAD^{}' " '" ' is not a branch." >expect &&
864
+ test_must_fail git branch --set-upstream-to HEAD^{} 2>err &&
865
+ test_i18ncmp expect err
857
866
'
858
867
859
868
test_expect_success ' --set-upstream-to fails on locked config' '
860
869
test_when_finished "rm -f .git/config.lock" &&
861
870
>.git/config.lock &&
862
871
git branch locked &&
863
- test_must_fail git branch --set-upstream-to locked
872
+ test_must_fail git branch --set-upstream-to locked 2>err &&
873
+ test_i18ngrep "could not lock config file .git/config: File exists" err
864
874
'
865
875
866
876
test_expect_success ' use --set-upstream-to modify HEAD' '
@@ -881,14 +891,17 @@ test_expect_success 'use --set-upstream-to modify a particular branch' '
881
891
'
882
892
883
893
test_expect_success ' --unset-upstream should fail if given a non-existent branch' '
884
- test_must_fail git branch --unset-upstream i-dont-exist
894
+ echo "fatal: Branch ' " '" ' i-dont-exist' " '" ' has no upstream information" >expect &&
895
+ test_must_fail git branch --unset-upstream i-dont-exist 2>err &&
896
+ test_i18ncmp expect err
885
897
'
886
898
887
899
test_expect_success ' --unset-upstream should fail if config is locked' '
888
900
test_when_finished "rm -f .git/config.lock" &&
889
901
git branch --set-upstream-to locked &&
890
902
>.git/config.lock &&
891
- test_must_fail git branch --unset-upstream
903
+ test_must_fail git branch --unset-upstream 2>err &&
904
+ test_i18ngrep "could not lock config file .git/config: File exists" err
892
905
'
893
906
894
907
test_expect_success ' test --unset-upstream on HEAD' '
@@ -900,17 +913,23 @@ test_expect_success 'test --unset-upstream on HEAD' '
900
913
test_must_fail git config branch.master.remote &&
901
914
test_must_fail git config branch.master.merge &&
902
915
# fail for a branch without upstream set
903
- test_must_fail git branch --unset-upstream
916
+ echo "fatal: Branch ' " '" ' master' " '" ' has no upstream information" >expect &&
917
+ test_must_fail git branch --unset-upstream 2>err &&
918
+ test_i18ncmp expect err
904
919
'
905
920
906
921
test_expect_success ' --unset-upstream should fail on multiple branches' '
907
- test_must_fail git branch --unset-upstream a b c
922
+ echo "fatal: too many arguments to unset upstream" >expect &&
923
+ test_must_fail git branch --unset-upstream a b c 2>err &&
924
+ test_i18ncmp expect err
908
925
'
909
926
910
927
test_expect_success ' --unset-upstream should fail on detached HEAD' '
911
928
git checkout HEAD^{} &&
912
- test_must_fail git branch --unset-upstream &&
913
- git checkout -
929
+ test_when_finished git checkout - &&
930
+ echo "fatal: could not unset upstream of HEAD when it does not point to any branch." >expect &&
931
+ test_must_fail git branch --unset-upstream 2>err &&
932
+ test_i18ncmp expect err
914
933
'
915
934
916
935
test_expect_success ' test --unset-upstream on a particular branch' '
@@ -922,17 +941,17 @@ test_expect_success 'test --unset-upstream on a particular branch' '
922
941
'
923
942
924
943
test_expect_success ' disabled option --set-upstream fails' '
925
- test_must_fail git branch --set-upstream origin/master
944
+ test_must_fail git branch --set-upstream origin/master
926
945
'
927
946
928
947
test_expect_success ' --set-upstream-to notices an error to set branch as own upstream' '
929
948
git branch --set-upstream-to refs/heads/my13 my13 2>actual &&
930
- cat >expected <<-\EOF &&
949
+ cat >expect <<-\EOF &&
931
950
warning: Not setting branch my13 as its own upstream.
932
951
EOF
933
952
test_expect_code 1 git config branch.my13.remote &&
934
953
test_expect_code 1 git config branch.my13.merge &&
935
- test_i18ncmp expected actual
954
+ test_i18ncmp expect actual
936
955
'
937
956
938
957
# Keep this test last, as it changes the current branch
0 commit comments