From: Konstantin Khorenko <khorenko@virtuozzo.com>
To: tools@kernel.org
Cc: Konstantin Khorenko <khorenko@virtuozzo.com>
Subject: [PATCH b4] review: separate revisions from paths when diffing a commit
Date: Fri, 4 Sep 2026 16:59:41 +0200 [thread overview]
Message-ID: <20260904145941.1414684-1-khorenko@virtuozzo.com> (raw)
Reviewing a series fails with "Could not generate diff" whenever the
work tree contains a file or directory named after the commit being
diffed:
$ mkdir 1b7771486ae3d9dec8959dbb4da51e535364fb8e
$ git diff 1b7771486ae3d9dec8959dbb4da51e535364fb8e~1 \
1b7771486ae3d9dec8959dbb4da51e535364fb8e
fatal: ambiguous argument '1b7771486ae3d9dec8959dbb4da51e535364fb8e':
both revision and filename
Any tooling that names its output after a bare SHA (review notes,
logs, build artifacts) can shadow the revision this way. Both
arguments here are always revisions, so terminate them with '--' at
every site that diffs a commit against its parent.
Signed-off-by: Konstantin Khorenko <khorenko@virtuozzo.com>
Assisted-by: claude-sonnet-5
---
src/b4/review/_review.py | 14 ++++++++++----
src/b4/review_tui/_review_app.py | 8 +++++---
2 files changed, 15 insertions(+), 7 deletions(-)
diff --git a/src/b4/review/_review.py b/src/b4/review/_review.py
index a375332..07a0d51 100644
--- a/src/b4/review/_review.py
+++ b/src/b4/review/_review.py
@@ -1305,7 +1305,9 @@ def reanchor_patch_comments(
if not comments or not any(c.get('content') for c in comments):
continue
if real_diff is None:
- ecode, real_diff = b4.git_run_command(topdir, ['diff', f'{sha}~1', sha])
+ ecode, real_diff = b4.git_run_command(
+ topdir, ['diff', f'{sha}~1', sha, '--']
+ )
if ecode != 0:
break
_resolve_comment_positions(real_diff, comments)
@@ -1461,7 +1463,9 @@ def _integrate_agent_reviews(
# Resolve comment positions against the real diff
if comments:
sha = commit_shas[idx]
- ecode, real_diff = b4.git_run_command(topdir, ['diff', f'{sha}~1', sha])
+ ecode, real_diff = b4.git_run_command(
+ topdir, ['diff', f'{sha}~1', sha, '--']
+ )
if ecode == 0:
_resolve_comment_positions(real_diff, comments)
@@ -1855,7 +1859,7 @@ def _integrate_sashiko_reviews(
# Resolve comment positions against the real diff, then fall back
# to structured finding locations for any still-unpositioned comments.
sha = commit_shas[idx]
- ecode, real_diff = b4.git_run_command(topdir, ['diff', f'{sha}~1', sha])
+ ecode, real_diff = b4.git_run_command(topdir, ['diff', f'{sha}~1', sha, '--'])
if ecode == 0:
_resolve_comment_positions(real_diff, comments)
if locations_by_file:
@@ -1950,7 +1954,9 @@ def _integrate_followup_inline_comments(
# Resolve positions against the real diff
sha = commit_shas[idx]
- ecode, real_diff = b4.git_run_command(topdir, ['diff', f'{sha}~1', sha])
+ ecode, real_diff = b4.git_run_command(
+ topdir, ['diff', f'{sha}~1', sha, '--']
+ )
if ecode == 0:
_resolve_comment_positions(real_diff, comments)
diff --git a/src/b4/review_tui/_review_app.py b/src/b4/review_tui/_review_app.py
index da60455..26ce90a 100644
--- a/src/b4/review_tui/_review_app.py
+++ b/src/b4/review_tui/_review_app.py
@@ -699,7 +699,9 @@ from b4.review_tui._modals import (
viewer.write(Rule(style='dim'))
viewer.write(Text(''))
- ecode, diff_out = b4.git_run_command(self._topdir, ['diff', f'{sha}~1', sha])
+ ecode, diff_out = b4.git_run_command(
+ self._topdir, ['diff', f'{sha}~1', sha, '--']
+ )
if ecode > 0:
viewer.write(Text('Could not generate diff', style=ts['error']))
return
@@ -1336,7 +1338,7 @@ from b4.review_tui._modals import (
return
sha = self._commit_shas[patch_idx]
ecode, real_diff = b4.git_run_command(
- self._topdir, ['diff', f'{sha}~1', sha]
+ self._topdir, ['diff', f'{sha}~1', sha, '--']
)
if ecode > 0:
self.notify('Could not get diff', severity='error')
@@ -2054,7 +2056,7 @@ from b4.review_tui._modals import (
sha = self._commit_shas[idx]
ecode, real_diff = b4.git_run_command(
- self._topdir, ['diff', f'{sha}~1', sha]
+ self._topdir, ['diff', f'{sha}~1', sha, '--']
)
if ecode == 0:
b4.review._resolve_comment_positions(real_diff, comments)
--
2.43.0
reply other threads:[~2026-09-04 14:59 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260904145941.1414684-1-khorenko@virtuozzo.com \
--to=khorenko@virtuozzo.com \
--cc=tools@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox