git-checkout: fix branch name output from the command
[gitweb.git] / copy.c
diff --git a/copy.c b/copy.c
index 7100eedbc3277b9b0997311459d054ba06950b61..08a3d388a4c312fca18558b2b8e5dcf027c7afaf 100644 (file)
--- a/copy.c
+++ b/copy.c
@@ -22,11 +22,14 @@ int copy_fd(int ifd, int ofd)
                                buf += written;
                                len -= written;
                        }
-                       else if (!written)
+                       else if (!written) {
+                               close(ifd);
                                return error("copy-fd: write returned 0");
-                       else
+                       } else {
+                               close(ifd);
                                return error("copy-fd: write returned %s",
                                             strerror(errno));
+                       }
                }
        }
        close(ifd);