b4: sparse-checkout related fixes
cover b4: sparse-checkout related fixes
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(-)
Signature · 1 line
MST
PATCH 1/2 test_shazam: clean worktree before git am
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.
--- src/b4/__init__.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
src/b4/__init__.py +3 -3
@@ -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)
Signature · 1 line
MST
PATCH 2/2 ez: cleanup sparse-checkout usage
In reply to Michael S. TsirkinSimilarly 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.
--- src/b4/ez.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
src/b4/ez.py +3 -3
@@ -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)
Signature · 1 line
MST
Quoted 4 lines · Michael S. Tsirkin
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 [email protected] is the right thing. And do you want to be CC'd? Thanks!
Quoted 11 lines
Michael S. Tsirkin (2):
test_shazam: clean worktree before git am
ez: cleanup sparse-checkout usagesrc/b4/__init__.py | 6 +++--- src/b4/ez.py | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-)Signature · 1 line
MST
Quoted 9 lines · Michael S. Tsirkin
Quoted 4 lines · Michael S. Tsirkin
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 [email protected] 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
Konstantin Ryabitsev
AppliedQuoted 10 lines · Michael S. Tsirkin
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: 9e52ea82688a8ca37e6f59a86a723768c6044547Best regards,
Signature · 1 line
Konstantin Ryabitsev <[email protected]>
Konstantin Ryabitsev
AppliedQuoted 10 lines · Michael S. Tsirkin
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: 9e52ea82688a8ca37e6f59a86a723768c6044547Best regards,
Signature · 1 line
Konstantin Ryabitsev <[email protected]>
Quoted 4 lines · Konstantin Ryabitsev
[1/2]
test_shazam: clean worktree before git amcommit: 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