{"thread":{"id":"33156","subject":"A bug or unhandled case","startedAt":"2013-03-11T16:06:26Z","lastAt":"2013-03-11T16:53:30Z","messageCount":4,"participants":["Michał Janiszewski","Junio C Hamano"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"211050","messageId":"CABB6UqEfx=ssbiD1+2HA3AtmSrFeJeg5fmU3z1SKukNsKvd4qw@mail.gmail.com","threadId":"33156","inReplyTo":null,"subject":"A bug or unhandled case","fromName":"Michał Janiszewski","fromEmail":"janisozaur@gmail.com","sentAt":"2013-03-11T16:06:26Z","receivedAt":"2013-03-11T16:06:26Z","isPatch":false,"sender":{"key":"janisozaur@gmail.com","avatar":null},"body":"Hi,\nI think I've found a bug in git or at least a use case that is not handled.\nIn few words it can be described like this: if you push a remote\nbranch to another remote, which is bare repository, you cannot remove\nthat branch from said bare repository.\nHere is a recipe how to reproduce that with git 1.8.0:\ngit init foo\ngit init --bare bar.git\ngit init --bare baz.git\ncd foo\necho test > file\ngit commit -am \"initial commit\"\ngit remote add bar ../bar.git\ngit remote add baz ../baz.git\ngit push bar master\ncd ..\ngit clone bar.git bax\ncd bax\ngit checkout -b \"test_branch\"\necho evil > file\ngit commit -am \"evil commit\"\ngit push origin test-branch\ncd ../foo\ngit fetch bar\ngit push baz bar/test_branch\ncd ../baz.git\n\n###\n# on that point in baz.git there is only one branch:\n# remotes/bar/test_branch 8b96ffe evil commit\n# trying to remove that branch yields no results:\n$ git branch -D refs/remotes/bar/test_branch\nerror: branch 'refs/remotes/bar/test_branch' not found.\n$ git branch -D remotes/bar/test_branch\nerror: branch 'remotes/bar/test_branch' not found.\n$ git branch -D bar/test_branch\nerror: branch 'bar/test_branch' not found.\n$ git branch -D test_branch\nerror: branch 'test_branch' not found.\n\ngit gc --prune=now\n# also does nothing\n\nThe only way to remove that branch is to:\ncd ../foo\ngit push baz :bar/test_branch\n\nShouldn't someone who owns bare repository be able to delete that kind\nof branches as he is able to do with \"regular\" branches?\n\n--\nMichal Janiszewski\n"},{"id":"211053","messageId":"7vvc8xaoia.fsf@alter.siamese.dyndns.org","threadId":"33156","inReplyTo":"CABB6UqEfx=ssbiD1+2HA3AtmSrFeJeg5fmU3z1SKukNsKvd4qw@mail.gmail.com","subject":"Re: A bug or unhandled case","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2013-03-11T16:29:33Z","receivedAt":"2013-03-11T16:29:33Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Michał Janiszewski <janisozaur@gmail.com> writes:\n\n> Hi,\n> I think I've found a bug in git or at least a use case that is not handled.\n> In few words it can be described like this: if you push a remote\n> branch to another remote, which is bare repository, you cannot remove\n> that branch from said bare repository.\n> Here is a recipe how to reproduce that with git 1.8.0:\n> git init foo\n> git init --bare bar.git\n> git init --bare baz.git\n> cd foo\n> echo test > file\n> git commit -am \"initial commit\"\n\nNothing added, nothing committed, at this point.\nI'd assume there is \"git add file\" before this commit.\n\n> git remote add bar ../bar.git\n> git remote add baz ../baz.git\n> git push bar master\n> cd ..\n> git clone bar.git bax\n> cd bax\n> git checkout -b \"test_branch\"\n> echo evil > file\n> git commit -am \"evil commit\"\n> git push origin test-branch\n\nerror: src refspec test-branch does not match any.\nerror: failed to push some refs to '...../bar.git'\n\nI'd assume that is test_branch\n\n> cd ../foo\n> git fetch bar\n> git push baz bar/test_branch\n> cd ../baz.git\n>\n> ###\n> # on that point in baz.git there is only one branch:\n\nCorrect.\n\n> # remotes/bar/test_branch 8b96ffe evil commit\n> # trying to remove that branch yields no results:\n> $ git branch -D refs/remotes/bar/test_branch\n\nThat is not the way to remove the remote tracking branch test_branch\nyou have from remote bar, is it?\n\n\tgit branch -r -D bar/test_branch\n"},{"id":"211054","messageId":"CABB6UqHgcsx9oK2GHhmwpuhv+T3aMAJk_udw8enkGB3OutzbNg@mail.gmail.com","threadId":"33156","inReplyTo":"7vvc8xaoia.fsf@alter.siamese.dyndns.org","subject":"Re: A bug or unhandled case","fromName":"Michał Janiszewski","fromEmail":"janisozaur@gmail.com","sentAt":"2013-03-11T16:39:09Z","receivedAt":"2013-03-11T16:39:09Z","isPatch":false,"sender":{"key":"janisozaur@gmail.com","avatar":null},"body":"Hmm, indeed it works. Sorry for the confusion then (and a bit mistaken\ncommands, but you got them correct).\nI wasn't aware of the -r option.\n\nOn Mon, Mar 11, 2013 at 5:29 PM, Junio C Hamano <gitster@pobox.com> wrote:\n> Michał Janiszewski <janisozaur@gmail.com> writes:\n>\n>> Hi,\n>> I think I've found a bug in git or at least a use case that is not handled.\n>> In few words it can be described like this: if you push a remote\n>> branch to another remote, which is bare repository, you cannot remove\n>> that branch from said bare repository.\n>> Here is a recipe how to reproduce that with git 1.8.0:\n>> git init foo\n>> git init --bare bar.git\n>> git init --bare baz.git\n>> cd foo\n>> echo test > file\n>> git commit -am \"initial commit\"\n>\n> Nothing added, nothing committed, at this point.\n> I'd assume there is \"git add file\" before this commit.\n>\n>> git remote add bar ../bar.git\n>> git remote add baz ../baz.git\n>> git push bar master\n>> cd ..\n>> git clone bar.git bax\n>> cd bax\n>> git checkout -b \"test_branch\"\n>> echo evil > file\n>> git commit -am \"evil commit\"\n>> git push origin test-branch\n>\n> error: src refspec test-branch does not match any.\n> error: failed to push some refs to '...../bar.git'\n>\n> I'd assume that is test_branch\n>\n>> cd ../foo\n>> git fetch bar\n>> git push baz bar/test_branch\n>> cd ../baz.git\n>>\n>> ###\n>> # on that point in baz.git there is only one branch:\n>\n> Correct.\n>\n>> # remotes/bar/test_branch 8b96ffe evil commit\n>> # trying to remove that branch yields no results:\n>> $ git branch -D refs/remotes/bar/test_branch\n>\n> That is not the way to remove the remote tracking branch test_branch\n> you have from remote bar, is it?\n>\n>         git branch -r -D bar/test_branch\n>\n\n\n\n--\nMichal Janiszewski\n"},{"id":"211058","messageId":"7vk3pdaned.fsf@alter.siamese.dyndns.org","threadId":"33156","inReplyTo":"CABB6UqHgcsx9oK2GHhmwpuhv+T3aMAJk_udw8enkGB3OutzbNg@mail.gmail.com","subject":"Re: A bug or unhandled case","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2013-03-11T16:53:30Z","receivedAt":"2013-03-11T16:53:30Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Michał Janiszewski <janisozaur@gmail.com> writes:\n\n> Hmm, indeed it works. Sorry for the confusion then (and a bit mistaken\n> commands, but you got them correct).\n> I wasn't aware of the -r option.\n\nI think what tripped you was that \"git branch\" deals with branch\nnames, and not refnames (which is the underlying but lower level\nconcept).  \"git branch -d refs/heads/master\" is not a way to remove\nyour local mastar branch.\n"}]}