notes-merge: convert write_note_to_worktree to struct object_id
Signed-off-by: Brandon Williams <bmwill@google.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Brandon Williams committed
May 30, 2017 at 10:31 UTC
9e5e0c289a900186b8943741cc632ea3bb6e1510
1 file changed
+10
-10
notes-merge.c
+10
-10
@@ -292,11 +292,11 @@ static void check_notes_merge_worktree(struct notes_merge_options *o)
292
git_path(NOTES_MERGE_WORKTREE));
293
}
294
295
-static void write_buf_to_worktree(const unsigned char *obj,
295
+static void write_buf_to_worktree(const struct object_id *obj,
296
const char *buf, unsigned long size)
297
{
298
int fd;
299
- char *path = git_pathdup(NOTES_MERGE_WORKTREE "/%s", sha1_to_hex(obj));
299
+ char *path = git_pathdup(NOTES_MERGE_WORKTREE "/%s", oid_to_hex(obj));
300
if (safe_create_leading_directories_const(path))
301
die_errno("unable to create directory for '%s'", path);
302
@@ -320,19 +320,19 @@ static void write_buf_to_worktree(const unsigned char *obj,
320
free(path);
321
}
322
323
-static void write_note_to_worktree(const unsigned char *obj,
324
- const unsigned char *note)
323
+static void write_note_to_worktree(const struct object_id *obj,
324
+ const struct object_id *note)
325
{
326
enum object_type type;
327
unsigned long size;
328
- void *buf = read_sha1_file(note, &type, &size);
328
+ void *buf = read_sha1_file(note->hash, &type, &size);
329
330
if (!buf)
331
die("cannot read note %s for object %s",
332
- sha1_to_hex(note), sha1_to_hex(obj));
332
+ oid_to_hex(note), oid_to_hex(obj));
333
if (type != OBJ_BLOB)
334
die("blob expected in note %s for object %s",
335
- sha1_to_hex(note), sha1_to_hex(obj));
335
+ oid_to_hex(note), oid_to_hex(obj));
336
write_buf_to_worktree(obj, buf, size);
337
free(buf);
338
}
@@ -358,7 +358,7 @@ static int ll_merge_in_worktree(struct notes_merge_options *o,
358
if ((status < 0) || !result_buf.ptr)
359
die("Failed to execute internal merge");
360
361
- write_buf_to_worktree(p->obj.hash, result_buf.ptr, result_buf.size);
361
+ write_buf_to_worktree(&p->obj, result_buf.ptr, result_buf.size);
362
free(result_buf.ptr);
363
364
return status;
@@ -393,7 +393,7 @@ static int merge_one_change_manual(struct notes_merge_options *o,
393
"deleted in %s and modified in %s. Version from %s "
394
"left in tree.\n",
395
oid_to_hex(&p->obj), lref, rref, rref);
396
- write_note_to_worktree(p->obj.hash, p->remote.hash);
396
+ write_note_to_worktree(&p->obj, &p->remote);
397
} else if (is_null_oid(&p->remote)) {
398
/* D/F conflict, checkout p->local */
399
assert(!is_null_oid(&p->local));
@@ -402,7 +402,7 @@ static int merge_one_change_manual(struct notes_merge_options *o,
402
"deleted in %s and modified in %s. Version from %s "
403
"left in tree.\n",
404
oid_to_hex(&p->obj), rref, lref, lref);
405
- write_note_to_worktree(p->obj.hash, p->local.hash);
405
+ write_note_to_worktree(&p->obj, &p->local);
406
} else {
407
/* "regular" conflict, checkout result of ll_merge() */
408
const char *reason = "content";