git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jeff King <peff@peff.net>
To: Nguyen Thai Ngoc Duy <pclouds@gmail.com>
Cc: Seth Robertson <in-gitvger@baka.org>,
	Woody Wu <narkewoody@gmail.com>, git <git@vger.kernel.org>
Subject: Re: Find the starting point of a local branch
Date: Mon, 24 Dec 2012 01:19:38 -0500	[thread overview]
Message-ID: <20121224061938.GA25186@sigill.intra.peff.net> (raw)
In-Reply-To: <CACsJy8CNd3W_WUMbZ1QZ4ReZ5ziX90QejK9mh1TMs0ig33kGMw@mail.gmail.com>

On Mon, Dec 24, 2012 at 12:28:45PM +0700, Nguyen Thai Ngoc Duy wrote:

> > You want to know "what commit was I at when I typed `git branch
> > mybranch`"?  The problem is git doesn't record this information and
> > doesn't have the slightest clue.
> 
> Maybe we should store this information. reflog is a perfect place for
> this, I think. If this information is reliably available, git rebase
> can be told to "rebase my whole branch" instead of my choosing the
> base commit for it.

Is that what you really want, though? We record the "upstream" branch
already, and you can calculate the merge base with that branch to see
which commits are unique to your branch. In simple cases, that is the
same as "where did I start the branch". In more complex cases, it may
not be (e.g., if you merged some of the early commits in the branch
already).  But in that latter case, would you really want to rebase
those commits that had been merged?

The reason that git does not bother storing "where did I start this
branch" is that it is usually not useful. The right question is usually
"what is the merge base". There are exceptions, of course (e.g., if you
are asking something like "what work did I do while checked out on the
'foo' branch"). But for merging and rebasing, I think the computed
merge-base is much more likely to do what people want.

-Peff

  parent reply	other threads:[~2012-12-24  6:20 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-12-24  3:58 Find the starting point of a local branch Woody Wu
2012-12-24  4:09 ` Seth Robertson
2012-12-24  5:28   ` Nguyen Thai Ngoc Duy
2012-12-24  5:34     ` Tomas Carnecky
2012-12-24  5:45       ` Nguyen Thai Ngoc Duy
2012-12-24  6:27         ` Junio C Hamano
2012-12-24 11:21           ` Nguyen Thai Ngoc Duy
2012-12-24 19:10             ` Junio C Hamano
2012-12-25  1:09               ` Nguyen Thai Ngoc Duy
2012-12-24  6:19     ` Jeff King [this message]
2012-12-24 11:16       ` Nguyen Thai Ngoc Duy
2012-12-24 15:34         ` Jeff King
2012-12-24  7:31   ` Woody Wu
2012-12-24  9:12     ` Kevin
2012-12-24 17:24     ` Martin von Zweigbergk
2012-12-28  5:15       ` Woody Wu
2012-12-28  6:38         ` Martin von Zweigbergk

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=20121224061938.GA25186@sigill.intra.peff.net \
    --to=peff@peff.net \
    --cc=git@vger.kernel.org \
    --cc=in-gitvger@baka.org \
    --cc=narkewoody@gmail.com \
    --cc=pclouds@gmail.com \
    /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).