git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* List all commits of a specified file in oldest to newest order
@ 2021-11-05  4:10 Vipul Kumar
  2021-11-05  8:13 ` Ævar Arnfjörð Bjarmason
  2021-11-05  8:17 ` Jeff King
  0 siblings, 2 replies; 9+ messages in thread
From: Vipul Kumar @ 2021-11-05  4:10 UTC (permalink / raw)
  To: git

Hi,

I want to list all commits (including renames) of a specified file in 
oldest to newest order. But when I run "git log --follow --reverse -- 
<path/to/the/file>" command, I'm getting a single commit, which points 
to the "rename of the file". This behavior is weird to me because I 
expected to get list of all commit in oldest to newest order, whereas 
"git log --follow -- <path/to/the/file>" command works as expected.

### Steps to reproduce

$ git init test
$ cd test
$ echo "Hello from foo." > a.txt
$ git add a.txt
$ git commit -m 'Initial commit'
$ git mv a.txt b.txt
$ git commit -m 'Rename a.txt to b.txt'
$ git log --follow -- b.txt
commit 55e3e6857755fe815449e787a90fe82feb174817
Author: Redacted <Redacted>
Date:   Fri Nov 5 06:56:58 2021 +0530

     Rename a.txt to b.txt

commit f40baf5e777b2618e02805d16c950687d98356fe
Author: Redacted <Redacted>
Date:   Fri Nov 5 06:53:35 2021 +0530

     Initial commit
$ git log --follow --reverse -- b.txt
commit 55e3e6857755fe815449e787a90fe82feb174817
Author: Redacted <Redacted>
Date:   Fri Nov 5 06:56:58 2021 +0530

     Rename a.txt to b.txt


### Expected output

As far as I understand, using "--reverse" option along with "git log" 
command reverse the chronological order of the commits. So expected 
output of "git log --follow --reverse" command should be in oldest to 
newest commits order that's reverse the chronological order of "git log 
--follow" command's output.

$ git log --follow --reverse -- b.txt
commit f40baf5e777b2618e02805d16c950687d98356fe
Author: Redacted <Redacted>
Date:   Fri Nov 5 06:53:35 2021 +0530

     Initial commit

commit 55e3e6857755fe815449e787a90fe82feb174817
Author: Redacted <Redacted>
Date:   Fri Nov 5 06:56:58 2021 +0530

     Rename a.txt to b.txt


### Actual output

But when I use "--reverse" along with "--follow" option, I'm getting a 
single commit which points to the rename of the file.

$ git log --follow --reverse -- b.txt
commit 55e3e6857755fe815449e787a90fe82feb174817
Author: Redacted <Redacted>
Date:   Fri Nov 5 06:56:58 2021 +0530

     Rename a.txt to b.txt


### Additional

$ git --version
git version 2.33.0

First I thought "--follow --reverse" showing to me the newest commit. 
But later, I found out that, it always shows a single commit which 
points to the rename of the file.

$ echo "Hello from bar." >> b.txt
$ git add b.txt
$ git commit -m 'Update b.txt'
$ git log --follow --reverse -- b.txt
commit 55e3e6857755fe815449e787a90fe82feb174817
Author: Redacted <Redacted>
Date:   Fri Nov 5 06:56:58 2021 +0530

     Rename a.txt to b.txt



Cheers,
Vipul

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2021-12-14  3:58 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-11-05  4:10 List all commits of a specified file in oldest to newest order Vipul Kumar
2021-11-05  8:13 ` Ævar Arnfjörð Bjarmason
2021-11-09  3:35   ` Vipul Kumar
2021-11-09  9:42     ` Ævar Arnfjörð Bjarmason
2021-12-14  3:58       ` Vipul Kumar
2021-11-05  8:17 ` Jeff King
2021-11-05 18:49   ` Junio C Hamano
2021-11-05 23:26     ` Jeff King
2021-11-09  5:24   ` Vipul Kumar

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).