Skip to content

Commit e683f17

Browse files
committed
Merge branch 'rs/checkout-init-macro'
Code cleanup. * rs/checkout-init-macro: introduce CHECKOUT_INIT
2 parents 48b2181 + 68e3d62 commit e683f17

File tree

5 files changed

+5
-9
lines changed

5 files changed

+5
-9
lines changed

apply.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3334,10 +3334,8 @@ static void prepare_fn_table(struct apply_state *state, struct patch *patch)
33343334
static int checkout_target(struct index_state *istate,
33353335
struct cache_entry *ce, struct stat *st)
33363336
{
3337-
struct checkout costate;
3337+
struct checkout costate = CHECKOUT_INIT;
33383338

3339-
memset(&costate, 0, sizeof(costate));
3340-
costate.base_dir = "";
33413339
costate.refresh_cache = 1;
33423340
costate.istate = istate;
33433341
if (checkout_entry(ce, &costate, NULL) || lstat(ce->name, st))

builtin/checkout-index.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ static int checkout_stage; /* default to checkout stage0 */
1616
static int to_tempfile;
1717
static char topath[4][TEMPORARY_FILENAME_LENGTH + 1];
1818

19-
static struct checkout state;
19+
static struct checkout state = CHECKOUT_INIT;
2020

2121
static void write_tempfile_record(const char *name, const char *prefix)
2222
{

builtin/checkout.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ static int checkout_paths(const struct checkout_opts *opts,
239239
const char *revision)
240240
{
241241
int pos;
242-
struct checkout state;
242+
struct checkout state = CHECKOUT_INIT;
243243
static char *ps_matched;
244244
struct object_id rev;
245245
struct commit *head;
@@ -352,7 +352,6 @@ static int checkout_paths(const struct checkout_opts *opts,
352352
return 1;
353353

354354
/* Now we are committed to check them out */
355-
memset(&state, 0, sizeof(state));
356355
state.force = 1;
357356
state.refresh_cache = 1;
358357
state.istate = &the_index;

cache.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1356,6 +1356,7 @@ struct checkout {
13561356
not_new:1,
13571357
refresh_cache:1;
13581358
};
1359+
#define CHECKOUT_INIT { NULL, "" }
13591360

13601361
#define TEMPORARY_FILENAME_LENGTH 25
13611362
extern int checkout_entry(struct cache_entry *ce, const struct checkout *state, char *topath);

unpack-trees.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1094,12 +1094,10 @@ int unpack_trees(unsigned len, struct tree_desc *t, struct unpack_trees_options
10941094
int i, ret;
10951095
static struct cache_entry *dfc;
10961096
struct exclude_list el;
1097-
struct checkout state;
1097+
struct checkout state = CHECKOUT_INIT;
10981098

10991099
if (len > MAX_UNPACK_TREES)
11001100
die("unpack_trees takes at most %d trees", MAX_UNPACK_TREES);
1101-
memset(&state, 0, sizeof(state));
1102-
state.base_dir = "";
11031101
state.force = 1;
11041102
state.quiet = 1;
11051103
state.refresh_cache = 1;

0 commit comments

Comments
 (0)