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

Re: How to verify that lines were only moved, not edited?

From
Junio C Hamano <gitster@pobox.com>
Date
Oct 19, 2011, 17:07 UTC
Message-ID
<7vvcrkdi59.fsf@alter.siamese.dyndns.org>
In-Reply-To
<4E9EDFEC.3040009@viscovery.net>
Johannes Sixt <j.sixt@viscovery.net> writes:
> I thought there was a way to use git-blame to find out whether a change
> only shuffled lines, but otherwise did not modify them. I tried "git blame
> -M -- the/file",...

You said "a change" and I somehow expected that such a blame would be done with a revision range, e.g. "git blame -M HEAD^..HEAD -- the/file".

If the two endpoints you are comparing have other commits in between that make changes then revert them in such a way that the end result cancels out, "git diff A B -- the/file" won't see such intermediate changes, but they may interfere with "git blame A..B -- the/file", i.e. when A is not a direct parent of B.

> ... nor with a 5000+ lines file (with 55 lines moved).
> ... while this produces the same as with just -M:
> $ git blame -M2 -s -- foo

Yes, blame tries to omit matches that consists only of non words, so that you won't see "all those lines with a single "}" on them that close definitions for your 100 new functions were copied from the closing brace of one function you originally had in the file" symptom, and -M<level> controls it.

> But neither helps with my 5000+ lines file. Does it mean that the lines
> were changed? But I'm sure they were just moved! Please help!

When reviewing a "supposedly move-only" change, I typically just grab +/- blocks from the patch, remove the +/- prefix and run comparison between them.

Previous: Johannes SixtNext: Johannes Sixt
Message 4 of 5 in “How to verify that lines were only moved, not edited?”
  1. Johannes SixtOct 19, 2011
  2. Jeff KingOct 19, 2011
  3. Johannes SixtOct 20, 2011
  4. Junio C HamanoOct 19, 2011
  5. Johannes SixtOct 20, 2011

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.