Am Dienstag, den 23.04.2013, 22:50 +0200 schrieb Johan Herland:
> On Tue, Apr 23, 2013 at 4:59 PM, Junio C Hamano <gits...@pobox.com> wrote:
> > Jan Weitzel <j.weit...@phytec.de> writes:
> >
> >> Hello,
> >> I have the following problem: I have 2 bare git repositories one has
> >> several branches and tags.
> >> If I try this in the second repository:
> >> git fetch -f ../main.git refs/heads/master:refs/heads/master
> >> I'm getting also tags from other branches, if I have an old object from
> >> one of the other branches.
> >> I would expect to have only tags pointing to master ref.
> >
> > A tag that points at a commit that is reachable from 'master' will
> > be followed, not just pointing _at_ 'master'.  For example, when
> > your 'master' is a bit beyond v1.2 release, it is likely you will
> > also get v1.1 and v1.0 tags (if your release structure is such that
> > new release contains everything old releases had).
> 
> That is all true, and behaves as expected. However, what Jan is observing
> is (I believe) equivalent to the following:
> 
Thank you for the explanation, you show exactly what I mean :)
Jan
> Remote repo:
> 
>   o---o---o---o <---- master, tag: spam
>    \      ^---- tag: eggs
>     \
>      o---o---o <---- tag: sausage
> 
> Local repo:
> 
>   o---o
>    \  ^---- master
>     \
>      o---o---o (unreachable)
> 
> Now, when Jan fetches master, he gets the new master, plus tags spam and
> eggs (as expected), but he ALSO gets tag sausage, which he _shouldn't_
> get, since it is not reachable from master (hence not part of the fetched
> history). The following session demonstrates the problem using the above
> example:
> 
> # Prepare history in repo1
> $ git init repo1
> Initialized empty Git repository in /home/johan/git/repo1/.git/
> $ cd repo1/
> $ echo foo>foo
> $ git add foo
> $ git commit -m a
> [master (root-commit) 92f92ec] a
>  1 file changed, 1 insertion(+)
>  create mode 100644 foo
> $ echo bar >> foo
> $ git commit -am b
> [master e90d835] b
>  1 file changed, 1 insertion(+)
> $ echo baz >> foo
> $ git commit -am c
> [master 09e4bb2] c
>  1 file changed, 1 insertion(+)
> $ echo xyzzy >> foo
> $ git commit -am d
> [master 13ce4fb] d
>  1 file changed, 1 insertion(+)
> $ git checkout -b side HEAD~3
> Switched to a new branch 'side'
> $ echo side >> foo
> $ git commit -am side
> [side 7294fc9] side
>  1 file changed, 1 insertion(+)
> 
> # Copy history to repo2, and make most of it unreachable
> $ cd ..
> $ git clone repo1 repo2
> Cloning into 'repo2'...
> done.
> $ cd repo2/
> $ git checkout -b master origin/master~2
> Switched to a new branch 'master'
> $ git remote rm origin
> $ git branch -D side
> Deleted branch side (was 7294fc9).
> $ git show-ref
> e90d8356350e4f2fd5e7bfb3a0327e2fa6115c2a refs/heads/master
> 
> # Create tags in repo1
> $ cd ../repo1/
> $ git checkout master
> Switched to branch 'master'
> $ git tag spam master
> $ git tag eggs master^
> $ git tag sausage side
> $ git branch -D side
> Deleted branch side (was 7294fc9).
> $ git show-ref
> 13ce4fbc1761562a36f755b081b0d44b657c25a9 refs/heads/master
> 09e4bb21112b0f0acb82ed3b0fd6af9c685c3799 refs/tags/eggs
> 7294fc90fc1fbd1dd941c8999518d4a4b57048b4 refs/tags/sausage
> 13ce4fbc1761562a36f755b081b0d44b657c25a9 refs/tags/spam
> 
> # Fetch master into repo2
> $ cd ../repo2
> $ git checkout -b foo
> Switched to a new branch 'foo'
> $ git fetch -f ../repo1 refs/heads/master:refs/heads/master
> From ../repo1
>    e90d835..13ce4fb  master     -> master
>  * [new tag]         eggs       -> eggs
>  * [new tag]         sausage    -> sausage
>  * [new tag]         spam       -> spam
> 
> # See that tag sausage was fetched even though it's not reachable from master
> $ git show-ref
> e90d8356350e4f2fd5e7bfb3a0327e2fa6115c2a refs/heads/foo
> 13ce4fbc1761562a36f755b081b0d44b657c25a9 refs/heads/master
> 09e4bb21112b0f0acb82ed3b0fd6af9c685c3799 refs/tags/eggs
> 7294fc90fc1fbd1dd941c8999518d4a4b57048b4 refs/tags/sausage
> 13ce4fbc1761562a36f755b081b0d44b657c25a9 refs/tags/spam
> $ git log --graph --decorate --all --oneline
> * 7294fc9 (tag: sausage) side
> | * 13ce4fb (tag: spam, master) d
> | * 09e4bb2 (tag: eggs) c
> | * e90d835 (HEAD, foo) b
> |/
> * 92f92ec a
> 
> 
> Have fun! :)
> 
> ...Johan
> 
> --
> Johan Herland, <jo...@herland.net>
> www.herland.net


--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to