diff mbox series

[b4,2/2] ez: Fix check-deps when strategy is commit

Message ID 20240521-fix-check-deps-v1-2-d149bf40e7ee@bootlin.com (mailing list archive)
State Accepted
Headers show
Series get_info and check_deps fixes | expand

Commit Message

Louis Chauvet May 21, 2024, 2:41 p.m. UTC
When using the commit strategy for the cover letter, the first commit is
empty. This commit can't be applied properly with git am, so just skip it.

Signed-off-by: Louis Chauvet <louis.chauvet@bootlin.com>

---

I tested to use --empty=drop/keep, but the error was the same, maybe
because there are many patches to apply at the same time?
---
 src/b4/ez.py | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

Comments

Konstantin Ryabitsev May 21, 2024, 3:20 p.m. UTC | #1
On Tue, May 21, 2024 at 04:41:38PM GMT, Louis Chauvet wrote:
> When using the commit strategy for the cover letter, the first commit is
> empty. This commit can't be applied properly with git am, so just skip it.

This shouldn't be required, because get_prep_branch_as_patches will 
already omit the cover letter commit:

ez.py: 1408:

    strategy = get_cover_strategy()
    ignore_commits = None
    if strategy in {'commit', 'tip-commit'}:
        cover_commit = find_cover_commit()
        if cover_commit:
            ignore_commits = {cover_commit}

Something else must be going on, maybe?

-K
Louis Chauvet May 21, 2024, 3:42 p.m. UTC | #2
Le 21/05/24 - 11:20, Konstantin Ryabitsev a écrit :
> On Tue, May 21, 2024 at 04:41:38PM GMT, Louis Chauvet wrote:
> > When using the commit strategy for the cover letter, the first commit is
> > empty. This commit can't be applied properly with git am, so just skip it.
> 
> This shouldn't be required, because get_prep_branch_as_patches will 
> already omit the cover letter commit:
> 
> ez.py: 1408:
> 
>     strategy = get_cover_strategy()
>     ignore_commits = None
>     if strategy in {'commit', 'tip-commit'}:
>         cover_commit = find_cover_commit()
>         if cover_commit:
>             ignore_commits = {cover_commit}
> 
> Something else must be going on, maybe?
> 
> -K

Without my patch I have this log:

Checking message-id: <20240516-yuv-v8-0-cf8d6f86430e@bootlin.com>
Breaking thread to remove parents of 20240516-yuv-v8-0-cf8d6f86430e@bootlin.com
Checking message-id: <20240516-b4-new-color-formats-v1-0-74cf9fe07317@bootlin.com>
Breaking thread to remove parents of 20240516-b4-new-color-formats-v1-0-74cf9fe07317@bootlin.com
Checking message-id: <20240516-writeback_line_by_line-v1-0-7b2e3bf9f1c9@bootlin.com>
Breaking thread to remove parents of 20240516-writeback_line_by_line-v1-0-7b2e3bf9f1c9@bootlin.com
Checking base-commit: drm-misc/drm-misc-next
Testing if all patches can be applied to drm-misc/drm-misc-next
  [PATCH v8 1/17] drm/vkms: Code formatting
  [PATCH v8 2/17] drm/vkms: Use drm_frame directly
  [PATCH v8 3/17] drm/vkms: write/update the documentation for pixel conversion and pixel write functions
[...]
  [PATCH 2/3] drm/vkms: Add a macro for write_line functions
  [PATCH 3/3] drm/vkms: Add support for XRGB2101010
  [PATCH 0/3] drm/vkms: Miscelanious clarifications ---- this is the current series
  [PATCH 1/3] drm/vkms: Formatting and typo fix
  [PATCH 2/3] drm/vkms: Rename index to possible_crtc
  [PATCH 3/3] drm/vkms: Add documentation
Magic: Preparing a sparse worktree
Unable to cleanly apply series, see failure log below
---
Application de  drm/vkms: Code formatting
Application de  drm/vkms: Use drm_frame directly
Application de  drm/vkms: write/update the documentation for pixel conversion and pixel write functions
[...]
Application de  drm/vkms: Add support for XRGB2101010
Application de  drm/vkms: Miscelanious clarifications
l'application de la rustine a échoué à 0026 drm/vkms: Miscelanious clarifications
Quand vous avez résolu ce problème, lancez "git am --continue".
Si vous préférez plutôt sauter ce patch, lancez "git am --skip".
Pour restaurer la branche originale et arrêter de patcher, lancez "git am --abort".
erreur : Pas de rustine valide sur l'entrée (permis avec "--allow-empty")
astuce: Utilisez 'git am --show-current-patch=diff' pour visualiser le patch en échec
---
Not fetching into FETCH_HEAD
---
● message-id: <20240516-yuv-v8-0-cf8d6f86430e@bootlin.com>
● message-id: <20240516-b4-new-color-formats-v1-0-74cf9fe07317@bootlin.com>
● message-id: <20240516-writeback_line_by_line-v1-0-7b2e3bf9f1c9@bootlin.com>
● base-commit: drm-misc/drm-misc-next
   - Could not cleanly apply patches


If I understood correctly the code, the cover is removed at line 1408, but 
re-added at 1545 if the series contains multiple patches:

    if len(patches) == 1:
        mixin_cover(cbody, patches)
    else:
        add_cover(csubject, msgid_tpt, patches, cbody, seriests, thread=thread)
Konstantin Ryabitsev May 21, 2024, 5:24 p.m. UTC | #3
On Tue, May 21, 2024 at 05:42:10PM GMT, Louis Chauvet wrote:
> If I understood correctly the code, the cover is removed at line 1408, 
> but re-added at 1545 if the series contains multiple patches:

Yes, you're right -- my test case only had a single patch. Thanks for 
catching this.

-K
diff mbox series

Patch

diff --git a/src/b4/ez.py b/src/b4/ez.py
index 76121ab02d03..5e6ed7f90900 100644
--- a/src/b4/ez.py
+++ b/src/b4/ez.py
@@ -919,7 +919,11 @@  def check_deps(cmdargs: argparse.Namespace) -> None:
     elif allgood:
         logger.info('Testing if all patches can be applied to %s', base_commit)
         tos, ccs, tstr, mypatches = get_prep_branch_as_patches(thread=False, movefrom=False, addtracking=False)
-        prereq_patches += [x[1] for x in mypatches]
+        if get_cover_strategy() == "commit":
+            # If the cover letter is stored as a commit, skip it to avoid empty patches
+            prereq_patches += [x[1] for x in mypatches[1:]]
+        else:
+            prereq_patches += [x[1] for x in mypatches]
         gitdir = os.getcwd()
         topdir = b4.git_get_toplevel(gitdir)
         if b4.git_commit_exists(topdir, base_commit):
@@ -2451,7 +2455,9 @@  def get_info(usebranch: str) -> Dict[str, str]:
     info['preflight-checks-failing'] = bool(info['needs-editing'] or info['needs-auto-to-cc'] or
                                             info['needs-checking'] or info['needs-checking-deps'])
 
-    # Add commits information
+    # Add informations about the commits in this series
+    #   `commit-<hash>`: stores the subject of each commit
+    #   `series-<rev>`: stores the commit range for a particular revision
     for line in oneline:
         short, subject = line.split(maxsplit=1)
         info[f'commit-{short}'] = subject