@matheusbsbs / matheus-bagliano / commits / 0bf8c1f9be
Fork 0

http-push: reuse existing is_null_ref

Signed-off-by: Clemens Buchacher <drizzd@aon.at> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Clemens Buchacher committed May 31, 2009 at 12:36 UTC 0bf8c1f9be55ae9c6a592324582526778e45b8dd
1 file changed +5 -16
http-push.c
+5 -16
@@ -1884,17 +1884,6 @@ static void get_dav_remote_heads(void)
1884 remote_ls("refs/", (PROCESS_FILES | PROCESS_DIRS | RECURSIVE), process_ls_ref, NULL);
1885 }
1886
1887 -static int is_zero_sha1(const unsigned char *sha1)
1888 -{
1889 - int i;
1890 -
1891 - for (i = 0; i < 20; i++) {
1892 - if (*sha1++)
1893 - return 0;
1894 - }
1895 - return 1;
1896 -}
1897 -
1887 static void add_remote_info_ref(struct remote_ls_ctx *ls)
1888 {
1889 struct strbuf *buf = (struct strbuf *)ls->userData;
@@ -2120,13 +2109,13 @@ static int delete_remote_branch(char *pattern, int force)
2109 /* Remote HEAD must resolve to a known object */
2110 if (symref)
2111 return error("Remote HEAD symrefs too deep");
2123 - if (is_zero_sha1(head_sha1))
2112 + if (is_null_sha1(head_sha1))
2113 return error("Unable to resolve remote HEAD");
2114 if (!has_sha1_file(head_sha1))
2115 return error("Remote HEAD resolves to object %s\nwhich does not exist locally, perhaps you need to fetch?", sha1_to_hex(head_sha1));
2116
2117 /* Remote branch must resolve to a known object */
2129 - if (is_zero_sha1(remote_ref->old_sha1))
2118 + if (is_null_sha1(remote_ref->old_sha1))
2119 return error("Unable to resolve remote branch %s",
2120 remote_ref->name);
2121 if (!has_sha1_file(remote_ref->old_sha1))
@@ -2334,7 +2323,7 @@ int main(int argc, char **argv)
2323 if (!ref->peer_ref)
2324 continue;
2325
2337 - if (is_zero_sha1(ref->peer_ref->new_sha1)) {
2326 + if (is_null_sha1(ref->peer_ref->new_sha1)) {
2327 if (delete_remote_branch(ref->name, 1) == -1) {
2328 error("Could not remove %s", ref->name);
2329 rc = -4;
@@ -2350,7 +2339,7 @@ int main(int argc, char **argv)
2339 }
2340
2341 if (!force_all &&
2353 - !is_zero_sha1(ref->old_sha1) &&
2342 + !is_null_sha1(ref->old_sha1) &&
2343 !ref->force) {
2344 if (!has_sha1_file(ref->old_sha1) ||
2345 !ref_newer(ref->peer_ref->new_sha1,
@@ -2400,7 +2389,7 @@ int main(int argc, char **argv)
2389 old_sha1_hex = NULL;
2390 commit_argv[1] = "--objects";
2391 commit_argv[2] = new_sha1_hex;
2403 - if (!push_all && !is_zero_sha1(ref->old_sha1)) {
2392 + if (!push_all && !is_null_sha1(ref->old_sha1)) {
2393 old_sha1_hex = xmalloc(42);
2394 sprintf(old_sha1_hex, "^%s",
2395 sha1_to_hex(ref->old_sha1));