diff options
author | René Scharfe <l.s.r@web.de> | 2016-09-22 18:11:33 +0200 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2016-09-22 13:42:18 -0700 |
commit | 68e3d6292f27f123c072175748183c9cb9bc1c70 (patch) | |
tree | 3a3fcb89a074a31c3f0689c207f3390612b12379 | |
parent | Fourth batch for 2.11 (diff) | |
download | tgif-68e3d6292f27f123c072175748183c9cb9bc1c70.tar.xz |
introduce CHECKOUT_INIT
Add a static initializer for struct checkout and use it throughout the
code base. It's shorter, avoids a memset(3) call and makes sure the
base_dir member is initialized to a valid (empty) string.
Signed-off-by: Rene Scharfe <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
-rw-r--r-- | apply.c | 4 | ||||
-rw-r--r-- | builtin/checkout-index.c | 2 | ||||
-rw-r--r-- | builtin/checkout.c | 3 | ||||
-rw-r--r-- | cache.h | 1 | ||||
-rw-r--r-- | unpack-trees.c | 4 |
5 files changed, 5 insertions, 9 deletions
@@ -3334,10 +3334,8 @@ static void prepare_fn_table(struct apply_state *state, struct patch *patch) static int checkout_target(struct index_state *istate, struct cache_entry *ce, struct stat *st) { - struct checkout costate; + struct checkout costate = CHECKOUT_INIT; - memset(&costate, 0, sizeof(costate)); - costate.base_dir = ""; costate.refresh_cache = 1; costate.istate = istate; if (checkout_entry(ce, &costate, NULL) || lstat(ce->name, st)) diff --git a/builtin/checkout-index.c b/builtin/checkout-index.c index 92c69672e9..30a49d9f42 100644 --- a/builtin/checkout-index.c +++ b/builtin/checkout-index.c @@ -16,7 +16,7 @@ static int checkout_stage; /* default to checkout stage0 */ static int to_tempfile; static char topath[4][TEMPORARY_FILENAME_LENGTH + 1]; -static struct checkout state; +static struct checkout state = CHECKOUT_INIT; static void write_tempfile_record(const char *name, const char *prefix) { diff --git a/builtin/checkout.c b/builtin/checkout.c index 9941abc3ac..4c86272087 100644 --- a/builtin/checkout.c +++ b/builtin/checkout.c @@ -239,7 +239,7 @@ static int checkout_paths(const struct checkout_opts *opts, const char *revision) { int pos; - struct checkout state; + struct checkout state = CHECKOUT_INIT; static char *ps_matched; struct object_id rev; struct commit *head; @@ -352,7 +352,6 @@ static int checkout_paths(const struct checkout_opts *opts, return 1; /* Now we are committed to check them out */ - memset(&state, 0, sizeof(state)); state.force = 1; state.refresh_cache = 1; state.istate = &the_index; @@ -1354,6 +1354,7 @@ struct checkout { not_new:1, refresh_cache:1; }; +#define CHECKOUT_INIT { NULL, "" } #define TEMPORARY_FILENAME_LENGTH 25 extern int checkout_entry(struct cache_entry *ce, const struct checkout *state, char *topath); diff --git a/unpack-trees.c b/unpack-trees.c index 3db3f02577..ea6bdd20e0 100644 --- a/unpack-trees.c +++ b/unpack-trees.c @@ -1094,12 +1094,10 @@ int unpack_trees(unsigned len, struct tree_desc *t, struct unpack_trees_options int i, ret; static struct cache_entry *dfc; struct exclude_list el; - struct checkout state; + struct checkout state = CHECKOUT_INIT; if (len > MAX_UNPACK_TREES) die("unpack_trees takes at most %d trees", MAX_UNPACK_TREES); - memset(&state, 0, sizeof(state)); - state.base_dir = ""; state.force = 1; state.quiet = 1; state.refresh_cache = 1; |