1
0
mirror of https://github.com/git/git.git synced 2024-11-16 00:03:06 +01:00
git/builtin
Jeff King 74543a0423 pkt-line: provide a LARGE_PACKET_MAX static buffer
Most of the callers of packet_read_line just read into a
static 1000-byte buffer (callers which handle arbitrary
binary data already use LARGE_PACKET_MAX). This works fine
in practice, because:

  1. The only variable-sized data in these lines is a ref
     name, and refs tend to be a lot shorter than 1000
     characters.

  2. When sending ref lines, git-core always limits itself
     to 1000 byte packets.

However, the only limit given in the protocol specification
in Documentation/technical/protocol-common.txt is
LARGE_PACKET_MAX; the 1000 byte limit is mentioned only in
pack-protocol.txt, and then only describing what we write,
not as a specific limit for readers.

This patch lets us bump the 1000-byte limit to
LARGE_PACKET_MAX. Even though git-core will never write a
packet where this makes a difference, there are two good
reasons to do this:

  1. Other git implementations may have followed
     protocol-common.txt and used a larger maximum size. We
     don't bump into it in practice because it would involve
     very long ref names.

  2. We may want to increase the 1000-byte limit one day.
     Since packets are transferred before any capabilities,
     it's difficult to do this in a backwards-compatible
     way. But if we bump the size of buffer the readers can
     handle, eventually older versions of git will be
     obsolete enough that we can justify bumping the
     writers, as well. We don't have plans to do this
     anytime soon, but there is no reason not to start the
     clock ticking now.

Just bumping all of the reading bufs to LARGE_PACKET_MAX
would waste memory. Instead, since most readers just read
into a temporary buffer anyway, let's provide a single
static buffer that all callers can use. We can further wrap
this detail away by having the packet_read_line wrapper just
use the buffer transparently and return a pointer to the
static storage.  That covers most of the cases, and the
remaining ones already read into their own LARGE_PACKET_MAX
buffers.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2013-02-20 13:42:22 -08:00
..
add.c Merge branch 'maint' 2013-02-12 12:23:12 -08:00
annotate.c
apply.c Merge branch 'jc/extended-fake-ancestor-for-gitlink' 2013-02-14 10:28:48 -08:00
archive.c pkt-line: provide a LARGE_PACKET_MAX static buffer 2013-02-20 13:42:22 -08:00
bisect--helper.c
blame.c logmsg_reencode: lazily load missing commit buffers 2013-01-26 13:28:22 -08:00
branch.c Merge branch 'nd/branch-error-cases' 2013-02-07 14:41:38 -08:00
bundle.c
cat-file.c
check-attr.c
check-ignore.c add git-check-ignore sub-command 2013-01-06 14:26:38 -08:00
check-ref-format.c
checkout-index.c
checkout.c
clean.c Merge branch 'as/check-ignore' 2013-01-23 21:19:10 -08:00
clone.c Merge branch 'jc/no-git-config-in-clone' 2013-02-01 12:39:37 -08:00
column.c
commit-tree.c
commit.c Merge branch 'maint' 2013-02-12 12:23:12 -08:00
config.c
count-objects.c
credential.c
describe.c
diff-files.c
diff-index.c
diff-tree.c
diff.c
fast-export.c
fetch-pack.c pkt-line: provide a LARGE_PACKET_MAX static buffer 2013-02-20 13:42:22 -08:00
fetch.c Merge branch 'jk/gc-auto-after-fetch' 2013-02-01 12:40:16 -08:00
fmt-merge-msg.c Merge branch 'jc/custom-comment-char' 2013-02-04 10:23:49 -08:00
for-each-ref.c
fsck.c
gc.c
grep.c grep: avoid accepting ambiguous revision 2013-01-21 16:57:38 -08:00
hash-object.c
help.c Merge branch 'jk/config-parsing-cleanup' 2013-02-04 10:24:50 -08:00
index-pack.c
init-db.c
log.c Merge branch 'ap/log-mailmap' 2013-01-20 17:06:53 -08:00
ls-files.c Merge branch 'as/check-ignore' 2013-01-23 21:19:10 -08:00
ls-remote.c
ls-tree.c
mailinfo.c
mailsplit.c
merge-base.c
merge-file.c
merge-index.c
merge-ours.c
merge-recursive.c
merge-tree.c merge-tree: fix d/f conflicts 2012-12-26 14:46:15 -08:00
merge.c Merge branch 'jc/custom-comment-char' 2013-02-04 10:23:49 -08:00
mktag.c
mktree.c
mv.c
name-rev.c
notes.c Allow custom "comment char" 2013-01-16 12:48:22 -08:00
pack-objects.c
pack-redundant.c
pack-refs.c
patch-id.c
prune-packed.c
prune.c
push.c Merge branch 'jc/push-reject-reasons' 2013-02-04 10:25:04 -08:00
read-tree.c
receive-pack.c pkt-line: provide a LARGE_PACKET_MAX static buffer 2013-02-20 13:42:22 -08:00
reflog.c reflog: use parse_config_key in config callback 2013-01-23 12:58:33 -08:00
remote-ext.c
remote-fd.c
remote.c
replace.c
rerere.c
reset.c reset: update documentation to require only tree-ish with paths 2013-01-16 12:50:23 -08:00
rev-list.c
rev-parse.c
revert.c
rm.c
send-pack.c pkt-line: drop safe_write function 2013-02-20 13:42:21 -08:00
shortlog.c Merge branch 'ap/log-mailmap' 2013-01-20 17:06:53 -08:00
show-branch.c
show-ref.c
stripspace.c Allow custom "comment char" 2013-01-16 12:48:22 -08:00
symbolic-ref.c
tag.c Allow custom "comment char" 2013-01-16 12:48:22 -08:00
tar-tree.c
unpack-file.c
unpack-objects.c
update-index.c
update-ref.c
update-server-info.c
upload-archive.c pkt-line: provide a LARGE_PACKET_MAX static buffer 2013-02-20 13:42:22 -08:00
var.c
verify-pack.c
verify-tag.c
write-tree.c