{"thread":{"id":"36908","subject":"[PATCH 2/2] receive-pack.c: add missing xstrdup","startedAt":"2014-06-13T15:51:04Z","lastAt":"2014-06-13T19:47:00Z","messageCount":5,"participants":["Ronnie Sahlberg","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":2},"messages":[{"id":"244140","messageId":"1402674666-6634-1-git-send-email-sahlberg@google.com","threadId":"36908","inReplyTo":null,"subject":"[PATCH 0/2] Fixes for the ref-transactions series in origin/pu","fromName":"Ronnie Sahlberg","fromEmail":"sahlberg@google.com","sentAt":"2014-06-13T15:51:04Z","receivedAt":"2014-06-13T15:51:04Z","isPatch":true,"sender":{"key":"sahlberg@google.com","avatar":"https://avatars.githubusercontent.com/u/7320636?v=4"},"body":"Jun,\nPlease find two fixes for the ref-transactions series in origin/pu\n\nRonnie Sahlberg (2):\n  remotes.c: update calls to new signature for repack_without_refs\n  receive-pack.c: add missing xstrdup\n\n builtin/receive-pack.c | 21 +++++++++++----------\n builtin/remote.c       |  5 +++--\n refs.h                 |  3 ++-\n 3 files changed, 16 insertions(+), 13 deletions(-)\n\n-- \n2.0.0.415.g8cd8cf8\n"},{"id":"244139","messageId":"1402674666-6634-2-git-send-email-sahlberg@google.com","threadId":"36908","inReplyTo":"1402674666-6634-1-git-send-email-sahlberg@google.com","subject":"[PATCH 1/2] remotes.c: update calls to new signature for repack_without_refs","fromName":"Ronnie Sahlberg","fromEmail":"sahlberg@google.com","sentAt":"2014-06-13T15:51:05Z","receivedAt":"2014-06-13T15:51:05Z","isPatch":true,"sender":{"key":"sahlberg@google.com","avatar":"https://avatars.githubusercontent.com/u/7320636?v=4"},"body":"This should be merged into patch:\n00c74db refs.c: add an err argument to repack_without_refs\n\nSigned-off-by: Ronnie Sahlberg <sahlberg@google.com>\n---\n builtin/remote.c | 5 +++--\n refs.h           | 3 ++-\n 2 files changed, 5 insertions(+), 3 deletions(-)\n\ndiff --git a/builtin/remote.c b/builtin/remote.c\nindex c9102e8..401feb3 100644\n--- a/builtin/remote.c\n+++ b/builtin/remote.c\n@@ -755,7 +755,7 @@ static int remove_branches(struct string_list *branches)\n \tbranch_names = xmalloc(branches->nr * sizeof(*branch_names));\n \tfor (i = 0; i < branches->nr; i++)\n \t\tbranch_names[i] = branches->items[i].string;\n-\tresult |= repack_without_refs(branch_names, branches->nr);\n+\tresult |= repack_without_refs(branch_names, branches->nr, NULL);\n \tfree(branch_names);\n \n \tfor (i = 0; i < branches->nr; i++) {\n@@ -1333,7 +1333,8 @@ static int prune_remote(const char *remote, int dry_run)\n \t\tfor (i = 0; i < states.stale.nr; i++)\n \t\t\tdelete_refs[i] = states.stale.items[i].util;\n \t\tif (!dry_run)\n-\t\t\tresult |= repack_without_refs(delete_refs, states.stale.nr);\n+\t\t\tresult |= repack_without_refs(delete_refs,\n+\t\t\t\t\t\t      states.stale.nr, NULL);\n \t\tfree(delete_refs);\n \t}\n \ndiff --git a/refs.h b/refs.h\nindex 1b236f7..db463d0 100644\n--- a/refs.h\n+++ b/refs.h\n@@ -162,7 +162,8 @@ extern void rollback_packed_refs(void);\n  */\n int pack_refs(unsigned int flags);\n \n-extern int repack_without_refs(const char **refnames, int n);\n+extern int repack_without_refs(const char **refnames, int n,\n+\t\t\t       struct strbuf *err);\n \n extern int ref_exists(const char *);\n \n-- \n2.0.0.415.g8cd8cf8\n"},{"id":"244138","messageId":"1402674666-6634-3-git-send-email-sahlberg@google.com","threadId":"36908","inReplyTo":"1402674666-6634-1-git-send-email-sahlberg@google.com","subject":"[PATCH 2/2] receive-pack.c: add missing xstrdup","fromName":"Ronnie Sahlberg","fromEmail":"sahlberg@google.com","sentAt":"2014-06-13T15:51:06Z","receivedAt":"2014-06-13T15:51:06Z","isPatch":true,"sender":{"key":"sahlberg@google.com","avatar":"https://avatars.githubusercontent.com/u/7320636?v=4"},"body":"This should be merged into patch :\n1685d87 receive-pack.c: use a reference transaction for updating the refs\n\nSigned-off-by: Ronnie Sahlberg <sahlberg@google.com>\n---\n builtin/receive-pack.c | 21 +++++++++++----------\n 1 file changed, 11 insertions(+), 10 deletions(-)\n\ndiff --git a/builtin/receive-pack.c b/builtin/receive-pack.c\nindex 2575d06..64d54f8 100644\n--- a/builtin/receive-pack.c\n+++ b/builtin/receive-pack.c\n@@ -479,7 +479,7 @@ static char *update(struct command *cmd, struct shallow_info *si)\n \t/* only refs/... are allowed */\n \tif (!starts_with(name, \"refs/\") || check_refname_format(name + 5, 0)) {\n \t\trp_error(\"refusing to create funny ref '%s' remotely\", name);\n-\t\treturn \"funny refname\";\n+\t\treturn xstrdup(\"funny refname\");\n \t}\n \n \tstrbuf_addf(&namespaced_name_buf, \"%s%s\", get_git_namespace(), name);\n@@ -497,20 +497,20 @@ static char *update(struct command *cmd, struct shallow_info *si)\n \t\t\trp_error(\"refusing to update checked out branch: %s\", name);\n \t\t\tif (deny_current_branch == DENY_UNCONFIGURED)\n \t\t\t\trefuse_unconfigured_deny();\n-\t\t\treturn \"branch is currently checked out\";\n+\t\t\treturn xstrdup(\"branch is currently checked out\");\n \t\t}\n \t}\n \n \tif (!is_null_sha1(new_sha1) && !has_sha1_file(new_sha1)) {\n \t\terror(\"unpack should have generated %s, \"\n \t\t      \"but I can't find it!\", sha1_to_hex(new_sha1));\n-\t\treturn \"bad pack\";\n+\t\treturn xstrdup(\"bad pack\");\n \t}\n \n \tif (!is_null_sha1(old_sha1) && is_null_sha1(new_sha1)) {\n \t\tif (deny_deletes && starts_with(name, \"refs/heads/\")) {\n \t\t\trp_error(\"denying ref deletion for %s\", name);\n-\t\t\treturn \"deletion prohibited\";\n+\t\t\treturn xstrdup(\"deletion prohibited\");\n \t\t}\n \n \t\tif (!strcmp(namespaced_name, head_name)) {\n@@ -525,7 +525,8 @@ static char *update(struct command *cmd, struct shallow_info *si)\n \t\t\t\tif (deny_delete_current == DENY_UNCONFIGURED)\n \t\t\t\t\trefuse_unconfigured_deny_delete_current();\n \t\t\t\trp_error(\"refusing to delete the current branch: %s\", name);\n-\t\t\t\treturn \"deletion of the current branch prohibited\";\n+\t\t\t\treturn xstrdup(\"deletion of the current branch \"\n+\t\t\t\t\t       \"prohibited\");\n \t\t\t}\n \t\t}\n \t}\n@@ -543,19 +544,19 @@ static char *update(struct command *cmd, struct shallow_info *si)\n \t\t    old_object->type != OBJ_COMMIT ||\n \t\t    new_object->type != OBJ_COMMIT) {\n \t\t\terror(\"bad sha1 objects for %s\", name);\n-\t\t\treturn \"bad ref\";\n+\t\t\treturn xstrdup(\"bad ref\");\n \t\t}\n \t\told_commit = (struct commit *)old_object;\n \t\tnew_commit = (struct commit *)new_object;\n \t\tif (!in_merge_bases(old_commit, new_commit)) {\n \t\t\trp_error(\"denying non-fast-forward %s\"\n \t\t\t\t \" (you should pull first)\", name);\n-\t\t\treturn \"non-fast-forward\";\n+\t\t\treturn xstrdup(\"non-fast-forward\");\n \t\t}\n \t}\n \tif (run_update_hook(cmd)) {\n \t\trp_error(\"hook declined to update %s\", name);\n-\t\treturn \"hook declined\";\n+\t\treturn xstrdup(\"hook declined\");\n \t}\n \n \tif (is_null_sha1(new_sha1)) {\n@@ -570,7 +571,7 @@ static char *update(struct command *cmd, struct shallow_info *si)\n \t\t}\n \t\tif (delete_ref(namespaced_name, old_sha1, 0)) {\n \t\t\trp_error(\"failed to delete %s\", name);\n-\t\t\treturn \"failed to delete\";\n+\t\t\treturn xstrdup(\"failed to delete\");\n \t\t}\n \t\treturn NULL; /* good */\n \t}\n@@ -580,7 +581,7 @@ static char *update(struct command *cmd, struct shallow_info *si)\n \n \t\tif (shallow_update && si->shallow_ref[cmd->index] &&\n \t\t    update_shallow_ref(cmd, si))\n-\t\t\treturn \"shallow error\";\n+\t\t\treturn xstrdup(\"shallow error\");\n \n \t\ttransaction = ref_transaction_begin(&err);\n \t\tif (!transaction ||\n-- \n2.0.0.415.g8cd8cf8\n"},{"id":"244166","messageId":"xmqqwqck1tu2.fsf@gitster.dls.corp.google.com","threadId":"36908","inReplyTo":"1402674666-6634-2-git-send-email-sahlberg@google.com","subject":"Re: [PATCH 1/2] remotes.c: update calls to new signature for repack_without_refs","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2014-06-13T19:40:37Z","receivedAt":"2014-06-13T19:40:37Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Ronnie Sahlberg <sahlberg@google.com> writes:\n\n> This should be merged into patch:\n> 00c74db refs.c: add an err argument to repack_without_refs\n>\n> Signed-off-by: Ronnie Sahlberg <sahlberg@google.com>\n> ---\n>  builtin/remote.c | 5 +++--\n>  refs.h           | 3 ++-\n>  2 files changed, 5 insertions(+), 3 deletions(-)\n>\n> diff --git a/builtin/remote.c b/builtin/remote.c\n> index c9102e8..401feb3 100644\n> --- a/builtin/remote.c\n> +++ b/builtin/remote.c\n> @@ -755,7 +755,7 @@ static int remove_branches(struct string_list *branches)\n>  \tbranch_names = xmalloc(branches->nr * sizeof(*branch_names));\n>  \tfor (i = 0; i < branches->nr; i++)\n>  \t\tbranch_names[i] = branches->items[i].string;\n> -\tresult |= repack_without_refs(branch_names, branches->nr);\n> +\tresult |= repack_without_refs(branch_names, branches->nr, NULL);\n>  \tfree(branch_names);\n>  \n>  \tfor (i = 0; i < branches->nr; i++) {\n> @@ -1333,7 +1333,8 @@ static int prune_remote(const char *remote, int dry_run)\n>  \t\tfor (i = 0; i < states.stale.nr; i++)\n>  \t\t\tdelete_refs[i] = states.stale.items[i].util;\n>  \t\tif (!dry_run)\n> -\t\t\tresult |= repack_without_refs(delete_refs, states.stale.nr);\n> +\t\t\tresult |= repack_without_refs(delete_refs,\n> +\t\t\t\t\t\t      states.stale.nr, NULL);\n>  \t\tfree(delete_refs);\n>  \t}\n>  \n> diff --git a/refs.h b/refs.h\n> index 1b236f7..db463d0 100644\n> --- a/refs.h\n> +++ b/refs.h\n> @@ -162,7 +162,8 @@ extern void rollback_packed_refs(void);\n>   */\n>  int pack_refs(unsigned int flags);\n>  \n> -extern int repack_without_refs(const char **refnames, int n);\n> +extern int repack_without_refs(const char **refnames, int n,\n> +\t\t\t       struct strbuf *err);\n>  \n>  extern int ref_exists(const char *);\n\nHow does this related to v16?  The reason I ask is because even\nthough v16 0/48 says it is to be applied on 'next' it won't at least\nfor me X-< and this is one of the early places where the patches\nfail to apply without adjustment.\n"},{"id":"244167","messageId":"CAL=YDWnq5=3z09huNddO5zW4=uXgc4U3xh_oa2K3R082HvrM_g@mail.gmail.com","threadId":"36908","inReplyTo":"xmqqwqck1tu2.fsf@gitster.dls.corp.google.com","subject":"Re: [PATCH 1/2] remotes.c: update calls to new signature for repack_without_refs","fromName":"Ronnie Sahlberg","fromEmail":"sahlberg@google.com","sentAt":"2014-06-13T19:47:00Z","receivedAt":"2014-06-13T19:47:00Z","isPatch":true,"sender":{"key":"sahlberg@google.com","avatar":"https://avatars.githubusercontent.com/u/7320636?v=4"},"body":"It should have been in\n[PATCH v16 08/48] refs.c: add an err argument to repack_without_refs\n\nbut it is not. It must have gone AWOL during one of the many conflicts.\nIt should be there nevertheless since we change the signature for this\nfunction in this patch.\n\n\nOn Fri, Jun 13, 2014 at 12:40 PM, Junio C Hamano <gitster@pobox.com> wrote:\n> Ronnie Sahlberg <sahlberg@google.com> writes:\n>\n>> This should be merged into patch:\n>> 00c74db refs.c: add an err argument to repack_without_refs\n>>\n>> Signed-off-by: Ronnie Sahlberg <sahlberg@google.com>\n>> ---\n>>  builtin/remote.c | 5 +++--\n>>  refs.h           | 3 ++-\n>>  2 files changed, 5 insertions(+), 3 deletions(-)\n>>\n>> diff --git a/builtin/remote.c b/builtin/remote.c\n>> index c9102e8..401feb3 100644\n>> --- a/builtin/remote.c\n>> +++ b/builtin/remote.c\n>> @@ -755,7 +755,7 @@ static int remove_branches(struct string_list *branches)\n>>       branch_names = xmalloc(branches->nr * sizeof(*branch_names));\n>>       for (i = 0; i < branches->nr; i++)\n>>               branch_names[i] = branches->items[i].string;\n>> -     result |= repack_without_refs(branch_names, branches->nr);\n>> +     result |= repack_without_refs(branch_names, branches->nr, NULL);\n>>       free(branch_names);\n>>\n>>       for (i = 0; i < branches->nr; i++) {\n>> @@ -1333,7 +1333,8 @@ static int prune_remote(const char *remote, int dry_run)\n>>               for (i = 0; i < states.stale.nr; i++)\n>>                       delete_refs[i] = states.stale.items[i].util;\n>>               if (!dry_run)\n>> -                     result |= repack_without_refs(delete_refs, states.stale.nr);\n>> +                     result |= repack_without_refs(delete_refs,\n>> +                                                   states.stale.nr, NULL);\n>>               free(delete_refs);\n>>       }\n>>\n>> diff --git a/refs.h b/refs.h\n>> index 1b236f7..db463d0 100644\n>> --- a/refs.h\n>> +++ b/refs.h\n>> @@ -162,7 +162,8 @@ extern void rollback_packed_refs(void);\n>>   */\n>>  int pack_refs(unsigned int flags);\n>>\n>> -extern int repack_without_refs(const char **refnames, int n);\n>> +extern int repack_without_refs(const char **refnames, int n,\n>> +                            struct strbuf *err);\n>>\n>>  extern int ref_exists(const char *);\n>\n> How does this related to v16?  The reason I ask is because even\n> though v16 0/48 says it is to be applied on 'next' it won't at least\n> for me X-< and this is one of the early places where the patches\n> fail to apply without adjustment.\n"}]}