From: Junio C Hamano Date: Wed, 2 Jan 2013 18:36:59 +0000 (-0800) Subject: Merge branch 'mh/ceiling' X-Git-Tag: v1.8.2-rc0~215 X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/f470e901f21d7a2b408c3e54e33e07bcc94913b1?ds=inline;hp=-c Merge branch 'mh/ceiling' An element on GIT_CEILING_DIRECTORIES list that does not name the real path to a directory (i.e. a symbolic link) could have caused the GIT_DIR discovery logic to escape the ceiling. * mh/ceiling: string_list_longest_prefix(): remove function setup_git_directory_gently_1(): resolve symlinks in ceiling paths longest_ancestor_length(): require prefix list entries to be normalized longest_ancestor_length(): take a string_list argument for prefixes longest_ancestor_length(): use string_list_split() Introduce new function real_path_if_valid() real_path_internal(): add comment explaining use of cwd Introduce new static function real_path_internal() --- f470e901f21d7a2b408c3e54e33e07bcc94913b1 diff --combined Documentation/technical/api-string-list.txt index 7386bcab3e,618400d803..20be348834 --- a/Documentation/technical/api-string-list.txt +++ b/Documentation/technical/api-string-list.txt @@@ -38,8 -38,7 +38,8 @@@ member (you need this if you add thing `unsorted_string_list_delete_item`. . Can remove items not matching a criterion from a sorted or unsorted - list using `filter_string_list`. + list using `filter_string_list`, or remove empty strings using + `string_list_remove_empty_items`. . Finally it should free the list using `string_list_clear`. @@@ -76,20 -75,6 +76,12 @@@ Function to be deleted. Preserve the order of the items that are retained. +`string_list_remove_empty_items`:: + + Remove any empty strings from the list. If free_util is true, + call free() on the util members of any items that have to be + deleted. Preserve the order of the items that are retained. + - `string_list_longest_prefix`:: - - Return the longest string within a string_list that is a - prefix (in the sense of prefixcmp()) of the specified string, - or NULL if no such prefix exists. This function does not - require the string_list to be sorted (it does a linear - search). - `print_string_list`:: Dump a string_list to stdout, useful mainly for debugging purposes. It diff --combined cache.h index 18fdd18f36,810338552d..2b192d24ac --- a/cache.h +++ b/cache.h @@@ -714,10 -714,11 +714,11 @@@ static inline int is_absolute_path(cons } int is_directory(const char *); const char *real_path(const char *path); + const char *real_path_if_valid(const char *path); const char *absolute_path(const char *path); const char *relative_path(const char *abs, const char *base); int normalize_path_copy(char *dst, const char *src); - int longest_ancestor_length(const char *path, const char *prefix_list); + int longest_ancestor_length(const char *path, struct string_list *prefixes); char *strip_path_suffix(const char *path, const char *suffix); int daemon_avoid_alias(const char *path); int offset_1st_component(const char *path); @@@ -1149,8 -1150,11 +1150,8 @@@ struct config_include_data #define CONFIG_INCLUDE_INIT { 0 } extern int git_config_include(const char *name, const char *value, void *data); -#define IDENT_NAME_GIVEN 01 -#define IDENT_MAIL_GIVEN 02 -#define IDENT_ALL_GIVEN (IDENT_NAME_GIVEN|IDENT_MAIL_GIVEN) -extern int user_ident_explicitly_given; -extern int user_ident_sufficiently_given(void); +extern int committer_ident_sufficiently_given(void); +extern int author_ident_sufficiently_given(void); extern const char *git_commit_encoding; extern const char *git_log_output_encoding; @@@ -1180,7 -1184,6 +1181,7 @@@ extern int pager_in_use(void) extern int pager_use_color; extern int term_columns(void); extern int decimal_width(int); +extern int check_pager_config(const char *cmd); extern const char *editor_program; extern const char *askpass_program; @@@ -1263,15 -1266,8 +1264,15 @@@ struct startup_info }; extern struct startup_info *startup_info; -/* builtin/merge.c */ -int checkout_fast_forward(const unsigned char *from, const unsigned char *to); +/* merge.c */ +struct commit_list; +int try_merge_command(const char *strategy, size_t xopts_nr, + const char **xopts, struct commit_list *common, + const char *head_arg, struct commit_list *remotes); +int checkout_fast_forward(const unsigned char *from, + const unsigned char *to, + int overwrite_ignore); + int sane_execvp(const char *file, char *const argv[]); diff --combined string-list.c index 397e6cfa7d,decfa747fc..480173fe6d --- a/string-list.c +++ b/string-list.c @@@ -136,35 -136,6 +136,15 @@@ void filter_string_list(struct string_l list->nr = dst; } +static int item_is_not_empty(struct string_list_item *item, void *unused) +{ + return *item->string != '\0'; +} + +void string_list_remove_empty_items(struct string_list *list, int free_util) { + filter_string_list(list, free_util, item_is_not_empty, NULL); +} + - char *string_list_longest_prefix(const struct string_list *prefixes, - const char *string) - { - int i, max_len = -1; - char *retval = NULL; - - for (i = 0; i < prefixes->nr; i++) { - char *prefix = prefixes->items[i].string; - if (!prefixcmp(string, prefix)) { - int len = strlen(prefix); - if (len > max_len) { - retval = prefix; - max_len = len; - } - } - } - - return retval; - } - void string_list_clear(struct string_list *list, int free_util) { if (list->items) { diff --combined string-list.h index c50b0d0dea,3a6a6dc392..db1284861a --- a/string-list.h +++ b/string-list.h @@@ -38,22 -38,7 +38,13 @@@ int for_each_string_list(struct string_ void filter_string_list(struct string_list *list, int free_util, string_list_each_func_t want, void *cb_data); +/* + * Remove any empty strings from the list. If free_util is true, call + * free() on the util members of any items that have to be deleted. + * Preserve the order of the items that are retained. + */ +void string_list_remove_empty_items(struct string_list *list, int free_util); - /* - * Return the longest string in prefixes that is a prefix (in the - * sense of prefixcmp()) of string, or NULL if no such prefix exists. - * This function does not require the string_list to be sorted (it - * does a linear search). - */ - char *string_list_longest_prefix(const struct string_list *prefixes, const char *string); - - /* Use these functions only on sorted lists: */ int string_list_has_string(const struct string_list *list, const char *string); int string_list_find_insert_index(const struct string_list *list, const char *string,