Re: List all commits of a specified file in oldest to newest order

2 messages, 2 authors, 2021-11-05 · open the first message on its own page

Re: List all commits of a specified file in oldest to newest order

From: Junio C Hamano <hidden>
Date: 2021-11-05 18:49:12

Jeff King [off-list ref] writes:
As a workaround, you can get what you want by two separate traversals:
one to collect the commits via --follow, and then another to actually
show them (but without doing any further walking). Like:

  git log --follow --format=%H -- $your_file |
  git log --stdin --no-walk --reverse [--oneline, -p, etc]
We learn new things every day.

Knowing the implementation, it is sort of obvious (we push the
objects into the pending list, populate the revs.commits in
prepare_revision_walk() from the pending list in order,
get_revision() first reverses the revs.commits and then gives out
the elements), but I didn't know the combination of "--no-walk" and
"--reverse" did something sensible ;-)

Thanks.

Re: List all commits of a specified file in oldest to newest order

From: Jeff King <hidden>
Date: 2021-11-05 23:26:20

On Fri, Nov 05, 2021 at 11:49:03AM -0700, Junio C Hamano wrote:
Jeff King [off-list ref] writes:
quoted
As a workaround, you can get what you want by two separate traversals:
one to collect the commits via --follow, and then another to actually
show them (but without doing any further walking). Like:

  git log --follow --format=%H -- $your_file |
  git log --stdin --no-walk --reverse [--oneline, -p, etc]
We learn new things every day.

Knowing the implementation, it is sort of obvious (we push the
objects into the pending list, populate the revs.commits in
prepare_revision_walk() from the pending list in order,
get_revision() first reverses the revs.commits and then gives out
the elements), but I didn't know the combination of "--no-walk" and
"--reverse" did something sensible ;-)
I admit that I did not know if it would work either until I tried it
earlier today. ;)

-Peff
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help