Remove the temp file if it is empty after the request has failed
[git.git] / ls-files.c
index 3085b2f..d9c8b21 100644 (file)
@@ -97,7 +97,7 @@ static int add_excludes_from_file_1(const char *fname,
        for (i = 0; i < size; i++) {
                if (buf[i] == '\n') {
                        if (entry != buf + i && entry[0] != '#') {
-                               buf[i] = 0;
+                               buf[i - (i && buf[i-1] == '\r')] = 0;
                                add_exclude(entry, base, baselen, which);
                        }
                        entry = buf + i + 1;