Skip to content

Commit bd3a5b5

Browse files
torvaldsJunio C Hamano
authored andcommitted
Mark places that need blob munging later for CRLF conversion.
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent e19b91b commit bd3a5b5

File tree

3 files changed

+3
-0
lines changed

3 files changed

+3
-0
lines changed

diff.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1364,6 +1364,7 @@ int diff_populate_filespec(struct diff_filespec *s, int size_only)
13641364
s->data = xmmap(NULL, s->size, PROT_READ, MAP_PRIVATE, fd, 0);
13651365
close(fd);
13661366
s->should_munmap = 1;
1367+
/* FIXME! CRLF -> LF conversion goes here, based on "s->path" */
13671368
}
13681369
else {
13691370
char type[20];

entry.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ static int write_entry(struct cache_entry *ce, char *path, struct checkout *stat
8989
return error("git-checkout-index: unable to create file %s (%s)",
9090
path, strerror(errno));
9191
}
92+
/* FIXME: LF -> CRLF conversion goes here, based on "ce->name" */
9293
wrote = write_in_full(fd, new, size);
9394
close(fd);
9495
free(new);

sha1_file.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2091,6 +2091,7 @@ int index_fd(unsigned char *sha1, int fd, struct stat *st, int write_object, con
20912091

20922092
if (!type)
20932093
type = blob_type;
2094+
/* FIXME: CRLF -> LF conversion here for blobs! We'll need the path! */
20942095
if (write_object)
20952096
ret = write_sha1_file(buf, size, type, sha1);
20962097
else

0 commit comments

Comments
 (0)