Code

user-manual: edit "ignoring files" for conciseness
[git.git] / diff.c
diff --git a/diff.c b/diff.c
index 8354e71e0707960f7a1094e288bea0fac83ec6b8..da992dd4851dd67ab9a307c1b08ebed442e406cb 100644 (file)
--- a/diff.c
+++ b/diff.c
@@ -186,13 +186,11 @@ static const char *external_diff(void)
        return external_diff_cmd;
 }
 
-#define TEMPFILE_PATH_LEN              50
-
 static struct diff_tempfile {
        const char *name; /* filename external diff should read from */
        char hex[41];
        char mode[10];
-       char tmp_path[TEMPFILE_PATH_LEN];
+       char tmp_path[PATH_MAX];
 } diff_temp[2];
 
 static int count_lines(const char *data, int size)
@@ -1109,10 +1107,8 @@ static void setup_diff_attr_check(struct git_attr_check *check)
        check->attr = attr_diff;
 }
 
-#define FIRST_FEW_BYTES 8000
 static int file_is_binary(struct diff_filespec *one)
 {
-       unsigned long sz;
        struct git_attr_check attr_diff_check;
 
        setup_diff_attr_check(&attr_diff_check);
@@ -1129,10 +1125,7 @@ static int file_is_binary(struct diff_filespec *one)
                        return 0;
                diff_populate_filespec(one, 0);
        }
-       sz = one->size;
-       if (FIRST_FEW_BYTES < sz)
-               sz = FIRST_FEW_BYTES;
-       return !!memchr(one->data, 0, sz);
+       return buffer_is_binary(one->data, one->size);
 }
 
 static void builtin_diff(const char *name_a,
@@ -1351,7 +1344,7 @@ void fill_filespec(struct diff_filespec *spec, const unsigned char *sha1,
 }
 
 /*
- * Given a name and sha1 pair, if the dircache tells us the file in
+ * Given a name and sha1 pair, if the index tells us the file in
  * the work tree has that object contents, return true, so that
  * prepare_temp_file() does not have to inflate and extract.
  */
@@ -1411,7 +1404,7 @@ static int populate_from_stdin(struct diff_filespec *s)
 #define INCREMENT 1024
        char *buf;
        unsigned long size;
-       int got;
+       ssize_t got;
 
        size = 0;
        buf = NULL;
@@ -1561,7 +1554,7 @@ static void prep_temp_blob(struct diff_tempfile *temp,
 {
        int fd;
 
-       fd = git_mkstemp(temp->tmp_path, TEMPFILE_PATH_LEN, ".diff_XXXXXX");
+       fd = git_mkstemp(temp->tmp_path, PATH_MAX, ".diff_XXXXXX");
        if (fd < 0)
                die("unable to create temp-file");
        if (write_in_full(fd, blob, size) != size)
@@ -2414,7 +2407,8 @@ static void diff_flush_raw(struct diff_filepair *p,
                printf("%s ",
                       diff_unique_abbrev(p->two->sha1, abbrev));
        }
-       printf("%s%c%s", status, inter_name_termination, path_one);
+       printf("%s%c%s", status, inter_name_termination,
+                       two_paths || p->one->mode ?  path_one : path_two);
        if (two_paths)
                printf("%c%s", inter_name_termination, path_two);
        putchar(line_termination);