Search code examples
gitgit-loggit-plumbinggit-rev-list

What plumbing command provides the same functionality as git log --follow?


In an effort to improve stability, I'm currently refactoring all my Git-related shell scripts so that they use only plumbing (rather than porcelain) commands. In particular, I'm trying to replace calls to git log (porcelain) by calls to git rev-list (plumbing).

However, although git rev-list seems to offer much of the functionalities of git log, it seems to be missing an option equivalent to git log's --follow flag, which tells Git to list commits that affected a path even beyond renames (e.g. README -> README.md). From the git log man page:

--follow

Continue listing the history of a file beyond renames (works only for a single file).

I've sifted through the git rev-list man page, but I couldn't find any option that does the same as git log --follow. What am I missing? Can that be done with git rev-list? Or should I use another plumbing command altogether?


Solution

  • Unfortunately, --follow is actually built (poorly) into git log itself. It turns on the rename-detection machinery, in a special one file only mode, and can then find backwards transitions (new file foo = old file bar).

    (It does not find forward transitions, so that if you use --reverse and name a path that used to exist, e.g., with the intent of finding what file it became, it simply fails.)