{"thread":{"id":"16255","subject":"[PATCH] git push: Interpret $GIT_DIR/branches in a Cogito compatible way","startedAt":"2008-11-10T21:47:11Z","lastAt":"2008-11-11T17:25:44Z","messageCount":5,"participants":["Martin Koegler","Junio C Hamano","Mike Ralphson"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"95393","messageId":"1226353631-3716-1-git-send-email-mkoegler@auto.tuwien.ac.at","threadId":"16255","inReplyTo":null,"subject":"[PATCH] git push: Interpret $GIT_DIR/branches in a Cogito compatible way","fromName":"Martin Koegler","fromEmail":"mkoegler@auto.tuwien.ac.at","sentAt":"2008-11-10T21:47:11Z","receivedAt":"2008-11-10T21:47:11Z","isPatch":true,"sender":{"key":"mkoegler@auto.tuwien.ac.at","avatar":null},"body":"Current git versions ignore everything after # (called <head> in the\nfollowing) when pushing. Older versions (before cf818348f1ab57),\ninterpret #<head> as part of the URL, which make git bail out.\n\nIgnoring the <head> part for push (fetch respects them) is unlogical.\nAs branches origin from Cogito, it is the best to correct this by\nusing the behaviour of cg-push:\n\npush HEAD to remote refs/heads/<head>\n\nSigned-off-by: Martin Koegler <mkoegler@auto.tuwien.ac.at>\n---\n Documentation/urls-remotes.txt |   19 +++++++++++----\n remote.c                       |   11 ++++++++\n t/t5516-fetch-push.sh          |   50 ++++++++++++++++++++++++++++++++++++++++\n 3 files changed, 75 insertions(+), 5 deletions(-)\n\ndiff --git a/Documentation/urls-remotes.txt b/Documentation/urls-remotes.txt\nindex 504ae8a..d9e284c 100644\n--- a/Documentation/urls-remotes.txt\n+++ b/Documentation/urls-remotes.txt\n@@ -68,13 +68,22 @@ This file should have the following format:\n ------------\n \n `<url>` is required; `#<head>` is optional.\n-When you do not provide a refspec on the command line,\n-git will use the following refspec, where `<head>` defaults to `master`,\n-and `<repository>` is the name of this file\n-you provided in the command line.\n+\n+Depending on the operation, git will use one of the following\n+refsprecs, if you don't provide one on the command line.\n+`<branch>` is the name of this file in `$GIT_DIR/branches` and\n+`<head>` defaults to `master`.\n+\n+git fetch uses:\n+\n+------------\n+\trefs/heads/<head>:refs/heads/<branch>\n+------------\n+\n+git push uses:\n \n ------------\n-\trefs/heads/<head>:<repository>\n+\tHEAD:refs/heads/<head>\n ------------\n \n \ndiff --git a/remote.c b/remote.c\nindex e530a21..660b2ce 100644\n--- a/remote.c\n+++ b/remote.c\n@@ -297,6 +297,17 @@ static void read_branches_file(struct remote *remote)\n \t}\n \tadd_url_alias(remote, p);\n \tadd_fetch_refspec(remote, strbuf_detach(&branch, 0));\n+\t/*\n+\t * Cogito compatible push: push current HEAD to remote #branch\n+\t * (master if missing)\n+\t */\n+\tstrbuf_init(&branch, 0);\n+\tstrbuf_addstr(&branch, \"HEAD\");\n+\tif (frag)\n+\t\tstrbuf_addf(&branch, \":refs/heads/%s\", frag);\n+\telse\n+\t\tstrbuf_addstr(&branch, \":refs/heads/master\");\n+\tadd_push_refspec(remote, strbuf_detach(&branch, 0));\n \tremote->fetch_tags = 1; /* always auto-follow */\n }\n \ndiff --git a/t/t5516-fetch-push.sh b/t/t5516-fetch-push.sh\nindex a6532cb..4426df9 100755\n--- a/t/t5516-fetch-push.sh\n+++ b/t/t5516-fetch-push.sh\n@@ -523,4 +523,54 @@ test_expect_success 'allow push to HEAD of non-bare repository (config)' '\n \t! grep \"warning.*this may cause confusion\" stderr\n '\n \n+test_expect_success 'fetch with branches' '\n+\tmk_empty &&\n+\tgit branch second $the_first_commit &&\n+\tgit checkout second &&\n+\techo \"..\" > testrepo/.git/branches/branch1 &&\n+\t(cd testrepo &&\n+\t\tgit fetch branch1 &&\n+\t\tr=$(git show-ref -s --verify refs/heads/branch1) &&\n+\t\ttest \"z$r\" = \"z$the_commit\" &&\n+\t\ttest 1 = $(git for-each-ref refs/heads | wc -l)\n+\t) &&\n+\tgit checkout master\n+'\n+\n+test_expect_success 'fetch with branches containing #' '\n+\tmk_empty &&\n+\techo \"..#second\" > testrepo/.git/branches/branch2 &&\n+\t(cd testrepo &&\n+\t\tgit fetch branch2 &&\n+\t\tr=$(git show-ref -s --verify refs/heads/branch2) &&\n+\t\ttest \"z$r\" = \"z$the_first_commit\" &&\n+\t\ttest 1 = $(git for-each-ref refs/heads | wc -l)\n+\t) &&\n+\tgit checkout master\n+'\n+\n+test_expect_success 'push with branches' '\n+\tmk_empty &&\n+\tgit checkout second &&\n+\techo \"testrepo\" > .git/branches/branch1 &&\n+\tgit push branch1 &&\n+\t(cd testrepo &&\n+\t\tr=$(git show-ref -s --verify refs/heads/master) &&\n+\t\ttest \"z$r\" = \"z$the_first_commit\" &&\n+\t\ttest 1 = $(git for-each-ref refs/heads | wc -l)\n+\t)\n+'\n+\n+test_expect_success 'push with branches containing #' '\n+\tmk_empty &&\n+\techo \"testrepo#branch3\" > .git/branches/branch2 &&\n+\tgit push branch2 &&\n+\t(cd testrepo &&\n+\t\tr=$(git show-ref -s --verify refs/heads/branch3) &&\n+\t\ttest \"z$r\" = \"z$the_first_commit\" &&\n+\t\ttest 1 = $(git for-each-ref refs/heads | wc -l)\n+\t) &&\n+\tgit checkout master\n+'\n+\n test_done\n-- \n1.5.6.5\n"},{"id":"95400","messageId":"7viqqv410q.fsf@gitster.siamese.dyndns.org","threadId":"16255","inReplyTo":"1226353631-3716-1-git-send-email-mkoegler@auto.tuwien.ac.at","subject":"Re: [PATCH] git push: Interpret $GIT_DIR/branches in a Cogito compatible way","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2008-11-10T23:25:09Z","receivedAt":"2008-11-10T23:25:09Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Martin Koegler <mkoegler@auto.tuwien.ac.at> writes:\n\n> Current git versions ignore everything after # (called <head> in the\n> following) when pushing. Older versions (before cf818348f1ab57),\n> interpret #<head> as part of the URL, which make git bail out.\n>\n> Ignoring the <head> part for push (fetch respects them) is unlogical.\n> As branches origin from Cogito, it is the best to correct this by\n> using the behaviour of cg-push:\n>\n> push HEAD to remote refs/heads/<head>\n>\n> Signed-off-by: Martin Koegler <mkoegler@auto.tuwien.ac.at>\n\nThis message was addressed to me, but is it meant for inclusion?\n\nI do not recall seeing an agreement on what the desired behaviour should\nbe from (ex-)Cogito users, if this change of behaviour hurts real world\nusage of existing git users, andr if so how we ease this change in to the\nrelease.\n\nWhile I'd personally agree matching with whatever cg-push used to do might\nmake the most sense in the end, I am not sure changing of behaviour\nabruptly like this is a good idea.\n\nI am also not so sure url#branch is illogical; I'd suggest dropping that\nline from the commit log message in any case.\n\n> +\n> +Depending on the operation, git will use one of the following\n> +refsprecs, if you don't provide one on the command line.\n> +`<branch>` is the name of this file in `$GIT_DIR/branches` and\n> +`<head>` defaults to `master`.\n> +\n> +git fetch uses:\n> +\n> +------------\n> +\trefs/heads/<head>:refs/heads/<branch>\n> +------------\n> +\n> +git push uses:\n>  \n>  ------------\n> -\trefs/heads/<head>:<repository>\n> +\tHEAD:refs/heads/<head>\n>  ------------\n\nWhy isn't this \"refs/heads/<head>:refs/heads/<head>\", by the way?\n"},{"id":"95443","messageId":"20081111083704.GA4075@auto.tuwien.ac.at","threadId":"16255","inReplyTo":"7viqqv410q.fsf@gitster.siamese.dyndns.org","subject":"Re: [PATCH] git push: Interpret $GIT_DIR/branches in a Cogito compatible way","fromName":"Martin Koegler","fromEmail":"mkoegler@auto.tuwien.ac.at","sentAt":"2008-11-11T08:37:04Z","receivedAt":"2008-11-11T08:37:04Z","isPatch":true,"sender":{"key":"mkoegler@auto.tuwien.ac.at","avatar":null},"body":"On Mon, Nov 10, 2008 at 03:25:09PM -0800, Junio C Hamano wrote:\n> Martin Koegler <mkoegler@auto.tuwien.ac.at> writes:\n> > Current git versions ignore everything after # (called <head> in the\n> > following) when pushing. Older versions (before cf818348f1ab57),\n> > interpret #<head> as part of the URL, which make git bail out.\n> >\n> > Ignoring the <head> part for push (fetch respects them) is unlogical.\n> > As branches origin from Cogito, it is the best to correct this by\n> > using the behaviour of cg-push:\n> >\n> > push HEAD to remote refs/heads/<head>\n> >\n> > Signed-off-by: Martin Koegler <mkoegler@auto.tuwien.ac.at>\n> \n> This message was addressed to me, but is it meant for inclusion?\n> \n> I do not recall seeing an agreement on what the desired behaviour should\n> be from (ex-)Cogito users, if this change of behaviour hurts real world\n> usage of existing git users, andr if so how we ease this change in to the\n> release.\n\nNobody else seemd to be interessted in this topic, so its difficult to\nstart a discussion.\n\nI would suggest to queue it in pu for some time and wait for other\nfeedback.\n\n> While I'd personally agree matching with whatever cg-push used to do might\n> make the most sense in the end, I am not sure changing of behaviour\n> abruptly like this is a good idea.\n\nI'm open for any suggestion, how to make this change smoothly. I\nthink, that doing such a behaviour change should be OK for 1.6.1 or\n1.6.2:\n\nUntil v1.5.4 (9 month ago), git-push with # was totally broken. Daniel\nBarkalow fixed the fetch case in v1.5.4. As a side effect, git-push no\nlonger fails, but ignores everything after #. So in my option, the\ncurrent behaviour was created by chance.\n\n> I am also not so sure url#branch is illogical; I'd suggest dropping that\n> line from the commit log message in any case.\n\nOK, I'll drop it in the next version.\n\n> > +git push uses:\n> >  \n> >  ------------\n> > -\trefs/heads/<head>:<repository>\n> > +\tHEAD:refs/heads/<head>\n> >  ------------\n> \n> Why isn't this \"refs/heads/<head>:refs/heads/<head>\", by the way?\n\n1) It's Cogito behaviour (cg-push(2)):\n|      It will push your commits on the current branch (or as specified\n|      by the -r option) to the remote repository, provided that your\n|      commits follow the last commit in the remote repository.\n\n2) In my options, it's more flexible\n\nIf you want to push to <head>, you must create a local branch called\n<head>. If you want to fetch from the remote too, you must choose a\nname != <head> for the branches file, as you normaly don't want to\nfetch into a local branch. Pushing to <head> in multiple remote\nrepositories is also more difficult, if they are used for diffent\nthings, as they are based on one local branch.\n\n=> It's a way to seperate the remote head names from the local ones.\n\nmfg Martin Kögler\n"},{"id":"95444","messageId":"e2b179460811110045r4ef02285x3f31f0444980c20f@mail.gmail.com","threadId":"16255","inReplyTo":"1226353631-3716-1-git-send-email-mkoegler@auto.tuwien.ac.at","subject":"Re: [PATCH] git push: Interpret $GIT_DIR/branches in a Cogito compatible way","fromName":"Mike Ralphson","fromEmail":"mike.ralphson@gmail.com","sentAt":"2008-11-11T08:45:41Z","receivedAt":"2008-11-11T08:45:41Z","isPatch":true,"sender":{"key":"mike.ralphson@gmail.com","avatar":"https://avatars.githubusercontent.com/u/21603?v=4"},"body":"2008/11/10 Martin Koegler <mkoegler@auto.tuwien.ac.at>:\n> +Depending on the operation, git will use one of the following\n> +refsprecs, if you don't provide one on the command line.\n\ns/refsprecs,/refspecs/\n"},{"id":"95471","messageId":"7vod0m18fb.fsf@gitster.siamese.dyndns.org","threadId":"16255","inReplyTo":"20081111083704.GA4075@auto.tuwien.ac.at","subject":"Re: [PATCH] git push: Interpret $GIT_DIR/branches in a Cogito compatible way","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2008-11-11T17:25:44Z","receivedAt":"2008-11-11T17:25:44Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"mkoegler@auto.tuwien.ac.at (Martin Koegler) writes:\n\n> Nobody else seemd to be interessted in this topic, so its difficult to\n> start a discussion.\n>\n> I would suggest to queue it in pu for some time and wait for other\n> feedback.\n>\n>> While I'd personally agree matching with whatever cg-push used to do might\n>> make the most sense in the end, I am not sure changing of behaviour\n>> abruptly like this is a good idea.\n>\n> I'm open for any suggestion, how to make this change smoothly. I\n> think, that doing such a behaviour change should be OK for 1.6.1 or\n> 1.6.2:\n>\n> Until v1.5.4 (9 month ago), git-push with # was totally broken. Daniel\n> Barkalow fixed the fetch case in v1.5.4. As a side effect, git-push no\n> longer fails, but ignores everything after #. So in my option, the\n> current behaviour was created by chance.\n>\n>> I am also not so sure url#branch is illogical; I'd suggest dropping that\n>> line from the commit log message in any case.\n>\n> OK, I'll drop it in the next version.\n\nThanks for detailed explanation of the background.\n\nEverything you said makes sense.  You convinced me that this is just a\nbugfix that does not warrant a deprecation notice nor waiting for a flag\nday release.  I'm even inclined to say that we should apply this\neventually to 'maint' (which means we'd fork a topic branch from maint,\nmerge that first to next and then to master and eventually to maint to be\nincluded in 1.6.0.X, while the change will go to 1.6.1 as well).\n\nDoes the patch apply to 'maint' right now?\n"}]}