git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Dana How" <danahow@gmail.com>
To: "Junio C Hamano" <junkio@cox.net>
Cc: git@vger.kernel.org, danahow@gmail.com
Subject: [PATCH 11/13] implement write rollback in write_one() if --pack-limit exceeded
Date: Thu, 5 Apr 2007 15:39:24 -0700	[thread overview]
Message-ID: <56b7f5510704051539p36ba3368xd827acd3fa4a3181@mail.gmail.com> (raw)

[-- 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


                 reply	other threads:[~2007-04-05 22:39 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=56b7f5510704051539p36ba3368xd827acd3fa4a3181@mail.gmail.com \
    --to=danahow@gmail.com \
    --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).