git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Vipul Kumar <kumar+git@onenetbeyond.org>
To: git@vger.kernel.org
Subject: List all commits of a specified file in oldest to newest order
Date: Fri, 5 Nov 2021 04:10:31 +0000	[thread overview]
Message-ID: <c3932b3c-323a-39d6-26a7-ba0c3d17378b@onenetbeyond.org> (raw)

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

             reply	other threads:[~2021-11-05  4:18 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-05  4:10 Vipul Kumar [this message]
2021-11-05  8:13 ` List all commits of a specified file in oldest to newest order Æ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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=c3932b3c-323a-39d6-26a7-ba0c3d17378b@onenetbeyond.org \
    --to=kumar+git@onenetbeyond.org \
    --cc=git@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

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 read-only IMAP folder(s) and NNTP newsgroup(s).