Repository navigation
Closed
Description
Repository::logPath($path, $limit) only looks at the newest 5 * $limit commits (
Lines 793 to 820 in 5beb97d
| public function logPath(string $path, int $limit = 50): array | |
| { | |
| $allCommits = $this->log($limit * 5); // over-fetch to filter | |
| $treeDiff = new TreeDiff($this->objects); | |
| $result = []; | |
| foreach ($allCommits as $commit) { | |
| $parentTree = $commit->parents !== [] | |
| ? $this->getCommitTree($commit->parents[0]) | |
| : null; | |
| $diffs = $treeDiff->diff($parentTree, $commit->tree); | |
| foreach ($diffs as $diff) { | |
| if ($diff->oldPath === $path || $diff->newPath === $path) { | |
| $result[] = $commit; | |
| break; | |
| } | |
| } | |
| if (count($result) >= $limit) { | |
| break; | |
| } | |
| } | |
| return $result; | |
| } | |
$this->log($limit * 5), "over-fetch to filter"). Commits that touch the path further back are never found, so pitmaster log <path> and log -n 1 <path> can print nothing for a file that has history.
Repro
git init -q t && cd t && git config user.name T && git config user.email t@x
echo x > x.txt && git add x.txt && git commit -qm "add x"
for i in 1 2 3 4 5 6 7; do echo $i > y.txt; git add y.txt; git commit -qm "y $i"; done
git log --oneline -1 -- x.txt # 5dda7f7 add x
pitmaster log --oneline -n 1 x.txt # prints nothing$repo->logPath('x.txt', 1) returns 0 commits, logPath('x.txt', 2) returns 1.
The match is also an exact file path comparison against the first parent only, so a directory path (src) never matches, unlike git log -- src.
Expected
Walk history until $limit matching commits are found or history ends.
Metadata
Metadata
Assignees
Labels
No labels
Activity