Code

reset: unbreak hard resets with GIT_WORK_TREE
[git.git] / commit.c
index a6c6f70a9237385d163ea12ef28e5087e9f80411..6393e1b36218e5f8970b0c43092b07f5d94b0bce 100644 (file)
--- a/commit.c
+++ b/commit.c
@@ -132,8 +132,8 @@ struct commit_graft *read_graft_line(char *buf, int len)
        int i;
        struct commit_graft *graft = NULL;
 
-       if (buf[len-1] == '\n')
-               buf[--len] = 0;
+       while (len && isspace(buf[len-1]))
+               buf[--len] = '\0';
        if (buf[0] == '#' || buf[0] == '\0')
                return NULL;
        if ((len + 1) % 41) {
@@ -212,7 +212,7 @@ int write_shallow_commits(int fd, int use_pack_protocol)
                        else {
                                if (write_in_full(fd, hex,  40) != 40)
                                        break;
-                               if (write_in_full(fd, "\n", 1) != 1)
+                               if (write_str_in_full(fd, "\n") != 1)
                                        break;
                        }
                }