ref:a778ca2397205d5eee6bbdbd73dcd7cc0a1f5e4a

perf: add fast path for identical tree shas and task timeout resilience

SHA: a778ca2397205d5eee6bbdbd73dcd7cc0a1f5e4a
Author: t <t@t.com>
Date: 2026-09-01 04:12
Parents: 5360104
1 files changed +16 -1
Type
lib/ex_git_objectstore/diff.ex +16 −1
@@ -52,6 +52,8 @@
"""
@spec diff_trees(Repo.t(), String.t() | nil, String.t() | nil) ::
{:ok, [file_change()]} | {:error, term()}
def diff_trees(_repo, tree_sha, tree_sha), do: {:ok, []}
def diff_trees(repo, old_tree_sha, new_tree_sha) do
old_entries = load_tree_entries(repo, old_tree_sha)
new_entries = load_tree_entries(repo, new_tree_sha)
@@ -121,9 +123,22 @@
|> Task.async_stream(&build_file_diff(repo, &1, opts),
max_concurrency: max_concurrency,
timeout: timeout,
on_timeout: :kill_task,
ordered: true
)
|> Enum.zip(changes)
|> Enum.map(fn
{{:ok, diff}, _change} ->
diff
{{:exit, _reason}, change} ->
|> Enum.map(fn {:ok, diff} -> diff end)
%{
path: change.path,
status: change.status,
hunks: [],
binary: true
}
end)
{:ok, file_diffs}
end