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

Re: Trying to push into empty repo, get fatal: bad revision 'HEAD'

From
Johannes Schindelin <johannes.schindelin@gmx.de>
Date
Apr 1, 2015, 08:51 UTC
Message-ID
<cb4098391d46cc25b3d4d059e35dc806@www.dscho.org>
In-Reply-To
<xmqq8uecocjg.fsf@gitster.dls.corp.google.com>
Hi Samuel & Junio,
On 2015-04-01 03:36, Junio C Hamano wrote:
Show 20 quoted lines
> Junio C Hamano <gitster@pobox.com> writes:
> 
>> Samuel Williams <space.ship.traveller@gmail.com> writes:
>>
>>> I would expect if you push to an empty repo, it would update it
>>> (because denyCurrentBranch = updateInstead).
>>
>> Good finding.
>>
>> I think the current implementation of updateInstead is set up to
>> bootstrap from an empty repository but only supports incremental
>> updates once the receiving repository and its working tree gets set
>> up.  But I do not think it was a conscious design decison to forbid
>> bootstrapping an empty repository, but was a mere gap in the
>> implementation.  At least, I do not think of a reason why we should
>> forbid it (and I am Cc'ing Dscho to confirm).
> 
> This is a tangent but I think we should unify the "do we already
> have history behind HEAD, or is the current branch still unborn"
> test done by various commands and tighten it.
Right, I did not think about that use case at all.
> As a quick and dirty hack, I just mimicked what builtin/merge.c seems to do, but this would tell a detached HEAD that points at a nonsense object name (i.e. "abcde" not a full 40-hex) as "unborn", where we would be better off stopping the operation instead of making the repository breakage worse by doing further damage.
Yeah, and we could refactor that into a global function, too. But for the moment, I think your proposed patch is good enough.

Ciao, Dscho

Previous: Junio C HamanoNext: Junio C Hamano
Message 5 of 7 in “Trying to push into empty repo, get fatal: bad revision 'HEAD'”
  1. Samuel WilliamsMar 31, 2015
  2. Junio C HamanoApr 1, 2015
  3. Junio C HamanoApr 1, 2015
  4. Junio C HamanoApr 1, 2015
  5. Johannes SchindelinApr 1, 2015
  6. Junio C HamanoApr 1, 2015
  7. Johannes SchindelinApr 2, 2015

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.