summaryrefslogtreecommitdiff
path: root/builtin/merge.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2015-12-10 20:36:13 (GMT)
committerJunio C Hamano <gitster@pobox.com>2015-12-10 20:36:13 (GMT)
commit844a9ce47208de173341525c15a4c8c689dd278e (patch)
treed771915b28609179ddf1f3f911bcb30b7019d7cf /builtin/merge.c
parentb12a966eff3f66337f83c117dbab8fa0cca16e4b (diff)
parentfcd30b138759a2ab5ecb55758c3341f0d608df2b (diff)
downloadgit-844a9ce47208de173341525c15a4c8c689dd278e.zip
git-844a9ce47208de173341525c15a4c8c689dd278e.tar.gz
git-844a9ce47208de173341525c15a4c8c689dd278e.tar.bz2
Merge branch 'bc/object-id'
More transition from "unsigned char[40]" to "struct object_id". This needed a few merge fixups, but is mostly disentangled from other topics. * bc/object-id: remote: convert functions to struct object_id Remove get_object_hash. Convert struct object to object_id Add several uses of get_object_hash. object: introduce get_object_hash macro. ref_newer: convert to use struct object_id push_refs_with_export: convert to struct object_id get_remote_heads: convert to struct object_id parse_fetch: convert to use struct object_id add_sought_entry_mem: convert to struct object_id Convert struct ref to use object_id. sha1_file: introduce has_object_file helper.
Diffstat (limited to 'builtin/merge.c')
-rw-r--r--builtin/merge.c60
1 files changed, 30 insertions, 30 deletions
diff --git a/builtin/merge.c b/builtin/merge.c
index bbf3110..15bf95b 100644
--- a/builtin/merge.c
+++ b/builtin/merge.c
@@ -365,7 +365,7 @@ static void squash_message(struct commit *commit, struct commit_list *remotehead
while ((commit = get_revision(&rev)) != NULL) {
strbuf_addch(&out, '\n');
strbuf_addf(&out, "commit %s\n",
- sha1_to_hex(commit->object.sha1));
+ oid_to_hex(&commit->object.oid));
pretty_print_commit(&ctx, commit, &out);
}
if (write_in_full(fd, out.buf, out.len) != out.len)
@@ -380,7 +380,7 @@ static void finish(struct commit *head_commit,
const unsigned char *new_head, const char *msg)
{
struct strbuf reflog_message = STRBUF_INIT;
- const unsigned char *head = head_commit->object.sha1;
+ const unsigned char *head = head_commit->object.oid.hash;
if (!msg)
strbuf_addstr(&reflog_message, getenv("GIT_REFLOG_ACTION"));
@@ -497,7 +497,7 @@ static void merge_name(const char *remote, struct strbuf *msg)
if (ref_exists(truname.buf)) {
strbuf_addf(msg,
"%s\t\tbranch '%s'%s of .\n",
- sha1_to_hex(remote_head->object.sha1),
+ sha1_to_hex(remote_head->object.oid.hash),
truname.buf + 11,
(early ? " (early part)" : ""));
strbuf_release(&truname);
@@ -511,7 +511,7 @@ static void merge_name(const char *remote, struct strbuf *msg)
desc = merge_remote_util(remote_head);
if (desc && desc->obj && desc->obj->type == OBJ_TAG) {
strbuf_addf(msg, "%s\t\t%s '%s'\n",
- sha1_to_hex(desc->obj->sha1),
+ sha1_to_hex(desc->obj->oid.hash),
typename(desc->obj->type),
remote);
goto cleanup;
@@ -519,7 +519,7 @@ static void merge_name(const char *remote, struct strbuf *msg)
}
strbuf_addf(msg, "%s\t\tcommit '%s'\n",
- sha1_to_hex(remote_head->object.sha1), remote);
+ sha1_to_hex(remote_head->object.oid.hash), remote);
cleanup:
strbuf_release(&buf);
strbuf_release(&bname);
@@ -892,7 +892,7 @@ static struct commit *is_old_style_invocation(int argc, const char **argv,
second_token = lookup_commit_reference_gently(second_sha1, 0);
if (!second_token)
die(_("'%s' is not a commit"), argv[1]);
- if (hashcmp(second_token->object.sha1, head))
+ if (hashcmp(second_token->object.oid.hash, head))
return NULL;
}
return second_token;
@@ -958,14 +958,14 @@ static void write_merge_state(struct commit_list *remoteheads)
struct strbuf buf = STRBUF_INIT;
for (j = remoteheads; j; j = j->next) {
- unsigned const char *sha1;
+ struct object_id *oid;
struct commit *c = j->item;
if (c->util && merge_remote_util(c)->obj) {
- sha1 = merge_remote_util(c)->obj->sha1;
+ oid = &merge_remote_util(c)->obj->oid;
} else {
- sha1 = c->object.sha1;
+ oid = &c->object.oid;
}
- strbuf_addf(&buf, "%s\n", sha1_to_hex(sha1));
+ strbuf_addf(&buf, "%s\n", oid_to_hex(oid));
}
filename = git_path_merge_head();
fd = open(filename, O_WRONLY | O_CREAT, 0666);
@@ -1274,8 +1274,8 @@ int cmd_merge(int argc, const char **argv, const char *prefix)
die(_("%s - not something we can merge"), argv[0]);
if (remoteheads->next)
die(_("Can merge only exactly one commit into empty head"));
- read_empty(remote_head->object.sha1, 0);
- update_ref("initial pull", "HEAD", remote_head->object.sha1,
+ read_empty(remote_head->object.oid.hash, 0);
+ update_ref("initial pull", "HEAD", remote_head->object.oid.hash,
NULL, 0, UPDATE_REFS_DIE_ON_ERR);
goto done;
}
@@ -1289,7 +1289,7 @@ int cmd_merge(int argc, const char **argv, const char *prefix)
* additional safety measure to check for it.
*/
if (!have_message &&
- is_old_style_invocation(argc, argv, head_commit->object.sha1)) {
+ is_old_style_invocation(argc, argv, head_commit->object.oid.hash)) {
warning("old-style 'git merge <msg> HEAD <commit>' is deprecated.");
strbuf_addstr(&merge_msg, argv[0]);
head_arg = argv[1];
@@ -1323,7 +1323,7 @@ int cmd_merge(int argc, const char **argv, const char *prefix)
check_commit_signature(commit, &signature_check);
- find_unique_abbrev_r(hex, commit->object.sha1, DEFAULT_ABBREV);
+ find_unique_abbrev_r(hex, commit->object.oid.hash, DEFAULT_ABBREV);
switch (signature_check.result) {
case 'G':
break;
@@ -1353,7 +1353,7 @@ int cmd_merge(int argc, const char **argv, const char *prefix)
for (p = remoteheads; p; p = p->next) {
struct commit *commit = p->item;
strbuf_addf(&buf, "GITHEAD_%s",
- sha1_to_hex(commit->object.sha1));
+ sha1_to_hex(commit->object.oid.hash));
setenv(buf.buf, merge_remote_util(commit)->name, 1);
strbuf_reset(&buf);
if (fast_forward != FF_ONLY &&
@@ -1393,7 +1393,7 @@ int cmd_merge(int argc, const char **argv, const char *prefix)
free(list);
}
- update_ref("updating ORIG_HEAD", "ORIG_HEAD", head_commit->object.sha1,
+ update_ref("updating ORIG_HEAD", "ORIG_HEAD", head_commit->object.oid.hash,
NULL, 0, UPDATE_REFS_DIE_ON_ERR);
if (remoteheads && !common)
@@ -1409,16 +1409,16 @@ int cmd_merge(int argc, const char **argv, const char *prefix)
goto done;
} else if (fast_forward != FF_NO && !remoteheads->next &&
!common->next &&
- !hashcmp(common->item->object.sha1, head_commit->object.sha1)) {
+ !hashcmp(common->item->object.oid.hash, head_commit->object.oid.hash)) {
/* Again the most common case of merging one remote. */
struct strbuf msg = STRBUF_INIT;
struct commit *commit;
if (verbosity >= 0) {
char from[GIT_SHA1_HEXSZ + 1], to[GIT_SHA1_HEXSZ + 1];
- find_unique_abbrev_r(from, head_commit->object.sha1,
+ find_unique_abbrev_r(from, head_commit->object.oid.hash,
DEFAULT_ABBREV);
- find_unique_abbrev_r(to, remoteheads->item->object.sha1,
+ find_unique_abbrev_r(to, remoteheads->item->object.oid.hash,
DEFAULT_ABBREV);
printf(_("Updating %s..%s\n"), from, to);
}
@@ -1432,14 +1432,14 @@ int cmd_merge(int argc, const char **argv, const char *prefix)
goto done;
}
- if (checkout_fast_forward(head_commit->object.sha1,
- commit->object.sha1,
+ if (checkout_fast_forward(head_commit->object.oid.hash,
+ commit->object.oid.hash,
overwrite_ignore)) {
ret = 1;
goto done;
}
- finish(head_commit, remoteheads, commit->object.sha1, msg.buf);
+ finish(head_commit, remoteheads, commit->object.oid.hash, msg.buf);
drop_save();
goto done;
} else if (!remoteheads->next && common->next)
@@ -1458,9 +1458,9 @@ int cmd_merge(int argc, const char **argv, const char *prefix)
/* See if it is really trivial. */
git_committer_info(IDENT_STRICT);
printf(_("Trying really trivial in-index merge...\n"));
- if (!read_tree_trivial(common->item->object.sha1,
- head_commit->object.sha1,
- remoteheads->item->object.sha1)) {
+ if (!read_tree_trivial(common->item->object.oid.hash,
+ head_commit->object.oid.hash,
+ remoteheads->item->object.oid.hash)) {
ret = merge_trivial(head_commit, remoteheads);
goto done;
}
@@ -1483,8 +1483,8 @@ int cmd_merge(int argc, const char **argv, const char *prefix)
* HEAD^^" would be missed.
*/
common_one = get_merge_bases(head_commit, j->item);
- if (hashcmp(common_one->item->object.sha1,
- j->item->object.sha1)) {
+ if (hashcmp(common_one->item->object.oid.hash,
+ j->item->object.oid.hash)) {
up_to_date = 0;
break;
}
@@ -1520,7 +1520,7 @@ int cmd_merge(int argc, const char **argv, const char *prefix)
int ret;
if (i) {
printf(_("Rewinding the tree to pristine...\n"));
- restore_state(head_commit->object.sha1, stash);
+ restore_state(head_commit->object.oid.hash, stash);
}
if (use_strategies_nr != 1)
printf(_("Trying merge strategy %s...\n"),
@@ -1586,7 +1586,7 @@ int cmd_merge(int argc, const char **argv, const char *prefix)
* it up.
*/
if (!best_strategy) {
- restore_state(head_commit->object.sha1, stash);
+ restore_state(head_commit->object.oid.hash, stash);
if (use_strategies_nr > 1)
fprintf(stderr,
_("No merge strategy handled the merge.\n"));
@@ -1599,7 +1599,7 @@ int cmd_merge(int argc, const char **argv, const char *prefix)
; /* We already have its result in the working tree. */
else {
printf(_("Rewinding the tree to pristine...\n"));
- restore_state(head_commit->object.sha1, stash);
+ restore_state(head_commit->object.oid.hash, stash);
printf(_("Using the %s to prepare resolving by hand.\n"),
best_strategy);
try_merge_strategy(best_strategy, common, remoteheads,