FallenGameR (fallengamer) wrote,

git rev-parse with relative time

Git rev-parse that resolves reference via relative dates like in 'git rev-parse topic@{2 weeks 5 days ago}' can produce warning like 'warning: Log for 'topic' only goes back to Fri, 28 Sep 2012 16:07:12 -0700.' when it detects that the first reflog entry for the specified commit _could_ be out of date range.

We should distinguish 3 situations when this warning could be emitted:
1) Real warning when specified date is out commit timespan
2) False positive due to commit dates manipulation
3) False positive due to time range overlap

It's is possible (in tests and in source control bridges software) to perform commit date manipulation and thus it's ok to have the following situation in reflog:
» git reflog topic --date=relative
122218a topic@{2 weeks ago}: commit: F Fox
e604283 topic@{3 weeks ago}: commit: E Eagle
d7d2af8 topic@{3 weeks ago}: commit: D Dragonfly
c4ea4e3 topic@{3 weeks ago}: commit: C Cheetah
dab6cfe topic@{4 minutes ago}: branch: Created from HEAD

Note that from reflog perspective branch creation happened after first commit was commited.

Plus if commit is specified with a time period like in master@{3 weeks ago} that would cover time period [3;4) weeks ago. And while start of this time range could be valid, the end range could lie out of the reference timespan.

Note that to make warning more correct it's possible to delete branch creation reflog entries via:
» git reflog topic
» git reflog delete 'topic@{wrong_time_entry_number}'
Tags: git

  • Post a new comment


    default userpic

    Your IP address will be recorded 

    When you submit the form an invisible reCAPTCHA check will be performed.
    You must follow the Privacy Policy and Google Terms of use.