Commit 8b05e780180072d1fab525ec29100d63beb104a6

Romain Geissler 2011-06-05T00:17:26

Repository: Fixed a bug in read_gitfile (proprely remove trailings newlines)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
diff --git a/src/repository.c b/src/repository.c
index cae43dc..91f27d4 100644
--- a/src/repository.c
+++ b/src/repository.c
@@ -409,8 +409,8 @@ static int read_gitfile(char *path_out, size_t size, const char *file_path, cons
 
 	end_offset = strlen(data) - 1;
 
-	for (;data[end_offset] != '\r' && data[end_offset] != '\n'; --end_offset);
-	data[end_offset] = '\0';
+	for (;data[end_offset] == '\r' || data[end_offset] == '\n'; --end_offset);
+	data[end_offset + 1] = '\0';
 
 	if (GIT_FILE_CONTENT_PREFIX_LENGTH == end_offset) {
 		gitfo_free_buf(&file);