From: Pavan Kumar Sunkara <pavan.sss1991@gmail.com>
To: Jeff King <peff@peff.net>, Git List <git@vger.kernel.org>
Subject: Re: Walking commits from the first
Date: Mon, 15 Feb 2010 17:03:14 +0530 [thread overview]
Message-ID: <e72faaa81002150333r4eb27a15t7de6b3c820eb4bc2@mail.gmail.com> (raw)
In-Reply-To: <20100215080646.GD5347@coredump.intra.peff.net>
> In most repositories, you can do this:
>
> git checkout `git rev-list --reverse HEAD | head -n 1`
>
Thanks for the command
> It is not as simple as that, for two reasons.
>
> For walking backwards, you can take multiple paths from merge commits
> (which have multiple parents). So there may actually be several "first
> commits" if unrelated lines of development were merged together. For
> example, in git.git:
>
> $ git log --format='%h %p' |
> grep ' $'
> 16d6b8a
> cb07fc2
> 161332a
> 1db95b0
> 2744b23
> e83c516
>
> There are six root commits. You can see what they are by piping the
> above into "tr -d ' ' | git log --no-walk --stdin".
>
> For your "--next" suggestion, it is even worse. There may be an infinite
> number of commits that point to a given commit as the parent. So there
> is no such thing as "what came next from X". You can only ask
> "leading up to some commit Y which is a descendant of X, what was the
> commit that came after X". But while there are a finite number of
> answers, there is not necessarily just one. If two branches diverged at
> X and then remerged before Y, they are both equally "next".
>
> -Peff
>
My bad. I never thought of branch merging while writing this
So, if i want to get the second commit, Is this enough or will i get
the problem of branch diverging, if there is a branch diverging from
there.
git checkout `git rev-list --reverse HEAD | head -n 2`
Even though we have the problem branches to travel reversely, we can
do it in another way. As, we have the timestamp for every commit, then
it will be easy to implement --next. Take the next commit in timeline
and checkout. Even though it's completely different branch, no problem
as long as we are going in order.
Also we can have git checkout --next --same-branch to checkout the
next commit in timeline of the same branch.
next prev parent reply other threads:[~2010-02-15 11:33 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <e72faaa81002142037g7f5f518erb9fefbb239124bc5@mail.gmail.com>
2010-02-15 4:39 ` Walking commits from the first Pavan Kumar Sunkara
2010-02-15 8:06 ` Jeff King
2010-02-15 11:33 ` Pavan Kumar Sunkara [this message]
2010-02-15 14:05 ` Jon Seymour
2010-02-15 14:20 ` Jon Seymour
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=e72faaa81002150333r4eb27a15t7de6b3c820eb4bc2@mail.gmail.com \
--to=pavan.sss1991@gmail.com \
--cc=git@vger.kernel.org \
--cc=peff@peff.net \
/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 NNTP newsgroup(s).