get_shallow_commits: Avoid memory leak if a commit has been reached already.
[gitweb.git] / fetch-pack.c
index 6fd457035ef7d5ea0e0a6104aa9c73b57c5d949b..bb310b644f65116f96d711bd5a145acd2f10fa6a 100644 (file)
@@ -198,9 +198,6 @@ static int find_common(int fd[2], unsigned char *result_sha1,
                        if (!strncmp("shallow ", line, 8)) {
                                if (get_sha1_hex(line + 8, sha1))
                                        die("invalid shallow line: %s", line);
-                               /* no need making it shallow if we have it already */
-                               if (lookup_object(sha1))
-                                       continue;
                                register_shallow(sha1);
                                continue;
                        }
@@ -703,7 +700,7 @@ int main(int argc, char **argv)
 
                fd = hold_lock_file_for_update(&lock, shallow, 1);
                if (!write_shallow_commits(fd, 0)) {
-                       unlink(lock.filename);
+                       unlink(shallow);
                        rollback_lock_file(&lock);
                } else {
                        close(fd);