Specifying N revisions after the initial commit

3 messages, 2 authors, 2016-06-15 · open the first message on its own page

Specifying N revisions after the initial commit

From: Josh Boyer <hidden>
Date: 2016-06-15 23:06:39

Hi All,

Please CC me as I'm not subscribed.

I was hoping someone could help me with the revision shorthand to get
the commit sha of a commit N commits after the initial commit.  Thus
far I've figured out that to get the initial commit in a repository,
you can use:

git rev-list --max-parents=0 HEAD

but I can't figure out how to get "give me the commit sha1 of the
commit immediately after the initial commit", or for some number N.  I
could always do something like:

git rev-list HEAD | tail -2

to get both, but I was curious if there was a refspec shorthand for
this that could be used.  It seems that git's rev parsing is all built
on going backwards in order (and probably rightfully so).

Thanks in advance.

josh

Re: Specifying N revisions after the initial commit

From: Konstantin Khomoutov <hidden>
Date: 2016-06-15 23:06:39

On Tue, 22 Sep 2015 14:32:19 -0400
Josh Boyer [off-list ref] wrote:
Please CC me as I'm not subscribed.

I was hoping someone could help me with the revision shorthand to get
the commit sha of a commit N commits after the initial commit.
What happens if right after the initial commit, there have been five
branches created -- with no common commits except for the initial one?

That's the core limitation of the data model Git uses (and arguably any
other DVCS system): all commits form a directed acyclic graph.
The "directed" in that construct means that child commits contain a
link to their parent commit (or commits) but not vice-versa.

Hence, given any particular commit, you're able to trace all of its
ancestry, but the reverse is not possible.

Re: Specifying N revisions after the initial commit

From: Josh Boyer <hidden>
Date: 2016-06-15 23:06:39

On Tue, Sep 22, 2015 at 2:40 PM, Konstantin Khomoutov
[off-list ref] wrote:
On Tue, 22 Sep 2015 14:32:19 -0400
Josh Boyer [off-list ref] wrote:
quoted
Please CC me as I'm not subscribed.

I was hoping someone could help me with the revision shorthand to get
the commit sha of a commit N commits after the initial commit.
What happens if right after the initial commit, there have been five
branches created -- with no common commits except for the initial one?

That's the core limitation of the data model Git uses (and arguably any
other DVCS system): all commits form a directed acyclic graph.
The "directed" in that construct means that child commits contain a
link to their parent commit (or commits) but not vice-versa.
Hm.  It has been so long since I've looked at the underlying model and
git has proven to be so flexible on such a variety of things that I
guess I forgot it was constructed through a DAG.  The --reverse
parameter to git-log and git-rev-parse had left me hopeful.
Hence, given any particular commit, you're able to trace all of its
ancestry, but the reverse is not possible.
That makes sense.  I suppose I will have to resort to parsing output
of git-rev-list or something.  Thanks for the reminder.

josh
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help