This is a duplicate of #1956166: Auto-generate interdiffs between patch files (from patches uploaded previously). but that issue got horribly derailed on some kind of misunderstanding so I've closed it and opened this one instead.

In order to support easier patch review, patch authors are asked to upload an interdiff, which contains the lines that were changed between the current patch and the previous patch. Very useful.

Except that now, we waste a ton of collective time within the core team through one of the following activities:

- Learning how to make interdiffs
- Making interdiffs
- Trying to review patches with no interdiffs
- Posting comments about how interdiffs are missing
- Asking "what's an interdiff?"
- etc.

It'd be great if instead Drupal.org just did this automatically. I'm not sure how to quantify it exactly, but my gut feeling is this would probably save at least a couple of hours per week of frustrating issue churn.

Comments

tim.plunkett’s picture

This would be great, if it's actually feasible.

To clarify, an interdiff is *not* this:
diff first.patch second.patch > interdiff.txt

It's more like this:

git checkout -b before
git reset --hard origin/8.x
git apply --3way first.patch
git commit -a

git checkout -b after
git reset --hard origin/8.x
git apply --3way second.patch
git commit -a

git diff before..after > interdiff.txt

This assumes that both patches apply.
If they don't, you have to reroll them first.

In those cases, I'm not sure what we'd fall back to.

EDIT: One other option is to somehow track what commit hash HEAD was at when a patch is uploaded.
Then it would be something more like this, which might still break

git checkout -b before FIRSTHASH
git apply --3way first.patch
git commit -a
git rebase origin/8.x

git checkout -b after SECONDHASH
git apply --3way second.patch
git commit -a
git rebase origin/8.x

git diff before..after > interdiff.txt
chx’s picture

It's actually

interdiff patch1 patch2 > interdiff.txt

from patchutils http://cyberelk.net/tim/software/patchutils/

greg.1.anderson’s picture

Drush iq-submit will also automatically create interdiffs. Hm, I think the code in #1 and patchutils is probably better than what is in drush_iq right now, but I will leave the reference all the same. (n.b. drush iq itself still broken pending #1710850: Deploy RestWS for D7 project issue JSON.)

chx’s picture

Hell knows, patchutils sometimes gives me grief ; with (lots of?) new files I need to feed it a healthy diet of y-enter keystroke combos.

Crell’s picture

I can't speak to the implementation details, but as to the concept, "YES PLEASE!"

mgifford’s picture

I wish there was a Homebrew port of the Linux interdiff tool that @chx mentioned. Sadly it isn't there:
brew install interdiff

I've been using that but not very often as I develop on a mac.

Would be great to see this done on d.o by default though!

chx’s picture

YesCT’s picture

Agreeing with the end of tim's comment in #1, We should be able to know which commit hash a patch applied on, since if it goes to the testbot, it might say it didn't apply, but... we should be able know the *commit hash of head that it was last tested against*.

RainbowArray’s picture

Maybe I'm misunderstanding, but if we apply the first patch against HEAD at the time that patch was created, then an interdiff against a new patch applied to the current version of HEAD, then won't that generate not just the differences between the patches but also between old HEAD and new HEAD?

tim.plunkett’s picture

That's what the git rebase origin/8.x part is for.

RainbowArray’s picture

Got it. Makes sense now.

pwolanin’s picture

So, this would be nice indeed - we could shell out to the interdiff utility? Or better yet, maybe something like the revisions tab where you could select a pair of patches and generate this? Once generated it could be saved/cached in the filesystem?

Still, I find it a trivial amount of extra work normally following this local workflow starting form a current 8.x branch:

git checkout -b topic-NNN
curl https://drupal.org/path-to-priorpatch.patch | git apply --index
git commit -m"apply https://drupal.org/NNN-path-to-priorpatch.patch"
# hack on stuff...
git commit -am"patch #M"
git diff 8.x > ../topic-NNN-M.patch
git diff HEAD^ > ../interdiff.txt

As long as you commit when creating each patch, the interdiff is essentially free.

YesCT’s picture

I've thought of that revisions pattern also. it would be nice to interdiff particular patches.

but I'd be happy with just the most recent one.

YesCT’s picture

some of the ideas from git workspaces relate to automatic interdiffs.
https://www.drupal.org/roadmap/issue-workflow

jthorson’s picture

Project: Extended File Field » Drupal.org customizations
Version: 7.x-1.x-dev » 7.x-3.x-dev
Priority: Major » Normal

Hmmm ... probably out of scope for Extended File Field (though the implementation would then use its hooks to add the information to the files table) ... maybe drupalorg module for now?

geek-merlin’s picture