{"thread":{"id":"46160","subject":"bug? fetching from empty unnamed remote repos","startedAt":"2017-06-12T17:50:16Z","lastAt":"2017-06-12T18:08:54Z","messageCount":2,"participants":["David Turner","Junio C Hamano"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"321970","messageId":"b3d0d39fe9d443fd8202b8b055d31f86@exmbdft7.ad.twosigma.com","threadId":"46160","inReplyTo":null,"subject":"bug? fetching from empty unnamed remote repos","fromName":"David Turner","fromEmail":"david.turner@twosigma.com","sentAt":"2017-06-12T17:50:05Z","receivedAt":"2017-06-12T17:50:16Z","isPatch":false,"sender":{"key":"david.turner@twosigma.com","avatar":null},"body":"$ git init empty-1\n$ git init empty-2 \n$ cd empty-1\n$ git fetch ../empty-2\nfatal: Couldn't find remote ref HEAD\nfatal: The remote end hung up unexpectedly\n\nBut:\n$ git init empty-1\n$ git init empty-2 \n$ cd empty-1\n$ git remote add other ../empty-2\n$ git fetch other\n# this works\n\nI haven't spent a lot of time looking into the code, because we can use the second option.  But it does seem weird.\n"},{"id":"321976","messageId":"xmqqink1nknk.fsf@gitster.mtv.corp.google.com","threadId":"46160","inReplyTo":"b3d0d39fe9d443fd8202b8b055d31f86@exmbdft7.ad.twosigma.com","subject":"Re: bug? fetching from empty unnamed remote repos","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2017-06-12T18:08:47Z","receivedAt":"2017-06-12T18:08:54Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"David Turner <David.Turner@twosigma.com> writes:\n\n> $ git init empty-1\n> $ git init empty-2 \n> $ cd empty-1\n> $ git fetch ../empty-2\n> fatal: Couldn't find remote ref HEAD\n> fatal: The remote end hung up unexpectedly\n\nThe current repository does not know anything about empty-2\nrepository.  It does not have [remote \"name\"] section that points at\n../empty-2 and it does not have a refspec to fetch.\n\nHence \"git fetch ../empty-2\" tries to fetch HEAD from that\nrepository by default.  It does not exist, and it fails.\n\n> But:\n> $ git init empty-1\n> $ git init empty-2 \n> $ cd empty-1\n> $ git remote add other ../empty-2\n\nYou told to your current repository to have [remote \"other\"]\nsection, that points at ../empty-2 and fetch with refs/heads/*:refs/remotes/other/*\nas the refspec.\n\n> $ git fetch other\n\nHence \"git fetch other\" tries to fetch refs/heads/* into refs/remotes/other/*;\nnot having any matching source is not a crime---it is a simple noop.\n\n> # this works\n\nSo there is nothing surprising about all of the above as far as I\ncan see.\n\n"}]}