fix: use NULL bytes as git log format separators
The git log --graph output uses | characters in the ASCII art, which conflicts with using | as a format separator. Switch to NULL bytes (\x00) which won't appear in commit data. Also removed --graph flag since we build graph data from parent relationships instead.
This commit is contained in:
@@ -63,12 +63,11 @@ def get_commit_history(repo_path: str, branch: str | None = None, limit: int = 1
|
||||
branches_output = _run_git_command(repo_path, ["branch", "-a", "--format=%(refname:short)"])
|
||||
branches = [b.strip() for b in branches_output.strip().split("\n") if b.strip()]
|
||||
|
||||
# Build git log command
|
||||
# Build git log command - use NULL bytes as separators to avoid parsing issues
|
||||
log_args = [
|
||||
"log",
|
||||
"--all",
|
||||
"--graph",
|
||||
f"--format=%H|%P|%an|%ae|%at|%s",
|
||||
"--format=%H%x00%P%x00%an%x00%ae%x00%at%x00%s",
|
||||
f"--max-count={limit}",
|
||||
f"--skip={offset}",
|
||||
]
|
||||
@@ -82,13 +81,14 @@ def get_commit_history(repo_path: str, branch: str | None = None, limit: int = 1
|
||||
tag_map = _get_tag_map(repo_path)
|
||||
|
||||
commits = []
|
||||
graph_lines = log_output.strip().split("\n") if log_output.strip() else []
|
||||
log_lines = log_output.strip().split("\n") if log_output.strip() else []
|
||||
|
||||
for line in graph_lines:
|
||||
if "|" not in line:
|
||||
for line in log_lines:
|
||||
line = line.strip()
|
||||
if not line:
|
||||
continue
|
||||
|
||||
parts = line.split("|")
|
||||
parts = line.split("\x00")
|
||||
if len(parts) < 6:
|
||||
continue
|
||||
|
||||
|
||||
Reference in New Issue
Block a user