From: Philippe Blain <levraiphilippeblain@gmail.com>
To: levraiphilippeblain@gmail.com
Cc: konstantin@linuxfoundation.org, tools@linux.kernel.org
Subject: [RFC PATCH] Fix 'LoreSeries::make_fake_am_range' with renamed, then modified file
Date: Wed, 26 Oct 2022 14:11:59 -0400 [thread overview]
Message-ID: <20221026181159.49623-1-levraiphilippeblain@gmail.com> (raw)
In-Reply-To: <e759026c-4f49-cc2a-7885-10b88212d20e@gmail.com>
Signed-off-by: Philippe Blain <levraiphilippeblain@gmail.com>
---
This seems to fix it, I can send a proper patch with full commit message if you
think the design/direction is good.
Sorry for the resend, forgot the list!
b4/__init__.py | 43 ++++++++++++++++++++++++-------------------
1 file changed, 24 insertions(+), 19 deletions(-)
diff --git a/b4/__init__.py b/b4/__init__.py
index 4456414..d9cebc9 100644
--- a/b4/__init__.py
+++ b/b4/__init__.py
@@ -640,16 +640,16 @@ class LoreSeries:
for lmsg in self.patches[1:]:
if lmsg is None or lmsg.blob_indexes is None:
continue
- for fn, bh in lmsg.blob_indexes:
- if fn in seenfiles:
+ for ofn, obh, nfn in lmsg.blob_indexes:
+ if ofn in seenfiles:
# if we have seen this file once already, then it's a repeat patch
# it's no longer going to match current hash
continue
- seenfiles.add(fn)
- if set(bh) == {'0'}:
+ seenfiles.add(ofn)
+ if set(obh) == {'0'}:
# New file, will for sure apply clean
continue
- self.indexes.append((fn, bh))
+ self.indexes.append((ofn, obh))
def check_applies_clean(self, gitdir: str, at: Optional[str] = None) -> Tuple[int, list]:
if self.indexes is None:
@@ -793,29 +793,33 @@ class LoreSeries:
logger.critical('ERROR: some patches do not have indexes')
logger.critical(' unable to create a fake-am range')
return None, None
- for fn, fi in lmsg.blob_indexes:
- if fn in seenfiles:
+ for ofn, ofi, nfn in lmsg.blob_indexes:
+ if ofn in seenfiles:
# We already processed this file, so this blob won't match
continue
- seenfiles.add(fn)
- if set(fi) == {'0'}:
+ seenfiles.add(ofn)
+ if set(ofi) == {'0'}:
# New file creation, nothing to do here
- logger.debug(' New file: %s', fn)
+ logger.debug(' New file: %s', ofn)
continue
+ if not ofn == nfn:
+ # renamed file, make sure to not add the new name later on
+ logger.debug(' Renamed file: %s -> %s', ofn, nfn)
+ seenfiles.add(nfn)
# Try to grab full ref_id of this hash
- ecode, out = git_run_command(gitdir, ['rev-parse', fi])
+ ecode, out = git_run_command(gitdir, ['rev-parse', ofi])
if ecode > 0:
- logger.critical(' ERROR: Could not find matching blob for %s (%s)', fn, fi)
+ logger.critical(' ERROR: Could not find matching blob for %s (%s)', ofn, ofi)
logger.critical(' If you know on which tree this patchset is based,')
logger.critical(' add it as a remote and perform "git remote update"')
logger.critical(' in order to fetch the missing objects.')
return None, None
- logger.debug(' Found matching blob for: %s', fn)
+ logger.debug(' Found matching blob for: %s', ofn)
fullref = out.strip()
- gitargs = ['update-index', '--add', '--cacheinfo', f'0644,{fullref},{fn}']
+ gitargs = ['update-index', '--add', '--cacheinfo', f'0644,{fullref},{ofn}']
ecode, out = git_run_command(None, gitargs)
if ecode > 0:
- logger.critical(' ERROR: Could not run update-index for %s (%s)', fn, fullref)
+ logger.critical(' ERROR: Could not run update-index for %s (%s)', ofn, fullref)
return None, None
mbx.add(lmsg.msg.as_string(policy=emlpolicy).encode('utf-8'))
@@ -1517,12 +1521,13 @@ 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]:
- curfile = matches.groups()[0]
+ if matches:
+ oldfile = matches.groups()[0]
+ newfile = matches.groups()[1]
continue
matches = re.search(r'^index\s+([\da-f]+)\.\.[\da-f]+.*$', line)
- if matches and curfile is not None:
- indexes.add((curfile, matches.groups()[0]))
+ if matches and oldfile is not None:
+ indexes.add((oldfile, matches.groups()[0], newfile))
return indexes
@staticmethod
base-commit: 2a16f701dfae031ed89b58505bbf50846b13518d
--
2.29.2
next prev parent reply other threads:[~2022-10-26 18:12 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-10-26 13:01 b4 can't diff a series with a file renamed, then modified Philippe Blain
2022-10-26 18:11 ` Philippe Blain [this message]
2022-10-31 19:51 ` [RFC PATCH] Fix 'LoreSeries::make_fake_am_range' with renamed, then modified file 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
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=20221026181159.49623-1-levraiphilippeblain@gmail.com \
--to=levraiphilippeblain@gmail.com \
--cc=konstantin@linuxfoundation.org \
--cc=tools@linux.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 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.