555
cat >expected <<-EOF &&
556
refs/heads/master
557
refs/heads/matching-branch
558
+ refs/remotes/other/branch-in-other
559
+ refs/remotes/other/master-in-other
560
+ refs/tags/matching-tag
561
EOF
562
(
563
cur=refs/heads/ &&
623
624
test_expect_success '__git_refs - configured remote - full refs' '
625
cat >expected <<-EOF &&
626
+ HEAD
627
refs/heads/branch-in-other
628
refs/heads/master-in-other
629
refs/tags/tag-in-other
652
653
test_expect_success '__git_refs - configured remote - full refs - repo given on the command line' '
654
cat >expected <<-EOF &&
655
+ HEAD
656
refs/heads/branch-in-other
657
refs/heads/master-in-other
658
refs/tags/tag-in-other
697
698
test_expect_success '__git_refs - URL remote - full refs' '
699
cat >expected <<-EOF &&
700
+ HEAD
701
refs/heads/branch-in-other
702
refs/heads/master-in-other
703
refs/tags/tag-in-other
843
test_cmp expected "$actual"
844
'
845
846
+test_expect_success 'setup for filtering matching refs' '
847
+ git branch matching/branch &&
848
+ git tag matching/tag &&
849
+ git -C otherrepo branch matching/branch-in-other &&
850
+ git fetch --no-tags other &&
851
+ rm -f .git/FETCH_HEAD
852
+'
853
+
854
+test_expect_success '__git_refs - dont filter refs unless told so' '
855
+ cat >expected <<-EOF &&
856
+ HEAD
857
+ master
858
+ matching-branch
859
+ matching/branch
860
+ other/branch-in-other
861
+ other/master-in-other
862
+ other/matching/branch-in-other
863
+ matching-tag
864
+ matching/tag
865
+ EOF
866
+ (
867
+ cur=master &&
868
+ __git_refs >"$actual"
869
+ ) &&
870
+ test_cmp expected "$actual"
871
+'
872
+
873
+test_expect_success '__git_refs - only matching refs' '
874
+ cat >expected <<-EOF &&
875
+ matching-branch
876
+ matching/branch
877
+ matching-tag
878
+ matching/tag
879
+ EOF
880
+ (
881
+ cur=mat &&
882
+ __git_refs "" "" "" "$cur" >"$actual"
883
+ ) &&
884
+ test_cmp expected "$actual"
885
+'
886
+
887
+test_expect_success '__git_refs - only matching refs - full refs' '
888
+ cat >expected <<-EOF &&
889
+ refs/heads/matching-branch
890
+ refs/heads/matching/branch
891
+ EOF
892
+ (
893
+ cur=refs/heads/mat &&
894
+ __git_refs "" "" "" "$cur" >"$actual"
895
+ ) &&
896
+ test_cmp expected "$actual"
897
+'
898
+
899
+test_expect_success '__git_refs - only matching refs - remote on local file system' '
900
+ cat >expected <<-EOF &&
901
+ master-in-other
902
+ matching/branch-in-other
903
+ EOF
904
+ (
905
+ cur=ma &&
906
+ __git_refs otherrepo "" "" "$cur" >"$actual"
907
+ ) &&
908
+ test_cmp expected "$actual"
909
+'
910
+
911
+test_expect_success '__git_refs - only matching refs - configured remote' '
912
+ cat >expected <<-EOF &&
913
+ master-in-other
914
+ matching/branch-in-other
915
+ EOF
916
+ (
917
+ cur=ma &&
918
+ __git_refs other "" "" "$cur" >"$actual"
919
+ ) &&
920
+ test_cmp expected "$actual"
921
+'
922
+
923
+test_expect_success '__git_refs - only matching refs - remote - full refs' '
924
+ cat >expected <<-EOF &&
925
+ refs/heads/master-in-other
926
+ refs/heads/matching/branch-in-other
927
+ EOF
928
+ (
929
+ cur=refs/heads/ma &&
930
+ __git_refs other "" "" "$cur" >"$actual"
931
+ ) &&
932
+ test_cmp expected "$actual"
933
+'
934
+
935
+test_expect_success '__git_refs - only matching refs - checkout DWIMery' '
936
+ cat >expected <<-EOF &&
937
+ matching-branch
938
+ matching/branch
939
+ matching-tag
940
+ matching/tag
941
+ matching/branch-in-other
942
+ EOF
943
+ for remote_ref in refs/remotes/other/ambiguous \
944
+ refs/remotes/remote/ambiguous \
945
+ refs/remotes/remote/branch-in-remote
946
+ do
947
+ git update-ref $remote_ref master &&
948
+ test_when_finished "git update-ref -d $remote_ref"
949
+ done &&
950
+ (
951
+ cur=mat &&
952
+ __git_refs "" 1 "" "$cur" >"$actual"
953
+ ) &&
954
+ test_cmp expected "$actual"
955
+'
956
+
957
+test_expect_success 'teardown after filtering matching refs' '
958
+ git branch -d matching/branch &&
959
+ git tag -d matching/tag &&
960
+ git update-ref -d refs/remotes/other/matching/branch-in-other &&
961
+ git -C otherrepo branch -D matching/branch-in-other
962
+'
963
+
964
test_expect_success '__git_complete_refs - simple' '
965
sed -e "s/Z$//" >expected <<-EOF &&
966
HEAD Z