Skip to content

Commit

Permalink
minor git-prune optimization
Browse files Browse the repository at this point in the history
Don't try to remove the containing directory for every pruned object but
try only once after the directory has been scanned instead.

Signed-off-by: Nicolas Pitre <nico@cam.org>
Signed-off-by: Junio C Hamano <junkio@cox.net>
  • Loading branch information
Nicolas Pitre authored and Junio C Hamano committed Mar 21, 2007
1 parent 5721685 commit 3254d21
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions builtin-prune.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,8 @@ static int prune_object(char *path, const char *filename, const unsigned char *s
enum object_type type = sha1_object_info(sha1, NULL);
printf("%s %s\n", sha1_to_hex(sha1),
(type > 0) ? typename(type) : "unknown");
return 0;
}
unlink(mkpath("%s/%s", path, filename));
rmdir(path);
} else
unlink(mkpath("%s/%s", path, filename));
return 0;
}

Expand Down Expand Up @@ -60,6 +58,8 @@ static int prune_dir(int i, char *path)
}
fprintf(stderr, "bad sha1 file: %s/%s\n", path, de->d_name);
}
if (!show_only)
rmdir(path);
closedir(dir);
return 0;
}
Expand Down

0 comments on commit 3254d21

Please sign in to comment.