{"thread":{"id":"22243","subject":"[PATCH v3] Add push --set-upstream","startedAt":"2010-01-16T09:23:47Z","lastAt":"2010-01-16T18:43:13Z","messageCount":11,"participants":["Ilari Liusvaara","Tay Ray Chuan","Junio C Hamano","Jeff King"],"isPatch":true,"patchVersion":3,"patchTotal":null},"messages":[{"id":"131863","messageId":"1263633827-23720-1-git-send-email-ilari.liusvaara@elisanet.fi","threadId":"22243","inReplyTo":null,"subject":"[PATCH v3] Add push --set-upstream","fromName":"Ilari Liusvaara","fromEmail":"ilari.liusvaara@elisanet.fi","sentAt":"2010-01-16T09:23:47Z","receivedAt":"2010-01-16T09:23:47Z","isPatch":true,"sender":{"key":"ilari.liusvaara@elisanet.fi","avatar":null},"body":"Frequent complaint is lack of easy way to set up upstream (tracking)\nreferences for git pull to work as part of push command. So add switch\n--set-upstream (-u) to do just that.\n\nSigned-off-by: Jeff King <peff@peff.net>\nSigned-off-by: Ilari Liusvaara <ilari.liusvaara@elisanet.fi>\n---\nDifferences from v2:\n- Only pretend to set up tracking in case of --dry-run.\n\n Documentation/git-push.txt |    9 +++++-\n builtin-push.c             |    1 +\n t/t5523-push-upstream.sh   |   69 ++++++++++++++++++++++++++++++++++++++++++++\n transport.c                |   56 +++++++++++++++++++++++++++++++++++\n transport.h                |    1 +\n 5 files changed, 135 insertions(+), 1 deletions(-)\n create mode 100755 t/t5523-push-upstream.sh\n\ndiff --git a/Documentation/git-push.txt b/Documentation/git-push.txt\nindex e3eb1e8..2a5394b 100644\n--- a/Documentation/git-push.txt\n+++ b/Documentation/git-push.txt\n@@ -10,7 +10,7 @@ SYNOPSIS\n --------\n [verse]\n 'git push' [--all | --mirror | --tags] [-n | --dry-run] [--receive-pack=<git-receive-pack>]\n-\t   [--repo=<repository>] [-f | --force] [-v | --verbose]\n+\t   [--repo=<repository>] [-f | --force] [-v | --verbose] [-u | --set-upstream]\n \t   [<repository> <refspec>...]\n \n DESCRIPTION\n@@ -122,6 +122,13 @@ nor in any Push line of the corresponding remotes file---see below).\n \tthe name \"origin\" is used. For this latter case, this option\n \tcan be used to override the name \"origin\". In other words,\n \tthe difference between these two commands\n+\n+-u::\n+--set-upstream::\n+\tFor every branch that is up to date or successfully pushed, add\n+\tupstream (tracking) reference, used by argument-less\n+\tlinkgit:git-pull[1] and other commands. For more information,\n+\tsee 'branch.<name>.merge' in linkgit:git-config[1].\n +\n --------------------------\n git push public         #1\ndiff --git a/builtin-push.c b/builtin-push.c\nindex 28a26e7..75ddaf4 100644\n--- a/builtin-push.c\n+++ b/builtin-push.c\n@@ -218,6 +218,7 @@ int cmd_push(int argc, const char **argv, const char *prefix)\n \t\tOPT_BOOLEAN( 0 , \"thin\", &thin, \"use thin pack\"),\n \t\tOPT_STRING( 0 , \"receive-pack\", &receivepack, \"receive-pack\", \"receive pack program\"),\n \t\tOPT_STRING( 0 , \"exec\", &receivepack, \"receive-pack\", \"receive pack program\"),\n+\t\tOPT_BIT('u', \"set-upstream\", &flags, \"Set upstream for git pull\", TRANSPORT_PUSH_SET_UPSTREAM),\n \t\tOPT_END()\n \t};\n \ndiff --git a/t/t5523-push-upstream.sh b/t/t5523-push-upstream.sh\nnew file mode 100755\nindex 0000000..00da707\n--- /dev/null\n+++ b/t/t5523-push-upstream.sh\n@@ -0,0 +1,69 @@\n+#!/bin/sh\n+\n+test_description='push with --set-upstream'\n+. ./test-lib.sh\n+\n+test_expect_success 'setup bare parent' '\n+\tgit init --bare parent &&\n+\tgit remote add upstream parent\n+'\n+\n+test_expect_success 'setup local commit' '\n+\techo content >file &&\n+\tgit add file &&\n+\tgit commit -m one\n+'\n+\n+check_config() {\n+\t(echo $2; echo $3) >expect.$1\n+\t(git config branch.$1.remote\n+\t git config branch.$1.merge) >actual.$1\n+\ttest_cmp expect.$1 actual.$1\n+}\n+\n+test_expect_success 'push -u master:master' '\n+\tgit push -u upstream master:master &&\n+\tcheck_config master upstream refs/heads/master\n+'\n+\n+test_expect_success 'push -u master:other' '\n+\tgit push -u upstream master:other &&\n+\tcheck_config master upstream refs/heads/other\n+'\n+\n+test_expect_success 'push -u --dry-run master:otherX' '\n+\tgit push -u --dry-run upstream master:otherX &&\n+\tcheck_config master upstream refs/heads/other\n+'\n+\n+test_expect_success 'push -u master2:master2' '\n+\tgit branch master2 &&\n+\tgit push -u upstream master2:master2 &&\n+\tcheck_config master2 upstream refs/heads/master2\n+'\n+\n+test_expect_success 'push -u master2:other2' '\n+\tgit push -u upstream master2:other2 &&\n+\tcheck_config master2 upstream refs/heads/other2\n+'\n+\n+test_expect_success 'push -u :master2' '\n+\tgit push -u upstream :master2 &&\n+\tcheck_config master2 upstream refs/heads/other2\n+'\n+\n+test_expect_success 'push -u --all' '\n+\tgit branch all1 &&\n+\tgit branch all2 &&\n+\tgit push -u --all &&\n+\tcheck_config all1 upstream refs/heads/all1 &&\n+\tcheck_config all2 upstream refs/heads/all2\n+'\n+\n+test_expect_success 'push -u HEAD' '\n+\tgit checkout -b headbranch &&\n+\tgit push -u upstream HEAD &&\n+\tcheck_config headbranch upstream refs/heads/headbranch\n+'\n+\n+test_done\ndiff --git a/transport.c b/transport.c\nindex b5332c0..12b3d69 100644\n--- a/transport.c\n+++ b/transport.c\n@@ -8,6 +8,7 @@\n #include \"bundle.h\"\n #include \"dir.h\"\n #include \"refs.h\"\n+#include \"branch.h\"\n \n /* rsync support */\n \n@@ -135,6 +136,53 @@ static void insert_packed_refs(const char *packed_refs, struct ref **list)\n \t}\n }\n \n+static void set_upstreams(struct transport *trans, struct ref *refs,\n+\tint pretend)\n+{\n+\tstruct ref *i;\n+\tfor (i = refs; i; i = i->next) {\n+\t\tconst char *localname;\n+\t\tconst char *tmp;\n+\t\tconst char *remotename;\n+\t\tunsigned char sha[20];\n+\t\tint flag = 0;\n+\t\t/*\n+\t\t * Check suitability for tracking. Must be successful /\n+\t\t * alreay up-to-date ref create/modify (not delete).\n+\t\t */\n+\t\tif (i->status != REF_STATUS_OK &&\n+\t\t\ti->status != REF_STATUS_UPTODATE)\n+\t\t\tcontinue;\n+\t\tif (!i->peer_ref)\n+\t\t\tcontinue;\n+\t\tif (!i->new_sha1 || is_null_sha1(i->new_sha1))\n+\t\t\tcontinue;\n+\n+\t\t/* Chase symbolic refs (mainly for HEAD). */\n+\t\tlocalname = i->peer_ref->name;\n+\t\tremotename = i->name;\n+\t\ttmp = resolve_ref(localname, sha, 1, &flag);\n+\t\tif (tmp && flag & REF_ISSYMREF &&\n+\t\t\t!prefixcmp(tmp, \"refs/heads/\"))\n+\t\t\tlocalname = tmp;\n+\n+\t\t/* Both source and destination must be local branches. */\n+\t\tif (!localname || prefixcmp(localname, \"refs/heads/\"))\n+\t\t\tcontinue;\n+\t\tif (!remotename || prefixcmp(remotename, \"refs/heads/\"))\n+\t\t\tcontinue;\n+\n+\t\tif (!pretend)\n+\t\t\tinstall_branch_config(BRANCH_CONFIG_VERBOSE,\n+\t\t\t\tlocalname + 11, trans->remote->name,\n+\t\t\t\tremotename);\n+\t\telse\n+\t\t\tprintf(\"Would set upstream '%s' -> '%s' of '%s'\\n\",\n+\t\t\t\tlocalname + 11, remotename + 11,\n+\t\t\t\ttrans->remote->name);\n+\t}\n+}\n+\n static const char *rsync_url(const char *url)\n {\n \treturn prefixcmp(url, \"rsync://\") ? skip_prefix(url, \"rsync:\") : url;\n@@ -974,6 +1022,10 @@ int transport_push(struct transport *transport,\n \tverify_remote_names(refspec_nr, refspec);\n \n \tif (transport->push) {\n+\t\t/* Maybe FIXME. But no important transport uses this case. */\n+\t\tif (flags & TRANSPORT_PUSH_SET_UPSTREAM)\n+\t\t\tdie(\"This transport does not support using --set-upstream\");\n+\n \t\treturn transport->push(transport, refspec_nr, refspec, flags);\n \t} else if (transport->push_refs) {\n \t\tstruct ref *remote_refs =\n@@ -983,6 +1035,7 @@ int transport_push(struct transport *transport,\n \t\tint verbose = flags & TRANSPORT_PUSH_VERBOSE;\n \t\tint quiet = flags & TRANSPORT_PUSH_QUIET;\n \t\tint porcelain = flags & TRANSPORT_PUSH_PORCELAIN;\n+\t\tint pretend = flags & TRANSPORT_PUSH_DRY_RUN;\n \t\tint ret;\n \n \t\tif (flags & TRANSPORT_PUSH_ALL)\n@@ -1002,6 +1055,9 @@ int transport_push(struct transport *transport,\n \t\t\t\t\tverbose | porcelain, porcelain,\n \t\t\t\t\tnonfastforward);\n \n+\t\tif (flags & TRANSPORT_PUSH_SET_UPSTREAM)\n+\t\t\tset_upstreams(transport, remote_refs, pretend);\n+\n \t\tif (!(flags & TRANSPORT_PUSH_DRY_RUN)) {\n \t\t\tstruct ref *ref;\n \t\t\tfor (ref = remote_refs; ref; ref = ref->next)\ndiff --git a/transport.h b/transport.h\nindex 97ba251..c4314dd 100644\n--- a/transport.h\n+++ b/transport.h\n@@ -91,6 +91,7 @@ struct transport {\n #define TRANSPORT_PUSH_VERBOSE 16\n #define TRANSPORT_PUSH_PORCELAIN 32\n #define TRANSPORT_PUSH_QUIET 64\n+#define TRANSPORT_PUSH_SET_UPSTREAM 128\n \n /* Returns a transport suitable for the url */\n struct transport *transport_get(struct remote *, const char *);\n-- \n1.6.6.102.gd6f8f.dirty\n"},{"id":"131877","messageId":"20100116203557.95340c00.rctay89@gmail.com","threadId":"22243","inReplyTo":"1263633827-23720-1-git-send-email-ilari.liusvaara@elisanet.fi","subject":"Re: [PATCH v3] Add push --set-upstream","fromName":"Tay Ray Chuan","fromEmail":"rctay89@gmail.com","sentAt":"2010-01-16T12:35:57Z","receivedAt":"2010-01-16T12:35:57Z","isPatch":true,"sender":{"key":"rctay89@gmail.com","avatar":"https://avatars.githubusercontent.com/u/61553?v=4"},"body":"Hi,\n\nOn Sat, 16 Jan 2010 11:23:47 +0200\nIlari Liusvaara <ilari.liusvaara@elisanet.fi> wrote:\n\n> [snip]\n> @@ -218,6 +218,7 @@ int cmd_push(int argc, const char **argv, const char *prefix)\n>  \t\tOPT_BOOLEAN( 0 , \"thin\", &thin, \"use thin pack\"),\n>  \t\tOPT_STRING( 0 , \"receive-pack\", &receivepack, \"receive-pack\", \"receive pack program\"),\n>  \t\tOPT_STRING( 0 , \"exec\", &receivepack, \"receive-pack\", \"receive pack program\"),\n> +\t\tOPT_BIT('u', \"set-upstream\", &flags, \"Set upstream for git pull\", TRANSPORT_PUSH_SET_UPSTREAM),\n\nThis line exceeds 80 characters.\n\nAlso, I think you should follow the case-style of the other option\ndescriptions and s/Set(?= upstream)/set/.\n\n> [snip]\n> +static void set_upstreams(struct transport *trans, struct ref *refs,\n\nI would prefer if you could follow the naming convention and say\n\"transport\" instead of truncating to \"trans\".\n\n> +\tint pretend)\n> +{\n> +\tstruct ref *i;\n> +\tfor (i = refs; i; i = i->next) {\n\nIn most places, \"ref\" instead of \"i\" is used; ie.\n\n\tstruct ref *ref;\n\tfor (ref = refs; ref; ref = ref->next) {\n\t\t..\n\t}\n\n> [snip]\n> +\t\t/*\n> +\t\t * Check suitability for tracking. Must be successful /\n> +\t\t * alreay up-to-date ref create/modify (not delete).\n> +\t\t */\n\ns/alreay/already/.\n\n> [snip]\n> +\t\t/* Chase symbolic refs (mainly for HEAD). */\n\nDid you mean \"Change\" here?\n\nRegarding the checking of ref->status here:\n\n> @@ -135,6 +136,53 @@ static void insert_packed_refs(const char *packed_refs, struct ref **list)\n>  \t}\n>  }\n>  \n> [snip]\n> +\t\tif (i->status != REF_STATUS_OK &&\n> +\t\t\ti->status != REF_STATUS_UPTODATE)\n> +\t\t\tcontinue;\n\nIs it possible to delegate this to push_had_errors(remote_refs)\ninstead? We skip setting up upstream tracking when there are errors\nfrom pushing, so we don't have to check ref->status anymore.\n\n(Note: this would skip setting up upstream when ref->status is 'none',\nin addition to 'ok' and 'uptodate', as you have it right now. I think\nthis should be safe.)\n\n@@ -1002,8 +1055,9 @@ int transport_push(struct transport *transport,\n\t\t\t\t\tverbose | porcelain, porcelain,\n\t\t\t\t\tnonfastforward);\n\n-\t\tif (flags & TRANSPORT_PUSH_SET_UPSTREAM)\n-\t\t\tset_upstreams(transport, remote_refs, pretend);\n+\t\tif (!push_had_errors(remote_refs) && \n+\t\t\t(flags & TRANSPORT_PUSH_SET_UPSTREAM))\n+\t\t\tset_upstreams(transport, remote_refs, pretend);\n\n\t\tif (!(flags & TRANSPORT_PUSH_DRY_RUN)) {\n\t\t\tstruct ref *ref;\n\t\t\tfor (ref = remote_refs; ref; ref = ref->next)\n\n(As a side note, if you apply this on top of 'tr/http-push-ref-status'\nin 'pu', the result of push_had_errors() is saved in a variable\n('err'), so you could just use it and not have to call push_had_errors\n() again.)\n\n-- \nCheers,\nRay Chuan\n"},{"id":"131880","messageId":"20100116134656.GA4504@Knoppix","threadId":"22243","inReplyTo":"20100116203557.95340c00.rctay89@gmail.com","subject":"Re: [PATCH v3] Add push --set-upstream","fromName":"Ilari Liusvaara","fromEmail":"ilari.liusvaara@elisanet.fi","sentAt":"2010-01-16T13:46:57Z","receivedAt":"2010-01-16T13:46:57Z","isPatch":true,"sender":{"key":"ilari.liusvaara@elisanet.fi","avatar":null},"body":"On Sat, Jan 16, 2010 at 08:35:57PM +0800, Tay Ray Chuan wrote:\n> Hi,\n> \n> On Sat, 16 Jan 2010 11:23:47 +0200\n> Ilari Liusvaara <ilari.liusvaara@elisanet.fi> wrote:\n> > +\t\tOPT_BIT('u', \"set-upstream\", &flags, \"Set upstream for git pull\", TRANSPORT_PUSH_SET_UPSTREAM),\n> \n> This line exceeds 80 characters.\n\nBroken into two (without breaking the message), it is still over 80.\n \n> Also, I think you should follow the case-style of the other option\n> descriptions and s/Set(?= upstream)/set/.\n\nFixed.\n\n> > [snip]\n> > +static void set_upstreams(struct transport *trans, struct ref *refs,\n> \n> I would prefer if you could follow the naming convention and say\n> \"transport\" instead of truncating to \"trans\".\n\nFixed.\n\n> > +\tstruct ref *i;\n> > +\tfor (i = refs; i; i = i->next) {\n> \n> In most places, \"ref\" instead of \"i\" is used; ie.\n \nFixed.\n\n> > +\t\t * alreay up-to-date ref create/modify (not delete).\n> \n> s/alreay/already/.\n\nFixed.\n\n> > +\t\t/* Chase symbolic refs (mainly for HEAD). */\n> \n> Did you mean \"Change\" here?\n\nNo. Changed to 'Follow'.\n\n> Regarding the checking of ref->status here:\n> \n> Is it possible to delegate this to push_had_errors(remote_refs)\n> instead? We skip setting up upstream tracking when there are errors\n> from pushing, so we don't have to check ref->status anymore.\n\nNo. As documetnation says, the update or no update is done on per-branch\nbasis.\n\n<snip patch>\n \n> (As a side note, if you apply this on top of 'tr/http-push-ref-status'\n> in 'pu', the result of push_had_errors() is saved in a variable\n> ('err'), so you could just use it and not have to call push_had_errors\n> () again.)\n\nSee above.\n\nI'll sit on v4 for some more time to wait for more comments.\n\n-Ilari\n"},{"id":"131881","messageId":"20100116233043.26a5636d.rctay89@gmail.com","threadId":"22243","inReplyTo":"20100116134656.GA4504@Knoppix","subject":"Re: [PATCH v3] Add push --set-upstream","fromName":"Tay Ray Chuan","fromEmail":"rctay89@gmail.com","sentAt":"2010-01-16T15:30:43Z","receivedAt":"2010-01-16T15:30:43Z","isPatch":true,"sender":{"key":"rctay89@gmail.com","avatar":"https://avatars.githubusercontent.com/u/61553?v=4"},"body":"Hi,\n\nOn Sat, 16 Jan 2010 15:46:57 +0200\nIlari Liusvaara <ilari.liusvaara@elisanet.fi> wrote:\n\n> > Regarding the checking of ref->status here:\n> > \n> > Is it possible to delegate this to push_had_errors(remote_refs)\n> > instead? We skip setting up upstream tracking when there are errors\n> > from pushing, so we don't have to check ref->status anymore.\n> \n> No. As documetnation says, the update or no update is done on per-branch\n> basis.\n> \n> <snip patch>\n\nI see. If that's the case, could you also allow setting up upstream\ntracking when ref->status is 'none' and not consider it errorneous?\n\nAfter all, push_had_errors() does not consider 'none' errorneous.\n\nI think a switch block might be neater too.\n\n@@ -149,9 +149,15 @@ static void insert_packed_refs(const char *packed_refs, struct ref **list)\n\t\t * Check suitability for tracking. Must be successful /\n\t\t * already up-to-date ref create/modify (not delete).\n\t\t */\n-\t\tif (ref->status != REF_STATUS_OK &&\n-\t\t\tref->status != REF_STATUS_UPTODATE)\n+\t\tswitch (ref->status) {\n+\t\tcase REF_STATUS_NONE:\n+\t\tcase REF_STATUS_UPTODATE:\n+\t\tcase REF_STATUS_OK:\n+\t\t\t; /* no-op */\n+\t\tdefault:\n\t\t\tcontinue;\n+\t\t}\n\t\tif (!ref->peer_ref)\n\t\t\tcontinue;\n\t\tif (!ref->new_sha1 || is_null_sha1(ref->new_sha1))\n\n\n-- \nCheers,\nRay Chuan\n"},{"id":"131882","messageId":"20100116155612.GA8383@Knoppix","threadId":"22243","inReplyTo":"20100116233043.26a5636d.rctay89@gmail.com","subject":"Re: [PATCH v3] Add push --set-upstream","fromName":"Ilari Liusvaara","fromEmail":"ilari.liusvaara@elisanet.fi","sentAt":"2010-01-16T15:56:12Z","receivedAt":"2010-01-16T15:56:12Z","isPatch":true,"sender":{"key":"ilari.liusvaara@elisanet.fi","avatar":null},"body":"On Sat, Jan 16, 2010 at 11:30:43PM +0800, Tay Ray Chuan wrote:\n> Hi,\n> \n> On Sat, 16 Jan 2010 15:46:57 +0200\n> Ilari Liusvaara <ilari.liusvaara@elisanet.fi> wrote:\n> \n> > > Regarding the checking of ref->status here:\n> > > \n> > > Is it possible to delegate this to push_had_errors(remote_refs)\n> > > instead? We skip setting up upstream tracking when there are errors\n> > > from pushing, so we don't have to check ref->status anymore.\n> > \n> > No. As documetnation says, the update or no update is done on per-branch\n> > basis.\n> > \n> > <snip patch>\n> \n> I see. If that's the case, could you also allow setting up upstream\n> tracking when ref->status is 'none' and not consider it errorneous?\n> \n> After all, push_had_errors() does not consider 'none' errorneous.\n\nHmm... In what conditions ref->status is 'none' after push operation\nhas completed?\n\n-Ilari\n"},{"id":"131883","messageId":"be6fef0d1001160813o674ed93dn33843813be6f45be@mail.gmail.com","threadId":"22243","inReplyTo":"20100116155612.GA8383@Knoppix","subject":"Re: [PATCH v3] Add push --set-upstream","fromName":"Tay Ray Chuan","fromEmail":"rctay89@gmail.com","sentAt":"2010-01-16T16:13:20Z","receivedAt":"2010-01-16T16:13:20Z","isPatch":true,"sender":{"key":"rctay89@gmail.com","avatar":"https://avatars.githubusercontent.com/u/61553?v=4"},"body":"Hi,\n\nOn Sat, Jan 16, 2010 at 11:56 PM, Ilari Liusvaara\n<ilari.liusvaara@elisanet.fi> wrote:\n> Hmm... In what conditions ref->status is 'none' after push operation\n> has completed?\n\nwhen a match between a local and remote ref is not found.\n\nFor example, the local ref 'master' will match the remote ref\n'master', but not 'retsam' ('master' spelled in reverse).\n\n-- \nCheers,\nRay Chuan\n"},{"id":"131884","messageId":"7v7hridmjc.fsf@alter.siamese.dyndns.org","threadId":"22243","inReplyTo":"20100116233043.26a5636d.rctay89@gmail.com","subject":"Re: [PATCH v3] Add push --set-upstream","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2010-01-16T16:47:35Z","receivedAt":"2010-01-16T16:47:35Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Tay Ray Chuan <rctay89@gmail.com> writes:\n\n> +\t\tswitch (ref->status) {\n> +\t\tcase REF_STATUS_NONE:\n> +\t\tcase REF_STATUS_UPTODATE:\n> +\t\tcase REF_STATUS_OK:\n> +\t\t\t; /* no-op */\n> +\t\tdefault:\n> \t\t\tcontinue;\n> +\t\t}\n\nCould somebody document what these values (and what \"struct ref\" has in\ngeneral) mean in the transport API documentation?\n"},{"id":"131893","messageId":"be6fef0d1001161012w7ad12730p7cda2d74db732db1@mail.gmail.com","threadId":"22243","inReplyTo":"be6fef0d1001160813o674ed93dn33843813be6f45be@mail.gmail.com","subject":"Re: [PATCH v3] Add push --set-upstream","fromName":"Tay Ray Chuan","fromEmail":"rctay89@gmail.com","sentAt":"2010-01-16T18:12:36Z","receivedAt":"2010-01-16T18:12:36Z","isPatch":true,"sender":{"key":"rctay89@gmail.com","avatar":"https://avatars.githubusercontent.com/u/61553?v=4"},"body":"Hi,\n\nOn Sun, Jan 17, 2010 at 12:13 AM, Tay Ray Chuan <rctay89@gmail.com> wrote:\n> Hi,\n>\n> On Sat, Jan 16, 2010 at 11:56 PM, Ilari Liusvaara\n> <ilari.liusvaara@elisanet.fi> wrote:\n>> Hmm... In what conditions ref->status is 'none' after push operation\n>> has completed?\n>\n> when a match between a local and remote ref is not found.\n>\n> For example, the local ref 'master' will match the remote ref\n> 'master', but not 'retsam' ('master' spelled in reverse).\n\nI'd like to add that in this case ('none'), no data is pushed to the\nremote repo.\n\nThis is true for 'uptodate' too, and shouldn't be taken as an error.\n\n-- \nCheers,\nRay Chuan\n"},{"id":"131895","messageId":"20100116182829.GA27474@sigill.intra.peff.net","threadId":"22243","inReplyTo":"be6fef0d1001160813o674ed93dn33843813be6f45be@mail.gmail.com","subject":"Re: [PATCH v3] Add push --set-upstream","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2010-01-16T18:28:31Z","receivedAt":"2010-01-16T18:28:31Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Sun, Jan 17, 2010 at 12:13:20AM +0800, Tay Ray Chuan wrote:\n\n> On Sat, Jan 16, 2010 at 11:56 PM, Ilari Liusvaara\n> <ilari.liusvaara@elisanet.fi> wrote:\n> > Hmm... In what conditions ref->status is 'none' after push operation\n> > has completed?\n> \n> when a match between a local and remote ref is not found.\n> \n> For example, the local ref 'master' will match the remote ref\n> 'master', but not 'retsam' ('master' spelled in reverse).\n\nHow would it make any sense to set up a tracking branch, then? Not only\nis it not desired (if I said \"git push -u foo:bar\", I don't expect it to\ndo _anything_ with some other local branch besides foo), but it wouldn't\nwork, since the peer_ref pointer would be NULL.\n\n-Peff\n"},{"id":"131896","messageId":"be6fef0d1001161039l7daf32f8v68e5ba4b03c3e2b3@mail.gmail.com","threadId":"22243","inReplyTo":"20100116182829.GA27474@sigill.intra.peff.net","subject":"Re: [PATCH v3] Add push --set-upstream","fromName":"Tay Ray Chuan","fromEmail":"rctay89@gmail.com","sentAt":"2010-01-16T18:39:16Z","receivedAt":"2010-01-16T18:39:16Z","isPatch":true,"sender":{"key":"rctay89@gmail.com","avatar":"https://avatars.githubusercontent.com/u/61553?v=4"},"body":"Hi,\n\nOn Sun, Jan 17, 2010 at 2:28 AM, Jeff King <peff@peff.net> wrote:\n> On Sun, Jan 17, 2010 at 12:13:20AM +0800, Tay Ray Chuan wrote:\n>\n>> On Sat, Jan 16, 2010 at 11:56 PM, Ilari Liusvaara\n>> <ilari.liusvaara@elisanet.fi> wrote:\n>> > Hmm... In what conditions ref->status is 'none' after push operation\n>> > has completed?\n>>\n>> when a match between a local and remote ref is not found.\n>>\n>> For example, the local ref 'master' will match the remote ref\n>> 'master', but not 'retsam' ('master' spelled in reverse).\n>\n> How would it make any sense to set up a tracking branch, then? Not only\n> is it not desired (if I said \"git push -u foo:bar\", I don't expect it to\n> do _anything_ with some other local branch besides foo), but it wouldn't\n> work, since the peer_ref pointer would be NULL.\n\nNoted.\n\nIlari, please ignore my thought on 'none' then.\n\n-- \nCheers,\nRay Chuan\n"},{"id":"131897","messageId":"be6fef0d1001161043q2ace931fyb17c2b2b03fe2cf6@mail.gmail.com","threadId":"22243","inReplyTo":"20100116134656.GA4504@Knoppix","subject":"Re: [PATCH v3] Add push --set-upstream","fromName":"Tay Ray Chuan","fromEmail":"rctay89@gmail.com","sentAt":"2010-01-16T18:43:13Z","receivedAt":"2010-01-16T18:43:13Z","isPatch":true,"sender":{"key":"rctay89@gmail.com","avatar":"https://avatars.githubusercontent.com/u/61553?v=4"},"body":"Hi,\n\nyet again, this patch has gone through another iteration, so I'm\nadding people from the 'git push --track' thread here.\n\n-- \nCheers,\nRay Chuan\n\nOn Sat, Jan 16, 2010 at 9:46 PM, Ilari Liusvaara\n<ilari.liusvaara@elisanet.fi> wrote:\n> On Sat, Jan 16, 2010 at 08:35:57PM +0800, Tay Ray Chuan wrote:\n>> Hi,\n>>\n>> On Sat, 16 Jan 2010 11:23:47 +0200\n>> Ilari Liusvaara <ilari.liusvaara@elisanet.fi> wrote:\n>> > +           OPT_BIT('u', \"set-upstream\", &flags, \"Set upstream for git pull\", TRANSPORT_PUSH_SET_UPSTREAM),\n>>\n>> This line exceeds 80 characters.\n>\n> Broken into two (without breaking the message), it is still over 80.\n>\n>> Also, I think you should follow the case-style of the other option\n>> descriptions and s/Set(?= upstream)/set/.\n>\n> Fixed.\n>\n>> > [snip]\n>> > +static void set_upstreams(struct transport *trans, struct ref *refs,\n>>\n>> I would prefer if you could follow the naming convention and say\n>> \"transport\" instead of truncating to \"trans\".\n>\n> Fixed.\n>\n>> > +   struct ref *i;\n>> > +   for (i = refs; i; i = i->next) {\n>>\n>> In most places, \"ref\" instead of \"i\" is used; ie.\n>\n> Fixed.\n>\n>> > +            * alreay up-to-date ref create/modify (not delete).\n>>\n>> s/alreay/already/.\n>\n> Fixed.\n>\n>> > +           /* Chase symbolic refs (mainly for HEAD). */\n>>\n>> Did you mean \"Change\" here?\n>\n> No. Changed to 'Follow'.\n>\n>> Regarding the checking of ref->status here:\n>>\n>> Is it possible to delegate this to push_had_errors(remote_refs)\n>> instead? We skip setting up upstream tracking when there are errors\n>> from pushing, so we don't have to check ref->status anymore.\n>\n> No. As documetnation says, the update or no update is done on per-branch\n> basis.\n>\n> <snip patch>\n>\n>> (As a side note, if you apply this on top of 'tr/http-push-ref-status'\n>> in 'pu', the result of push_had_errors() is saved in a variable\n>> ('err'), so you could just use it and not have to call push_had_errors\n>> () again.)\n>\n> See above.\n>\n> I'll sit on v4 for some more time to wait for more comments.\n>\n> -Ilari\n>\n"}]}