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

Re: [BUG] Git clone of a bundle fails, but works (somewhat) when run with strace

From
Jeff King <peff@peff.net>
Date
Feb 16, 2013, 04:01 UTC
Message-ID
<20130216040109.GA31630@sigill.intra.peff.net>
In-Reply-To
<kfmide$4ro$3@ger.gmane.org>
On Sat, Feb 16, 2013 at 12:03:58AM +0000, Alain Kalker wrote:
Show 25 quoted lines
> ---test.sh---
> #!/bin/sh
> 
> make clean
> make || return 125
> GIT=$(pwd)/git
> 
> cd /tmp
> rm -rf testrepo
> mkdir testrepo
> cd testrepo
> $GIT init
> echo test > test.txt
> $GIT add test.txt
> $GIT commit -m "Add test.txt"
> $GIT bundle create ../testrepo.bundle master || return 125
> cd ..
> 
> rm -rf testrepofrombundle
> $GIT clone testrepo.bundle testrepofrombundle || return 1
> ---
> I was unable to find a bad revision.
> After a lot more searching I found that I had `git` aliased to `hub`, a 
> tool used to make Github actions easier.
> Eliminating `hub` from the equation resolved most problems.
Great.
> The only ones remaining are the confusing error message from `git bundle 
> create` and the "missing HEAD" (you can interpret that in different 
> ways) ;-)

I do not see any odd message from "bundle create" in the recipe above. Mine says:

$ git bundle create ../repo.bundle master Counting objects: 3, done. Writing objects: 100% (3/3), 209 bytes, done. Total 3 (delta 0), reused 0 (delta 0)

What you _might_ be seeing is the fact that the invocation above is likely to be running two different versions of git under the hood. "git bundle" will invoke "git rev-list", and it will use the first git in your PATH, even if it is not $GIT. The proper way to test an un-installed version of git is to use $YOUR_GIT_BUILD/bin-wrappers/git, which will set up environment variables sufficient to make sure all sub-gits are from the same version. Sometimes mixing versions can have weird results (e.g., the new "git bundle" expects "rev-list" to have a particular option, but the older version does not have it).

Secondly, I do get the same warning about HEAD:
  $ git clone repo.bundle repofrombundle
  Cloning into 'repofrombundle'...
  Receiving objects: 100% (3/3), done.
  warning: remote HEAD refers to nonexistent ref, unable to checkout.

but that warning makes sense. You did not create a bundle that contains HEAD, therefore when we clone it, we do not know what to point HEAD to. You probably wanted "git bundle create ../repo.bundle --all" which includes both "master" and "HEAD".

It would be slightly more accurate to say "the remote HEAD does not exist", rather than "refers to nonexistent ref". It would perhaps be nicer still for "git clone" to make a guess about the correct HEAD when one is not present (especially in the single-branch case, it is easy to make the right guess).

Patches welcome. In the meantime, you can clone with "-b master" to tell it explicitly, or you can "git checkout master" inside the newly-cloned repository.

-Peff
Previous: Junio C HamanoNext: Alain Kalker
Message 5 of 9 in “[BUG] Git clone of a bundle fails, but works (somewhat) when run with strace”
  1. Alain KalkerFeb 15, 2013
  2. Alain KalkerFeb 15, 2013
  3. Alain KalkerFeb 16, 2013
  4. Junio C HamanoFeb 16, 2013
  5. Jeff KingFeb 16, 2013
  6. Alain KalkerFeb 17, 2013
  7. Philip OakleyFeb 17, 2013
  8. Junio C HamanoFeb 25, 2013
  9. Bram GeronMay 28, 2014

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.