Thread (1 message) 1 message, 1 author, 2024-05-13

Re: Options to have git log presents commits of a non linear history in a meaningful order

From: Junio C Hamano <hidden>
Date: 2024-05-13 22:52:57

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.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help