{"thread":{"id":"19615","subject":"[PATCH] http-push: reuse existing is_null_ref","startedAt":"2009-05-31T10:36:10Z","lastAt":"2009-05-31T10:36:10Z","messageCount":1,"participants":["Clemens Buchacher"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"115128","messageId":"20090531103610.GA7913@localhost","threadId":"19615","inReplyTo":null,"subject":"[PATCH] http-push: reuse existing is_null_ref","fromName":"Clemens Buchacher","fromEmail":"drizzd@aon.at","sentAt":"2009-05-31T10:36:10Z","receivedAt":"2009-05-31T10:36:10Z","isPatch":true,"sender":{"key":"drizzd@gmx.net","avatar":"https://avatars.githubusercontent.com/u/59082?v=4"},"body":"Signed-off-by: Clemens Buchacher <drizzd@aon.at>\n---\n\nWhile we're at it, here's a trivial cleanup for http-push. Applies to both\nmaster and pu.\n\nClemens\n\n http-push.c |   21 +++++----------------\n 1 files changed, 5 insertions(+), 16 deletions(-)\n\ndiff --git a/http-push.c b/http-push.c\nindex 45e8a69..43e2dda 100644\n--- a/http-push.c\n+++ b/http-push.c\n@@ -1884,17 +1884,6 @@ static void get_dav_remote_heads(void)\n \tremote_ls(\"refs/\", (PROCESS_FILES | PROCESS_DIRS | RECURSIVE), process_ls_ref, NULL);\n }\n \n-static int is_zero_sha1(const unsigned char *sha1)\n-{\n-\tint i;\n-\n-\tfor (i = 0; i < 20; i++) {\n-\t\tif (*sha1++)\n-\t\t\treturn 0;\n-\t}\n-\treturn 1;\n-}\n-\n static void add_remote_info_ref(struct remote_ls_ctx *ls)\n {\n \tstruct strbuf *buf = (struct strbuf *)ls->userData;\n@@ -2120,13 +2109,13 @@ static int delete_remote_branch(char *pattern, int force)\n \t\t/* Remote HEAD must resolve to a known object */\n \t\tif (symref)\n \t\t\treturn error(\"Remote HEAD symrefs too deep\");\n-\t\tif (is_zero_sha1(head_sha1))\n+\t\tif (is_null_sha1(head_sha1))\n \t\t\treturn error(\"Unable to resolve remote HEAD\");\n \t\tif (!has_sha1_file(head_sha1))\n \t\t\treturn error(\"Remote HEAD resolves to object %s\\nwhich does not exist locally, perhaps you need to fetch?\", sha1_to_hex(head_sha1));\n \n \t\t/* Remote branch must resolve to a known object */\n-\t\tif (is_zero_sha1(remote_ref->old_sha1))\n+\t\tif (is_null_sha1(remote_ref->old_sha1))\n \t\t\treturn error(\"Unable to resolve remote branch %s\",\n \t\t\t\t     remote_ref->name);\n \t\tif (!has_sha1_file(remote_ref->old_sha1))\n@@ -2334,7 +2323,7 @@ int main(int argc, char **argv)\n \t\tif (!ref->peer_ref)\n \t\t\tcontinue;\n \n-\t\tif (is_zero_sha1(ref->peer_ref->new_sha1)) {\n+\t\tif (is_null_sha1(ref->peer_ref->new_sha1)) {\n \t\t\tif (delete_remote_branch(ref->name, 1) == -1) {\n \t\t\t\terror(\"Could not remove %s\", ref->name);\n \t\t\t\trc = -4;\n@@ -2350,7 +2339,7 @@ int main(int argc, char **argv)\n \t\t}\n \n \t\tif (!force_all &&\n-\t\t    !is_zero_sha1(ref->old_sha1) &&\n+\t\t    !is_null_sha1(ref->old_sha1) &&\n \t\t    !ref->force) {\n \t\t\tif (!has_sha1_file(ref->old_sha1) ||\n \t\t\t    !ref_newer(ref->peer_ref->new_sha1,\n@@ -2400,7 +2389,7 @@ int main(int argc, char **argv)\n \t\told_sha1_hex = NULL;\n \t\tcommit_argv[1] = \"--objects\";\n \t\tcommit_argv[2] = new_sha1_hex;\n-\t\tif (!push_all && !is_zero_sha1(ref->old_sha1)) {\n+\t\tif (!push_all && !is_null_sha1(ref->old_sha1)) {\n \t\t\told_sha1_hex = xmalloc(42);\n \t\t\tsprintf(old_sha1_hex, \"^%s\",\n \t\t\t\tsha1_to_hex(ref->old_sha1));\n-- \n1.6.3.1.147.g637c3\n"}]}