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

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

From
Johannes Sixt <j.sixt@viscovery.net>
Date
Oct 19, 2011, 14:34 UTC
Message-ID
<4E9EDFEC.3040009@viscovery.net>

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", but it does not work as expected, neither with a toy file nor with a 5000+ lines file (with 55 lines moved).

git init echo A > foo echo B >> foo git add foo git commit -m initial echo B > foo echo A >> foo git commit -a -m swapped

The results are: $ git blame -M -s -- foo ^e3abca2 1) B 6189cb46 2) A

I would have expected: ^e3abca2 1) B ^e3abca2 2) A

Oh, look! This produces the expected result: $ git blame -M1 -s -- foo

while this produces the same as with just -M: $ git blame -M2 -s -- foo

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!

-- Hannes
Next: Jeff King
Message 1 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.