git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: "Devi Srinivas Vasamsetti via GitGitGadget" <gitgitgadget@gmail.com>
Cc: git@vger.kernel.org,
	 Devi Srinivas Vasamsetti <devisrinivas.vasamsetti@gmail.com>
Subject: Re: [PATCH] commit: warn when a new commit is dated before its parent
Date: Tue, 06 Oct 2026 07:37:27 -0700	[thread overview]
Message-ID: <xmqqld8agajc.fsf@gitster.g> (raw)
In-Reply-To: <pull.2235.git.1791212998072.gitgitgadget@gmail.com> (Devi Srinivas Vasamsetti via GitGitGadget's message of "Mon, 05 Oct 2026 15:09:58 +0000")

"Devi Srinivas Vasamsetti via GitGitGadget" <gitgitgadget@gmail.com>
writes:

> From: Devi Srinivas Vasamsetti <devisrinivas.vasamsetti@gmail.com>
>
> Git writes whatever the clock says into the commit object. This can
> be problematic because history traversal assumes commit dates are
> non-decreasing. For example, "git log --since" stops walking at the
> first commit older than the cutoff, so an out-of-order date hides
> the commits behind it.

It might be annoying, but the value of such a warning is unclear.
If you clone from an upstream repository, you might find that the
commit at the tip was made on a machine with a clock set far in the
future.  When you try to make a commit on top of it, what are you
supposed to do?  Wait for a year so your commit is newer than the
tip?  Ask the committer to correct their clock, redo the commit, and
force-push?

It also does not help if the commit at the tip of the cloned branch
has a timestamp in the past, but is a child of a commit with an
incorrect timestamp.  Nobody would receive a warning, yet --since
may still stop prematurely.

Stepping back a bit, suppose you clone from upstream and obtain a
HEAD dated 24 hours ago, HEAD~1 dated 72 hours ago, and HEAD~2 dated
48 hours ago.  A command like git log --since=50.hours may stop
without showing HEAD~2, but if you suspect that some clocks are
skewed, there is no way to determine the correct output from these
timestamps anyway.  It is possible that HEAD~1 has an incorrect
timestamp and was actually written 30 hours ago, meaning all three
commits should be shown.  Alternatively, HEAD~2 might have an
incorrect timestamp and was written 80 hours ago, in which case
showing neither HEAD~1 nor HEAD~2 is correct.

The moral of the story is that --since or any other time-based
option cannot be fully reliable, as you cannot force everyone to
run with a correctly synchronized clock.  If you truly need to
know the ancestral relationship between commits, you should avoid
these options and use topology-based ones instead.

      reply	other threads:[~2026-10-06 14:37 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-05 15:09 [PATCH] commit: warn when a new commit is dated before its parent Devi Srinivas Vasamsetti via GitGitGadget
2026-10-06 14:37 ` Junio C Hamano [this message]

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

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

  git send-email \
    --in-reply-to=xmqqld8agajc.fsf@gitster.g \
    --to=gitster@pobox.com \
    --cc=devisrinivas.vasamsetti@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitgitgadget@gmail.com \
    /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.
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).