Skip to content

Commit 9397f3c

Browse files
avarttaylorr
authored andcommitted
merge: remove always-the-same "verbose" arguments
Simplify the code that builds the arguments for the "read-tree" invocation in reset_hard() and read_empty() to remove the "verbose" parameter. Before 172b642 (do not overwrite untracked during merge from unborn branch, 2010-11-14) there was a "reset_hard()" function that would be called in two places, one of those passed a "verbose=1", the other a "verbose=0". After 172b642 when read_empty() was split off from reset_hard() both of these functions only had one caller. The "verbose" in read_empty() would always be false, and the one in reset_hard() would always be true. There was never a good reason for the code to act this way, it happened because the read_empty() function was a copy/pasted and adjusted version of reset_hard(). Since we're no longer conditionally adding the "-v" parameter here (and we'd only add it for "reset_hard()" we'll be able to move to a simpler and safer run-command API in the subsequent commit. Signed-off-by: Ævar Arnfjörð Bjarmason <[email protected]> Signed-off-by: René Scharfe <[email protected]> Signed-off-by: Taylor Blau <[email protected]>
1 parent db29e6b commit 9397f3c

File tree

1 file changed

+5
-8
lines changed

1 file changed

+5
-8
lines changed

builtin/merge.c

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -345,14 +345,12 @@ static int save_state(struct object_id *stash)
345345
return rc;
346346
}
347347

348-
static void read_empty(const struct object_id *oid, int verbose)
348+
static void read_empty(const struct object_id *oid)
349349
{
350350
int i = 0;
351351
const char *args[7];
352352

353353
args[i++] = "read-tree";
354-
if (verbose)
355-
args[i++] = "-v";
356354
args[i++] = "-m";
357355
args[i++] = "-u";
358356
args[i++] = empty_tree_oid_hex();
@@ -363,14 +361,13 @@ static void read_empty(const struct object_id *oid, int verbose)
363361
die(_("read-tree failed"));
364362
}
365363

366-
static void reset_hard(const struct object_id *oid, int verbose)
364+
static void reset_hard(const struct object_id *oid)
367365
{
368366
int i = 0;
369367
const char *args[6];
370368

371369
args[i++] = "read-tree";
372-
if (verbose)
373-
args[i++] = "-v";
370+
args[i++] = "-v";
374371
args[i++] = "--reset";
375372
args[i++] = "-u";
376373
args[i++] = oid_to_hex(oid);
@@ -385,7 +382,7 @@ static void restore_state(const struct object_id *head,
385382
{
386383
struct strvec args = STRVEC_INIT;
387384

388-
reset_hard(head, 1);
385+
reset_hard(head);
389386

390387
if (is_null_oid(stash))
391388
goto refresh_cache;
@@ -1470,7 +1467,7 @@ int cmd_merge(int argc, const char **argv, const char *prefix)
14701467
check_trust_level);
14711468

14721469
remote_head_oid = &remoteheads->item->object.oid;
1473-
read_empty(remote_head_oid, 0);
1470+
read_empty(remote_head_oid);
14741471
update_ref("initial pull", "HEAD", remote_head_oid, NULL, 0,
14751472
UPDATE_REFS_DIE_ON_ERR);
14761473
goto done;

0 commit comments

Comments
 (0)