3

Let's assume we have two commits A and B in the same repository and that A is an ancestor of B.
That has been checked with exist status 0 for:

git merge-base --is-ancestor A B

or, in older way if the output from the following two commands is identical:

git merge-base A B
git rev-parse A

I would like to know if there is a git command or simple solution to find the representation of B based on A using ancestry references, using ^ and ~.

If there are multiple paths, what I need for now is to find the fastest path that has the least number of non-first parent path (^n, n>1). From my calculation there are no two path that have the same number of non-first parents in it's path.

The results could look like this:
A~3, A~4^2~3, A^^3~2

Alex P
  • 602
  • 5
  • 19
  • 1
    Alexandru, your Git-related questions (I consider also [this one](http://stackoverflow.com/q/15589862/720999)) seem to be hardcore enough to warrant asking on [the main Git mailing list](http://vger.kernel.org/vger-lists.html#git) as very few Git developers really follow the "git" tag on SO. You do not have to subscribe to it before posting, but please be sure your mail user agent does not produce HTML as such mails will not reach the list. Oh, and be sure to post *questions* there, not just links to SO questions -- few people bother following links. – kostix Mar 24 '13 at 17:43
  • 2
    As to the question at hand -- I think the closest existing approximation of what you want is produced by the `git name-rev --name only ...` command, but it anchors at branches or tags, not arbitrary commits. And `git describe` is even more higher-level, so my take on this is that such a plumbing command you need does not yet exist (and honestly I can hardly imagine a use case for it). – kostix Mar 24 '13 at 17:49
  • Adding to @kostix' comment, what do you want this for? It is quite far out, probably there is a simpler way to getting where you want to go. – vonbrand Mar 24 '13 at 19:34
  • @vonbrand I want to find a way to solve this other problem: [stackoverflow.com/q/15589862](http://stackoverflow.com/q/15589862). Indeed is a bit more generalized but using `git name-rev` might be a solution. – Alex P Mar 24 '13 at 20:01

0 Answers0