Merge branch 'ag/maint-apply-too-large-p'
authorJunio C Hamano <gitster@pobox.com>
Thu, 21 Jan 2010 04:28:50 +0000 (20:28 -0800)
committerJunio C Hamano <gitster@pobox.com>
Thu, 21 Jan 2010 04:28:50 +0000 (20:28 -0800)
* ag/maint-apply-too-large-p:
builtin-apply.c: Skip filenames without enough components

1  2 
builtin-apply.c
diff --combined builtin-apply.c
index 541493e1ba81462f4b01bb99c2840938bae02e4f,218363fe04bafa70ac205542c94ddc9002aec48e..b99db0b80027685190eb14bf036b8eec8e4f76b2
@@@ -404,6 -404,9 +404,9 @@@ static char *squash_slash(char *name
  {
        int i = 0, j = 0;
  
+       if (!name)
+               return NULL;
        while (name[i]) {
                if ((name[j++] = name[i++]) == '/')
                        while (name[i] == '/')
  static char *find_name(const char *line, char *def, int p_value, int terminate)
  {
        int len;
-       const char *start = line;
+       const char *start = NULL;
+       if (p_value == 0)
+               start = line;
  
        if (*line == '"') {
                struct strbuf name = STRBUF_INIT;
@@@ -1199,7 -1205,8 +1205,8 @@@ static int find_header(char *line, unsi
                                continue;
                        if (!patch->old_name && !patch->new_name) {
                                if (!patch->def_name)
-                                       die("git diff header lacks filename information (line %d)", linenr);
+                                       die("git diff header lacks filename information when removing "
+                                           "%d leading pathname components (line %d)" , p_value, linenr);
                                patch->old_name = patch->new_name = patch->def_name;
                        }
                        patch->is_toplevel_relative = 1;
@@@ -2666,7 -2673,7 +2673,7 @@@ static int verify_index_match(struct ca
                        return -1;
                return 0;
        }
 -      return ce_match_stat(ce, st, CE_MATCH_IGNORE_VALID);
 +      return ce_match_stat(ce, st, CE_MATCH_IGNORE_VALID|CE_MATCH_IGNORE_SKIP_WORKTREE);
  }
  
  static int check_preimage(struct patch *patch, struct cache_entry **ce, struct stat *st)