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

git log bug: -n flag doesn't work with --follow

From
JRJohn Rocha <rocha@stratovan.com>
Date
Jan 27, 2022, 21:59 UTC
Message-ID
<BYAPR20MB27282CFEA29DA37516CE38E3B4219@BYAPR20MB2728.namprd20.prod.outlook.com>
I was attempting to find the oldest commit for a file that has been moved.
I can get the entire list by using the command
$ git log --reverse --follow -- <filename>
However if I add  the option "-n 1" or "--max-count=1" to see JUST the last entry, the command displays nothing
If I remove --follow, it will display the oldest entry for this file in its current location.

Thank you for filling out a Git bug report! Please answer the following questions to help us understand your issue.

What did you do before the bug happened? (Steps to reproduce your issue)

git log --reverse --follow -n 1 -- <filename> git log --reverse --follow --max-count=1 -- <filename>

What did you expect to happen? (Expected behavior)
I expected to see the oldest commit information for the file, following it through renames.
What happened instead? (Actual behavior)
Nothing was displayed.
What's different between what you expected and what actually happened?
I expected to see the appropriate information.
Anything else you want to add:

Please review the rest of the bug report below. You can delete any lines you don't wish to share.

[System Info] git version: git version 2.33.1.windows.1 cpu: x86_64 built from commit: 05d80adb775077d673fab685009ede4a1003ed92 sizeof-long: 4 sizeof-size_t: 8 shell-path: /bin/sh feature: fsmonitor--daemon uname: Windows 10.0 19043 compiler info: gnuc: 10.3 libc info: no libc information available $SHELL (typically, interactive shell): C:\Program Files\Git\usr\bin\bash.exe

[Enabled Hooks]
Message 1 of 1 in “git log bug: -n flag doesn't work with --follow”
  1. John RochaJan 27, 2022

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.