write_one_ref(): rewrite to take an object_id argument

Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu> Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Michael Haggerty committed May 25, 2015 at 18:39 UTC 1700cb3b057c6d7703f2452b22f0171630988d5f
1 file changed +5 -8
transport.c
+5 -8
@@ -278,8 +278,8 @@ static int fetch_objs_via_rsync(struct transport *transport,
278 return run_command(&rsync);
279 }
280
281 -static int write_one_ref(const char *name, const unsigned char *sha1,
282 - int flags, void *data)
281 +static int write_one_ref(const char *name, const struct object_id *oid,
282 + int flags, void *data)
283 {
284 struct strbuf *buf = data;
285 int len = buf->len;
@@ -291,7 +291,7 @@ static int write_one_ref(const char *name, const unsigned char *sha1,
291
292 strbuf_addstr(buf, name);
293 if (safe_create_leading_directories(buf->buf) ||
294 - write_file(buf->buf, 0, "%s\n", sha1_to_hex(sha1)))
294 + write_file(buf->buf, 0, "%s\n", oid_to_hex(oid)))
295 return error("problems writing temporary file %s: %s",
296 buf->buf, strerror(errno));
297 strbuf_setlen(buf, len);
@@ -310,7 +310,7 @@ static int write_refs_to_temp_dir(struct strbuf *temp_dir,
310 if (dwim_ref(refspec[i], strlen(refspec[i]), oid.hash, &ref) != 1)
311 return error("Could not get ref %s", refspec[i]);
312
313 - if (write_one_ref(ref, oid.hash, 0, temp_dir)) {
313 + if (write_one_ref(ref, &oid, 0, temp_dir)) {
314 free(ref);
315 return -1;
316 }
@@ -363,10 +363,7 @@ static int rsync_transport_push(struct transport *transport,
363 strbuf_addch(&temp_dir, '/');
364
365 if (flags & TRANSPORT_PUSH_ALL) {
366 - struct each_ref_fn_sha1_adapter wrapped_write_one_ref =
367 - {write_one_ref, &temp_dir};
368 -
369 - if (for_each_ref(each_ref_fn_adapter, &wrapped_write_one_ref))
366 + if (for_each_ref(write_one_ref, &temp_dir))
367 return -1;
368 } else if (write_refs_to_temp_dir(&temp_dir, refspec_nr, refspec))
369 return -1;