зеркало из https://github.com/microsoft/git.git
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>
This commit is contained in:
Родитель
4d77896eeb
Коммит
9e5e0c289a
|
@ -292,11 +292,11 @@ static void check_notes_merge_worktree(struct notes_merge_options *o)
|
||||||
git_path(NOTES_MERGE_WORKTREE));
|
git_path(NOTES_MERGE_WORKTREE));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void write_buf_to_worktree(const unsigned char *obj,
|
static void write_buf_to_worktree(const struct object_id *obj,
|
||||||
const char *buf, unsigned long size)
|
const char *buf, unsigned long size)
|
||||||
{
|
{
|
||||||
int fd;
|
int fd;
|
||||||
char *path = git_pathdup(NOTES_MERGE_WORKTREE "/%s", sha1_to_hex(obj));
|
char *path = git_pathdup(NOTES_MERGE_WORKTREE "/%s", oid_to_hex(obj));
|
||||||
if (safe_create_leading_directories_const(path))
|
if (safe_create_leading_directories_const(path))
|
||||||
die_errno("unable to create directory for '%s'", path);
|
die_errno("unable to create directory for '%s'", path);
|
||||||
|
|
||||||
|
@ -320,19 +320,19 @@ static void write_buf_to_worktree(const unsigned char *obj,
|
||||||
free(path);
|
free(path);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void write_note_to_worktree(const unsigned char *obj,
|
static void write_note_to_worktree(const struct object_id *obj,
|
||||||
const unsigned char *note)
|
const struct object_id *note)
|
||||||
{
|
{
|
||||||
enum object_type type;
|
enum object_type type;
|
||||||
unsigned long size;
|
unsigned long size;
|
||||||
void *buf = read_sha1_file(note, &type, &size);
|
void *buf = read_sha1_file(note->hash, &type, &size);
|
||||||
|
|
||||||
if (!buf)
|
if (!buf)
|
||||||
die("cannot read note %s for object %s",
|
die("cannot read note %s for object %s",
|
||||||
sha1_to_hex(note), sha1_to_hex(obj));
|
oid_to_hex(note), oid_to_hex(obj));
|
||||||
if (type != OBJ_BLOB)
|
if (type != OBJ_BLOB)
|
||||||
die("blob expected in note %s for object %s",
|
die("blob expected in note %s for object %s",
|
||||||
sha1_to_hex(note), sha1_to_hex(obj));
|
oid_to_hex(note), oid_to_hex(obj));
|
||||||
write_buf_to_worktree(obj, buf, size);
|
write_buf_to_worktree(obj, buf, size);
|
||||||
free(buf);
|
free(buf);
|
||||||
}
|
}
|
||||||
|
@ -358,7 +358,7 @@ static int ll_merge_in_worktree(struct notes_merge_options *o,
|
||||||
if ((status < 0) || !result_buf.ptr)
|
if ((status < 0) || !result_buf.ptr)
|
||||||
die("Failed to execute internal merge");
|
die("Failed to execute internal merge");
|
||||||
|
|
||||||
write_buf_to_worktree(p->obj.hash, result_buf.ptr, result_buf.size);
|
write_buf_to_worktree(&p->obj, result_buf.ptr, result_buf.size);
|
||||||
free(result_buf.ptr);
|
free(result_buf.ptr);
|
||||||
|
|
||||||
return status;
|
return status;
|
||||||
|
@ -393,7 +393,7 @@ static int merge_one_change_manual(struct notes_merge_options *o,
|
||||||
"deleted in %s and modified in %s. Version from %s "
|
"deleted in %s and modified in %s. Version from %s "
|
||||||
"left in tree.\n",
|
"left in tree.\n",
|
||||||
oid_to_hex(&p->obj), lref, rref, rref);
|
oid_to_hex(&p->obj), lref, rref, rref);
|
||||||
write_note_to_worktree(p->obj.hash, p->remote.hash);
|
write_note_to_worktree(&p->obj, &p->remote);
|
||||||
} else if (is_null_oid(&p->remote)) {
|
} else if (is_null_oid(&p->remote)) {
|
||||||
/* D/F conflict, checkout p->local */
|
/* D/F conflict, checkout p->local */
|
||||||
assert(!is_null_oid(&p->local));
|
assert(!is_null_oid(&p->local));
|
||||||
|
@ -402,7 +402,7 @@ static int merge_one_change_manual(struct notes_merge_options *o,
|
||||||
"deleted in %s and modified in %s. Version from %s "
|
"deleted in %s and modified in %s. Version from %s "
|
||||||
"left in tree.\n",
|
"left in tree.\n",
|
||||||
oid_to_hex(&p->obj), rref, lref, lref);
|
oid_to_hex(&p->obj), rref, lref, lref);
|
||||||
write_note_to_worktree(p->obj.hash, p->local.hash);
|
write_note_to_worktree(&p->obj, &p->local);
|
||||||
} else {
|
} else {
|
||||||
/* "regular" conflict, checkout result of ll_merge() */
|
/* "regular" conflict, checkout result of ll_merge() */
|
||||||
const char *reason = "content";
|
const char *reason = "content";
|
||||||
|
|
Загрузка…
Ссылка в новой задаче