clone/sha1_file: read info/alternates with strbuf_getline()

$GIT_OBJECT_DIRECTORY/info/alternates is a text file that can be
edited with a DOS editor.  We do not want to use the real path with
CR appended at the end.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Junio C Hamano 2015-10-28 13:29:24 -07:00
Родитель 18814d0e2d
Коммит 3f16396228
2 изменённых файлов: 2 добавлений и 2 удалений

Просмотреть файл

@ -339,7 +339,7 @@ static void copy_alternates(struct strbuf *src, struct strbuf *dst,
FILE *in = fopen(src->buf, "r");
struct strbuf line = STRBUF_INIT;
while (strbuf_getline_lf(&line, in) != EOF) {
while (strbuf_getline(&line, in) != EOF) {
char *abs_path;
if (!line.len || line.buf[0] == '#')
continue;

Просмотреть файл

@ -396,7 +396,7 @@ void add_to_alternates_file(const char *reference)
struct strbuf line = STRBUF_INIT;
int found = 0;
while (strbuf_getline_lf(&line, in) != EOF) {
while (strbuf_getline(&line, in) != EOF) {
if (!strcmp(reference, line.buf)) {
found = 1;
break;