From: Nicolas Pitre <nico@cam.org>
To: Junio C Hamano <junkio@cox.net>
Cc: git@vger.kernel.org, Nicolas Pitre <nico@cam.org>
Subject: [PATCH 5/6] have index-pack create .keep file more carefully
Date: Wed, 01 Nov 2006 17:06:24 -0500 [thread overview]
Message-ID: <11624187871572-git-send-email-nico@cam.org> (raw)
In-Reply-To: <1162418786390-git-send-email-nico@cam.org>
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>
---
index-pack.c | 17 ++++++++++-------
1 files changed, 10 insertions(+), 7 deletions(-)
diff --git a/index-pack.c b/index-pack.c
index a3b55f9..8d64a88 100644
--- a/index-pack.c
+++ b/index-pack.c
@@ -788,14 +788,17 @@ static void final(const char *final_pack
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) {
--
1.4.3.3.g87b2-dirty
next prev parent reply other threads:[~2006-11-01 22:06 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-11-01 22:06 [PATCH 1/6] Allow pack header preprocessing before unpack-objects/index-pack Nicolas Pitre
2006-11-01 22:06 ` [PATCH 2/6] Teach receive-pack how to keep pack files based on object count Nicolas Pitre
2006-11-01 22:06 ` [PATCH 3/6] git-fetch can use both --thin and --keep with fetch-pack now Nicolas Pitre
2006-11-01 22:06 ` [PATCH 4/6] improve fetch-pack's handling of kept packs Nicolas Pitre
2006-11-01 22:06 ` Nicolas Pitre [this message]
2006-11-01 22:06 ` [PATCH 6/6] remove .keep pack lock files when done with refs update Nicolas Pitre
2006-11-02 5:18 ` Shawn Pearce
2006-11-02 5:27 ` Junio C Hamano
2006-11-02 15:09 ` Nicolas Pitre
2006-11-02 17:25 ` Nicolas Pitre
2006-11-03 9:35 ` Junio C Hamano
2006-11-01 23:50 ` [PATCH 1/6] Allow pack header preprocessing before unpack-objects/index-pack Junio C Hamano
2006-11-02 3:58 ` Nicolas Pitre
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=11624187871572-git-send-email-nico@cam.org \
--to=nico@cam.org \
--cc=git@vger.kernel.org \
--cc=junkio@cox.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).