sequencer: convert fast_forward_to to struct object_id

fast_forward_to is required for checkout_fast_fowrard, which is required for parse_tree_indirect. Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>

brian m. carlson committed May 6, 2017 at 22:10 UTC ace976b26ced2f35415119984f9d58d26b478afd
1 file changed +11 -11
sequencer.c
+11 -11
@@ -374,7 +374,7 @@ static void update_abort_safety_file(void)
374 write_file(git_path_abort_safety_file(), "%s", "");
375 }
376
377 -static int fast_forward_to(const unsigned char *to, const unsigned char *from,
377 +static int fast_forward_to(const struct object_id *to, const struct object_id *from,
378 int unborn, struct replay_opts *opts)
379 {
380 struct ref_transaction *transaction;
@@ -382,7 +382,7 @@ static int fast_forward_to(const unsigned char *to, const unsigned char *from,
382 struct strbuf err = STRBUF_INIT;
383
384 read_cache();
385 - if (checkout_fast_forward(from, to, 1))
385 + if (checkout_fast_forward(from->hash, to->hash, 1))
386 return -1; /* the callee should have complained already */
387
388 strbuf_addf(&sb, _("%s: fast-forward"), _(action_name(opts)));
@@ -390,7 +390,7 @@ static int fast_forward_to(const unsigned char *to, const unsigned char *from,
390 transaction = ref_transaction_begin(&err);
391 if (!transaction ||
392 ref_transaction_update(transaction, "HEAD",
393 - to, unborn ? null_sha1 : from,
393 + to->hash, unborn ? null_sha1 : from->hash,
394 0, sb.buf, &err) ||
395 ref_transaction_commit(transaction, &err)) {
396 ref_transaction_free(transaction);
@@ -935,7 +935,7 @@ static int do_pick_commit(enum todo_command command, struct commit *commit,
935 {
936 unsigned int flags = opts->edit ? EDIT_MSG : 0;
937 const char *msg_file = opts->edit ? NULL : git_path_merge_msg();
938 - unsigned char head[20];
938 + struct object_id head;
939 struct commit *base, *next, *parent;
940 const char *base_label, *next_label;
941 struct commit_message msg = { NULL, NULL, NULL, NULL };
@@ -949,12 +949,12 @@ static int do_pick_commit(enum todo_command command, struct commit *commit,
949 * that represents the "current" state for merge-recursive
950 * to work on.
951 */
952 - if (write_cache_as_tree(head, 0, NULL))
952 + if (write_cache_as_tree(head.hash, 0, NULL))
953 return error(_("your index file is unmerged."));
954 } else {
955 - unborn = get_sha1("HEAD", head);
955 + unborn = get_oid("HEAD", &head);
956 if (unborn)
957 - hashcpy(head, EMPTY_TREE_SHA1_BIN);
957 + oidcpy(&head, &empty_tree_oid);
958 if (index_differs_from(unborn ? EMPTY_TREE_SHA1_HEX : "HEAD", 0, 0))
959 return error_dirty_index(opts);
960 }
@@ -990,11 +990,11 @@ static int do_pick_commit(enum todo_command command, struct commit *commit,
990 oid_to_hex(&commit->object.oid));
991
992 if (opts->allow_ff && !is_fixup(command) &&
993 - ((parent && !hashcmp(parent->object.oid.hash, head)) ||
993 + ((parent && !oidcmp(&parent->object.oid, &head)) ||
994 (!parent && unborn))) {
995 if (is_rebase_i(opts))
996 write_author_script(msg.message);
997 - res = fast_forward_to(commit->object.oid.hash, head, unborn,
997 + res = fast_forward_to(&commit->object.oid, &head, unborn,
998 opts);
999 if (res || command != TODO_REWORD)
1000 goto leave;
@@ -1081,7 +1081,7 @@ static int do_pick_commit(enum todo_command command, struct commit *commit,
1081 res = -1;
1082 else if (!opts->strategy || !strcmp(opts->strategy, "recursive") || command == TODO_REVERT) {
1083 res = do_recursive_merge(base, next, base_label, next_label,
1084 - head, &msgbuf, opts);
1084 + head.hash, &msgbuf, opts);
1085 if (res < 0)
1086 return res;
1087 res |= write_message(msgbuf.buf, msgbuf.len,
@@ -1097,7 +1097,7 @@ static int do_pick_commit(enum todo_command command, struct commit *commit,
1097 commit_list_insert(next, &remotes);
1098 res |= try_merge_command(opts->strategy,
1099 opts->xopts_nr, (const char **)opts->xopts,
1100 - common, sha1_to_hex(head), remotes);
1100 + common, oid_to_hex(&head), remotes);
1101 free_commit_list(common);
1102 free_commit_list(remotes);
1103 }