Git Mailing List Archive mirror
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: u34@net9.cf
Cc: git@vger.kernel.org
Subject: Re: Options to have git log presents commits of a non linear history in a meaningful order
Date: Mon, 13 May 2024 15:52:51 -0700	[thread overview]
Message-ID: <xmqqmsotcojg.fsf@gitster.g> (raw)
In-Reply-To: <E1s6cl5-0003nc-3D@mx1.net9.cf> (u34@net9.cf's message of "Mon, 13 May 2024 20:58:55 +0000")

u34@net9.cf writes:

> Am I right by default, git log present commits of a non linear history in
> a meaningles order? Am I right git log has options, such as --graph, to 
> get the order of commits presented in a more meaningful way?

I wouldn't say --graph gives much meaningful ordering.  

Rather, "--graph" is a way to present the list of things that is
fundamentally not an ordered list by giving an extra information
(information that cannot be captured by orders alone) to make it
visually apparent in the output which ones form partial ordering
among them.

If you have two branches, one has commits A and B and the other has
commits X, Y, and Z, since they forked, your history may look like:

    o---A---B
     \
      X---Y---Z

and your command "git log ^O B Z" can present them in any order as
long as B is shown before A, Z is shown before Y and X, and Y is
shown before X.  There is a partial ordering among the commits that
are ancestors of B, and there is another partial ordering among the
commits that are ancestores of Z.  But there is no "meaningful"
ordering between sets (A, B) and (X, Y, Z).  This is especially true
if the two branches were done by different people, perhaps in
different timezones, possibly with one of them using a wrong clock.
Their timestamps cannot tell you the relative ordering of the
commits across these two sets.

> As of git 2.45.0, gittutorial states 
>     
>    The git log command has a weakness: it must present commits in
>    a list. When the history has lines of development that
>    diverged and then merged back together, the order in which git
>    log presents those commits is meaningless.
>
> Is it accurate?

I wouldn't read the tutorial with such a fine toothed comb.  It is
good if it is filled with white lies to make the initial learning
process smoother.  When it tells that users shouldn't read too much
into the ordering of commits, readers should just stick to what was
suggested.


      reply	other threads:[~2024-05-13 22:52 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-05-13 20:58 Options to have git log presents commits of a non linear history in a meaningful order u34
2024-05-13 22:52 ` 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=xmqqmsotcojg.fsf@gitster.g \
    --to=gitster@pobox.com \
    --cc=git@vger.kernel.org \
    --cc=u34@net9.cf \
    /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 read-only IMAP folder(s) and NNTP newsgroup(s).