Re: [PATCH 0/3] built-in add -p: support diff-so-fancy better
- From
Philippe Blain <levraiphilippeblain@gmail.com>
- Date
- Aug 24, 2022, 13:21 UTC
- Message-ID
- <41781ceb-bfad-2534-2970-c74618c93f2a@gmail.com>
- In-Reply-To
- <1r3pq48q-s728-8r2r-r4q3-72413r5483o1@tzk.qr>
Hi Dscho,
Le 2022-08-24 à 02:27, Johannes Schindelin a écrit :
Show 17 quoted lines
> Hi Philippe, > > On Tue, 23 Aug 2022, Philippe Blain wrote: > >> However, I've tried it on a more "real-life" example, and then I get: >> >> error: mismatched output from interactive.diffFilter >> hint: Your filter must maintain a one-to-one correspondence >> hint: between its input and output lines. >> >> This is despite using "diff-so-fancy --patch" as interactive.diffFilter, which should >> keep the number of lines the same. > > Would you mind sharing the example with me? > > Thanks, > Dscho
In trying to write a reproducer, I realize that this is in fact a separate "bug". I happened to have a submodule in the repository I was testing, and it had modified content. This is what was causing the "mismatched output" error, although I'm not sure why. If I use a pathspec that does not include the submodule when invoking 'git add -p', it works correctly.
I'm a bit out of time now but I'll try to write a separate reproducer for this later today.
As for my real-life example, I noticed a little change in the output. Here is what it looks like with the Perl version:
$ git -c interactive.diffFilter="diff-so-fancy --patch" -c add.interactive.useBuiltin=false -add p ice_dyn_vp.F90
───────────────────────────────────────────────────────────────────────
modified: ice_dyn_vp.F90
───────────────────────────────────────────────────────────────────────
@ ice_dyn_vp.F90:274 @ subroutine implicit_solver (dt)
do i = 1, nx_block
rdg_conv (i,j,iblk) = c0
rdg_shear(i,j,iblk) = c0
divu (i,j,iblk) = c0
divv (i,j,iblk) = c0
shear(i,j,iblk) = c0
enddo
enddo
(1/1) Stage this hunk [y,n,q,a,d,e,?]? The first part of the hunk header "ice_dyn_vp.F90:274" is in pink and the subroutine name is in light mauve (default diff-so-fancy colors). Here is what it looks like with your patches with the builtin version:
$ git -c interactive.diffFilter="diff-so-fancy --patch" add -p ice_dyn_vp.F90
─────────────────────────────────────────────────────────────────────── modified: ice_dyn_vp.F90 ───────────────────────────────────────────────────────────────────────
@@ -271,7 +271,7 @@ @ ice_dyn_vp.F90:274 @ subroutine implicit_solver (dt) do i = 1, nx_block rdg_conv (i,j,iblk) = c0 rdg_shear(i,j,iblk) = c0 divu (i,j,iblk) = c0 divv (i,j,iblk) = c0 shear(i,j,iblk) = c0 enddo enddo (1/1) Stage this hunk [y,n,q,a,d,e,?]? Notice we have the line numbers (-271,7 +271,7) in cyan, then the first part of the hunk header modified by diff-so-fancy (ice_dyn_vp.F90:274) in pink, and then the subroutine name (in light mauve). We can see the same thing with my earlier reproducer, only there is no function matched. I really don't mind having this first part with the line numbers, I just wanted to share my observation. Thanks, Philippe.