builtin/merge: switch tree functions to use object_id

The read_empty and reset_hard functions are static and their callers have already changed to use struct object_id, so convert them as well. To avoid dependency on the hash algorithm in use, switch from using EMPTY_TREE_SHA1_HEX to using empty_tree_oid_hex. Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>

brian m. carlson committed May 2, 2018 at 00:25 UTC cb91022c0e6d5e926d009156c1aea7dc137ddefd
1 file changed +7 -7
builtin/merge.c
+7 -7
@@ -280,7 +280,7 @@ out:
280 return rc;
281 }
282
283 -static void read_empty(unsigned const char *sha1, int verbose)
283 +static void read_empty(const struct object_id *oid, int verbose)
284 {
285 int i = 0;
286 const char *args[7];
@@ -290,15 +290,15 @@ static void read_empty(unsigned const char *sha1, int verbose)
290 args[i++] = "-v";
291 args[i++] = "-m";
292 args[i++] = "-u";
293 - args[i++] = EMPTY_TREE_SHA1_HEX;
294 - args[i++] = sha1_to_hex(sha1);
293 + args[i++] = empty_tree_oid_hex();
294 + args[i++] = oid_to_hex(oid);
295 args[i] = NULL;
296
297 if (run_command_v_opt(args, RUN_GIT_CMD))
298 die(_("read-tree failed"));
299 }
300
301 -static void reset_hard(unsigned const char *sha1, int verbose)
301 +static void reset_hard(const struct object_id *oid, int verbose)
302 {
303 int i = 0;
304 const char *args[6];
@@ -308,7 +308,7 @@ static void reset_hard(unsigned const char *sha1, int verbose)
308 args[i++] = "-v";
309 args[i++] = "--reset";
310 args[i++] = "-u";
311 - args[i++] = sha1_to_hex(sha1);
311 + args[i++] = oid_to_hex(oid);
312 args[i] = NULL;
313
314 if (run_command_v_opt(args, RUN_GIT_CMD))
@@ -324,7 +324,7 @@ static void restore_state(const struct object_id *head,
324 if (is_null_oid(stash))
325 return;
326
327 - reset_hard(head->hash, 1);
327 + reset_hard(head, 1);
328
329 args[2] = oid_to_hex(stash);
330
@@ -1297,7 +1297,7 @@ int cmd_merge(int argc, const char **argv, const char *prefix)
1297 if (remoteheads->next)
1298 die(_("Can merge only exactly one commit into empty head"));
1299 remote_head_oid = &remoteheads->item->object.oid;
1300 - read_empty(remote_head_oid->hash, 0);
1300 + read_empty(remote_head_oid, 0);
1301 update_ref("initial pull", "HEAD", remote_head_oid, NULL, 0,
1302 UPDATE_REFS_DIE_ON_ERR);
1303 goto done;