Skip to content

Commit 1700cb3

Browse files
mhaggergitster
authored andcommitted
write_one_ref(): rewrite to take an object_id argument
Signed-off-by: Michael Haggerty <[email protected]> Signed-off-by: brian m. carlson <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent f31ba7e commit 1700cb3

File tree

1 file changed

+5
-8
lines changed

1 file changed

+5
-8
lines changed

transport.c

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -278,8 +278,8 @@ static int fetch_objs_via_rsync(struct transport *transport,
278278
return run_command(&rsync);
279279
}
280280

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)
283283
{
284284
struct strbuf *buf = data;
285285
int len = buf->len;
@@ -291,7 +291,7 @@ static int write_one_ref(const char *name, const unsigned char *sha1,
291291

292292
strbuf_addstr(buf, name);
293293
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)))
295295
return error("problems writing temporary file %s: %s",
296296
buf->buf, strerror(errno));
297297
strbuf_setlen(buf, len);
@@ -310,7 +310,7 @@ static int write_refs_to_temp_dir(struct strbuf *temp_dir,
310310
if (dwim_ref(refspec[i], strlen(refspec[i]), oid.hash, &ref) != 1)
311311
return error("Could not get ref %s", refspec[i]);
312312

313-
if (write_one_ref(ref, oid.hash, 0, temp_dir)) {
313+
if (write_one_ref(ref, &oid, 0, temp_dir)) {
314314
free(ref);
315315
return -1;
316316
}
@@ -363,10 +363,7 @@ static int rsync_transport_push(struct transport *transport,
363363
strbuf_addch(&temp_dir, '/');
364364

365365
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))
370367
return -1;
371368
} else if (write_refs_to_temp_dir(&temp_dir, refspec_nr, refspec))
372369
return -1;

0 commit comments

Comments
 (0)