Branch

commit first line goes here

Sun Dec 07 2025

Tucker McKnight <tucker@pangolin.lan>

Use the git -C flag instead of changing directories

For some reason, when trying to generate the site in a git
post-receive hook, the `cd` command doesn't seem to be working.
Let's try it with git's built-in -C flag instead, which allows
you to specify the location of the git repo without actually
cd-ing into that directory.

c945a92bbe22b7562626d9667dd71b6050b79279

Side-by-side
Stacked
js_templates/helpers/nav.ts:3
Before
3
  const rootPath = `${reposPath}/${slugify(repoName)}/branches`
After
3 4 5 6 7 8 9 10 11

  // These two aren't actually used by any pages, but they're in almost
  // every page URL. E.g. all of them start with 'repos/my-repo-name'
  // or 'repos/my-repo-name/branches.'
  const repoBasePath = `${reposPath}/${slugify(repoName)}`
  const rootBasePathBranches = `${repoBasePath}/branches`


  const currentBranchPath = `${rootBasePathBranches}/${slugify(branchName)}`
js_templates/helpers/nav.ts:15
Before
15 16 17 18 19
      return `${rootPath}/${slugify(reposConfig.repos[repoName].defaultBranch)}`
    repoCurrentBranchHome: () => rootPath,
      return `${rootPath}/files`
    repoCurrentBranchCommits: () => `${rootPath}/commits`,
    repoCurrentBranchBranches: () => `${rootPath}/branches`,
After
15 16 17 18 19 20 21
      return `${rootBasePathBranches}/${slugify(reposConfig.repos[repoName].defaultBranch)}`
    },
    repoCurrentBranchHome: () => {
      return currentBranchPath
      return `${currentBranchPath}/files`
    repoCurrentBranchCommits: () => `${currentBranchPath}/commits`,
    repoCurrentBranchBranches: () => `${currentBranchPath}/branches`,
main.ts:66
Before
66 67 68 69
          const fetchCommands = repoConfig.branchesToPull.map(branch => `git fetch origin ${branch}:${branch}`).join('; ')
          await exec(`(cd ${eleventyConfig.dir.output + reposPath + "/" + gitRepoName} && ${fetchCommands}; git update-server-info)`)
          await exec(`(cd ${eleventyConfig.dir.output + reposPath + "/"} && git clone ${originalLocation} ${gitRepoName} --bare)`)
          await exec(`(cd ${eleventyConfig.dir.output + reposPath + "/" + gitRepoName} && git update-server-info)`)
After
66 67 68 69 70
          const location = eleventyConfig.dir.output + reposPath + "/" + gitRepoName
          const fetchCommands = repoConfig.branchesToPull.map(branch => `git -C ${location} fetch origin ${branch}:${branch}`).join('; ')
          await exec(`${fetchCommands} && git update-server-info`)
          await exec(`git clone ${originalLocation} ${eleventyConfig.dir.output + reposPath + "/" + gitRepoName} --bare`)
          await exec(`git -C ${eleventyConfig.dir.output + reposPath + "/" + gitRepoName} update-server-info`)
main.ts:84
Before
84
            await exec(`(cd ${tempDirRepoPath} && git checkout ${branch})`)
After
84
            await exec(`git -C ${tempDirRepoPath} checkout ${branch}`)
main.ts:95
Before
95
After
95 96 97

        const location = eleventyConfig.dir.output + reposPath + "/" + gitRepoName
        await exec(`git -C ${location} symbolic-ref HEAD refs/heads/${repoConfig.defaultBranch}`)
main.ts:203
Before
203 204
    const command = `git show ${branch}:${filename}`
    const res = await exec(`(cd ${location} && ${command})`)
After
203 204
    const command = `git -C ${location} show ${branch}:${filename}`
    const res = await exec(command)
main.ts:222
Before
222 223
    const command = `git show ${branchName}:README.md`
      const res = await exec(`(cd ${location} && ${command})`)
After
222 223
    const command = `git -C ${location} show ${branchName}:README.md`
      const res = await exec(command)
src/repos.ts:42
Before
42
      const branchHeadRes = await exec(`(cd ${repoLocation} && git show-ref --branch ${branchName})`)
After
42
      const branchHeadRes = await exec(`git -C ${repoLocation} show-ref --branch ${branchName}`)
src/vcses/git/operations.ts:5
Before
5 6
  const command = `git ls-tree -r --name-only ${branchName}`
  const result = await exec(`(cd ${repoLocation} && ${command})`)
After
5 6
  const command = `git -C ${repoLocation} ls-tree -r --name-only ${branchName}`
  const result = await exec(command)
src/vcses/git/operations.ts:39
Before
39 40
  const totalPatchesCountRes = await exec(`(cd ${repoLocation} && git rev-list --count ${branchName})`)
    const gitLogSubsetRes = await exec(`(cd ${repoLocation} && git log ${branchName} -p -n 10 --skip ${i})`)
After
39 40
  const totalPatchesCountRes = await exec(`git -C ${repoLocation} rev-list --count ${branchName}`)
    const gitLogSubsetRes = await exec(`git -C ${repoLocation} log ${branchName} -p -n 10 --skip ${i}`)
src/vcses/git/operations.ts:99
Before
99 100
  const command = `git blame --porcelain ${branch} ${filename}`
  const res = await exec(`(cd ${repoLocation} && ${command})`)
After
99 100
  const command = `git -C ${repoLocation} blame --porcelain ${branch} ${filename}`
  const res = await exec(command)