link_temp_to_file: don't leave the path truncated on adjust_shared_perm failure
authorJunio C Hamano <junkio@cox.net>
Tue, 31 Oct 2006 23:56:58 +0000 (15:56 -0800)
committerJunio C Hamano <junkio@cox.net>
Tue, 31 Oct 2006 23:56:58 +0000 (15:56 -0800)
Signed-off-by: Junio C Hamano <junkio@cox.net>
sha1_file.c

index 47e2a29abd6d2ae067d72c0f73bcf4e6afe0a938..5fcad2893fec7739262b06e2883ee3c261768099 100644 (file)
@@ -1383,8 +1383,10 @@ static int link_temp_to_file(const char *tmpfile, const char *filename)
        if (dir) {
                *dir = 0;
                mkdir(filename, 0777);
-               if (adjust_shared_perm(filename))
+               if (adjust_shared_perm(filename)) {
+                       *dir = '/';
                        return -2;
+               }
                *dir = '/';
                if (!link(tmpfile, filename))
                        return 0;