Re: [PATCH 1/1] Preserve topological ordering after merges This modifies the algorithm of topopological ordering. The problem with the current algoritm is that it displays the graph below as follows

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 1/7/2020 5:30 AM, Sergey Rudyshin via GitGitGadget wrote:
> From: Sergey Rudyshin <540555@xxxxxxxxx>
> 
> * E
> |\
> | * D
> | |\
> | |/
> |/|
> * | C
> | * B
> |/
> * A
> 
> commit B is placed between A and C, which is wrong
> because E stays that D and B comes after C
> 
> the only correct solution here is
> 
> * E
> |\
> | * D
> | |\
> | |/
> |/|
> | * B
> * | C
> |/
> * A
> 
> while it seems that it contradicts to
> D stating that C should be between D and B
> The new algorithm solves this issue

This ordering concern makes sense _somewhat_, because D is the
second parent of D and that wants to say "Show everything in C..D
before showing C". The issues is that since C is the second parent
of D, the topo-ordering says "Show everything in B..C before showing
things reachable from B". It is unfortunate that these constraints
collide.

Perhaps your description could do a better job clarifying this
issue and how your algorithm change fixes the problem.

However, I'm not sure we even want to make the change, as this
is still a valid topological order (parents appear after children).
When we have an ambiguous pair (like B and C) the order can differ.
The --topo-order option tries to group commits by when they were
introduced, and that's the reason for presenting the commits reachable
from the later parents before presenting the commits from earlier
parents.

The only documentation we have is from [1]:

"Show no parents before all of its children are shown, and avoid
showing commits on multiple lines of history intermixed."

The first part of the sentence is still true, and the second part
is ambiguous of how to do that.

[1] https://git-scm.com/docs/git-log#Documentation/git-log.txt---topo-order

> This change makes option "--topo-order" obsolete, because
> there is only one way to order parents of a single commit.
> "--date-order" and "--author-date-order" are preserved and make sense
> only for the case when multiple commits are given
> to be able to sort those commits.

This part of the change needs to be removed. The default sort does
not preserve topological orderings (like --date-order does), and
so is much faster to output, especially without a commit-graph file.

>  void sort_in_topological_order(struct commit_list **list, enum rev_sort_order sort_order)

Since you are only editing this code, and not the incremental topo-order code, your
test changes will likely break when run with GIT_TEST_COMMIT_GRAPH=1. When the commit-graph
exists and generation numbers are calculated, we use a different algorithm for topo-order.

I've been meaning to clean up this "duplicated" logic by deleting this method in favor of
the incremental algorithm in all cases. It needs some perf testing to make sure that
refactor doesn't have too large of a perf hit in the case of no commit-graph.

>  	/* update the indegree */
> @@ -832,51 +886,56 @@ void sort_in_topological_order(struct commit_list **list, enum rev_sort_order so
>  	for (next = orig; next; next = next->next) {
>  		struct commit *commit = next->item;
>  
> -		if (*(indegree_slab_at(&indegree, commit)) == 1)
> -			prio_queue_put(&queue, commit);
> +		if (*(indegree_slab_at(&indegree, commit)) == 1) {
> +			/* also record the author dates, if needed */
> +			if (sort_order == REV_SORT_BY_AUTHOR_DATE)
> +				record_author_date(&author_date, commit);
> +			prio_queue_put(&queue_tips, commit);
> +		}

Your code change looks rather large for what I expected to be a much simpler change.
Likely the only thing we need is to avoid adding to the priority queue if we already
have the commit in the queue (maybe using a hashset storing the commits that we've
added to the queue). I believe the reason C appears before B in your example is that
it was added to the queue a second time, and the queue behaves like a stack in the
topo-order case.

Thanks,
-Stolee



[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux