{"thread":{"id":"13696","subject":"[PATCH] builtin-fetch.c (store_updated_refs): Honor update_local_ref() return value","startedAt":"2008-05-27T20:53:49Z","lastAt":"2008-05-28T15:29:36Z","messageCount":3,"participants":["Dmitry V. Levin","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"77893","messageId":"20080527205348.GC32722@wo.int.altlinux.org","threadId":"13696","inReplyTo":null,"subject":"[PATCH] builtin-fetch.c (store_updated_refs): Honor update_local_ref() return value","fromName":"Dmitry V. Levin","fromEmail":"ldv@altlinux.org","sentAt":"2008-05-27T20:53:49Z","receivedAt":"2008-05-27T20:53:49Z","isPatch":true,"sender":{"key":"ldv@altlinux.org","avatar":"https://avatars.githubusercontent.com/u/5281408?v=4"},"body":"Sync with builtin-fetch--tool.c where append_fetch_head()\nhonors update_local_ref() return value.\n\nThis fixes git-fetch exit status,\nhttp://bugzilla.altlinux.org/show_bug.cgi?id=15037\n---\n builtin-fetch.c |    6 +++---\n 1 files changed, 3 insertions(+), 3 deletions(-)\n\ndiff --git a/builtin-fetch.c b/builtin-fetch.c\nindex 167f948..db60966 100644\n--- a/builtin-fetch.c\n+++ b/builtin-fetch.c\n@@ -292,7 +292,7 @@ static int store_updated_refs(const char *url, struct ref *ref_map)\n {\n \tFILE *fp;\n \tstruct commit *commit;\n-\tint url_len, i, note_len, shown_url = 0;\n+\tint rc = 0, url_len, i, note_len, shown_url = 0;\n \tchar note[1024];\n \tconst char *what, *kind;\n \tstruct ref *rm;\n@@ -359,7 +359,7 @@ static int store_updated_refs(const char *url, struct ref *ref_map)\n \t\t\tnote);\n \n \t\tif (ref)\n-\t\t\tupdate_local_ref(ref, what, verbose, note);\n+\t\t\trc |= update_local_ref(ref, what, verbose, note);\n \t\telse if (verbose)\n \t\t\tsprintf(note, \"* %-*s %-*s -> FETCH_HEAD\",\n \t\t\t\tSUMMARY_WIDTH, *kind ? kind : \"branch\",\n@@ -376,7 +376,7 @@ static int store_updated_refs(const char *url, struct ref *ref_map)\n \t\t}\n \t}\n \tfclose(fp);\n-\treturn 0;\n+\treturn rc;\n }\n \n /*\n-- \nldv\n"},{"id":"77913","messageId":"7v4p8jx9uf.fsf@gitster.siamese.dyndns.org","threadId":"13696","inReplyTo":"20080527205348.GC32722@wo.int.altlinux.org","subject":"Re: [PATCH] builtin-fetch.c (store_updated_refs): Honor update_local_ref() return value","fromName":"Junio C Hamano","fromEmail":"junio@pobox.com","sentAt":"2008-05-28T05:43:04Z","receivedAt":"2008-05-28T05:43:04Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"Dmitry V. Levin\" <ldv@altlinux.org> writes:\n\n> Sync with builtin-fetch--tool.c where append_fetch_head()\n> honors update_local_ref() return value.\n>\n> This fixes git-fetch exit status,\n> http://bugzilla.altlinux.org/show_bug.cgi?id=15037\n> ---\n\nThanks, but we would also want sign-off and tests, wouldn't we?\n"},{"id":"77942","messageId":"20080528152936.GA5687@wo.int.altlinux.org","threadId":"13696","inReplyTo":"7v4p8jx9uf.fsf@gitster.siamese.dyndns.org","subject":"[PATCH] builtin-fetch.c (store_updated_refs): Honor update_local_ref() return value","fromName":"Dmitry V. Levin","fromEmail":"ldv@altlinux.org","sentAt":"2008-05-28T15:29:36Z","receivedAt":"2008-05-28T15:29:36Z","isPatch":true,"sender":{"key":"ldv@altlinux.org","avatar":"https://avatars.githubusercontent.com/u/5281408?v=4"},"body":"Sync with builtin-fetch--tool.c where append_fetch_head()\nhonors update_local_ref() return value.\n\nThis fixes non fast forward fetch exit status,\nhttp://bugzilla.altlinux.org/show_bug.cgi?id=15037\n\nSigned-off-by: Dmitry V. Levin <ldv@altlinux.org>\n---\n builtin-fetch.c              |    6 +++---\n t/t5518-fetch-exit-status.sh |   37 +++++++++++++++++++++++++++++++++++++\n 2 files changed, 40 insertions(+), 3 deletions(-)\n create mode 100644 t/t5518-fetch-exit-status.sh\n\ndiff --git a/builtin-fetch.c b/builtin-fetch.c\nindex 167f948..db60966 100644\n--- a/builtin-fetch.c\n+++ b/builtin-fetch.c\n@@ -292,7 +292,7 @@ static int store_updated_refs(const char *url, struct ref *ref_map)\n {\n \tFILE *fp;\n \tstruct commit *commit;\n-\tint url_len, i, note_len, shown_url = 0;\n+\tint rc = 0, url_len, i, note_len, shown_url = 0;\n \tchar note[1024];\n \tconst char *what, *kind;\n \tstruct ref *rm;\n@@ -359,7 +359,7 @@ static int store_updated_refs(const char *url, struct ref *ref_map)\n \t\t\tnote);\n \n \t\tif (ref)\n-\t\t\tupdate_local_ref(ref, what, verbose, note);\n+\t\t\trc |= update_local_ref(ref, what, verbose, note);\n \t\telse if (verbose)\n \t\t\tsprintf(note, \"* %-*s %-*s -> FETCH_HEAD\",\n \t\t\t\tSUMMARY_WIDTH, *kind ? kind : \"branch\",\n@@ -376,7 +376,7 @@ static int store_updated_refs(const char *url, struct ref *ref_map)\n \t\t}\n \t}\n \tfclose(fp);\n-\treturn 0;\n+\treturn rc;\n }\n \n /*\ndiff --git a/t/t5518-fetch-exit-status.sh b/t/t5518-fetch-exit-status.sh\nnew file mode 100644\nindex 0000000..c6bc65f\n--- /dev/null\n+++ b/t/t5518-fetch-exit-status.sh\n@@ -0,0 +1,37 @@\n+#!/bin/sh\n+#\n+# Copyright (c) 2008 Dmitry V. Levin\n+#\n+\n+test_description='fetch exit status test'\n+\n+. ./test-lib.sh\n+\n+test_expect_success setup '\n+\n+\t>file &&\n+\tgit add file &&\n+\tgit commit -m initial &&\n+\n+\tgit checkout -b side &&\n+\techo side >file &&\n+\tgit commit -a -m side &&\n+\n+\tgit checkout master &&\n+\techo next >file &&\n+\tgit commit -a -m next\n+'\n+\n+test_expect_success 'non fast forward fetch' '\n+\n+\ttest_must_fail git fetch . master:side\n+\n+'\n+\n+test_expect_success 'forced update' '\n+\n+\tgit fetch . +master:side\n+\n+'\n+\n+test_done\n\n-- \nldv\n"}]}