aboutsummaryrefslogtreecommitdiff
path: root/builtin-apply.c
diff options
context:
space:
mode:
authorAlex Riesen <raa.lkml@gmail.com>2007-04-19 02:05:03 +0200
committerJunio C Hamano <junkio@cox.net>2007-04-20 23:24:34 -0700
commitac78e548049f4e86b38368d2c4b4dbb546c64ac6 (patch)
tree37994b847883946eefb34b50d53549335525d428 /builtin-apply.c
parent88e7fdf2cb436e068434241b0519577293055c19 (diff)
downloadgit-ac78e548049f4e86b38368d2c4b4dbb546c64ac6.tar.gz
git-ac78e548049f4e86b38368d2c4b4dbb546c64ac6.tar.xz
Simplify calling of CR/LF conversion routines
Signed-off-by: Alex Riesen <raa.lkml@gmail.com> Signed-off-by: Junio C Hamano <junkio@cox.net>
Diffstat (limited to 'builtin-apply.c')
-rw-r--r--builtin-apply.c18
1 files changed, 7 insertions, 11 deletions
diff --git a/builtin-apply.c b/builtin-apply.c
index fd92ef717..ccd342c1c 100644
--- a/builtin-apply.c
+++ b/builtin-apply.c
@@ -1475,8 +1475,8 @@ static int read_old_data(struct stat *st, const char *path, char **buf_p, unsign
}
close(fd);
nsize = got;
- nbuf = buf;
- if (convert_to_git(path, &nbuf, &nsize)) {
+ nbuf = convert_to_git(path, buf, &nsize);
+ if (nbuf) {
free(buf);
*buf_p = nbuf;
*alloc_p = nsize;
@@ -2355,9 +2355,8 @@ static void add_index_file(const char *path, unsigned mode, void *buf, unsigned
static int try_create_file(const char *path, unsigned int mode, const char *buf, unsigned long size)
{
- int fd, converted;
+ int fd;
char *nbuf;
- unsigned long nsize;
if (has_symlinks && S_ISLNK(mode))
/* Although buf:size is counted string, it also is NUL
@@ -2369,13 +2368,10 @@ static int try_create_file(const char *path, unsigned int mode, const char *buf,
if (fd < 0)
return -1;
- nsize = size;
- nbuf = (char *) buf;
- converted = convert_to_working_tree(path, &nbuf, &nsize);
- if (converted) {
+ nbuf = convert_to_working_tree(path, buf, &size);
+ if (nbuf)
buf = nbuf;
- size = nsize;
- }
+
while (size) {
int written = xwrite(fd, buf, size);
if (written < 0)
@@ -2387,7 +2383,7 @@ static int try_create_file(const char *path, unsigned int mode, const char *buf,
}
if (close(fd) < 0)
die("closing file %s: %s", path, strerror(errno));
- if (converted)
+ if (nbuf)
free(nbuf);
return 0;
}