Git Mailing List Archive mirror
 help / color / mirror / Atom feed
From: Derrick Stolee <derrickstolee@github.com>
To: Junio C Hamano <gitster@pobox.com>
Cc: Javier Mora <cousteaulecommandant@gmail.com>, git@vger.kernel.org
Subject: Re: Commit graph not using minimal number of columns
Date: Wed, 26 Apr 2023 13:35:32 -0400	[thread overview]
Message-ID: <eb1c6c62-1081-a9d2-8504-db8bffc6c870@github.com> (raw)
In-Reply-To: <xmqq1qk6vd3v.fsf@gitster.g>

On 4/26/2023 12:10 PM, Junio C Hamano wrote:
> Derrick Stolee <derrickstolee@github.com> writes:

>> I don't think there is anything actionable to do here, as
>> these commit-ordering options are well-defined and should not
>> be altered. If there was an algorithm to modify the commit
>> order in such a way that minimized the graph output, that
>> would be interesting, but the cases it minimizes are probably
>> too rare to be worth the effort.
> 
> Yes, in addition to and next to "--{topo,date}-order", if somebody
> can come up with a new "--graph-friendly-order", it may be an
> interesting addition.
> 
> A tangent.  I do not offhand remember if --date-order works purely
> on the timestamps in the commit objects, or do we take corrections
> based on the generation numbers?  It seems that we only use the
> compare_commits_by_gen_then_commit_date helper for prio queue
> manipulation (to avoid the "slop" thing terminating the revision
> walk too early) and not actual sorting.  I wonder if it makes much
> difference if we used it instead of compare_commits_by_commit_date()

The --date-order guarantees topological relationships are respected,
which is how it is different from the default order.

For the incremental topo-order logic, the topo_queue determines the
final order (the algorithm ensures that the indegree_queue has walked
far enough that we only add commits to topo_queue if their "in
degree" is zero and thus safe to use within topological constraints).

Here is how we pick the comparison:

	switch (revs->sort_order) {
	default: /* REV_SORT_IN_GRAPH_ORDER */
		info->topo_queue.compare = NULL;
		break;
	case REV_SORT_BY_COMMIT_DATE:
		info->topo_queue.compare = compare_commits_by_commit_date;
		break;
	case REV_SORT_BY_AUTHOR_DATE:
		init_author_date_slab(&info->author_date);
		info->topo_queue.compare = compare_commits_by_author_date;
		info->topo_queue.cb_data = &info->author_date;
		break;
	}

Using NULL makes the topo_queue act as a stack instead of a queue.

But crucially, --date-order sets to compare_commits_by_commit_date, so
generation number has nothing to do with this part of the walk (it has
everything to do with indegree_queue, though).

To adapt this algorithm to a newer, dynamic ordering that cares about
minimizing the rendered graph, I don't think changing the priority
queue comparison would be sufficient. Something deeper would be
required and would be quite messy.

Thanks,
-Stolee

  reply	other threads:[~2023-04-26 17:35 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-04-25 23:39 Commit graph not using minimal number of columns Javier Mora
2023-04-25 23:50 ` Junio C Hamano
2023-04-26 10:45   ` Derrick Stolee
2023-04-26 16:10     ` Junio C Hamano
2023-04-26 17:35       ` Derrick Stolee [this message]
2023-04-26 17:43         ` Junio C Hamano
2023-04-27 13:02           ` Derrick Stolee
2023-04-27 18:24             ` Junio C Hamano

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=eb1c6c62-1081-a9d2-8504-db8bffc6c870@github.com \
    --to=derrickstolee@github.com \
    --cc=cousteaulecommandant@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.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 read-only IMAP folder(s) and NNTP newsgroup(s).