All of lore.kernel.org
 help / color / mirror / Atom feed
* b4 can't diff a series with a file renamed, then modified
@ 2022-10-26 13:01 Philippe Blain
  2022-10-26 18:11 ` [RFC PATCH] Fix 'LoreSeries::make_fake_am_range' with renamed, then modified file Philippe Blain
  0 siblings, 1 reply; 6+ messages in thread
From: Philippe Blain @ 2022-10-26 13:01 UTC (permalink / raw)
  To: tools; +Cc: Konstantin Ryabitsev

Hi Konstantin,

I'm hitting a bug when running 'b4 diff' on https://lore.kernel.org/git/pull.1321.v2.git.git.1666297238.gitgitgadget@gmail.com/.

Here is a reproducer in a clone of git.git:

git checkout 9bf691b78c # the base commit of v1
b4 am -v 1 -o- https://lore.kernel.org/git/pull.1321.v2.git.git.1666297238.gitgitgadget@gmail.com  | git am # apply v1 to get the necessary blobs
b4 -d diff -C -n https://lore.kernel.org/git/pull.1321.v2.git.git.1666297238.gitgitgadget@gmail.com/

This is on b4's 2a16f70 (am: ignore base-commit info if commit not present, 2022-10-19).

The 'b4 diff' command errors like so:

    Looking at [PATCH 3/6] t5617: drop references to remote-tracking branches
    ERROR: some patches do not have indexes
           unable to create a fake-am range
    Running git --no-pager worktree remove --force /var/folders/lr/r6n2057j0dzd4gdb614fp0740000gp/T/tmp7hpz_ac1
    ---
    Could not create fake-am range for lower series v1

I looked through the code and found that LoreMessage::get_indexes
is not ready for rename patches, since the "rename" lines in the 'git diff' output
is placed between the 'diff --git' line and the 'index' line, which the code does 
not account for. This seems to help:

diff --git a/b4/__init__.py b/b4/__init__.py
index 4456414..fb618c7 100644
--- a/b4/__init__.py
+++ b/b4/__init__.py
@@ -1517,7 +1517,7 @@ class LoreMessage:
             if line.find('diff ') != 0 and line.find('index ') != 0:
                 continue
             matches = re.search(r'^diff\s+--git\s+\w/(.*)\s+\w/(.*)$', line)
-            if matches and matches.groups()[0] == matches.groups()[1]:
+            if matches:
                 curfile = matches.groups()[0]
                 continue
             matches = re.search(r'^index\s+([\da-f]+)\.\.[\da-f]+.*$', line)

With this change, the 'b4 diff' command goes a little further, but still fails:

    Running git --no-pager write-tree
    Running git --no-pager commit-tree 565d875b4fdf449501853a9bcbe608e4374d9eed^{tree} -F -
    Running git --no-pager reset --hard 1149ea03d905ba0a51d1c80e6352361cf34feee1
    Running git --no-pager am .__git-am__
    ERROR: Could not fake-am version 1
    Running git --no-pager worktree remove --force /var/folders/lr/r6n2057j0dzd4gdb614fp0740000gp/T/tmp1h_x78kk
    ---
    Could not create fake-am range for lower series v1

I ran the 'git am' command manually in the temporary worktree, and this is what it outputs:

    $ git am .__git-am__
    Applying: clone: teach --detach option
    warning: t/t5601-clone.sh has type 100644, expected 100755
    Applying: repo-settings: add submodule_propagate_branches
    Applying: t5617: drop references to remote-tracking branches
    warning: t/t5617-clone-submodules-remote.sh has type 100644, expected 100755
    error: t/t5617-clone-submodules.sh: already exists in index
    Patch failed at 0003 t5617: drop references to remote-tracking branches
    hint: Use 'git am --show-current-patch=diff' to see the failed patch
    When you have resolved this problem, run "git am --continue".
    If you prefer to skip this patch, run "git am --skip" instead.
    To restore the original branch and stop patching, run "git am --abort".

It aborts at 3/6 because t/t5617-clone-submodules.sh (the new name of the renamed file)
already exists in the index. From what I understand of LoreSeries::make_fake_am_range, this
is because it gets added to the index when preparing the initial fake commit because
6/6 modifies it.

Thanks,
Philippe.

^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2022-11-29 18:42 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-10-26 13:01 b4 can't diff a series with a file renamed, then modified Philippe Blain
2022-10-26 18:11 ` [RFC PATCH] Fix 'LoreSeries::make_fake_am_range' with renamed, then modified file Philippe Blain
2022-10-31 19:51   ` Konstantin Ryabitsev
2022-11-07 13:40     ` [PATCH b4] " Philippe Blain
2022-11-28 18:07       ` Philippe Blain
2022-11-29 18:42       ` Konstantin Ryabitsev

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.