* [PATCH 3/3] git-bundle: prevent overwriting existing bundles
@ 2007-03-09 2:50 Johannes Schindelin
2007-03-09 2:59 ` Shawn O. Pearce
0 siblings, 1 reply; 3+ messages in thread
From: Johannes Schindelin @ 2007-03-09 2:50 UTC (permalink / raw)
To: git; +Cc: junkio, Mark Levedahl
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>
---
Alternatively, we could use O_TRUNC instead of O_EXCL, but
I think it makes sense to refuse to overwrite existing
bundles.
Mark, I guess this is what triggered the bug you were reporting.
builtin-bundle.c | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/builtin-bundle.c b/builtin-bundle.c
index ca3de60..5ebba0b 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'", path);
/* write signature */
write_or_die(bundle_fd, bundle_signature, strlen(bundle_signature));
--
1.5.0.3.2601.gc1e5-dirty
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH 3/3] git-bundle: prevent overwriting existing bundles
2007-03-09 2:50 [PATCH 3/3] git-bundle: prevent overwriting existing bundles Johannes Schindelin
@ 2007-03-09 2:59 ` Shawn O. Pearce
2007-03-09 3:05 ` Johannes Schindelin
0 siblings, 1 reply; 3+ messages in thread
From: Shawn O. Pearce @ 2007-03-09 2:59 UTC (permalink / raw)
To: Johannes Schindelin; +Cc: git, junkio, Mark Levedahl
Johannes Schindelin <Johannes.Schindelin@gmx.de> wrote:
> if (bundle_fd < 0)
> - return error("Could not write to '%s'", path);
> + return error("Could not create '%s'", path);
I hate to be a nit, but what about?
> + return error("Could not create '%s': %s", path, strerror(errno));
--
Shawn.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH 3/3] git-bundle: prevent overwriting existing bundles
2007-03-09 2:59 ` Shawn O. Pearce
@ 2007-03-09 3:05 ` Johannes Schindelin
0 siblings, 0 replies; 3+ messages in thread
From: Johannes Schindelin @ 2007-03-09 3:05 UTC (permalink / raw)
To: Shawn O. Pearce; +Cc: git, junkio, Mark Levedahl
Hi,
On Thu, 8 Mar 2007, Shawn O. Pearce wrote:
> Johannes Schindelin <Johannes.Schindelin@gmx.de> wrote:
> > if (bundle_fd < 0)
> > - return error("Could not write to '%s'", path);
> > + return error("Could not create '%s'", path);
>
> I hate to be a nit, but what about?
>
> > + return error("Could not create '%s': %s", path, strerror(errno));
ACK
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2007-03-09 3:05 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-03-09 2:50 [PATCH 3/3] git-bundle: prevent overwriting existing bundles Johannes Schindelin
2007-03-09 2:59 ` Shawn O. Pearce
2007-03-09 3:05 ` Johannes Schindelin
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox