summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: da093d3)
raw | patch | inline | side by side (parent: da093d3)
author | Nicolas Pitre <nico@cam.org> | |
Wed, 1 Nov 2006 22:06:24 +0000 (17:06 -0500) | ||
committer | Junio C Hamano <junkio@cox.net> | |
Fri, 3 Nov 2006 08:24:07 +0000 (00:24 -0800) |
If by chance we receive a pack which content (list of objects) matches
another pack that we already have, and if that pack is marked with a
.keep file, then we should not overwrite it.
Signed-off-by: Nicolas Pitre <nico@cam.org>
Signed-off-by: Junio C Hamano <junkio@cox.net>
another pack that we already have, and if that pack is marked with a
.keep file, then we should not overwrite it.
Signed-off-by: Nicolas Pitre <nico@cam.org>
Signed-off-by: Junio C Hamano <junkio@cox.net>
index-pack.c | patch | blob | history |
diff --git a/index-pack.c b/index-pack.c
index a3b55f9b0f07d39d3f2d7be184d250289abdb3da..8d64a883afe0b9868ae6c8d918986785ee3cdcfe 100644 (file)
--- a/index-pack.c
+++ b/index-pack.c
get_object_directory(), sha1_to_hex(sha1));
keep_name = name;
}
- keep_fd = open(keep_name, O_RDWR | O_CREAT, 0600);
- if (keep_fd < 0)
- die("cannot write keep file");
- if (keep_msg_len > 0) {
- write_or_die(keep_fd, keep_msg, keep_msg_len);
- write_or_die(keep_fd, "\n", 1);
+ keep_fd = open(keep_name, O_RDWR|O_CREAT|O_EXCL, 0600);
+ if (keep_fd < 0) {
+ if (errno != EEXIST)
+ die("cannot write keep file");
+ } else {
+ if (keep_msg_len > 0) {
+ write_or_die(keep_fd, keep_msg, keep_msg_len);
+ write_or_die(keep_fd, "\n", 1);
+ }
+ close(keep_fd);
}
- close(keep_fd);
}
if (final_pack_name != curr_pack_name) {