git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Shortest path between commits
@ 2006-02-08 16:03 Ralf Baechle
  2006-02-08 16:43 ` Linus Torvalds
  0 siblings, 1 reply; 2+ messages in thread
From: Ralf Baechle @ 2006-02-08 16:03 UTC (permalink / raw)
  To: git

I wonder if there some way to find the shortest path between two commits?
That is if there is a merge between the two commits I only want the merge
commit itself, not the potencially large list of commits that were merged.

I need that for commit notification scripts; I don't want to spam users
with too many emails and aggregating everything that came through a single
merge would be a reaonsable approach.

  Ralf

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Shortest path between commits
  2006-02-08 16:03 Shortest path between commits Ralf Baechle
@ 2006-02-08 16:43 ` Linus Torvalds
  0 siblings, 0 replies; 2+ messages in thread
From: Linus Torvalds @ 2006-02-08 16:43 UTC (permalink / raw)
  To: Ralf Baechle; +Cc: git



On Wed, 8 Feb 2006, Ralf Baechle wrote:
>
> I wonder if there some way to find the shortest path between two commits?
> That is if there is a merge between the two commits I only want the merge
> commit itself, not the potencially large list of commits that were merged.

The problem is that it's entirely possible that no such path even 
exists.

Two commits are not necessarily directly related, and asking for the 
shortest path may involve having to go both backwards _and_ forwards in 
history to get from one to the other. The most trivial case is

	    a  <- head of tree
	   / \
	  /   \
	 b     c
	  \   /
	   \ /
	    d  <- root

where the shortest path between "b" and "c" is not really a well-defined 
notion.

Now, _if_ you know that one of the commits is a direct descendant of the 
other, a sensible path can be decided on, but even then the notion of 
"shortest" is not obvious. Look at "a" vs "d" above - which path is the 
shortest one? The one through "b" or the one through "c"? There's really 
no way to tell them apart (you could select "first parent", but in more 
complex graphs that might not be unambiguous either).

That said, and to finally answer your question: selecing _one_ short path 
between two commits (if they are directly related) is certainly possible, 
but no, we don't have anything like that available right now. It wouldn't 
be hugely difficult to do an addition to git-rev-list to do so, though.

Can you describe your usage case? The operation really _isn't_ sensible in 
general, so while I could add a flag to git-rev-list to only print out as 
direct a chain as possible, I'd like to know that there is at least _one_ 
entirely sane usage for such a thing.

		Linus

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2006-02-08 16:44 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-02-08 16:03 Shortest path between commits Ralf Baechle
2006-02-08 16:43 ` Linus Torvalds

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).