Skip to content

Commit 69bf2b1

Browse files
pcloudsgitster
authored andcommitted
t1510: setup case #14
Signed-off-by: Nguyễn Thái Ngọc Duy <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent dc1c783 commit 69bf2b1

File tree

1 file changed

+291
-0
lines changed

1 file changed

+291
-0
lines changed

t/t1510-repo-setup.sh

Lines changed: 291 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1666,4 +1666,295 @@ EOF
16661666
test_repo 13/sub
16671667
'
16681668

1669+
#
1670+
# case #14
1671+
#
1672+
############################################################
1673+
#
1674+
# Input:
1675+
#
1676+
# - GIT_WORK_TREE is not set
1677+
# - GIT_DIR is set
1678+
# - core.worktree is set
1679+
# - .git is a file
1680+
# - core.bare is not set, cwd is outside .git
1681+
#
1682+
# Output:
1683+
#
1684+
# #6 except that git_dir is set by .git file
1685+
1686+
test_expect_success '#14: setup' '
1687+
unset GIT_DIR GIT_WORK_TREE &&
1688+
mkdir 14 14/sub 14/sub/sub 14.wt 14.wt/sub 14/wt 14/wt/sub &&
1689+
cd 14 &&
1690+
git init &&
1691+
mv .git ../14.git &&
1692+
echo gitdir: ../14.git >.git &&
1693+
cd ..
1694+
'
1695+
1696+
test_expect_failure '#14: GIT_DIR(rel), core.worktree=../14 at root' '
1697+
cat >14/expected <<EOF &&
1698+
setup: git_dir: $TRASH_DIRECTORY/14.git
1699+
setup: worktree: $TRASH_DIRECTORY/14
1700+
setup: cwd: $TRASH_DIRECTORY/14
1701+
setup: prefix: (null)
1702+
EOF
1703+
git config --file="$TRASH_DIRECTORY/14.git/config" core.worktree "$TRASH_DIRECTORY/14" &&
1704+
test_repo 14 .git
1705+
'
1706+
1707+
test_expect_failure '#14: GIT_DIR(rel), core.worktree=../14(rel) at root' '
1708+
cat >14/expected <<EOF &&
1709+
setup: git_dir: $TRASH_DIRECTORY/14.git
1710+
setup: worktree: $TRASH_DIRECTORY/14
1711+
setup: cwd: $TRASH_DIRECTORY/14
1712+
setup: prefix: (null)
1713+
EOF
1714+
git config --file="$TRASH_DIRECTORY/14.git/config" core.worktree ../14 &&
1715+
test_repo 14 .git
1716+
'
1717+
1718+
test_expect_failure '#14: GIT_DIR, core.worktree=../14 at root' '
1719+
cat >14/expected <<EOF &&
1720+
setup: git_dir: $TRASH_DIRECTORY/14.git
1721+
setup: worktree: $TRASH_DIRECTORY/14
1722+
setup: cwd: $TRASH_DIRECTORY/14
1723+
setup: prefix: (null)
1724+
EOF
1725+
git config --file="$TRASH_DIRECTORY/14.git/config" core.worktree "$TRASH_DIRECTORY/14" &&
1726+
test_repo 14 "$TRASH_DIRECTORY/14/.git"
1727+
'
1728+
1729+
test_expect_failure '#14: GIT_DIR, core.worktree=../14(rel) at root' '
1730+
cat >14/expected <<EOF &&
1731+
setup: git_dir: $TRASH_DIRECTORY/14.git
1732+
setup: worktree: $TRASH_DIRECTORY/14
1733+
setup: cwd: $TRASH_DIRECTORY/14
1734+
setup: prefix: (null)
1735+
EOF
1736+
git config --file="$TRASH_DIRECTORY/14.git/config" core.worktree ../14 &&
1737+
test_repo 14 "$TRASH_DIRECTORY/14/.git"
1738+
'
1739+
1740+
test_expect_failure '#14: GIT_DIR(rel), core.worktree=../14 in subdir' '
1741+
cat >14/sub/sub/expected <<EOF &&
1742+
setup: git_dir: $TRASH_DIRECTORY/14.git
1743+
setup: worktree: $TRASH_DIRECTORY/14
1744+
setup: cwd: $TRASH_DIRECTORY/14
1745+
setup: prefix: sub/sub/
1746+
EOF
1747+
git config --file="$TRASH_DIRECTORY/14.git/config" core.worktree "$TRASH_DIRECTORY/14" &&
1748+
test_repo 14/sub/sub ../../.git
1749+
'
1750+
1751+
test_expect_failure '#14: GIT_DIR(rel), core.worktree=../14(rel) in subdir' '
1752+
cat >14/sub/sub/expected <<EOF &&
1753+
setup: git_dir: $TRASH_DIRECTORY/14.git
1754+
setup: worktree: $TRASH_DIRECTORY/14
1755+
setup: cwd: $TRASH_DIRECTORY/14
1756+
setup: prefix: sub/sub/
1757+
EOF
1758+
git config --file="$TRASH_DIRECTORY/14.git/config" core.worktree ../14 &&
1759+
test_repo 14/sub/sub ../../.git
1760+
'
1761+
1762+
test_expect_failure '#14: GIT_DIR, core.worktree=../14 in subdir' '
1763+
cat >14/sub/expected <<EOF &&
1764+
setup: git_dir: $TRASH_DIRECTORY/14.git
1765+
setup: worktree: $TRASH_DIRECTORY/14
1766+
setup: cwd: $TRASH_DIRECTORY/14
1767+
setup: prefix: sub/
1768+
EOF
1769+
git config --file="$TRASH_DIRECTORY/14.git/config" core.worktree "$TRASH_DIRECTORY/14" &&
1770+
test_repo 14/sub "$TRASH_DIRECTORY/14/.git"
1771+
'
1772+
1773+
test_expect_failure '#14: GIT_DIR, core.worktree=../14(rel) in subdir' '
1774+
cat >14/sub/sub/expected <<EOF &&
1775+
setup: git_dir: $TRASH_DIRECTORY/14.git
1776+
setup: worktree: $TRASH_DIRECTORY/14
1777+
setup: cwd: $TRASH_DIRECTORY/14
1778+
setup: prefix: sub/sub/
1779+
EOF
1780+
git config --file="$TRASH_DIRECTORY/14.git/config" core.worktree ../14 &&
1781+
test_repo 14/sub/sub "$TRASH_DIRECTORY/14/.git"
1782+
'
1783+
1784+
test_expect_failure '#14: GIT_DIR(rel), core.worktree=../14/wt at root' '
1785+
cat >14/expected <<EOF &&
1786+
setup: git_dir: $TRASH_DIRECTORY/14.git
1787+
setup: worktree: $TRASH_DIRECTORY/14/wt
1788+
setup: cwd: $TRASH_DIRECTORY/14
1789+
setup: prefix: (null)
1790+
EOF
1791+
git config --file="$TRASH_DIRECTORY/14.git/config" core.worktree "$TRASH_DIRECTORY/14/wt" &&
1792+
test_repo 14 .git
1793+
'
1794+
1795+
test_expect_failure '#14: GIT_DIR(rel), core.worktree=../14/wt(rel) at root' '
1796+
cat >14/expected <<EOF &&
1797+
setup: git_dir: $TRASH_DIRECTORY/14.git
1798+
setup: worktree: $TRASH_DIRECTORY/14/wt
1799+
setup: cwd: $TRASH_DIRECTORY/14
1800+
setup: prefix: (null)
1801+
EOF
1802+
git config --file="$TRASH_DIRECTORY/14.git/config" core.worktree ../14/wt &&
1803+
test_repo 14 .git
1804+
'
1805+
1806+
test_expect_failure '#14: GIT_DIR, core.worktree=../14/wt(rel) at root' '
1807+
cat >14/expected <<EOF &&
1808+
setup: git_dir: $TRASH_DIRECTORY/14.git
1809+
setup: worktree: $TRASH_DIRECTORY/14/wt
1810+
setup: cwd: $TRASH_DIRECTORY/14
1811+
setup: prefix: (null)
1812+
EOF
1813+
git config --file="$TRASH_DIRECTORY/14.git/config" core.worktree ../14/wt &&
1814+
test_repo 14 "$TRASH_DIRECTORY/14/.git"
1815+
'
1816+
1817+
test_expect_failure '#14: GIT_DIR, core.worktree=../14/wt at root' '
1818+
cat >14/expected <<EOF &&
1819+
setup: git_dir: $TRASH_DIRECTORY/14.git
1820+
setup: worktree: $TRASH_DIRECTORY/14/wt
1821+
setup: cwd: $TRASH_DIRECTORY/14
1822+
setup: prefix: (null)
1823+
EOF
1824+
git config --file="$TRASH_DIRECTORY/14.git/config" core.worktree "$TRASH_DIRECTORY/14/wt" &&
1825+
test_repo 14 "$TRASH_DIRECTORY/14/.git"
1826+
'
1827+
1828+
test_expect_failure '#14: GIT_DIR(rel), core.worktree=../14/wt in subdir' '
1829+
cat >14/sub/sub/expected <<EOF &&
1830+
setup: git_dir: $TRASH_DIRECTORY/14.git
1831+
setup: worktree: $TRASH_DIRECTORY/14/wt
1832+
setup: cwd: $TRASH_DIRECTORY/14/sub/sub
1833+
setup: prefix: (null)
1834+
EOF
1835+
git config --file="$TRASH_DIRECTORY/14.git/config" core.worktree "$TRASH_DIRECTORY/14/wt" &&
1836+
test_repo 14/sub/sub ../../.git
1837+
'
1838+
1839+
test_expect_failure '#14: GIT_DIR(rel), core.worktree=../14/wt(rel) in subdir' '
1840+
cat >14/sub/sub/expected <<EOF &&
1841+
setup: git_dir: $TRASH_DIRECTORY/14.git
1842+
setup: worktree: $TRASH_DIRECTORY/14/wt
1843+
setup: cwd: $TRASH_DIRECTORY/14/sub/sub
1844+
setup: prefix: (null)
1845+
EOF
1846+
git config --file="$TRASH_DIRECTORY/14.git/config" core.worktree ../14/wt &&
1847+
test_repo 14/sub/sub ../../.git
1848+
'
1849+
1850+
test_expect_failure '#14: GIT_DIR, core.worktree=../14/wt(rel) in subdir' '
1851+
cat >14/sub/sub/expected <<EOF &&
1852+
setup: git_dir: $TRASH_DIRECTORY/14.git
1853+
setup: worktree: $TRASH_DIRECTORY/14/wt
1854+
setup: cwd: $TRASH_DIRECTORY/14/sub/sub
1855+
setup: prefix: (null)
1856+
EOF
1857+
git config --file="$TRASH_DIRECTORY/14.git/config" core.worktree ../14/wt &&
1858+
test_repo 14/sub/sub "$TRASH_DIRECTORY/14/.git"
1859+
'
1860+
1861+
test_expect_failure '#14: GIT_DIR, core.worktree=../14/wt in subdir' '
1862+
cat >14/sub/sub/expected <<EOF &&
1863+
setup: git_dir: $TRASH_DIRECTORY/14.git
1864+
setup: worktree: $TRASH_DIRECTORY/14/wt
1865+
setup: cwd: $TRASH_DIRECTORY/14/sub/sub
1866+
setup: prefix: (null)
1867+
EOF
1868+
git config --file="$TRASH_DIRECTORY/14.git/config" core.worktree "$TRASH_DIRECTORY/14/wt" &&
1869+
test_repo 14/sub/sub "$TRASH_DIRECTORY/14/.git"
1870+
'
1871+
1872+
test_expect_failure '#14: GIT_DIR(rel), core.worktree=.. at root' '
1873+
cat >14/expected <<EOF &&
1874+
setup: git_dir: $TRASH_DIRECTORY/14.git
1875+
setup: worktree: $TRASH_DIRECTORY
1876+
setup: cwd: $TRASH_DIRECTORY
1877+
setup: prefix: 14/
1878+
EOF
1879+
git config --file="$TRASH_DIRECTORY/14.git/config" core.worktree "$TRASH_DIRECTORY" &&
1880+
test_repo 14 .git
1881+
'
1882+
1883+
test_expect_failure '#14: GIT_DIR(rel), core.worktree=..(rel) at root' '
1884+
cat >14/expected <<EOF &&
1885+
setup: git_dir: $TRASH_DIRECTORY/14.git
1886+
setup: worktree: $TRASH_DIRECTORY
1887+
setup: cwd: $TRASH_DIRECTORY
1888+
setup: prefix: 14/
1889+
EOF
1890+
git config --file="$TRASH_DIRECTORY/14.git/config" core.worktree .. &&
1891+
test_repo 14 .git
1892+
'
1893+
1894+
test_expect_failure '#14: GIT_DIR, core.worktree=..(rel) at root' '
1895+
cat >14/expected <<EOF &&
1896+
setup: git_dir: $TRASH_DIRECTORY/14.git
1897+
setup: worktree: $TRASH_DIRECTORY
1898+
setup: cwd: $TRASH_DIRECTORY
1899+
setup: prefix: 14/
1900+
EOF
1901+
git config --file="$TRASH_DIRECTORY/14.git/config" core.worktree .. &&
1902+
test_repo 14 "$TRASH_DIRECTORY/14/.git"
1903+
'
1904+
1905+
test_expect_failure '#14: GIT_DIR, core.worktree=.. at root' '
1906+
cat >14/expected <<EOF &&
1907+
setup: git_dir: $TRASH_DIRECTORY/14.git
1908+
setup: worktree: $TRASH_DIRECTORY
1909+
setup: cwd: $TRASH_DIRECTORY
1910+
setup: prefix: 14/
1911+
EOF
1912+
git config --file="$TRASH_DIRECTORY/14.git/config" core.worktree "$TRASH_DIRECTORY" &&
1913+
test_repo 14 "$TRASH_DIRECTORY/14/.git"
1914+
'
1915+
1916+
test_expect_failure '#14: GIT_DIR(rel), core.worktree=.. in subdir' '
1917+
cat >14/sub/sub/expected <<EOF &&
1918+
setup: git_dir: $TRASH_DIRECTORY/14.git
1919+
setup: worktree: $TRASH_DIRECTORY
1920+
setup: cwd: $TRASH_DIRECTORY
1921+
setup: prefix: 14/sub/sub/
1922+
EOF
1923+
git config --file="$TRASH_DIRECTORY/14.git/config" core.worktree "$TRASH_DIRECTORY" &&
1924+
test_repo 14/sub/sub ../../.git
1925+
'
1926+
1927+
test_expect_failure '#14: GIT_DIR(rel), core.worktree=..(rel) in subdir' '
1928+
cat >14/sub/sub/expected <<EOF &&
1929+
setup: git_dir: $TRASH_DIRECTORY/14.git
1930+
setup: worktree: $TRASH_DIRECTORY
1931+
setup: cwd: $TRASH_DIRECTORY
1932+
setup: prefix: 14/sub/sub/
1933+
EOF
1934+
git config --file="$TRASH_DIRECTORY/14.git/config" core.worktree .. &&
1935+
test_repo 14/sub/sub ../../.git
1936+
'
1937+
1938+
test_expect_failure '#14: GIT_DIR, core.worktree=..(rel) in subdir' '
1939+
cat >14/sub/sub/expected <<EOF &&
1940+
setup: git_dir: $TRASH_DIRECTORY/14.git
1941+
setup: worktree: $TRASH_DIRECTORY
1942+
setup: cwd: $TRASH_DIRECTORY
1943+
setup: prefix: 14/sub/sub/
1944+
EOF
1945+
git config --file="$TRASH_DIRECTORY/14.git/config" core.worktree .. &&
1946+
test_repo 14/sub/sub "$TRASH_DIRECTORY/14/.git"
1947+
'
1948+
1949+
test_expect_failure '#14: GIT_DIR, core.worktree=.. in subdir' '
1950+
cat >14/sub/sub/expected <<EOF &&
1951+
setup: git_dir: $TRASH_DIRECTORY/14.git
1952+
setup: worktree: $TRASH_DIRECTORY
1953+
setup: cwd: $TRASH_DIRECTORY
1954+
setup: prefix: 14/sub/sub/
1955+
EOF
1956+
git config --file="$TRASH_DIRECTORY/14.git/config" core.worktree "$TRASH_DIRECTORY" &&
1957+
test_repo 14/sub/sub "$TRASH_DIRECTORY/14/.git"
1958+
'
1959+
16691960
test_done

0 commit comments

Comments
 (0)