Skip to content

Commit cb91022

Browse files
bk2204gitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent d41836a commit cb91022

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

builtin/merge.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,7 @@ static int save_state(struct object_id *stash)
280280
return rc;
281281
}
282282

283-
static void read_empty(unsigned const char *sha1, int verbose)
283+
static void read_empty(const struct object_id *oid, int verbose)
284284
{
285285
int i = 0;
286286
const char *args[7];
@@ -290,15 +290,15 @@ static void read_empty(unsigned const char *sha1, int verbose)
290290
args[i++] = "-v";
291291
args[i++] = "-m";
292292
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);
295295
args[i] = NULL;
296296

297297
if (run_command_v_opt(args, RUN_GIT_CMD))
298298
die(_("read-tree failed"));
299299
}
300300

301-
static void reset_hard(unsigned const char *sha1, int verbose)
301+
static void reset_hard(const struct object_id *oid, int verbose)
302302
{
303303
int i = 0;
304304
const char *args[6];
@@ -308,7 +308,7 @@ static void reset_hard(unsigned const char *sha1, int verbose)
308308
args[i++] = "-v";
309309
args[i++] = "--reset";
310310
args[i++] = "-u";
311-
args[i++] = sha1_to_hex(sha1);
311+
args[i++] = oid_to_hex(oid);
312312
args[i] = NULL;
313313

314314
if (run_command_v_opt(args, RUN_GIT_CMD))
@@ -324,7 +324,7 @@ static void restore_state(const struct object_id *head,
324324
if (is_null_oid(stash))
325325
return;
326326

327-
reset_hard(head->hash, 1);
327+
reset_hard(head, 1);
328328

329329
args[2] = oid_to_hex(stash);
330330

@@ -1297,7 +1297,7 @@ int cmd_merge(int argc, const char **argv, const char *prefix)
12971297
if (remoteheads->next)
12981298
die(_("Can merge only exactly one commit into empty head"));
12991299
remote_head_oid = &remoteheads->item->object.oid;
1300-
read_empty(remote_head_oid->hash, 0);
1300+
read_empty(remote_head_oid, 0);
13011301
update_ref("initial pull", "HEAD", remote_head_oid, NULL, 0,
13021302
UPDATE_REFS_DIE_ON_ERR);
13031303
goto done;

0 commit comments

Comments
 (0)