Code

hooks-pre-commit: use \t, rather than a literal TAB in regexp
[git.git] / builtin-blame.c
index e364b6c6c0efed272484718e502f2b5bc18e7946..8432b823e6ef6020a897838e7a561c3919c31f0b 100644 (file)
@@ -1430,8 +1430,7 @@ static void get_commit_info(struct commit *commit,
 static void write_filename_info(const char *path)
 {
        printf("filename ");
-       write_name_quoted(NULL, 0, path, 1, stdout);
-       putchar('\n');
+       write_name_quoted(path, stdout, '\n');
 }
 
 /*
@@ -2003,7 +2002,6 @@ static struct commit *fake_working_tree_commit(const char *path, const char *con
        unsigned char head_sha1[20];
        struct strbuf buf;
        const char *ident;
-       int fd;
        time_t now;
        int size, len;
        struct cache_entry *ce;
@@ -2042,11 +2040,8 @@ static struct commit *fake_working_tree_commit(const char *path, const char *con
                mode = canon_mode(st.st_mode);
                switch (st.st_mode & S_IFMT) {
                case S_IFREG:
-                       fd = open(read_from, O_RDONLY);
-                       if (fd < 0)
-                               die("cannot open %s", read_from);
-                       if (strbuf_read(&buf, fd, 0) != xsize_t(st.st_size))
-                               die("cannot read %s", read_from);
+                       if (strbuf_read_file(&buf, read_from, st.st_size) != st.st_size)
+                               die("cannot open or read %s", read_from);
                        break;
                case S_IFLNK:
                        if (readlink(read_from, buf.buf, buf.alloc) != fin_size)
@@ -2064,6 +2059,7 @@ static struct commit *fake_working_tree_commit(const char *path, const char *con
                if (strbuf_read(&buf, 0, 0) < 0)
                        die("read error %s from stdin", strerror(errno));
        }
+       convert_to_git(path, buf.buf, buf.len, &buf);
        origin->file.ptr = buf.buf;
        origin->file.size = buf.len;
        pretend_sha1_file(buf.buf, buf.len, OBJ_BLOB, origin->blob_sha1);