git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jakub Narebski <jnareb@gmail.com>
To: davetron5000 <davetron5000@gmail.com>
Cc: git@vger.kernel.org
Subject: Re: How does git store branchpoints?
Date: Mon, 09 Jun 2008 08:07:17 -0700 (PDT)	[thread overview]
Message-ID: <m3hcc2wso1.fsf@localhost.localdomain> (raw)
In-Reply-To: <beffea8c-fd2a-44d0-a566-3ded5d09a3d2@l42g2000hsc.googlegroups.com>

davetron5000 <davetron5000@gmail.com> writes:

> Following up this:
> 
> http://groups.google.com/group/git-version-control/browse_thread/thread/aa34d04120d0c361#
> 
> I'm trying to learn/examine the .git directory to see what Git thinks.
> 
> What I'm trying to determine is how Git knows the parent of a
> particular commit, how I can change it, and how that affects merging.

The parent (or parents in the case of merge commit) are stored in the
commit object itself.  You cannot change them short of rewriting
history, or telling git locally via .git/info/grafts file how it should
modify history (see "Repository Layout" documentation for more info
about grafts).
 
> My problem is that I have two branches, and a merge between the two
> produces conflicts in files that are unchanged on one branch.  Since
> my branches are linked to SVN branches, I'm thinking that Git is not
> properly clear on their shared history.
> 
> Any ideas where to look?

Use some kind of history viewer, be it gitk, qgit, giggle, tig,
git-show-branch (a bit cryptic), git log --graph (not yet released),
or similar tool.

> .git/info/refs has some strange data in it:
> 
> 5a3e01a8327c6139e9311b01548baf4a8876b5e3    refs/heads/local-FOO
> 71560b15ad6a2a7542556dfdf2d6c763625d5db4    refs/heads/local-trunk
> efb2ff2ac363600a2aaae60718bc76b6c3db4228    refs/remotes/FOO
> 
> The SHA-1 for refs/heads/local-FOO (branch created via git checkout -b
> local-FOO FOO) doesn't show in gitk --all, but a git log of that shows
> it to be a somewhat old commit (not the head, nor the branch point).

.git/info/refs is auxiliary information for "dumb" protocols, i.e.
for fetching via HTTP etc.  It is updated using git-update-server-info,
usually in the bare public repositories run from post-update hook
(in non-bare you would want to add it also to post-commit).

What you should look at is "git show-refs" or "git ls-remote ."
output, or "git for-each-ref" output.

> The SHA-1 for local-trunk is a similarly old commit
> 
> The SHA-1 for refs/remotes/FOO is the commit right before the SHA-1
> for refs/heads/local-FOO in my git log.

That said, if you have two divergent branches 'FOO' and 'trunk',
for example with the following history

   a<---b<---c<---d<---e  <--- trunk
             ^
              \---1<---2  <--- FOO

you can derive from parent info where history diverged.

You can ask git to find branch point using "git merge-base trunk FOO",
which should return 'c' (actually, sha-1 of this commit).

HTH.
-- 
Jakub Narebski
Poland
ShadeHawk on #git

  reply	other threads:[~2008-06-09 15:08 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-06-09 14:17 How does git store branchpoints? davetron5000
2008-06-09 15:07 ` Jakub Narebski [this message]
2008-06-09 19:54   ` davetron5000
2008-06-09 20:53     ` Jakub Narebski
2008-06-09 21:15       ` David Copeland

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=m3hcc2wso1.fsf@localhost.localdomain \
    --to=jnareb@gmail.com \
    --cc=davetron5000@gmail.com \
    --cc=git@vger.kernel.org \
    /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).