* A bug or unhandled case
@ 2013-03-11 16:06 Michał Janiszewski
2013-03-11 16:29 ` Junio C Hamano
0 siblings, 1 reply; 4+ messages in thread
From: Michał Janiszewski @ 2013-03-11 16:06 UTC (permalink / raw)
To: git
Hi,
I think I've found a bug in git or at least a use case that is not handled.
In few words it can be described like this: if you push a remote
branch to another remote, which is bare repository, you cannot remove
that branch from said bare repository.
Here is a recipe how to reproduce that with git 1.8.0:
git init foo
git init --bare bar.git
git init --bare baz.git
cd foo
echo test > file
git commit -am "initial commit"
git remote add bar ../bar.git
git remote add baz ../baz.git
git push bar master
cd ..
git clone bar.git bax
cd bax
git checkout -b "test_branch"
echo evil > file
git commit -am "evil commit"
git push origin test-branch
cd ../foo
git fetch bar
git push baz bar/test_branch
cd ../baz.git
###
# on that point in baz.git there is only one branch:
# remotes/bar/test_branch 8b96ffe evil commit
# trying to remove that branch yields no results:
$ git branch -D refs/remotes/bar/test_branch
error: branch 'refs/remotes/bar/test_branch' not found.
$ git branch -D remotes/bar/test_branch
error: branch 'remotes/bar/test_branch' not found.
$ git branch -D bar/test_branch
error: branch 'bar/test_branch' not found.
$ git branch -D test_branch
error: branch 'test_branch' not found.
git gc --prune=now
# also does nothing
The only way to remove that branch is to:
cd ../foo
git push baz :bar/test_branch
Shouldn't someone who owns bare repository be able to delete that kind
of branches as he is able to do with "regular" branches?
--
Michal Janiszewski
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: A bug or unhandled case
2013-03-11 16:06 A bug or unhandled case Michał Janiszewski
@ 2013-03-11 16:29 ` Junio C Hamano
2013-03-11 16:39 ` Michał Janiszewski
0 siblings, 1 reply; 4+ messages in thread
From: Junio C Hamano @ 2013-03-11 16:29 UTC (permalink / raw)
To: Michał Janiszewski; +Cc: git
Michał Janiszewski <janisozaur@gmail.com> writes:
> Hi,
> I think I've found a bug in git or at least a use case that is not handled.
> In few words it can be described like this: if you push a remote
> branch to another remote, which is bare repository, you cannot remove
> that branch from said bare repository.
> Here is a recipe how to reproduce that with git 1.8.0:
> git init foo
> git init --bare bar.git
> git init --bare baz.git
> cd foo
> echo test > file
> git commit -am "initial commit"
Nothing added, nothing committed, at this point.
I'd assume there is "git add file" before this commit.
> git remote add bar ../bar.git
> git remote add baz ../baz.git
> git push bar master
> cd ..
> git clone bar.git bax
> cd bax
> git checkout -b "test_branch"
> echo evil > file
> git commit -am "evil commit"
> git push origin test-branch
error: src refspec test-branch does not match any.
error: failed to push some refs to '...../bar.git'
I'd assume that is test_branch
> cd ../foo
> git fetch bar
> git push baz bar/test_branch
> cd ../baz.git
>
> ###
> # on that point in baz.git there is only one branch:
Correct.
> # remotes/bar/test_branch 8b96ffe evil commit
> # trying to remove that branch yields no results:
> $ git branch -D refs/remotes/bar/test_branch
That is not the way to remove the remote tracking branch test_branch
you have from remote bar, is it?
git branch -r -D bar/test_branch
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: A bug or unhandled case
2013-03-11 16:29 ` Junio C Hamano
@ 2013-03-11 16:39 ` Michał Janiszewski
2013-03-11 16:53 ` Junio C Hamano
0 siblings, 1 reply; 4+ messages in thread
From: Michał Janiszewski @ 2013-03-11 16:39 UTC (permalink / raw)
To: Junio C Hamano; +Cc: git
Hmm, indeed it works. Sorry for the confusion then (and a bit mistaken
commands, but you got them correct).
I wasn't aware of the -r option.
On Mon, Mar 11, 2013 at 5:29 PM, Junio C Hamano <gitster@pobox.com> wrote:
> Michał Janiszewski <janisozaur@gmail.com> writes:
>
>> Hi,
>> I think I've found a bug in git or at least a use case that is not handled.
>> In few words it can be described like this: if you push a remote
>> branch to another remote, which is bare repository, you cannot remove
>> that branch from said bare repository.
>> Here is a recipe how to reproduce that with git 1.8.0:
>> git init foo
>> git init --bare bar.git
>> git init --bare baz.git
>> cd foo
>> echo test > file
>> git commit -am "initial commit"
>
> Nothing added, nothing committed, at this point.
> I'd assume there is "git add file" before this commit.
>
>> git remote add bar ../bar.git
>> git remote add baz ../baz.git
>> git push bar master
>> cd ..
>> git clone bar.git bax
>> cd bax
>> git checkout -b "test_branch"
>> echo evil > file
>> git commit -am "evil commit"
>> git push origin test-branch
>
> error: src refspec test-branch does not match any.
> error: failed to push some refs to '...../bar.git'
>
> I'd assume that is test_branch
>
>> cd ../foo
>> git fetch bar
>> git push baz bar/test_branch
>> cd ../baz.git
>>
>> ###
>> # on that point in baz.git there is only one branch:
>
> Correct.
>
>> # remotes/bar/test_branch 8b96ffe evil commit
>> # trying to remove that branch yields no results:
>> $ git branch -D refs/remotes/bar/test_branch
>
> That is not the way to remove the remote tracking branch test_branch
> you have from remote bar, is it?
>
> git branch -r -D bar/test_branch
>
--
Michal Janiszewski
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: A bug or unhandled case
2013-03-11 16:39 ` Michał Janiszewski
@ 2013-03-11 16:53 ` Junio C Hamano
0 siblings, 0 replies; 4+ messages in thread
From: Junio C Hamano @ 2013-03-11 16:53 UTC (permalink / raw)
To: Michał Janiszewski; +Cc: git
Michał Janiszewski <janisozaur@gmail.com> writes:
> Hmm, indeed it works. Sorry for the confusion then (and a bit mistaken
> commands, but you got them correct).
> I wasn't aware of the -r option.
I think what tripped you was that "git branch" deals with branch
names, and not refnames (which is the underlying but lower level
concept). "git branch -d refs/heads/master" is not a way to remove
your local mastar branch.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2013-03-11 16:53 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-03-11 16:06 A bug or unhandled case Michał Janiszewski
2013-03-11 16:29 ` Junio C Hamano
2013-03-11 16:39 ` Michał Janiszewski
2013-03-11 16:53 ` Junio C Hamano
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).