{"thread":{"id":"4433","subject":"HEAD branch duplicated in remotes/origin","startedAt":"2006-06-08T07:38:57Z","lastAt":"2006-06-08T16:39:48Z","messageCount":4,"participants":["Uwe Zeisberger","Junio C Hamano"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"21415","messageId":"20060608073857.GA5072@informatik.uni-freiburg.de","threadId":"4433","inReplyTo":null,"subject":"HEAD branch duplicated in remotes/origin","fromName":"Uwe Zeisberger","fromEmail":"zeisberg@informatik.uni-freiburg.de","sentAt":"2006-06-08T07:38:57Z","receivedAt":"2006-06-08T07:38:57Z","isPatch":false,"sender":{"key":"u.kleine-koenig@pengutronix.de","avatar":"https://gravatar.com/avatar/354b5e3ceb2806a2f1e1e382ac29ddbdad18288654da62b61eb13583a857eee7?d=mp&s=160"},"body":"Hello,\n\nwhen cloning with --use-separate-remote, $GITDIR/remotes/origin contains\ntwo references to refs/heads/master.  This breaks `git fetch origin'.\n\nuzeisberger@io:~/gsrc$ git --version\ngit version 1.4.0.rc2.ga95e\n\nuzeisberger@io:~/gsrc$ git clone --use-separate-remote git://git.kernel.org/pub/scm/git/git.git git-copy\nChecking files out...)\n 100% (523/523) done\n\nuzeisberger@io:~/gsrc$ cd git-copy\n\nuzeisberger@io:~/gsrc/git-copy$ git fetch origin\nerror: no such remote ref refs/heads/master\nFetch failure: git://git.kernel.org/pub/scm/git/git.git\n\nuzeisberger@io:~/gsrc/git-copy$ grep -n master .git/remotes/origin\n2:Pull: refs/heads/master:refs/remotes/origin/master\n12:Pull: refs/heads/master:refs/remotes/origin/master\n\nuzeisberger@io:~/gsrc/git-copy$ sed -i 2d .git/remotes/origin\n\nuzeisberger@io:~/gsrc/git-copy$ git fetch origin\n\nuzeisberger@io:~/gsrc/git-copy$ \n\nI didn't look into it deeply, but I think this happens because the\nremote HEAD is translated to refs/heads/master and added while master is\nadded once more while processing refs/heads/master explicitly.\n\nBest regards\nUwe\n\n-- \nUwe Zeisberger\n\nhttp://www.google.com/search?q=12+divided+by+3\n"},{"id":"21416","messageId":"7vverc9i4i.fsf@assigned-by-dhcp.cox.net","threadId":"4433","inReplyTo":"20060608073857.GA5072@informatik.uni-freiburg.de","subject":"Re: HEAD branch duplicated in remotes/origin","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2006-06-08T08:17:01Z","receivedAt":"2006-06-08T08:17:01Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Uwe Zeisberger <zeisberg@informatik.uni-freiburg.de> writes:\n\n> when cloning with --use-separate-remote, $GITDIR/remotes/origin contains\n> two references to refs/heads/master.\n\nThanks for noticing.\n\nVery lightly tested but I think this should fix it.\n-- >8 --\ngit-clone: fix duplicated \"master\" in $GIT_DIR/remotes/origin\n\nUnder --use-separate-remote we ended up duplicating the branch\nremote HEAD pointed at in $GIT_DIR/remotes/origin file.\n\nSigned-off-by: Junio C Hamano <junkio@cox.net>\n---\ndiff --git a/git-clone.sh b/git-clone.sh\nindex de59904..64318b4 100755\n--- a/git-clone.sh\n+++ b/git-clone.sh\n@@ -391,11 +391,16 @@ Pull: refs/heads/$head_points_at:$origin\n \t\t(cd \"$GIT_DIR/$remote_top\" && find . -type f -print) |\n \t\twhile read dotslref\n \t\tdo\n-\t\t\tname=`expr \"$dotslref\" : './\\(.*\\)'` &&\n-\t\t\ttest \"$use_separate_remote\" = '' && {\n-\t\t\t\ttest \"$head_points_at\" = \"$name\" ||\n-\t\t\t\ttest \"$origin\" = \"$name\"\n-\t\t\t} ||\n+\t\t\tname=`expr \"$dotslref\" : './\\(.*\\)'`\n+\t\t\tif test \"z$head_points_at\" = \"z$name\"\n+\t\t\tthen\n+\t\t\t\tcontinue\n+\t\t\tfi\n+\t\t\tif test \"$use_separate_remote\" = '' &&\n+\t\t\t   test \"z$origin\" = \"z$name\"\n+\t\t\tthen\n+\t\t\t\tcontinue\n+\t\t\tfi\n \t\t\techo \"Pull: refs/heads/${name}:$remote_top/${name}\"\n \t\tdone >>\"$GIT_DIR/remotes/$origin\" &&\n \t\tcase \"$use_separate_remote\" in\n"},{"id":"21426","messageId":"20060608123337.GA12456@informatik.uni-freiburg.de","threadId":"4433","inReplyTo":"7vverc9i4i.fsf@assigned-by-dhcp.cox.net","subject":"Re: HEAD branch duplicated in remotes/origin","fromName":"Uwe Zeisberger","fromEmail":"zeisberg@informatik.uni-freiburg.de","sentAt":"2006-06-08T12:33:38Z","receivedAt":"2006-06-08T12:33:38Z","isPatch":false,"sender":{"key":"u.kleine-koenig@pengutronix.de","avatar":"https://gravatar.com/avatar/354b5e3ceb2806a2f1e1e382ac29ddbdad18288654da62b61eb13583a857eee7?d=mp&s=160"},"body":"Hello Junio,\n\nJunio C Hamano wrote:\n> Uwe Zeisberger <zeisberg@informatik.uni-freiburg.de> writes:\n> \n> > when cloning with --use-separate-remote, $GITDIR/remotes/origin contains\n> > two references to refs/heads/master.\n> \n> Thanks for noticing.\n> \n> Very lightly tested but I think this should fix it.\n> -- >8 --\n> git-clone: fix duplicated \"master\" in $GIT_DIR/remotes/origin\n> \n> Under --use-separate-remote we ended up duplicating the branch\n> remote HEAD pointed at in $GIT_DIR/remotes/origin file.\n> \n> Signed-off-by: Junio C Hamano <junkio@cox.net>\n> ---\n> diff --git a/git-clone.sh b/git-clone.sh\n> index de59904..64318b4 100755\n> --- a/git-clone.sh\n> +++ b/git-clone.sh\n> @@ -391,11 +391,16 @@ Pull: refs/heads/$head_points_at:$origin\n>  \t\t(cd \"$GIT_DIR/$remote_top\" && find . -type f -print) |\n>  \t\twhile read dotslref\n>  \t\tdo\n> -\t\t\tname=`expr \"$dotslref\" : './\\(.*\\)'` &&\n> -\t\t\ttest \"$use_separate_remote\" = '' && {\n> -\t\t\t\ttest \"$head_points_at\" = \"$name\" ||\n> -\t\t\t\ttest \"$origin\" = \"$name\"\n> -\t\t\t} ||\n> +\t\t\tname=`expr \"$dotslref\" : './\\(.*\\)'`\n> +\t\t\tif test \"z$head_points_at\" = \"z$name\"\n> +\t\t\tthen\n> +\t\t\t\tcontinue\n> +\t\t\tfi\n> +\t\t\tif test \"$use_separate_remote\" = '' &&\n> +\t\t\t   test \"z$origin\" = \"z$name\"\n> +\t\t\tthen\n> +\t\t\t\tcontinue\n> +\t\t\tfi\n>  \t\t\techo \"Pull: refs/heads/${name}:$remote_top/${name}\"\n>  \t\tdone >>\"$GIT_DIR/remotes/$origin\" &&\n>  \t\tcase \"$use_separate_remote\" in\n> \nI wonder if this is easier not to add the other duplicate.  That is let\nthis as it is and don't add the head HEAD points at.  Don't know, didn't\nlook into it.\n\nMoreover, is it sound to error if a Pull: line is duplicated?  In my\neyes at least the error message is wrong/missleading.  Otherwise the\npatch works for me, but probably I only did the same testing as you.\n\nBest regards\nUwe\n\n-- \nUwe Zeisberger\n\ncal 9 1752 | grep 10\n"},{"id":"21440","messageId":"7vpshj8uuj.fsf@assigned-by-dhcp.cox.net","threadId":"4433","inReplyTo":"20060608123337.GA12456@informatik.uni-freiburg.de","subject":"Re: HEAD branch duplicated in remotes/origin","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2006-06-08T16:39:48Z","receivedAt":"2006-06-08T16:39:48Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Uwe Zeisberger <zeisberg@informatik.uni-freiburg.de> writes:\n\n> I wonder if this is easier not to add the other duplicate.\n\nUnfortunately the above is probably easier.  The other duplicate\nis coming from the lowlevel code that makes sure each of the\nfetch-pack parameters is not used to match more than once.  We\nshould fix it eventually, though.\n"}]}