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
@@@ -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 --cc cache.h
Simple merge
diff --cc 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 --cc 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,