I'll be reusing it on the fetch-pack side as well.
Signed-off-by: Junio C Hamano <junkio@cox.net>
---
Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:
>> - git-push more agressively keeps the transferred objects
>> packed. Earlier we recommended to monitor amount of loose
>> objects and repack regularly, but you should repack when you
>> accumulated too many small packs this way as well. Updated
>> git-count-objects helps you with this.
>
> It might make sense to enable something similar for git-fetch in time for
> 1.5.0.
I have two patches that could become the beginning of this, not
much tested. This is the first of the two.
pack.h | 5 +++++
receive-pack.c | 26 ++++++++++++++------------
sha1_file.c | 21 +++++++++++++++++++++
3 files changed, 40 insertions(+), 12 deletions(-)
diff --git a/pack.h b/pack.h
index 821706f..deb427e 100644
--- a/pack.h
+++ b/pack.h
@@ -44,4 +44,9 @@ struct pack_header {
#define PACK_IDX_SIGNATURE 0xff744f63 /* "\377tOc" */
extern int verify_pack(struct packed_git *, int);
+
+#define PH_ERROR_EOF (-1)
+#define PH_ERROR_PACK_SIGNATURE (-2)
+#define PH_ERROR_PROTOCOL (-3)
+extern int read_pack_header(int fd, struct pack_header *);
#endif
diff --git a/receive-pack.c b/receive-pack.c
index 6333f00..b3a4552 100644
--- a/receive-pack.c
+++ b/receive-pack.c
@@ -250,20 +250,22 @@ static void read_head_info(void)
static const char *parse_pack_header(struct pack_header *hdr)
{
- char *c = (char*)hdr;
- ssize_t remaining = sizeof(struct pack_header);
- do {
- ssize_t r = xread(0, c, remaining);
- if (r <= 0)
- return "eof before pack header was fully read";
- remaining -= r;
- c += r;
- } while (remaining > 0);
- if (hdr->hdr_signature != htonl(PACK_SIGNATURE))
+ switch (read_pack_header(0, hdr)) {
+ case PH_ERROR_EOF:
+ return "eof before pack header was fully read";
+
+ case PH_ERROR_PACK_SIGNATURE:
return "protocol error (pack signature mismatch detected)";
- if (!pack_version_ok(hdr->hdr_version))
+
+ case PH_ERROR_PROTOCOL:
return "protocol error (pack version unsupported)";
- return NULL;
+
+ default:
+ return "unknown error in parse_pack_header";
+
+ case 0:
+ return NULL;
+ }
}
static const char *pack_lockfile;
diff --git a/sha1_file.c b/sha1_file.c
index 43ff402..498665e 100644
--- a/sha1_file.c
+++ b/sha1_file.c
@@ -2048,3 +2048,24 @@ int index_path(unsigned char *sha1, const char *path, struct stat *st, int write
}
return 0;
}
+
+int read_pack_header(int fd, struct pack_header *header)
+{
+ char *c = (char*)header;
+ ssize_t remaining = sizeof(struct pack_header);
+ do {
+ ssize_t r = xread(fd, c, remaining);
+ if (r <= 0)
+ /* "eof before pack header was fully read" */
+ return PH_ERROR_EOF;
+ remaining -= r;
+ c += r;
+ } while (remaining > 0);
+ if (header->hdr_signature != htonl(PACK_SIGNATURE))
+ /* "protocol error (pack signature mismatch detected)" */
+ return PH_ERROR_PACK_SIGNATURE;
+ if (!pack_version_ok(header->hdr_version))
+ /* "protocol error (pack version unsupported)" */
+ return PH_ERROR_PROTOCOL;
+ return 0;
+}
--
1.5.0.rc2.gc9a89
-
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
| Sean | Re: [AppArmor 39/45] AppArmor: Profile loading and manipulation,pathname matching |
| Herbert Xu | Re: 2.6.23-rc4-mm1 |
| Miklos Szeredi | Re: [BUG] long freezes on thinkpad t60 |
| Bart Van Assche | Integration of SCST in the mainstream Linux kernel |
git: | |
| Matthieu Moy | Re: [RFC] Convert builin-mailinfo.c to use The Better String Library. |
| Guido Ostkamp | [PATCH] Fix Solaris Workshop Compiler issues |
| Shawn Pearce | Re: [RFC] Submodules in GIT |
| Imran M Yousuf | Re: [kernel.org users] [RFD] On deprecating "git-foo" for builtins |
| Marcos Laufer | dmesg IBM x3650 OpenBSD 4.3 |
| Marco Peereboom | Re: Real men don't attack straw men |
| patrick keshishian | SMTP flood + spamdb |
| Andrés Delfino | Re: bcw(4) is gone |
| Tilman Schmidt | Re: 2.6.25-rc8: FTP transfer errors |
| Denys Fedoryshchenko | SFQ depth limit |
| David Miller | Re: [PATCH] pkt_sched: Destroy gen estimators under rtnl_lock(). |
| David Miller | [GIT]: Networking |
| high memory | 16 hours ago | Linux kernel |
| semaphore access speed | 19 hours ago | Applications and Utilities |
| the kernel how to power off the machine | 20 hours ago | Linux kernel |
| Easter Eggs in windows XP | 23 hours ago | Windows |
| Shared swap partition | 23 hours ago | Linux general |
| Root password | 1 day ago | Linux general |
| Where/when DNOTIFY is used? | 1 day ago | Linux kernel |
| How to convert Linux Kernel built-in module into a loadable module | 1 day ago | Linux kernel |
| Linux 2.6.24 and I/O schedulers | 1 day ago | Linux kernel |
| USB Driver -- Interrupt Polling -- A Little Help Please | 1 day ago | Linux general |
