MCPcopy Index your code
hub / github.com/codeaashu/claude-code / hasWorktreeChanges

Function hasWorktreeChanges

src/utils/worktree.ts:1144–1173  ·  view source on GitHub ↗
(
  worktreePath: string,
  headCommit: string,
)

Source from the content-addressed store, hash-verified

1142 * — callers use this to decide whether to remove a worktree, so fail-closed.
1143 */
1144export async function hasWorktreeChanges(
1145 worktreePath: string,
1146 headCommit: string,
1147): Promise<boolean> {
1148 const { code: statusCode, stdout: statusOutput } =
1149 await execFileNoThrowWithCwd(gitExe(), ['status', '--porcelain'], {
1150 cwd: worktreePath,
1151 })
1152 if (statusCode !== 0) {
1153 return true
1154 }
1155 if (statusOutput.trim().length > 0) {
1156 return true
1157 }
1158
1159 const { code: revListCode, stdout: revListOutput } =
1160 await execFileNoThrowWithCwd(
1161 gitExe(),
1162 ['rev-list', '--count', `${headCommit}..HEAD`],
1163 { cwd: worktreePath },
1164 )
1165 if (revListCode !== 0) {
1166 return true
1167 }
1168 if (parseInt(revListOutput.trim(), 10) > 0) {
1169 return true
1170 }
1171
1172 return false
1173}
1174
1175/**
1176 * Fast-path handler for --worktree --tmux.

Callers 1

cleanupWorktreeIfNeededFunction · 0.85

Calls 1

execFileNoThrowWithCwdFunction · 0.85

Tested by

no test coverage detected