diff options
author | Johannes Schindelin <Johannes.Schindelin@gmx.de> | 2007-03-09 03:50:06 +0100 |
---|---|---|
committer | Junio C Hamano <junkio@cox.net> | 2007-03-08 22:59:07 -0800 |
commit | 2e578f9a4f08ade4e8da52614c566e5dc1c8ca00 (patch) | |
tree | 5449ea3d9d114017252cad5dda44f00552238f3b /builtin-bundle.c | |
parent | d58c6184e345b9c8c8bfe8cc3eb1bbfe2f5ee4f9 (diff) | |
download | git-2e578f9a4f08ade4e8da52614c566e5dc1c8ca00.tar.gz |
git-bundle: prevent overwriting existing bundles
Not only does it prevent accidentally losing older bundles, but it
also fixes a subtle bug: when writing into an existing bundle,
git-pack-objects would not truncate the bundle. Therefore,
fetching from the bundle would trigger an error in unpack-objects:
"fatal: pack has junk at the end".
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <junkio@cox.net>
Diffstat (limited to 'builtin-bundle.c')
-rw-r--r-- | builtin-bundle.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/builtin-bundle.c b/builtin-bundle.c index ca3de60e44..55f6d0abcf 100644 --- a/builtin-bundle.c +++ b/builtin-bundle.c @@ -268,9 +268,9 @@ static int create_bundle(struct bundle_header *header, const char *path, struct rev_info revs; bundle_fd = (!strcmp(path, "-") ? 1 : - open(path, O_CREAT | O_WRONLY, 0666)); + open(path, O_CREAT | O_EXCL | O_WRONLY, 0666)); if (bundle_fd < 0) - return error("Could not write to '%s'", path); + return error("Could not create '%s': %s", path, strerror(errno)); /* write signature */ write_or_die(bundle_fd, bundle_signature, strlen(bundle_signature)); |