Code

Mark places that need blob munging later for CRLF conversion.
authorLinus Torvalds <torvalds@linux-foundation.org>
Tue, 13 Feb 2007 17:23:59 +0000 (09:23 -0800)
committerJunio C Hamano <junkio@cox.net>
Tue, 13 Feb 2007 18:12:37 +0000 (10:12 -0800)
Here's a patch that I think we can merge right now. There may be
other places that need this, but this at least points out the
three places that read/write working tree files for git
update-index, checkout and diff respectively. That should cover
a lot of it [jc: git-apply uses an entirely different codepath
both for reading and writing].

Some day we can actually implement it. In the meantime, this
points out a place for people to start. We *can* even start with
a really simple "we do CRLF conversion automatically, regardless
of filename" kind of approach, that just look at the data (all
three cases have the _full_ file data already in memory) and
says "ok, this is text, so let's convert to/from DOS format
directly".

THAT somebody can write in ten minutes, and it would already
make git much nicer on a DOS/Windows platform, I suspect.

And it would be totally zero-cost if you just make it a config
option (but please make it dynamic with the _default_ just being
0/1 depending on whether it's UNIX/Windows, just so that UNIX
people can _test_ it easily).

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Junio C Hamano <junkio@cox.net>
diff.c
entry.c
sha1_file.c

diff --git a/diff.c b/diff.c
index aaab3095a5f44d5d835bda4bc60112481bf94ed9..13b9b6c5602cc1aca4a95ed4d292756d3380c543 100644 (file)
--- a/diff.c
+++ b/diff.c
@@ -1364,6 +1364,7 @@ int diff_populate_filespec(struct diff_filespec *s, int size_only)
                s->data = xmmap(NULL, s->size, PROT_READ, MAP_PRIVATE, fd, 0);
                close(fd);
                s->should_munmap = 1;
+               /* FIXME! CRLF -> LF conversion goes here, based on "s->path" */
        }
        else {
                char type[20];
diff --git a/entry.c b/entry.c
index 0ebf0f0c1996b3f5ec3e16e0b557294f255b7b29..c2641ddefdfde5ccb08af900ac48378231f969c7 100644 (file)
--- a/entry.c
+++ b/entry.c
@@ -89,6 +89,7 @@ static int write_entry(struct cache_entry *ce, char *path, struct checkout *stat
                        return error("git-checkout-index: unable to create file %s (%s)",
                                path, strerror(errno));
                }
+               /* FIXME: LF -> CRLF conversion goes here, based on "ce->name" */
                wrote = write_in_full(fd, new, size);
                close(fd);
                free(new);
index 0d4bf80e74b16aa089acd06c24ad1b1a039e65b5..8ad7fad825708b5a56a3bfd4b8b98708de0bb2dc 100644 (file)
@@ -2091,6 +2091,7 @@ int index_fd(unsigned char *sha1, int fd, struct stat *st, int write_object, con
 
        if (!type)
                type = blob_type;
+       /* FIXME: CRLF -> LF conversion here for blobs! We'll need the path! */
        if (write_object)
                ret = write_sha1_file(buf, size, type, sha1);
        else