From: Junio C Hamano Date: Mon, 26 Sep 2016 23:09:21 +0000 (-0700) Subject: Merge branch 'rs/checkout-init-macro' X-Git-Tag: v2.11.0-rc0~107 X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/e683f17e6319b461def179b84d20dbcca546018a?ds=inline;hp=-c Merge branch 'rs/checkout-init-macro' Code cleanup. * rs/checkout-init-macro: introduce CHECKOUT_INIT --- e683f17e6319b461def179b84d20dbcca546018a diff --combined builtin/checkout.c index f4b24a432a,4c86272087..9b2a5b31d4 --- a/builtin/checkout.c +++ b/builtin/checkout.c @@@ -239,7 -239,7 +239,7 @@@ static int checkout_paths(const struct 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 +352,6 @@@ 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; @@@ -548,7 -547,7 +547,7 @@@ static int merge_working_tree(const str * entries in the index. */ - add_files_to_cache(NULL, NULL, 0, 0); + add_files_to_cache(NULL, NULL, 0); /* * NEEDSWORK: carrying over local changes * when branches have different end-of-line @@@ -985,7 -984,7 +984,7 @@@ static int parse_branchname_arg(int arg int recover_with_dwim = dwim_new_local_branch_ok; if (!has_dash_dash && - (check_filename(NULL, arg) || !no_wildcard(arg))) + (check_filename(opts->prefix, arg) || !no_wildcard(arg))) recover_with_dwim = 0; /* * Accept "git checkout foo" and "git checkout foo --" @@@ -1038,7 -1037,7 +1037,7 @@@ if (!*source_tree) /* case (1): want a tree */ die(_("reference is not a tree: %s"), arg); - if (!has_dash_dash) {/* case (3).(d) -> (1) */ + if (!has_dash_dash) { /* case (3).(d) -> (1) */ /* * Do not complain the most common case * git checkout branch @@@ -1046,7 -1045,7 +1045,7 @@@ * it would be extremely annoying. */ if (argc) - verify_non_filename(NULL, arg); + verify_non_filename(opts->prefix, arg); } else { argcount++; argv++; diff --combined cache.h index 1a56f81f33,5d9116c0c4..ed3d5dfce1 --- a/cache.h +++ b/cache.h @@@ -367,9 -367,8 +367,9 @@@ extern void free_name_hash(struct index #define rename_cache_entry_at(pos, new_name) rename_index_entry_at(&the_index, (pos), (new_name)) #define remove_cache_entry_at(pos) remove_index_entry_at(&the_index, (pos)) #define remove_file_from_cache(path) remove_file_from_index(&the_index, (path)) -#define add_to_cache(path, st, flags) add_to_index(&the_index, (path), (st), (flags), 0) -#define add_file_to_cache(path, flags) add_file_to_index(&the_index, (path), (flags), 0) +#define add_to_cache(path, st, flags) add_to_index(&the_index, (path), (st), (flags)) +#define add_file_to_cache(path, flags) add_file_to_index(&the_index, (path), (flags)) +#define chmod_cache_entry(ce, flip) chmod_index_entry(&the_index, (ce), (flip)) #define refresh_cache(flags) refresh_index(&the_index, (flags), NULL, NULL, NULL) #define ce_match_stat(ce, st, options) ie_match_stat(&the_index, (ce), (st), (options)) #define ce_modified(ce, st, options) ie_modified(&the_index, (ce), (st), (options)) @@@ -588,10 -587,9 +588,10 @@@ extern int remove_file_from_index(struc #define ADD_CACHE_IGNORE_ERRORS 4 #define ADD_CACHE_IGNORE_REMOVAL 8 #define ADD_CACHE_INTENT 16 -extern int add_to_index(struct index_state *, const char *path, struct stat *, int flags, int force_mode); -extern int add_file_to_index(struct index_state *, const char *path, int flags, int force_mode); +extern int add_to_index(struct index_state *, const char *path, struct stat *, int flags); +extern int add_file_to_index(struct index_state *, const char *path, int flags); extern struct cache_entry *make_cache_entry(unsigned int mode, const unsigned char *sha1, const char *path, int stage, unsigned int refresh_options); +extern int chmod_index_entry(struct index_state *, struct cache_entry *ce, char flip); extern int ce_same_name(const struct cache_entry *a, const struct cache_entry *b); extern void set_object_name_for_intent_to_add_entry(struct cache_entry *ce); extern int index_name_is_other(const struct index_state *, const char *, int); @@@ -1356,6 -1354,7 +1356,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); @@@ -1860,7 -1859,7 +1861,7 @@@ void packet_trace_identity(const char * * return 0 if success, 1 - if addition of a file failed and * ADD_FILES_IGNORE_ERRORS was specified in flags */ -int add_files_to_cache(const char *prefix, const struct pathspec *pathspec, int flags, int force_mode); +int add_files_to_cache(const char *prefix, const struct pathspec *pathspec, int flags); /* diff.c */ extern int diff_auto_refresh_index;