Merge early part of branch 'jc/diff-apply-patch'
authorJunio C Hamano <junkio@cox.net>
Thu, 19 Oct 2006 05:08:46 +0000 (22:08 -0700)
committerJunio C Hamano <junkio@cox.net>
Thu, 19 Oct 2006 05:08:46 +0000 (22:08 -0700)
1  2 
builtin-apply.c
diff --combined builtin-apply.c
index cbe597771b42e34a2a8c0a2e88e1b7baadf7a6b4,a7317d7544b3d18a5beddc69e2a92b110a7a4ba9..0bdcf63904a8c6763b316159ee139691bc04f972
@@@ -360,7 -360,7 +360,7 @@@ static int gitdiff_hdrend(const char *l
  static char *gitdiff_verify_name(const char *line, int isnull, char *orig_name, const char *oldnew)
  {
        if (!orig_name && !isnull)
-               return find_name(line, NULL, 1, 0);
+               return find_name(line, NULL, 1, TERM_TAB);
  
        if (orig_name) {
                int len;
                len = strlen(name);
                if (isnull)
                        die("git-apply: bad git-diff - expected /dev/null, got %s on line %d", name, linenr);
-               another = find_name(line, NULL, 1, 0);
+               another = find_name(line, NULL, 1, TERM_TAB);
                if (!another || memcmp(another, name, len))
                        die("git-apply: bad git-diff - inconsistent %s filename on line %d", oldnew, linenr);
                free(another);
@@@ -1783,6 -1783,8 +1783,6 @@@ static int apply_binary(struct buffer_d
  {
        const char *name = patch->old_name ? patch->old_name : patch->new_name;
        unsigned char sha1[20];
 -      unsigned char hdr[50];
 -      int hdrlen;
  
        /* For safety, we require patch index line to contain
         * full 40-byte textual SHA1 for old and new, at least for now.
                /* See if the old one matches what the patch
                 * applies to.
                 */
 -              write_sha1_file_prepare(desc->buffer, desc->size,
 -                                      blob_type, sha1, hdr, &hdrlen);
 +              hash_sha1_file(desc->buffer, desc->size, blob_type, sha1);
                if (strcmp(sha1_to_hex(sha1), patch->old_sha1_prefix))
                        return error("the patch applies to '%s' (%s), "
                                     "which does not match the "
                                     name);
  
                /* verify that the result matches */
 -              write_sha1_file_prepare(desc->buffer, desc->size, blob_type,
 -                                      sha1, hdr, &hdrlen);
 +              hash_sha1_file(desc->buffer, desc->size, blob_type, sha1);
                if (strcmp(sha1_to_hex(sha1), patch->new_sha1_prefix))
                        return error("binary patch to '%s' creates incorrect result (expecting %s, got %s)", name, patch->new_sha1_prefix, sha1_to_hex(sha1));
        }
@@@ -2108,7 -2112,7 +2108,7 @@@ static void numstat_patch_list(struct p
                        quote_c_style(name, NULL, stdout, 0);
                else
                        fputs(name, stdout);
 -              putchar('\n');
 +              putchar(line_termination);
        }
  }