* [PATCH 11/13] implement write rollback in write_one() if --pack-limit exceeded
@ 2007-04-05 22:39 Dana How
0 siblings, 0 replies; only message in thread
From: Dana How @ 2007-04-05 22:39 UTC (permalink / raw)
To: Junio C Hamano; +Cc: git, danahow
[-- Attachment #1: Type: text/plain, Size: 171 bytes --]
---
builtin-pack-objects.c | 26 ++++++++++++++++++++++++--
1 files changed, 24 insertions(+), 2 deletions(-)
--
Dana L. How danahow@gmail.com +1 650 804 5991 cell
[-- Attachment #2: 0011-implement-write-rollback-in-write_one-if-pack-li.patch.txt --]
[-- Type: text/plain, Size: 1821 bytes --]
From d7d73a914e7c4587845ea0408d3e62fa44b4ac65 Mon Sep 17 00:00:00 2001
From: Dana How <how@deathvalley.cswitch.com>
Date: Thu, 5 Apr 2007 14:25:50 -0700
Subject: [PATCH 11/13] implement write rollback in write_one() if --pack-limit exceeded
---
builtin-pack-objects.c | 26 ++++++++++++++++++++++++--
1 files changed, 24 insertions(+), 2 deletions(-)
diff --git a/builtin-pack-objects.c b/builtin-pack-objects.c
index a243eed..ac643dd 100644
--- a/builtin-pack-objects.c
+++ b/builtin-pack-objects.c
@@ -511,15 +511,37 @@ static off_t write_one(struct sha1file *f,
struct object_entry *e,
off_t offset)
{
- if (e->offset || e->preferred_base)
+ if (e->offset || e->preferred_base || e->no_write)
/* offset starts from header size and cannot be zero
* if it is written already.
*/
return offset;
/* if we are deltified, write out its base object first. */
- if (e->delta)
+ if (e->delta) {
offset = write_one(f, e->delta, offset);
+ if (!offset)
+ return offset;
+ }
e->offset = offset;
+ if (offset_limit) {
+ /* save state before write for possible later seekback */
+ struct sha1posn posn;
+ uint32_t save_written = written, save_written_delta = written_delta;
+ uint32_t save_reused = reused, save_reused_delta = reused_delta;
+ sha1mark(f, &posn);
+ offset += write_object(f, e);
+ /*
+ * Ensure the packfile size never exceeds or matches offset_limit.
+ * The "20" is for the final SHA1.
+ */
+ if ((unsigned long)offset < (unsigned long)(offset_limit - 20))
+ return offset;
+ written = save_written, written_delta = save_written_delta;
+ reused = save_reused, reused_delta = save_reused_delta;
+ sha1undo(f, &posn, offset, e->offset);
+ e->offset = 0;
+ return 0;
+ }
return offset + write_object(f, e);
}
--
1.5.1.rc2.18.g9c88-dirty
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2007-04-05 22:39 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-04-05 22:39 [PATCH 11/13] implement write rollback in write_one() if --pack-limit exceeded Dana How
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).