Merge branch 'nd/maint-relative' into maint
authorJunio C Hamano <gitster@pobox.com>
Wed, 19 Jan 2011 16:25:31 +0000 (08:25 -0800)
committerJunio C Hamano <gitster@pobox.com>
Wed, 19 Jan 2011 16:25:31 +0000 (08:25 -0800)
* nd/maint-relative:
get_cwd_relative(): do not misinterpret root path

1  2 
dir.c
diff --combined dir.c
index b2dfb69eb5606a7538cc5e1876a91f703ec4969c,ee9299db0536e14a6fdb78f3f5a25ea62aaf6075..b68750450cdec89df9ea7595ab9a7022619e6e58
--- 1/dir.c
--- 2/dir.c
+++ b/dir.c
@@@ -232,7 -232,7 +232,7 @@@ int add_excludes_from_file_to_list(cons
  {
        struct stat st;
        int fd, i;
 -      size_t size;
 +      size_t size = 0;
        char *buf, *entry;
  
        fd = open(fname, O_RDONLY);
@@@ -360,8 -360,7 +360,8 @@@ int excluded_from_list(const char *path
  
                        if (x->flags & EXC_FLAG_MUSTBEDIR) {
                                if (!dtype) {
 -                                      if (!prefixcmp(pathname, exclude))
 +                                      if (!prefixcmp(pathname, exclude) &&
 +                                          pathname[x->patternlen] == '/')
                                                return to_exclude;
                                        else
                                                continue;
@@@ -454,7 -453,7 +454,7 @@@ static struct dir_entry *dir_add_name(s
        return dir->entries[dir->nr++] = dir_entry_new(pathname, len);
  }
  
 -static struct dir_entry *dir_add_ignored(struct dir_struct *dir, const char *pathname, int len)
 +struct dir_entry *dir_add_ignored(struct dir_struct *dir, const char *pathname, int len)
  {
        if (!cache_name_is_other(pathname, len))
                return NULL;
  enum exist_status {
        index_nonexistent = 0,
        index_directory,
 -      index_gitdir,
 +      index_gitdir
  };
  
  /*
@@@ -534,7 -533,7 +534,7 @@@ static enum exist_status directory_exis
  enum directory_treatment {
        show_directory,
        ignore_directory,
 -      recurse_into_directory,
 +      recurse_into_directory
  };
  
  static enum directory_treatment treat_directory(struct dir_struct *dir,
@@@ -685,7 -684,7 +685,7 @@@ static int get_dtype(struct dirent *de
  enum path_treatment {
        path_ignored,
        path_handled,
 -      path_recurse,
 +      path_recurse
  };
  
  static enum path_treatment treat_one_path(struct dir_struct *dir,
@@@ -965,6 -964,12 +965,12 @@@ char *get_relative_cwd(char *buffer, in
        case '/':
                return cwd + 1;
        default:
+               /*
+                * dir can end with a path separator when it's root
+                * directory. Return proper prefix in that case.
+                */
+               if (dir[-1] == '/')
+                       return cwd;
                return NULL;
        }
  }