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

rename/copy detection not working for git-log?

From
KGKevin Green <kevin.t.green@morganstanley.com>
Date
Aug 11, 2009, 13:21 UTC
Message-ID
<20090811132144.GJ6327@morganstanley.com>
Hi,

I'm pretty sure I've seen this working as expected at some point in the past, but I'm now not able to get the full history of a file that's been moved to another directory and I can't understand why. Here's a simple way to reproduce:

  $ git init
  Initialized empty Git repository in /var/tmp/git/.git/
  $ mkdir bin
  $ cat > bin/test.sh
  #!/bin/sh
  echo Hello, world!
  $ git add .
  $ git commit -m 'initial import'
  [master (root-commit) b9dc5be] initial import
   1 files changed, 3 insertions(+), 0 deletions(-)
    create mode 100644 bin/test.sh
  $ mkdir scripts
  $ git mv bin/test.sh scripts/test.sh
  $ git commit -m 'move bin/ to scripts/'
  [master b4c6c72] move bin/ to scripts/
   1 files changed, 0 insertions(+), 0 deletions(-)
    rename {bin => scripts}/test.sh (100%)
  $ echo 'echo Goodbye!' >> scripts/test.sh
  $ git commit -a -m 'make a change in scripts/'
  [master 59830d5] make a change in scripts/
   1 files changed, 1 insertions(+), 0 deletions(-)
This now has full history of:
  $ git log --pretty=oneline
  59830d59f6b4d48b28f2ae8d51e921a9c8842b06 make a change in scripts/
  b4c6c72c548a1c17550c01350beede235d481aa4 move bin/ to scripts/
  b9dc5be440d2c843554e9b0302435d9a6f78cd65 initial import 
and the history of scripts/test.sh is as I expect:
  $ git log --pretty=oneline -- scripts/test.sh
  59830d59f6b4d48b28f2ae8d51e921a9c8842b06 make a change in scripts/
  b4c6c72c548a1c17550c01350beede235d481aa4 move bin/ to scripts/
and the history of bin/test.sh is as I would expect:
  $ git log --pretty=oneline -- bin/test.sh
  b4c6c72c548a1c17550c01350beede235d481aa4 move bin/ to scripts/
  b9dc5be440d2c843554e9b0302435d9a6f78cd65 initial import

But, I would expect that some combination of -M and -C would find me the full history of the current test.sh script so I could see what happened to it before it was moved. (Okay, the example above is not so interesting, but in the real world, bin/test.sh would have had lots of commits before moving):

  $ git log --pretty=oneline -M -C -C -- scripts/test.sh
  59830d59f6b4d48b28f2ae8d51e921a9c8842b06 make a change in scripts/
  b4c6c72c548a1c17550c01350beede235d481aa4 move bin/ to scripts/
git-blame seems to get this right:
  $ git blame scripts/test.sh
  ^b9dc5be bin/test.sh     (Kevin Green 2009-08-11 09:07:06 -0400 1) #!/bin/sh
  ^b9dc5be bin/test.sh     (Kevin Green 2009-08-11 09:07:06 -0400 2)
  ^b9dc5be bin/test.sh     (Kevin Green 2009-08-11 09:07:06 -0400 3) echo Hello, world!
  59830d59 scripts/test.sh (Kevin Green 2009-08-11 09:08:29 -0400 4) echo Goodbye!
What am I missing?
Thanks
--Kevin
Next: Bruce Stephens
Message 1 of 3 in “rename/copy detection not working for git-log?”
  1. Kevin GreenAug 11, 2009
  2. Bruce StephensAug 11, 2009
  3. Kevin GreenAug 11, 2009

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.