git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: Branches and all commits

From
JNJon Nelson <jnelson-git@jamponi.net>
Date
Dec 19, 2005, 17:39 UTC
Message-ID
<Pine.LNX.4.63.0512191104080.6812@gheavc.wnzcbav.cig>
In-Reply-To
<43A6DC90.3040403@op5.se>
On Mon, 19 Dec 2005, Andreas Ericsson wrote:
Show 36 quoted lines
> Jon Nelson wrote:
> > Should *all* commits be reachable via at least one branch? I ran into a
> > situation this weekend that has me a little confused. I had performed a
> > number of commits and such and I noticed that the author and committer info
> > had suboptimal values. A bit of searching led me to a comment made by Linus
> > that basically said "go hack git-convert-objects", which I did. After
> > performing git-convert-objects on every commit object in .git/refs/heads and
> > the requisite pruning, etc... just about everything looked fine. However, I
> > still had a long series of commits that contained the wrong information.
> > Further inspection makes it appear as though these commits are not reachable
> > via any branch, although they are /all/ reachable via a series of tags. I
> > worked around the problem by further modifying git-convert-objects to also
> > understand tags (at least the basic ones I've got) and that's all taken care
> > of, but the question remains: should *all* commit objects be reachable by at
> > least one branch?
> > 
> 
> AFAIU, yes.
> 
> For future reference, what you should have done is this;
> 
> $ git format-patch --mbox <first-unscrewed-commit-ish>
> # edit commit-messages in generated patches
> $ git reset --hard <first-unscrewed-commit-ish>
> $ for i in 00*.txt; do git apply < $i; done
> $ git prune;# to get rid of the unreachable objects AFTER you've checked
> everything's all right
> 
> If things fail, do
> 
> $ git reset --hard ORIG_HEAD
> 
> and ask again.
> 
> I'm afraid I can't help you fix up your repository from the state it's 
> in now. AFAIK, there's no tool to do it automagically.

The repository seems just fine with this single exception - no branch contains a reference to the commit that forms the chain of commits that would otherwise be described as a branch. As I understand it, then, the only thing that is missing is an entry in .git/refs/heads.

Experimentally, I added that entry by determining the first commit in that chain and echoing that sha1 into .git/refs/heads/some_name and that works as expected.

I suspect that the root cause was a 'git branch -D' I issued a while back. My question is this: if deleting a branch in that manner caused me to enter this situation, is that a bug or no? The commits in question *are* referenced by various tags, but not by any branch that exists any more. The echo command effectively re-created the branch and all seems well.

-- Jon Nelson <jnelson-git@jamponi.net>

Previous: Andreas EricssonNext: Andreas Ericsson
Message 3 of 6 in “Branches and all commits”
  1. Jon NelsonDec 19, 2005
  2. Andreas EricssonDec 19, 2005
  3. Jon NelsonDec 19, 2005
  4. Andreas EricssonDec 19, 2005
  5. Jon NelsonDec 19, 2005
  6. Andreas EricssonDec 19, 2005

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.