{"thread":{"id":"35499","subject":"[PATCH 0/7] Trivial patches","startedAt":"2013-12-08T05:56:53Z","lastAt":"2013-12-09T21:26:40Z","messageCount":11,"participants":["Felipe Contreras","Philip Oakley","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":7},"messages":[{"id":"231754","messageId":"1386482220-18558-1-git-send-email-felipe.contreras@gmail.com","threadId":"35499","inReplyTo":null,"subject":"[PATCH 0/7] Trivial patches","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2013-12-08T05:56:53Z","receivedAt":"2013-12-08T05:56:53Z","isPatch":true,"sender":{"key":"felipe.contreras@gmail.com","avatar":"https://avatars.githubusercontent.com/u/8358?v=4"},"body":"Felipe Contreras (7):\n  config: avoid yoda conditions\n  add: avoid yoda conditions\n  abspath: trivial style fix\n  t: trivial whitespace cleanups\n  fetch: add missing documentation\n  sha1_name: cleanup interpret_branch_name()\n  sha1_name: simplify track finding\n\n Documentation/git-fetch.txt |  3 +++\n abspath.c                   |  2 +-\n builtin/add.c               |  2 +-\n config.c                    |  4 ++--\n sha1_name.c                 | 33 +++++++++++++++++----------------\n t/t0002-gitfile.sh          |  3 +--\n t/t0003-attributes.sh       |  1 -\n 7 files changed, 25 insertions(+), 23 deletions(-)\n\n-- \n1.8.5.1+fc1.2.gebd1fb1\n"},{"id":"231755","messageId":"1386482220-18558-2-git-send-email-felipe.contreras@gmail.com","threadId":"35499","inReplyTo":"1386482220-18558-1-git-send-email-felipe.contreras@gmail.com","subject":"[PATCH 1/7] config: avoid yoda conditions","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2013-12-08T05:56:54Z","receivedAt":"2013-12-08T05:56:54Z","isPatch":true,"sender":{"key":"felipe.contreras@gmail.com","avatar":"https://avatars.githubusercontent.com/u/8358?v=4"},"body":"Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>\n---\n config.c | 4 ++--\n 1 file changed, 2 insertions(+), 2 deletions(-)\n\ndiff --git a/config.c b/config.c\nindex e1d66a1..7a44414 100644\n--- a/config.c\n+++ b/config.c\n@@ -610,7 +610,7 @@ static int git_config_maybe_bool_text(const char *name, const char *value)\n int git_config_maybe_bool(const char *name, const char *value)\n {\n \tint v = git_config_maybe_bool_text(name, value);\n-\tif (0 <= v)\n+\tif (v >= 0)\n \t\treturn v;\n \tif (git_parse_int(value, &v))\n \t\treturn !!v;\n@@ -620,7 +620,7 @@ int git_config_maybe_bool(const char *name, const char *value)\n int git_config_bool_or_int(const char *name, const char *value, int *is_bool)\n {\n \tint v = git_config_maybe_bool_text(name, value);\n-\tif (0 <= v) {\n+\tif (v >= 0) {\n \t\t*is_bool = 1;\n \t\treturn v;\n \t}\n-- \n1.8.5.1+fc1.2.gebd1fb1\n"},{"id":"231756","messageId":"1386482220-18558-3-git-send-email-felipe.contreras@gmail.com","threadId":"35499","inReplyTo":"1386482220-18558-1-git-send-email-felipe.contreras@gmail.com","subject":"[PATCH 2/7] add: avoid yoda conditions","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2013-12-08T05:56:55Z","receivedAt":"2013-12-08T05:56:55Z","isPatch":true,"sender":{"key":"felipe.contreras@gmail.com","avatar":"https://avatars.githubusercontent.com/u/8358?v=4"},"body":"Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>\n---\n builtin/add.c | 2 +-\n 1 file changed, 1 insertion(+), 1 deletion(-)\n\ndiff --git a/builtin/add.c b/builtin/add.c\nindex 226f758..9b30356 100644\n--- a/builtin/add.c\n+++ b/builtin/add.c\n@@ -429,7 +429,7 @@ int cmd_add(int argc, const char **argv, const char *prefix)\n \targc--;\n \targv++;\n \n-\tif (0 <= addremove_explicit)\n+\tif (addremove_explicit >= 0)\n \t\taddremove = addremove_explicit;\n \telse if (take_worktree_changes && ADDREMOVE_DEFAULT)\n \t\taddremove = 0; /* \"-u\" was given but not \"-A\" */\n-- \n1.8.5.1+fc1.2.gebd1fb1\n"},{"id":"231759","messageId":"1386482220-18558-4-git-send-email-felipe.contreras@gmail.com","threadId":"35499","inReplyTo":"1386482220-18558-1-git-send-email-felipe.contreras@gmail.com","subject":"[PATCH 3/7] abspath: trivial style fix","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2013-12-08T05:56:56Z","receivedAt":"2013-12-08T05:56:56Z","isPatch":true,"sender":{"key":"felipe.contreras@gmail.com","avatar":"https://avatars.githubusercontent.com/u/8358?v=4"},"body":"Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>\n---\n abspath.c | 2 +-\n 1 file changed, 1 insertion(+), 1 deletion(-)\n\ndiff --git a/abspath.c b/abspath.c\nindex e390994..8b3385a 100644\n--- a/abspath.c\n+++ b/abspath.c\n@@ -143,7 +143,7 @@ static const char *real_path_internal(const char *path, int die_on_error)\n error_out:\n \tfree(last_elem);\n \tif (*cwd && chdir(cwd))\n-\t\tdie_errno (\"Could not change back to '%s'\", cwd);\n+\t\tdie_errno(\"Could not change back to '%s'\", cwd);\n \n \treturn retval;\n }\n-- \n1.8.5.1+fc1.2.gebd1fb1\n"},{"id":"231758","messageId":"1386482220-18558-5-git-send-email-felipe.contreras@gmail.com","threadId":"35499","inReplyTo":"1386482220-18558-1-git-send-email-felipe.contreras@gmail.com","subject":"[PATCH 4/7] t: trivial whitespace cleanups","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2013-12-08T05:56:57Z","receivedAt":"2013-12-08T05:56:57Z","isPatch":true,"sender":{"key":"felipe.contreras@gmail.com","avatar":"https://avatars.githubusercontent.com/u/8358?v=4"},"body":"Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>\n---\n t/t0002-gitfile.sh    | 3 +--\n t/t0003-attributes.sh | 1 -\n 2 files changed, 1 insertion(+), 3 deletions(-)\n\ndiff --git a/t/t0002-gitfile.sh b/t/t0002-gitfile.sh\nindex cb14425..37e9396 100755\n--- a/t/t0002-gitfile.sh\n+++ b/t/t0002-gitfile.sh\n@@ -7,7 +7,7 @@ Verify that plumbing commands work when .git is a file\n . ./test-lib.sh\n \n objpath() {\n-    echo \"$1\" | sed -e 's|\\(..\\)|\\1/|'\n+\techo \"$1\" | sed -e 's|\\(..\\)|\\1/|'\n }\n \n objck() {\n@@ -19,7 +19,6 @@ objck() {\n \tfi\n }\n \n-\n test_expect_success 'initial setup' '\n \tREAL=\"$(pwd)/.real\" &&\n \tmv .git \"$REAL\"\ndiff --git a/t/t0003-attributes.sh b/t/t0003-attributes.sh\nindex 0b98b6f..b9d7947 100755\n--- a/t/t0003-attributes.sh\n+++ b/t/t0003-attributes.sh\n@@ -13,7 +13,6 @@ attr_check () {\n \ttest_line_count = 0 err\n }\n \n-\n test_expect_success 'setup' '\n \tmkdir -p a/b/d a/c b &&\n \t(\n-- \n1.8.5.1+fc1.2.gebd1fb1\n"},{"id":"231761","messageId":"1386482220-18558-6-git-send-email-felipe.contreras@gmail.com","threadId":"35499","inReplyTo":"1386482220-18558-1-git-send-email-felipe.contreras@gmail.com","subject":"[PATCH 5/7] fetch: add missing documentation","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2013-12-08T05:56:58Z","receivedAt":"2013-12-08T05:56:58Z","isPatch":true,"sender":{"key":"felipe.contreras@gmail.com","avatar":"https://avatars.githubusercontent.com/u/8358?v=4"},"body":"There's no mention of the 'origin' default, or the fact that the\nupstream tracking branch remote is used.\n\nSigned-off-by: Felipe Contreras <felipe.contreras@gmail.com>\n---\n Documentation/git-fetch.txt | 3 +++\n 1 file changed, 3 insertions(+)\n\ndiff --git a/Documentation/git-fetch.txt b/Documentation/git-fetch.txt\nindex e08a028..a7b245d 100644\n--- a/Documentation/git-fetch.txt\n+++ b/Documentation/git-fetch.txt\n@@ -37,6 +37,9 @@ or from several repositories at once if <group> is given and\n there is a remotes.<group> entry in the configuration file.\n (See linkgit:git-config[1]).\n \n+When no remote is specified, by default the `origin` remote will be used,\n+unless there's an upstream branch configured for the current branch.\n+\n OPTIONS\n -------\n include::fetch-options.txt[]\n-- \n1.8.5.1+fc1.2.gebd1fb1\n"},{"id":"231762","messageId":"67130C4F312A414DAB7EA610C78C9103@PhilipOakley","threadId":"35499","inReplyTo":"1386482220-18558-7-git-send-email-felipe.contreras@gmail.com","subject":"Re: [PATCH 6/7] sha1_name: cleanup interpret_branch_name()","fromName":"Philip Oakley","fromEmail":"philipoakley@iee.org","sentAt":null,"receivedAt":"2013-12-08T05:56:58Z","isPatch":true,"sender":{"key":"philipoakley@iee.email","avatar":"https://avatars.githubusercontent.com/u/914343?v=4"},"body":"From: \"Felipe Contreras\" <felipe.contreras@gmail.com>\n> The 'upstream' variable doesn't hold an \"upstream\", but a branch, so\n> make it clearer.\n>\n> Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>\n> ---\n> sha1_name.c | 18 +++++++++---------\n> 1 file changed, 9 insertions(+), 9 deletions(-)\n>\n> diff --git a/sha1_name.c b/sha1_name.c\n> index e9c2999..e27db88 100644\n> --- a/sha1_name.c\n> +++ b/sha1_name.c\n> @@ -1072,7 +1072,7 @@ static int reinterpret(const char *name, int \n> namelen, int len, struct strbuf *bu\n> int interpret_branch_name(const char *name, int namelen, struct strbuf \n> *buf)\n> {\n>  char *cp;\n> - struct branch *upstream;\n> + struct branch *branch;\n>  int len = interpret_nth_prior_checkout(name, buf);\n>  int tmp_len;\n>\n> @@ -1102,26 +1102,26 @@ int interpret_branch_name(const char *name, \n> int namelen, struct strbuf *buf)\n>\n>  len = cp + tmp_len - name;\n>  cp = xstrndup(name, cp - name);\n> - upstream = branch_get(*cp ? cp : NULL);\n> + branch = branch_get(*cp ? cp : NULL);\n>  /*\n>  * Upstream can be NULL only if cp refers to HEAD and HEAD\n>  * points to something different than a branch.\n\nDoesn't this comment also need updating, or at least clarifying any \ncontradictions between variable names and the concepts described. That \nis does \"Upstream\" refer to the original variable 'upstream', and now \nthe final \"branch\" can be confused with the new variable name.\n\nI'm not arguing against the change, rather just noting an additional \nconsequence.\n\n>  */\n> - if (!upstream)\n> + if (!branch)\n>  die(_(\"HEAD does not point to a branch\"));\n> - if (!upstream->merge || !upstream->merge[0]->dst) {\n> - if (!ref_exists(upstream->refname))\n> + if (!branch->merge || !branch->merge[0]->dst) {\n> + if (!ref_exists(branch->refname))\n>  die(_(\"No such branch: '%s'\"), cp);\n> - if (!upstream->merge) {\n> + if (!branch->merge) {\n>  die(_(\"No upstream configured for branch '%s'\"),\n> - upstream->name);\n> + branch->name);\n>  }\n>  die(\n>  _(\"Upstream branch '%s' not stored as a remote-tracking branch\"),\n> - upstream->merge[0]->src);\n> + branch->merge[0]->src);\n>  }\n>  free(cp);\n> - cp = shorten_unambiguous_ref(upstream->merge[0]->dst, 0);\n> + cp = shorten_unambiguous_ref(branch->merge[0]->dst, 0);\n>  strbuf_reset(buf);\n>  strbuf_addstr(buf, cp);\n>  free(cp);\n> -- \n> 1.8.5.1+fc1.2.gebd1fb1\n>\n> --\n> To unsubscribe from this list: send the line \"unsubscribe git\" in\n> the body of a message to majordomo@vger.kernel.org\n> More majordomo info at  http://vger.kernel.org/majordomo-info.html\n> \n"},{"id":"231760","messageId":"1386482220-18558-7-git-send-email-felipe.contreras@gmail.com","threadId":"35499","inReplyTo":"1386482220-18558-1-git-send-email-felipe.contreras@gmail.com","subject":"[PATCH 6/7] sha1_name: cleanup interpret_branch_name()","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2013-12-08T05:56:59Z","receivedAt":"2013-12-08T05:56:59Z","isPatch":true,"sender":{"key":"felipe.contreras@gmail.com","avatar":"https://avatars.githubusercontent.com/u/8358?v=4"},"body":"The 'upstream' variable doesn't hold an \"upstream\", but a branch, so\nmake it clearer.\n\nSigned-off-by: Felipe Contreras <felipe.contreras@gmail.com>\n---\n sha1_name.c | 18 +++++++++---------\n 1 file changed, 9 insertions(+), 9 deletions(-)\n\ndiff --git a/sha1_name.c b/sha1_name.c\nindex e9c2999..e27db88 100644\n--- a/sha1_name.c\n+++ b/sha1_name.c\n@@ -1072,7 +1072,7 @@ static int reinterpret(const char *name, int namelen, int len, struct strbuf *bu\n int interpret_branch_name(const char *name, int namelen, struct strbuf *buf)\n {\n \tchar *cp;\n-\tstruct branch *upstream;\n+\tstruct branch *branch;\n \tint len = interpret_nth_prior_checkout(name, buf);\n \tint tmp_len;\n \n@@ -1102,26 +1102,26 @@ int interpret_branch_name(const char *name, int namelen, struct strbuf *buf)\n \n \tlen = cp + tmp_len - name;\n \tcp = xstrndup(name, cp - name);\n-\tupstream = branch_get(*cp ? cp : NULL);\n+\tbranch = branch_get(*cp ? cp : NULL);\n \t/*\n \t * Upstream can be NULL only if cp refers to HEAD and HEAD\n \t * points to something different than a branch.\n \t */\n-\tif (!upstream)\n+\tif (!branch)\n \t\tdie(_(\"HEAD does not point to a branch\"));\n-\tif (!upstream->merge || !upstream->merge[0]->dst) {\n-\t\tif (!ref_exists(upstream->refname))\n+\tif (!branch->merge || !branch->merge[0]->dst) {\n+\t\tif (!ref_exists(branch->refname))\n \t\t\tdie(_(\"No such branch: '%s'\"), cp);\n-\t\tif (!upstream->merge) {\n+\t\tif (!branch->merge) {\n \t\t\tdie(_(\"No upstream configured for branch '%s'\"),\n-\t\t\t\tupstream->name);\n+\t\t\t\tbranch->name);\n \t\t}\n \t\tdie(\n \t\t\t_(\"Upstream branch '%s' not stored as a remote-tracking branch\"),\n-\t\t\tupstream->merge[0]->src);\n+\t\t\tbranch->merge[0]->src);\n \t}\n \tfree(cp);\n-\tcp = shorten_unambiguous_ref(upstream->merge[0]->dst, 0);\n+\tcp = shorten_unambiguous_ref(branch->merge[0]->dst, 0);\n \tstrbuf_reset(buf);\n \tstrbuf_addstr(buf, cp);\n \tfree(cp);\n-- \n1.8.5.1+fc1.2.gebd1fb1\n"},{"id":"231757","messageId":"1386482220-18558-8-git-send-email-felipe.contreras@gmail.com","threadId":"35499","inReplyTo":"1386482220-18558-1-git-send-email-felipe.contreras@gmail.com","subject":"[PATCH 7/7] sha1_name: simplify track finding","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2013-12-08T05:57:00Z","receivedAt":"2013-12-08T05:57:00Z","isPatch":true,"sender":{"key":"felipe.contreras@gmail.com","avatar":"https://avatars.githubusercontent.com/u/8358?v=4"},"body":"It's more efficient to check for the braces first, and we already have\nthe length of the whole thing.\n\nSigned-off-by: Felipe Contreras <felipe.contreras@gmail.com>\n---\n sha1_name.c | 15 ++++++++-------\n 1 file changed, 8 insertions(+), 7 deletions(-)\n\ndiff --git a/sha1_name.c b/sha1_name.c\nindex e27db88..1a68103 100644\n--- a/sha1_name.c\n+++ b/sha1_name.c\n@@ -417,7 +417,7 @@ static int ambiguous_path(const char *path, int len)\n \n static inline int upstream_mark(const char *string, int len)\n {\n-\tconst char *suffix[] = { \"@{upstream}\", \"@{u}\" };\n+\tconst char *suffix[] = { \"upstream\", \"u\" };\n \tint i;\n \n \tfor (i = 0; i < ARRAY_SIZE(suffix); i++) {\n@@ -475,7 +475,7 @@ static int get_sha1_basic(const char *str, int len, unsigned char *sha1)\n \t\t\t\t\tnth_prior = 1;\n \t\t\t\t\tcontinue;\n \t\t\t\t}\n-\t\t\t\tif (!upstream_mark(str + at, len - at)) {\n+\t\t\t\tif (!upstream_mark(str + at + 2, len - at - 3)) {\n \t\t\t\t\treflog_len = (len-1) - (at+2);\n \t\t\t\t\tlen = at;\n \t\t\t\t}\n@@ -1074,7 +1074,6 @@ int interpret_branch_name(const char *name, int namelen, struct strbuf *buf)\n \tchar *cp;\n \tstruct branch *branch;\n \tint len = interpret_nth_prior_checkout(name, buf);\n-\tint tmp_len;\n \n \tif (!namelen)\n \t\tnamelen = strlen(name);\n@@ -1096,11 +1095,13 @@ int interpret_branch_name(const char *name, int namelen, struct strbuf *buf)\n \tif (len > 0)\n \t\treturn reinterpret(name, namelen, len, buf);\n \n-\ttmp_len = upstream_mark(cp, namelen - (cp - name));\n-\tif (!tmp_len)\n+\tlen = namelen - (cp - name);\n+\tif (cp[1] != '{' && cp[len - 1] != '}')\n+\t\treturn -1;\n+\n+\tif (!upstream_mark(cp + 2, len - 3))\n \t\treturn -1;\n \n-\tlen = cp + tmp_len - name;\n \tcp = xstrndup(name, cp - name);\n \tbranch = branch_get(*cp ? cp : NULL);\n \t/*\n@@ -1125,7 +1126,7 @@ int interpret_branch_name(const char *name, int namelen, struct strbuf *buf)\n \tstrbuf_reset(buf);\n \tstrbuf_addstr(buf, cp);\n \tfree(cp);\n-\treturn len;\n+\treturn namelen;\n }\n \n int strbuf_branchname(struct strbuf *sb, const char *name)\n-- \n1.8.5.1+fc1.2.gebd1fb1\n"},{"id":"231826","messageId":"xmqqeh5lwwej.fsf@gitster.dls.corp.google.com","threadId":"35499","inReplyTo":"1386482220-18558-4-git-send-email-felipe.contreras@gmail.com","subject":"Re: [PATCH 3/7] abspath: trivial style fix","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2013-12-09T21:24:04Z","receivedAt":"2013-12-09T21:24:04Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Felipe Contreras <felipe.contreras@gmail.com> writes:\n\n> Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>\n> ---\n>  abspath.c | 2 +-\n>  1 file changed, 1 insertion(+), 1 deletion(-)\n>\n> diff --git a/abspath.c b/abspath.c\n> index e390994..8b3385a 100644\n> --- a/abspath.c\n> +++ b/abspath.c\n> @@ -143,7 +143,7 @@ static const char *real_path_internal(const char *path, int die_on_error)\n>  error_out:\n>  \tfree(last_elem);\n>  \tif (*cwd && chdir(cwd))\n> -\t\tdie_errno (\"Could not change back to '%s'\", cwd);\n> +\t\tdie_errno(\"Could not change back to '%s'\", cwd);\n\nWill queue; thanks.\n\nBy the way, there are quite a few hits from\n\n\tgit grep -e '\\(die\\|error\\|warning\\) (' -- \\*.c\n\neven if we ignore borrowed code that we do not want to touch up with\nthis kind of change.  Some may have overlapping changes in flight\nthat makes it better to leave them as they are for now, but some are\nin reasonably quiescent areas.\n"},{"id":"231827","messageId":"xmqqa9g9wwa7.fsf@gitster.dls.corp.google.com","threadId":"35499","inReplyTo":"1386482220-18558-6-git-send-email-felipe.contreras@gmail.com","subject":"Re: [PATCH 5/7] fetch: add missing documentation","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2013-12-09T21:26:40Z","receivedAt":"2013-12-09T21:26:40Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Felipe Contreras <felipe.contreras@gmail.com> writes:\n\n> There's no mention of the 'origin' default, or the fact that the\n> upstream tracking branch remote is used.\n>\n> Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>\n> ---\n>  Documentation/git-fetch.txt | 3 +++\n>  1 file changed, 3 insertions(+)\n>\n> diff --git a/Documentation/git-fetch.txt b/Documentation/git-fetch.txt\n> index e08a028..a7b245d 100644\n> --- a/Documentation/git-fetch.txt\n> +++ b/Documentation/git-fetch.txt\n> @@ -37,6 +37,9 @@ or from several repositories at once if <group> is given and\n>  there is a remotes.<group> entry in the configuration file.\n>  (See linkgit:git-config[1]).\n>  \n> +When no remote is specified, by default the `origin` remote will be used,\n> +unless there's an upstream branch configured for the current branch.\n> +\n\nIt is better than saying nothing, but the reader will be left\nwondering what happens when \"upstream branch\" is configured with the\nabove text.\n\n    When no remote is specified, by default the `origin` remote will\n    be used, unless there's an upstream branch configured for the\n    current branch, in which case the `fetch` goes to the remote the\n    specified upstream remote-tracking branch is taken from.\n\nor something, perhaps?\n\n>  OPTIONS\n>  -------\n>  include::fetch-options.txt[]\n"}]}