* [PATCH 0/2] b4: sparse-checkout related fixes
@ 2025-10-13 22:20 Michael S. Tsirkin
2025-10-13 22:20 ` [PATCH 1/2] test_shazam: clean worktree before git am Michael S. Tsirkin
` (4 more replies)
0 siblings, 5 replies; 8+ messages in thread
From: Michael S. Tsirkin @ 2025-10-13 22:20 UTC (permalink / raw)
To: tools
I encountered shazam test failures, diagnozing them I realized
b4 misuses the sparse-checkout command.
This patchset cleans this up.
Pls review, thanks!
Michael S. Tsirkin (2):
test_shazam: clean worktree before git am
ez: cleanup sparse-checkout usage
src/b4/__init__.py | 6 +++---
src/b4/ez.py | 6 +++---
2 files changed, 6 insertions(+), 6 deletions(-)
--
MST
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH 1/2] test_shazam: clean worktree before git am
2025-10-13 22:20 [PATCH 0/2] b4: sparse-checkout related fixes Michael S. Tsirkin
@ 2025-10-13 22:20 ` Michael S. Tsirkin
2025-10-13 22:20 ` [PATCH 2/2] ez: cleanup sparse-checkout usage Michael S. Tsirkin
` (3 subsequent siblings)
4 siblings, 0 replies; 8+ messages in thread
From: Michael S. Tsirkin @ 2025-10-13 22:20 UTC (permalink / raw)
To: tools
I see the following failures on master (as of commit 965071ee174d):
- test_shazam[shazam-git1-just-series-shazamargs1-compareargs1-shazam-git1-just-series-defaults-b4cfg1] FAILED
Error: "fatal: Dirty index: cannot apply patches (dirty: file1.txt file2.txt lipsum.txt)"
- test_shazam[shazam-git1-just-series-shazamargs2-compareargs2-shazam-git1-just-series-merged-b4cfg2] FAILED
Error: "fatal: Dirty index: cannot apply patches (dirty: file1.txt file2.txt lipsum.txt)"
Both tests fail because git am can't apply patches with a dirty index.
Specifically, the worktree is created with `git worktree add --detach --no-checkout`,
to save time checking out files to the working directory.
However, this means all files then appear as deleted in the index.
The test attempts to solve this by a combination of
"git sparse-checkout init" followed by "git checkout".
However, "git sparse-checkout init" does not actually create an empty
sparse checkout cone and additionally "git checkout" by default does not
update the index - it only updates the worktree from the index.
As a result, when "git am" tries to apply patches, it fails with "Dirty
index: cannot apply patches" because the index contains staged changes
(the "deleted" entries).
To fix, replace "git sparse-checkout init" with "git sparse-checkout
set" - with no patterns, this actually creates an empty sparse checkout -
followed by "git checkout -f" to update the index to match HEAD,
clearing the staged deletions.
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
src/b4/__init__.py | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/src/b4/__init__.py b/src/b4/__init__.py
index 142da25..31c7fa4 100644
--- a/src/b4/__init__.py
+++ b/src/b4/__init__.py
@@ -4501,12 +4501,12 @@ def git_fetch_am_into_repo(gitdir: Optional[str], ambytes: bytes, at_base: str =
with git_temp_worktree(topdir, at_base) as gwt:
logger.info('Magic: Preparing a sparse worktree')
- ecode, out = git_run_command(gwt, ['sparse-checkout', 'init'], logstderr=True)
+ ecode, out = git_run_command(gwt, ['sparse-checkout', 'set'], logstderr=True)
if ecode > 0:
- logger.critical('Error running sparse-checkout init')
+ logger.critical('Error running sparse-checkout set')
logger.critical(out)
raise RuntimeError
- ecode, out = git_run_command(gwt, ['checkout'], logstderr=True)
+ ecode, out = git_run_command(gwt, ['checkout', '-f'], logstderr=True)
if ecode > 0:
logger.critical('Error running checkout into sparse workdir')
logger.critical(out)
--
MST
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH 2/2] ez: cleanup sparse-checkout usage
2025-10-13 22:20 [PATCH 0/2] b4: sparse-checkout related fixes Michael S. Tsirkin
2025-10-13 22:20 ` [PATCH 1/2] test_shazam: clean worktree before git am Michael S. Tsirkin
@ 2025-10-13 22:20 ` Michael S. Tsirkin
2025-10-15 21:07 ` [PATCH 0/2] b4: sparse-checkout related fixes Michael S. Tsirkin
` (2 subsequent siblings)
4 siblings, 0 replies; 8+ messages in thread
From: Michael S. Tsirkin @ 2025-10-13 22:20 UTC (permalink / raw)
To: tools
Similarly to the previus patch, b4 ez uses sparse-checkout incorrectly:
- it does not want any files but it uses "init" which
actually gives some files (the ones in the root)
- it runs checkout but it's pointless - index is left dirty,
and it only happens to work because cherry-pick works
with a dirty index (unlike e.g. am).
To fix, switch to sparse-checkout set to get an empty cone +
checkout -f to update the index.
We could actually skip checkout completely but it seems better
not to rely on the quirk of cherry-pick that allows it to
work with a dirty index, and an empty index is quick to update.
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
src/b4/ez.py | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/src/b4/ez.py b/src/b4/ez.py
index 26772b4..4510be2 100644
--- a/src/b4/ez.py
+++ b/src/b4/ez.py
@@ -2386,12 +2386,12 @@ def reroll(mybranch: str, tag_msg: str, msgid: str, tagprefix: str = SENT_TAG_PR
base_commit, start_commit, end_commit = get_series_range(usebranch=mybranch)
with b4.git_temp_worktree(topdir, base_commit) as gwt:
logger.debug('Preparing a sparse worktree')
- ecode, out = b4.git_run_command(gwt, ['sparse-checkout', 'init'], logstderr=True)
+ ecode, out = b4.git_run_command(gwt, ['sparse-checkout', 'set'], logstderr=True)
if ecode > 0:
- logger.critical('Error running sparse-checkout init')
+ logger.critical('Error running sparse-checkout set')
logger.critical(out)
raise RuntimeError
- ecode, out = b4.git_run_command(gwt, ['checkout'], logstderr=True)
+ ecode, out = b4.git_run_command(gwt, ['checkout', '-f'], logstderr=True)
if ecode > 0:
logger.critical('Error running checkout into sparse workdir')
logger.critical(out)
--
MST
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH 0/2] b4: sparse-checkout related fixes
2025-10-13 22:20 [PATCH 0/2] b4: sparse-checkout related fixes Michael S. Tsirkin
2025-10-13 22:20 ` [PATCH 1/2] test_shazam: clean worktree before git am Michael S. Tsirkin
2025-10-13 22:20 ` [PATCH 2/2] ez: cleanup sparse-checkout usage Michael S. Tsirkin
@ 2025-10-15 21:07 ` Michael S. Tsirkin
2025-10-17 0:08 ` Konstantin Ryabitsev
2025-10-22 17:35 ` Konstantin Ryabitsev
2025-10-22 19:57 ` Konstantin Ryabitsev
4 siblings, 1 reply; 8+ messages in thread
From: Michael S. Tsirkin @ 2025-10-15 21:07 UTC (permalink / raw)
To: tools; +Cc: konstantin
On Mon, Oct 13, 2025 at 06:20:06PM -0400, Michael S. Tsirkin wrote:
> I encountered shazam test failures, diagnozing them I realized
> b4 misuses the sparse-checkout command.
> This patchset cleans this up.
> Pls review, thanks!
Hi Konstantin,
Just making sure sending this to tools@kernel.org is
the right thing. And do you want to be CC'd? Thanks!
> Michael S. Tsirkin (2):
> test_shazam: clean worktree before git am
> ez: cleanup sparse-checkout usage
>
> src/b4/__init__.py | 6 +++---
> src/b4/ez.py | 6 +++---
> 2 files changed, 6 insertions(+), 6 deletions(-)
>
> --
> MST
>
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 0/2] b4: sparse-checkout related fixes
2025-10-15 21:07 ` [PATCH 0/2] b4: sparse-checkout related fixes Michael S. Tsirkin
@ 2025-10-17 0:08 ` Konstantin Ryabitsev
0 siblings, 0 replies; 8+ messages in thread
From: Konstantin Ryabitsev @ 2025-10-17 0:08 UTC (permalink / raw)
To: Michael S. Tsirkin; +Cc: tools
On Wed, Oct 15, 2025 at 05:07:07PM -0400, Michael S. Tsirkin wrote:
> On Mon, Oct 13, 2025 at 06:20:06PM -0400, Michael S. Tsirkin wrote:
> > I encountered shazam test failures, diagnozing them I realized
> > b4 misuses the sparse-checkout command.
> > This patchset cleans this up.
> > Pls review, thanks!
>
> Hi Konstantin,
> Just making sure sending this to tools@kernel.org is
> the right thing. And do you want to be CC'd? Thanks!
Nope, it's all good, I just haven't been able to review it yet.
-K
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 0/2] b4: sparse-checkout related fixes
2025-10-13 22:20 [PATCH 0/2] b4: sparse-checkout related fixes Michael S. Tsirkin
` (2 preceding siblings ...)
2025-10-15 21:07 ` [PATCH 0/2] b4: sparse-checkout related fixes Michael S. Tsirkin
@ 2025-10-22 17:35 ` Konstantin Ryabitsev
2025-10-22 19:57 ` Konstantin Ryabitsev
4 siblings, 0 replies; 8+ messages in thread
From: Konstantin Ryabitsev @ 2025-10-22 17:35 UTC (permalink / raw)
To: tools, Michael S. Tsirkin
On Mon, 13 Oct 2025 18:20:04 -0400, Michael S. Tsirkin wrote:
> I encountered shazam test failures, diagnozing them I realized
> b4 misuses the sparse-checkout command.
> This patchset cleans this up.
> Pls review, thanks!
>
> Michael S. Tsirkin (2):
> test_shazam: clean worktree before git am
> ez: cleanup sparse-checkout usage
>
> [...]
Applied, thanks!
[1/2] test_shazam: clean worktree before git am
commit: 72af5e2f16d67610a018c08d264cd9c160cce8bf
[2/2] ez: cleanup sparse-checkout usage
commit: 9e52ea82688a8ca37e6f59a86a723768c6044547
Best regards,
--
Konstantin Ryabitsev <konstantin@linuxfoundation.org>
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 0/2] b4: sparse-checkout related fixes
2025-10-13 22:20 [PATCH 0/2] b4: sparse-checkout related fixes Michael S. Tsirkin
` (3 preceding siblings ...)
2025-10-22 17:35 ` Konstantin Ryabitsev
@ 2025-10-22 19:57 ` Konstantin Ryabitsev
2025-10-22 19:58 ` Konstantin Ryabitsev
4 siblings, 1 reply; 8+ messages in thread
From: Konstantin Ryabitsev @ 2025-10-22 19:57 UTC (permalink / raw)
To: tools, Michael S. Tsirkin
On Mon, 13 Oct 2025 18:20:04 -0400, Michael S. Tsirkin wrote:
> I encountered shazam test failures, diagnozing them I realized
> b4 misuses the sparse-checkout command.
> This patchset cleans this up.
> Pls review, thanks!
>
> Michael S. Tsirkin (2):
> test_shazam: clean worktree before git am
> ez: cleanup sparse-checkout usage
>
> [...]
Applied, thanks!
[1/2] test_shazam: clean worktree before git am
commit: 72af5e2f16d67610a018c08d264cd9c160cce8bf
[2/2] ez: cleanup sparse-checkout usage
commit: 9e52ea82688a8ca37e6f59a86a723768c6044547
Best regards,
--
Konstantin Ryabitsev <konstantin@linuxfoundation.org>
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 0/2] b4: sparse-checkout related fixes
2025-10-22 19:57 ` Konstantin Ryabitsev
@ 2025-10-22 19:58 ` Konstantin Ryabitsev
0 siblings, 0 replies; 8+ messages in thread
From: Konstantin Ryabitsev @ 2025-10-22 19:58 UTC (permalink / raw)
To: tools, Michael S. Tsirkin
On Wed, Oct 22, 2025 at 03:57:43PM -0400, Konstantin Ryabitsev wrote:
> [1/2] test_shazam: clean worktree before git am
> commit: 72af5e2f16d67610a018c08d264cd9c160cce8bf
> [2/2] ez: cleanup sparse-checkout usage
> commit: 9e52ea82688a8ca37e6f59a86a723768c6044547
Sometimes you find bugs in your own stuff. :)
Ignore the duplicate, please -- this is because I retrieved this patchset
again while testing fixes for "git am".
-K
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2025-10-22 19:58 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-10-13 22:20 [PATCH 0/2] b4: sparse-checkout related fixes Michael S. Tsirkin
2025-10-13 22:20 ` [PATCH 1/2] test_shazam: clean worktree before git am Michael S. Tsirkin
2025-10-13 22:20 ` [PATCH 2/2] ez: cleanup sparse-checkout usage Michael S. Tsirkin
2025-10-15 21:07 ` [PATCH 0/2] b4: sparse-checkout related fixes Michael S. Tsirkin
2025-10-17 0:08 ` Konstantin Ryabitsev
2025-10-22 17:35 ` Konstantin Ryabitsev
2025-10-22 19:57 ` Konstantin Ryabitsev
2025-10-22 19:58 ` Konstantin Ryabitsev
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).