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

Re: Feature request: implement '--follow' option for `git blame`

From
Junio C Hamano <gitster@pobox.com>
Date
Apr 8, 2015, 02:48 UTC
Message-ID
<xmqqvbh7baij.fsf@gitster.dls.corp.google.com>
In-Reply-To
<4215491428322362@web26m.yandex.ru>
KES <kes-kes@yandex.ua> writes:
> **UPDATE:** Short answer
>
> `git blame` follow renames but not for `git blame COMMIT^ -- <filename>`
Suppose you have file A and file B in your version v1.0.

Six month down the road, the code was much refactored, and you do not need the contents of these two files separately. You have removed A and B and much of what they had is now in file C. That is the current state.

    git blame -C HEAD -- C

may follow the contents from both just fine, but if you _were_ allowed to say

    git blame v1.0 -- C

what does it even mean? C did not exist v1.0 at all. Are you asking to follow the contents of A back then, or B? How did you tell you meant A and not B when you told it C in this command?

"git blame" follows content movements, and never treats "renames" in any special way, as it is a stupid thing to do to think a rename is somehow special ;-)

The way you tell what content to start digging from to the command from its command line is to give starting point commit (defaults to HEAD but you may give COMMIT^ as your example) and the path in that starting point. As it does not make any sense to tell C to Git and then magically make it guess you meant A in some cases and B in some other. If v1.0 did not have C, the only sensible thing to do is to exit instead of making a guess (and without telling the user how it guessed).

Previous: KESNext: Eugen Konkov
Message 3 of 6 in “Feature request: implement '--follow' option for `git blame`”
  1. KESApr 6, 2015
  2. Fwd: Feature request: implement '--follow' option for `git blame`KES, Apr 7, 2015
  3. Junio C HamanoApr 8, 2015
  4. Re[2]: Feature request: implement '--follow' option for `git blame`Eugen Konkov, Apr 10, 2015
  5. Junio C HamanoApr 13, 2015
  6. Re[2]: Feature request: implement '--follow' option for `git blame`Eugen Konkov, Apr 13, 2015

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.