Merge branch 'mh/ceiling' into maint
authorJunio C Hamano <gitster@pobox.com>
Mon, 28 Jan 2013 19:07:18 +0000 (11:07 -0800)
committerJunio C Hamano <gitster@pobox.com>
Mon, 28 Jan 2013 19:07:18 +0000 (11:07 -0800)
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()

1  2 
Documentation/technical/api-string-list.txt
cache.h
string-list.c
string-list.h
index 7386bcab3ec30a06f4663c953fa46e78ed26c07b,618400d803b062e7c5d4d3421658045c933ee4fb..20be3488349c2ddbafbd90c0200f2a7d3862a12f
@@@ -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_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).
 +`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.
 +
  `print_string_list`::
  
        Dump a string_list to stdout, useful mainly for debugging purposes. It
diff --combined cache.h
index 18fdd18f3674b1d7c62de65509bdb7bc57743395,810338552d22607be350e4658e739d35dfe54493..2b192d24ac63181b0bba08805c09f004af8ef1dc
+++ 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 397e6cfa7db82bdb17f7cdbe4662a1607c0773af,decfa747fcc8b9c400433dea3e202ff154b3a034..480173fe6dbee5428e3b135ff27ba7551c527ad8
@@@ -136,35 -136,6 +136,15 @@@ void filter_string_list(struct string_l
        list->nr = dst;
  }
  
- 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;
- }
 +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);
 +}
 +
  void string_list_clear(struct string_list *list, int free_util)
  {
        if (list->items) {
diff --combined string-list.h
index c50b0d0deac086cd5a50a5c021103a5f5e76c1cd,3a6a6dc3929964bce91b069bed62e823b3f8ac6c..db1284861adb707b675714edc1ecacf9357f6661
@@@ -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,