git: improve file path validation in add operation
Use Git CLI directly instead of GitPython index API to ensure proper path validation and prevent option injection. The '--' separator ensures file paths starting with '-' are handled correctly.
This commit is contained in:
parent
dcb47d2d94
commit
db96050800
1 changed files with 2 additions and 1 deletions
|
|
@ -132,7 +132,8 @@ def git_add(repo: git.Repo, files: list[str]) -> str:
|
|||
if files == ["."]:
|
||||
repo.git.add(".")
|
||||
else:
|
||||
repo.index.add(files)
|
||||
# Use '--' to prevent files starting with '-' from being interpreted as options
|
||||
repo.git.add("--", *files)
|
||||
return "Files staged successfully"
|
||||
|
||||
def git_reset(repo: git.Repo) -> str:
|
||||
|
|
|
|||
Loading…
Reference in a new issue