git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: report on a possible bug: git commit -p myfile.py unexpected output

From
JAJoan Aguilar <joan.aguilar.lorente@gmail.com>
Date
Mar 24, 2017, 15:31 UTC
Message-ID
<CAG+Y4s8WGwmP7uOsNz4GkR3tsaeB2e1qBysrs-4pqLBKYC+Grg@mail.gmail.com>
In-Reply-To
<20170324150921.vwh4yqpz25ph3zxe@sigill.intra.peff.net>
Hello Michael, hello Jeff,

I was writing a response to Michael and I received the Email from Jeff, so I decided to reply to the second one, with copy to both of you (and the mailing list too, of course). I hope this is ok for you.

It works exactly as Jeff said.
If I do git show --stat 96d1c24 the output is:
user@machine:~/mygitrepo$ git show --stat 96d1c24
commit 96d1c24*******
Author: Joan Aguilar Lorente <joan.aguilar.lorente@gmail.com>
Date:   Thu Mar 23 18:15:07 2017 +0100
    myfile.py -> old unused methods removed...
    1) mymethod1
    2) mymethod2
    3) mymethod3
    4) mymethod4
    5) mymethod5
 myfile.py | 120
------------------------------------------------------------------------------------------------------------------------
 1 file changed, 120 deletions(-)
But if I add the flag -B (git show --stat -B 96d1c24) the last two
lines are different (as already expected by Jeff) and match exactly
the output of git commit I got yesterday.
 myfile.py | 484
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-------------------------------------------------------------------------------------------------------------------------------------------------------------------
 1 file changed, 182 insertions(+), 302 deletions(-)
The output of git show -B is, of course, like the one expected by Jeff too.

Thank you! I learned a little bit about git. And most of all, I realize there are a lot of options and flags I am not aware of, and not using at all! I have to read the documentation. I am missing a lot of git!!

I am sorry that I reported this as possible bug. I guess I was just confused because the "standard behavior" of "git commit" differs from the one of "tig" or "git show".

Thank you again and I see you around.

Best regards Joan Aguilar Lorente -- Joan Aguilar Lorente

On Fri, Mar 24, 2017 at 4:09 PM, Jeff King <peff@peff.net> wrote:
Show 46 quoted lines
> On Fri, Mar 24, 2017 at 03:59:07PM +0100, Michael J Gruber wrote:
>
>> > [master 96d1c24] myfile.py -> old unused methods removed...
>> >  1 file changed, 182 insertions(+), 302 deletions(-)
>> >  rewrite myfile.py (60%)
>> [...]
>> > myfile.py | 120
>> > ---------------------------------------------------------------------------------------------------------------------
>> > 1 file changed, 120 deletions(-)
>>
>> 182-302 = -120
>>
>> Did you make any changes in the lines that you left? Apparantly, that's
>> what the rewrite looked like to git commit.
>
> Even without changes to the remaining lines, a rewrite diff would
> consider them removed from the preimage and added again in the
> post-image.
>
> The difference between the two commands is that "commit" turns on "-B"
> break detection by default, and "git show", "tig", etc, do not.
>
> Looking at the actual diff with "git show -B" should show something
> like:
>
>   -old
>   -lines
>   -that
>   -weren't
>   -touched
>   -some
>   -lines
>   -that
>   -were
>   -deleted
>   +old
>   +lines
>   +that
>   +weren't
>   +touched
>
> The change is the same no matter how you view it; the "-B" flag just
> asks Git to show a non-minimal diff when the file was substantially
> changed.
>
> -Peff
Previous: Jeff KingNext: Jeff King
Message 4 of 5 in “report on a possible bug: git commit -p myfile.py unexpected output”
  1. Joan AguilarMar 24, 2017
  2. Michael J GruberMar 24, 2017
  3. Jeff KingMar 24, 2017
  4. Joan AguilarMar 24, 2017
  5. Jeff KingMar 24, 2017

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.