1755
test_cmp expect actual
1756
'
1757
1758
+test_expect_success '--forked: setup' '
1759
+ test_create_repo forked-upstream &&
1760
+ (
1761
+ cd forked-upstream &&
1762
+ test_commit base &&
1763
+ git branch one base &&
1764
+ git branch two base
1765
+ ) &&
1766
+
1767
+ test_create_repo forked-other &&
1768
+ (
1769
+ cd forked-other &&
1770
+ test_commit other-base &&
1771
+ git branch foreign other-base
1772
+ ) &&
1773
+
1774
+ git clone forked-upstream forked &&
1775
+ (
1776
+ cd forked &&
1777
+ git remote add -f other ../forked-other &&
1778
+ git branch local-base &&
1779
+ git branch --track local-one origin/one &&
1780
+ git branch --track local-two origin/two &&
1781
+ git branch --track local-foreign other/foreign &&
1782
+ git branch --track local-onbase local-base &&
1783
+
1784
+ git checkout local-one &&
1785
+ test_commit --no-tag local-one-work local-one.t &&
1786
+ git checkout local-foreign &&
1787
+ test_commit --no-tag local-foreign-work local-foreign.t
1788
+ )
1789
+'
1790
+
1791
+test_expect_success '--forked <upstream-tracking-branch> filters by upstream' '
1792
+ git -C forked branch --forked origin/one --format="%(refname:short)" >actual &&
1793
+ echo local-one >expect &&
1794
+ test_cmp expect actual
1795
+'
1796
+
1797
+test_expect_success '--forked <glob> filters by wildmatch' '
1798
+ git -C forked branch --forked "origin/*" --format="%(refname:short)" >actual &&
1799
+ cat >expect <<-\EOF &&
1800
+ local-one
1801
+ local-two
1802
+ main
1803
+ EOF
1804
+ test_cmp expect actual
1805
+'
1806
+
1807
+test_expect_success '--forked <local-branch> matches branches with local upstream' '
1808
+ git -C forked branch --forked local-base --format="%(refname:short)" >actual &&
1809
+ echo local-onbase >expect &&
1810
+ test_cmp expect actual
1811
+'
1812
+
1813
+test_expect_success '--forked can be repeated to widen the filter' '
1814
+ git -C forked branch --forked origin/one --forked other/foreign --format="%(refname:short)" >actual &&
1815
+ cat >expect <<-\EOF &&
1816
+ local-foreign
1817
+ local-one
1818
+ EOF
1819
+ test_cmp expect actual
1820
+'
1821
+
1822
+test_expect_success '--forked combines literal and glob arguments' '
1823
+ git -C forked branch --forked local-base --forked "other/*" --format="%(refname:short)" >actual &&
1824
+ cat >expect <<-\EOF &&
1825
+ local-foreign
1826
+ local-onbase
1827
+ EOF
1828
+ test_cmp expect actual
1829
+'
1830
+
1831
+test_expect_success '--forked "*/*" covers every remote-tracking upstream' '
1832
+ git -C forked branch --forked "*/*" --format="%(refname:short)" >actual &&
1833
+ cat >expect <<-\EOF &&
1834
+ local-foreign
1835
+ local-one
1836
+ local-two
1837
+ main
1838
+ EOF
1839
+ test_cmp expect actual
1840
+'
1841
+
1842
+test_expect_success '--forked composes with --no-merged' '
1843
+ git -C forked branch --forked "origin/*" --no-merged origin/one --format="%(refname:short)" >actual &&
1844
+ echo local-one >expect &&
1845
+ test_cmp expect actual
1846
+'
1847
+
1848
+test_expect_success '--forked <remote> uses the branch <remote>/HEAD points at' '
1849
+ git -C forked branch --forked origin --format="%(refname:short)" >actual &&
1850
+ echo main >expect &&
1851
+ test_cmp expect actual
1852
+'
1853
+
1854
+test_expect_success '--forked narrows a <pattern> argument' '
1855
+ git -C forked branch --forked "origin/*" "local-*" --format="%(refname:short)" >actual &&
1856
+ cat >expect <<-\EOF &&
1857
+ local-one
1858
+ local-two
1859
+ EOF
1860
+ test_cmp expect actual
1861
+'
1862
+
1863
+test_expect_success '--forked rejects unknown branch/pattern' '
1864
+ test_must_fail git -C forked branch --forked nope 2>err &&
1865
+ test_grep "not a valid branch or pattern" err
1866
+'
1867
+
1868
+test_expect_success '--forked requires a value' '
1869
+ test_must_fail git -C forked branch --forked 2>err &&
1870
+ test_grep "requires a value" err
1871
+'
1872
+
1873
test_done