From: Nicolas Pitre <nico@cam.org>
To: Shawn Pearce <spearce@spearce.org>
Cc: Junio C Hamano <junkio@cox.net>, git@vger.kernel.org
Subject: Re: [PATCH 3/3] Teach git-index-pack how to keep a pack file.
Date: Sun, 29 Oct 2006 22:47:08 -0500 (EST) [thread overview]
Message-ID: <Pine.LNX.4.64.0610292232440.11384@xanadu.home> (raw)
In-Reply-To: <20061029094159.GE3847@spearce.org>
On Sun, 29 Oct 2006, Shawn Pearce wrote:
> I'm throwing a pair of pipes around index-pack so I can capture
> the pack name thus allowing receive-pack to delete the correct
> .keep file after its completed the ref updates. At that point
> receive-pack can easily examine the object count in the pack header
> and compare that against a config entry to decide if it should be
> keeping the pack or exploding it.
Is it really worth the trouble? Especially if you've already written
the pack out, why just not keep it instead of burning more CPU cycles
exploding it? The next repack will delete it anyway.
At least for the fetch/pull case here's what I've done so far. It is
not complete as the .keep file is not deleted as I'm not clear exactly
where in git-fetch.sh it can be safely deleted. But at least it works
to the point of displaying the name of the file it should consider for
deletion.
diff --git a/fetch-clone.c b/fetch-clone.c
index 96cdab4..c5747f4 100644
--- a/fetch-clone.c
+++ b/fetch-clone.c
@@ -81,7 +81,7 @@ int receive_unpack_pack(int xd[2], const
int receive_keep_pack(int xd[2], const char *me, int quiet, int sideband)
{
- const char *argv[5] = { "index-pack", "--stdin", "--fix-thin",
+ const char *argv[6] = { "index-pack", "--stdin", "--fix-thin", "--keep",
quiet ? NULL : "-v", NULL };
return get_pack(xd, me, sideband, argv);
}
diff --git a/git-fetch.sh b/git-fetch.sh
index 539dff6..dd0c00b 100755
--- a/git-fetch.sh
+++ b/git-fetch.sh
@@ -378,6 +378,10 @@ fetch_main () {
failed)
echo >&2 "Fetch failure: $remote"
exit 1 ;;
+ pack)
+ pack_lockfile="$GIT_OBJECT_DIRECTORY/pack/pack-$remote_name.keep"
+ [ -e "$pack_lockfile" ] && echo >&2 "$pack_lockfile exists"
+ continue ;;
esac
found=
single_force=
diff --git a/index-pack.c b/index-pack.c
index b37dd78..8db3c93 100644
--- a/index-pack.c
+++ b/index-pack.c
@@ -767,18 +767,6 @@ static void final(const char *final_pack
if (err)
die("error while closing pack file: %s", strerror(errno));
chmod(curr_pack_name, 0444);
-
- /*
- * Let's just mimic git-unpack-objects here and write
- * the last part of the buffer to stdout.
- */
- while (input_len) {
- err = xwrite(1, input_buffer + input_offset, input_len);
- if (err <= 0)
- break;
- input_len -= err;
- input_offset += err;
- }
}
if (keep_msg) {
@@ -818,6 +806,27 @@ static void final(const char *final_pack
if (move_temp_to_file(curr_index_name, final_index_name))
die("cannot store index file");
}
+
+ if (!from_stdin) {
+ printf("%s\n", sha1_to_hex(sha1));
+ } else {
+ char buf[48];
+ int len = snprintf(buf, sizeof(buf), "pack\t%s\n",
+ sha1_to_hex(sha1));
+ xwrite(1, buf, len);
+
+ /*
+ * Let's just mimic git-unpack-objects here and write
+ * the last part of the input buffer to stdout.
+ */
+ while (input_len) {
+ err = xwrite(1, input_buffer + input_offset, input_len);
+ if (err <= 0)
+ break;
+ input_len -= err;
+ input_offset += err;
+ }
+ }
}
int main(int argc, char **argv)
@@ -921,8 +930,5 @@ int main(int argc, char **argv)
free(index_name_buf);
free(keep_name_buf);
- if (!from_stdin)
- printf("%s\n", sha1_to_hex(sha1));
-
return 0;
prev parent reply other threads:[~2006-10-30 3:47 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-10-29 9:41 [PATCH 3/3] Teach git-index-pack how to keep a pack file Shawn Pearce
2006-10-29 10:49 ` Jakub Narebski
2006-10-29 19:14 ` Junio C Hamano
2006-10-29 19:44 ` Michael S. Tsirkin
2006-10-30 3:47 ` Nicolas Pitre [this message]
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=Pine.LNX.4.64.0610292232440.11384@xanadu.home \
--to=nico@cam.org \
--cc=git@vger.kernel.org \
--cc=junkio@cox.net \
--cc=spearce@spearce.org \
/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).