Re: git log --since to not stop after first old commit?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, Apr 01 2022, Miklos Vajna wrote:

> Hi Ævar,
>
> On Fri, Apr 01, 2022 at 11:57:33AM +0200, Ævar Arnfjörð Bjarmason <avarab@xxxxxxxxx> wrote:
>> So (just making sure I understand this) in this case the --since option
>> is behaving as expected in the sense that the information in the commit
>> itself matches what it's finding, but what you'd really like for it to
>> consider some "adjusted" commit date?
>> 
>> I.e. to be smart enough to spot that it should include a commit from
>> 2021 if all the preceding commits are from 2022, or some other similar
>> heuristic?
>
> No heuristics. Just a way to not stop at the first commit that doesn't
> match the --since criteria. Here is an example:
>
> Given:
>
> rm -rf .git file
> git init
> echo a > file
> git add file
> git commit -m init
> echo a >> file
> git add file
> GIT_COMMITTER_DATE="2021-01-01 0:00" git commit -m second
> echo a >> file
> git add file
> git commit -m third
>
> When I do:
>
> git log --pretty=oneline --since="2022-01-01"
>
> Then current I get:
>
> 91a24b6ccba6b1d26c3bd5bcea7ff86e6997b599 (HEAD -> master) third
>
> And I would like to have an opt-in way to instead get:
>
> 91a24b6ccba6b1d26c3bd5bcea7ff86e6997b599 (HEAD -> master) third
> e259a40784d3d70f3878105adac380c8e8a8ae52 init
>
> Arguing that both "init" and "third" was committed this year.

Indeed.

> The question is if there is a way to do this already (perhaps I missed
> something in the docs or didn't notice it while I briefly researched the
> commit walk code), or in case I want to do this, then would it make
> sense to have this feature in git or this is more a "run git rev-list
> and do your own filtering" case?

I think it might make sense to have it as feature, but hopefully we
could piggy-back on the date adjustment that the commit-graph needs to
do already, I'm not sure if we save that information anywhere though...

The assumption with --since was that this sort of timestamp drift
wouldn't be this bad, so mostly it works out. It could be made to work
like --grep, but then it needs to walk the whole history if no other
limit is provided.

So it'll be very slow if you just want --since=2.weeks.ago, but
accurate.

I think an alternate solution to this in the meantime is to use "git
replace" as a band-aid, I haven't tried, but you should be able to
replace the relevant commit with one that has adjusted dates.




[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux