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

Function isNormalizedGitCommand

src/tools/BashTool/bashPermissions.ts:2567–2588  ·  view source on GitHub ↗
(command: string)

Source from the content-addressed store, hash-verified

2565 * NO_COLOR=1 git status — env var prefix hides the command
2566 */
2567export function isNormalizedGitCommand(command: string): boolean {
2568 // Fast path: catch the most common case before any parsing
2569 if (command.startsWith('git ') || command === 'git') {
2570 return true
2571 }
2572 const stripped = stripSafeWrappers(command)
2573 const parsed = tryParseShellCommand(stripped)
2574 if (parsed.success && parsed.tokens.length > 0) {
2575 // Direct git command
2576 if (parsed.tokens[0] === 'git') {
2577 return true
2578 }
2579 // "xargs git ..." — xargs runs git in the current directory,
2580 // so it must be treated as a git command for cd+git security checks.
2581 // This matches the xargs prefix handling in filterRulesByContentsMatchingInput.
2582 if (parsed.tokens[0] === 'xargs' && parsed.tokens.includes('git')) {
2583 return true
2584 }
2585 return false
2586 }
2587 return /^git(?:\s|$)/.test(stripped)
2588}
2589
2590/**
2591 * Checks if a subcommand is a cd command after normalizing away safe wrappers

Callers 2

bashToolHasPermissionFunction · 0.85
commandHasAnyGitFunction · 0.85

Calls 2

stripSafeWrappersFunction · 0.85
tryParseShellCommandFunction · 0.85

Tested by

no test coverage detected