summaryrefslogtreecommitdiff
AgeCommit message (Collapse)Author
2013-02-20pkt-line: drop safe_write functionJeff King
This is just write_or_die by another name. The one distinction is that write_or_die will treat EPIPE specially by suppressing error messages. That's fine, as we die by SIGPIPE anyway (and in the off chance that it is disabled, write_or_die will simulate it). Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2013-02-20pkt-line: move a misplaced commentJeff King
The comment describing the packet writing interface was originally written above packet_write, but migrated to be above safe_write in f3a3214, probably because it is meant to generally describe the packet writing interface and not a single function. Let's move it into the header file, where users of the interface are more likely to see it. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2013-02-20write_or_die: raise SIGPIPE when we get EPIPEJeff King
The write_or_die function will always die on an error, including EPIPE. However, it currently treats EPIPE specially by suppressing any error message, and by exiting with exit code 0. Suppressing the error message makes some sense; a pipe death may just be a sign that the other side is not interested in what we have to say. However, exiting with a successful error code is not a good idea, as write_or_die is frequently used in cases where we want to be careful about having written all of the output, and we may need to signal to our caller that we have done so (e.g., you would not want a push whose other end has hung up to report success). This distinction doesn't typically matter in git, because we do not ignore SIGPIPE in the first place. Which means that we will not get EPIPE, but instead will just die when we get a SIGPIPE. But it's possible for a default handler to be set by a parent process, or for us to add a callsite inside one of our few SIGPIPE-ignoring blocks of code. This patch converts write_or_die to actually raise SIGPIPE when we see EPIPE, rather than exiting with zero. This brings the behavior in line with the "normal" case that we die from SIGPIPE (and any callers who want to check why we died will see the same thing). We also give the same treatment to other related functions, including write_or_whine_pipe and maybe_flush_or_die. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2013-02-20upload-archive: use argv_array to store client argumentsJeff King
The current parsing scheme for upload-archive is to pack arguments into a fixed-size buffer, separated by NULs, and put a pointer to each argument in the buffer into a fixed-size argv array. This works fine, and the limits are high enough that nobody reasonable is going to hit them, but it makes the code hard to follow. Instead, let's just stuff the arguments into an argv_array, which is much simpler. That lifts the "all arguments must fit inside 4K together" limit. We could also trivially lift the MAX_ARGS limitation (in fact, we have to keep extra code to enforce it). But that would mean a client could force us to allocate an arbitrary amount of memory simply by sending us "argument" lines. By limiting the MAX_ARGS, we limit an attacker to about 4 megabytes (64 times a maximum 64K packet buffer). That may sound like a lot compared to the 4K limit, but it's not a big deal compared to what git-archive will actually allocate while working (e.g., to load blobs into memory). The important thing is that it is bounded. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2013-02-20upload-archive: do not copy repo nameJeff King
According to the comment, enter_repo will modify its input. However, this has not been the case since 1c64b48 (enter_repo: do not modify input, 2011-10-04). Drop the now-useless copy. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2013-02-20send-pack: prefer prefixcmp over memcmp in receive_statusJeff King
This code predates prefixcmp, so it used memcmp along with static sizes. Replacing these memcmps with prefixcmp makes the code much more readable, and the lack of static sizes will make refactoring it in future patches simpler. Note that we used to be unnecessarily liberal in parsing the "unpack" status line, and would accept "unpack ok\njunk". No version of git has ever produced that, and it violates the BNF in Documentation/technical/pack-protocol.txt. Let's take this opportunity to tighten the check by converting the prefix comparison into a strcmp. While we're in the area, let's also fix a vague error message that does not follow our usual conventions (it writes directly to stderr and does not use the "error:" prefix). Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2013-02-20fetch-pack: fix out-of-bounds buffer offset in get_ackJeff King
When we read acks from the remote, we expect either: ACK <sha1> or ACK <sha1> <multi-ack-flag> We parse the "ACK <sha1>" bit from the line, and then start looking for the flag strings at "line+45"; if we don't have them, we assume it's of the first type. But if we do have the first type, then line+45 is not necessarily inside our string at all! It turns out that this works most of the time due to the way we parse the packets. They should come in with a newline, and packet_read puts an extra NUL into the buffer, so we end up with: ACK <sha1>\n\0 with the newline at offset 44 and the NUL at offset 45. We then strip the newline, putting a NUL at offset 44. So when we look at "line+45", we are looking past the end of our string; but it's OK, because we hit the terminator from the original string. This breaks down, however, if the other side does not terminate their packets with a newline. In that case, our packet is one character shorter, and we start looking through uninitialized memory for the flag. No known implementation sends such a packet, so it has never come up in practice. This patch tightens the check by looking for a short, flagless ACK before trying to parse the flag. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2013-02-20upload-pack: remove packet debugging harnessJeff King
If you set the GIT_DEBUG_SEND_PACK environment variable, upload-pack will dump lines it receives in the receive_needs phase to a descriptor. This debugging harness is a strict subset of what GIT_TRACE_PACKET can do. Let's just drop it in favor of that. A few tests used GIT_DEBUG_SEND_PACK to confirm which objects get sent; we have to adapt them to the new output format. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2013-02-20upload-pack: do not add duplicate objects to shallow listJeff King
When the client tells us it has a shallow object via "shallow <sha1>", we make sure we have the object, mark it with a flag, then add it to a dynamic array of shallow objects. This means that a client can get us to allocate arbitrary amounts of memory just by flooding us with shallow lines (whether they have the objects or not). You can demonstrate it easily with: yes '0035shallow e83c5163316f89bfbde7d9ab23ca2e25604af290' | git-upload-pack git.git We already protect against duplicates in want lines by checking if our flag is already set; let's do the same thing here. Note that a client can still get us to allocate some amount of memory by marking every object in the repo as "shallow" (or "want"). But this at least bounds it with the number of objects in the repository, which is not under the control of an upload-pack client. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2013-02-20upload-pack: use get_sha1_hex to parse "shallow" linesJeff King
When we receive a line like "shallow <sha1>" from the client, we feed the <sha1> part to get_sha1. This is a mistake, as the argument on a shallow line is defined by Documentation/technical/pack-protocol.txt to contain an "obj-id". This is never defined in the BNF, but it is clear from the text and from the other uses that it is meant to be a hex sha1, not an arbitrary identifier (and that is what fetch-pack has always sent). We should be using get_sha1_hex instead, which doesn't allow the client to request arbitrary junk like "HEAD@{yesterday}". Because this is just marking shallow objects, the client couldn't actually do anything interesting (like fetching objects from unreachable reflog entries), but we should keep our parsing tight to be on the safe side. Because get_sha1 is for the most part a superset of get_sha1_hex, in theory the only behavior change should be disallowing non-hex object references. However, there is one interesting exception: get_sha1 will only parse a 40-character hex sha1 if the string has exactly 40 characters, whereas get_sha1_hex will just eat the first 40 characters, leaving the rest. That means that current versions of git-upload-pack will not accept a "shallow" packet that has a trailing newline, even though the protocol documentation is clear that newlines are allowed (even encouraged) in non-binary parts of the protocol. This never mattered in practice, though, because fetch-pack, contrary to the protocol documentation, does not include a newline in its shallow lines. JGit follows its lead (though it correctly is strict on the parsing end about wanting a hex object id). We do not adjust fetch-pack to send newlines here, as it would break communication with older versions of git (and there is no actual benefit to doing so, except for consistency with other parts of the protocol). Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2013-02-17Git 1.8.2-rc0v1.8.2-rc0Junio C Hamano
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2013-02-17Merge branch 'jc/hidden-refs'Junio C Hamano
Allow the server side to redact the refs/ namespace it shows to the client. Will merge to 'master'. * jc/hidden-refs: upload/receive-pack: allow hiding ref hierarchies upload-pack: simplify request validation upload-pack: share more code
2013-02-17Merge branch 'mp/diff-algo-config'Junio C Hamano
Add diff.algorithm configuration so that the user does not type "diff --histogram". * mp/diff-algo-config: diff: Introduce --diff-algorithm command line option config: Introduce diff.algorithm variable git-completion.bash: Autocomplete --minimal and --histogram for git-diff
2013-02-17Merge branch 'mw/bash-prompt-show-untracked-config'Junio C Hamano
Allows skipping the untracked check GIT_PS1_SHOWUNTRACKEDFILES asks for the git-prompt (in contrib/) per repository. * mw/bash-prompt-show-untracked-config: t9903: add extra tests for bash.showDirtyState t9903: add tests for bash.showUntrackedFiles shell prompt: add bash.showUntrackedFiles option
2013-02-17Merge branch 'jk/rebase-i-comment-char'Junio C Hamano
Finishing touches to the earlier core.commentchar topic to cover "rebase -i" as well. * jk/rebase-i-comment-char: rebase -i: respect core.commentchar
2013-02-17Merge branch 'jk/read-commit-buffer-data-after-free'Junio C Hamano
"git log --grep=<pattern>" used to look for the pattern in literal bytes of the commit log message and ignored the log-output encoding. * jk/read-commit-buffer-data-after-free: log: re-encode commit messages before grepping
2013-02-15Update draft release notes to 1.8.2Junio C Hamano
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2013-02-15Merge branch 'wk/man-deny-current-branch-is-default-these-days'Junio C Hamano
* wk/man-deny-current-branch-is-default-these-days: user-manual: Update for receive.denyCurrentBranch=refuse
2013-02-15Merge branch 'mk/make-rm-depdirs-could-be-empty'Junio C Hamano
"make COMPUTE_HEADER_DEPENDENCIES=no clean" would try to run "rm -rf $(dep_dirs)" with an empty dep_dir, but some implementations of "rm -rf" barf on an empty argument list. * mk/make-rm-depdirs-could-be-empty: Makefile: don't run "rm" without any files
2013-02-15Merge branch 'mm/config-local-completion'Junio C Hamano
* mm/config-local-completion: completion: support 'git config --local'
2013-02-15Merge branch 'ef/non-ascii-parse-options-error-diag'Junio C Hamano
* ef/non-ascii-parse-options-error-diag: parse-options: report uncorrupted multi-byte options
2013-02-15Merge branch 'mk/old-expat'Junio C Hamano
* mk/old-expat: Allow building with xmlparse.h
2013-02-15Merge branch 'da/p4merge-mktemp-fix'Junio C Hamano
* da/p4merge-mktemp-fix: p4merge: fix printf usage
2013-02-14Documentation/git-add: kill remaining <filepattern>Junio C Hamano
The merge at 5bf72ed2 missed another instance of <filepattern> that we were converting to <pathspec>. Signed-off-by: Junio C Hamano <gitster@pobox.com>
2013-02-14user-manual: Update for receive.denyCurrentBranch=refuseW. Trevor King
acd2a45 (Refuse updating the current branch in a non-bare repository via push, 2009-02-11) changed the default to refuse such a push, but it forgot to update the docs. 7d182f5 (Documentation: receive.denyCurrentBranch defaults to 'refuse', 2010-03-17) updated Documentation/config.txt, but forgot to update the user manual. Signed-off-by: W. Trevor King <wking@tremily.us> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2013-02-14Update draft release notes to 1.8.2Junio C Hamano
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2013-02-14Merge branch 'jk/diff-graph-cleanup'Junio C Hamano
Refactors a lot of repetitive code sequence from the graph drawing code and adds it to the combined diff output. * jk/diff-graph-cleanup: combine-diff.c: teach combined diffs about line prefix diff.c: use diff_line_prefix() where applicable diff: add diff_line_prefix function diff.c: make constant string arguments const diff: write prefix to the correct file graph: output padding for merge subsequent parents
2013-02-14Merge branch 'nd/status-show-in-progress'Junio C Hamano
* nd/status-show-in-progress: status: show the branch name if possible in in-progress info
2013-02-14Merge branch 'mm/remote-mediawiki-build'Junio C Hamano
* mm/remote-mediawiki-build: git-remote-mediawiki: use toplevel's Makefile Makefile: make script-related rules usable from subdirectories
2013-02-14Merge branch 'bw/get-tz-offset-perl'Junio C Hamano
* bw/get-tz-offset-perl: cvsimport: format commit timestamp ourselves without using strftime perl/Git.pm: fix get_tz_offset to properly handle DST boundary cases Move Git::SVN::get_tz to Git::get_tz_offset
2013-02-14Merge branch 'al/mergetool-printf-fix'Junio C Hamano
* al/mergetool-printf-fix: difftool--helper: fix printf usage git-mergetool: print filename when it contains %
2013-02-14Merge branch 'jk/error-const-return'Junio C Hamano
* jk/error-const-return: Use __VA_ARGS__ for all of error's arguments
2013-02-14Merge branch 'jx/utf8-printf-width'Junio C Hamano
Use a new helper that prints a message and counts its display width to align the help messages parse-options produces. * jx/utf8-printf-width: Add utf8_fprintf helper that returns correct number of columns
2013-02-14Merge branch 'mg/bisect-doc'Junio C Hamano
* mg/bisect-doc: git-bisect.txt: clarify that reset quits bisect
2013-02-14Merge branch 'tz/perl-styles'Junio C Hamano
Add coding guidelines for writing Perl scripts for Git. * tz/perl-styles: Update CodingGuidelines for Perl
2013-02-14Merge branch 'jc/extended-fake-ancestor-for-gitlink'Junio C Hamano
Instead of requiring the full 40-hex object names on the index line, we can read submodule commit object names from the textual diff when synthesizing a fake ancestore tree for "git am -3". * jc/extended-fake-ancestor-for-gitlink: apply: verify submodule commit object name better
2013-02-14Merge branch 'dg/subtree-fixes'Junio C Hamano
contrib/subtree updates, but here are only the ones that looked ready. The remainder of the patches will have another day. * dg/subtree-fixes: contrib/subtree: make the manual directory if needed contrib/subtree: honor DESTDIR contrib/subtree: fix synopsis contrib/subtree: better error handling for 'subtree add' contrib/subtree: use %B for split subject/body contrib/subtree: remove test number comments
2013-02-13t9903: add extra tests for bash.showDirtyStateMartin Erik Werner
Add 3 extra tests for the bash.showDirtyState config option; the tests now cover all combinations of the shell var being set/unset and the config option being missing/enabled/disabled, given a dirty file. Signed-off-by: Martin Erik Werner <martinerikwerner@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2013-02-13t9903: add tests for bash.showUntrackedFilesMartin Erik Werner
Add 4 tests for the bash.showUntrackedFiles config option, covering all combinations of the shell var being set/unset and the config option being enabled/disabled (the other 2 cases, missing config with and without shell variable, are already covered by existing tests). Signed-off-by: Martin Erik Werner <martinerikwerner@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2013-02-13Makefile: don't run "rm" without any filesMatt Kraai
When COMPUTE_HEADER_DEPENDENCIES is set to "auto" and the compiler does not support it, $(dep_dirs) becomes empty. "make clean" runs "rm -rf $(dep_dirs)", which can fail in such a case. Signed-off-by: Matt Kraai <matt.kraai@amo.abbott.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2013-02-13shell prompt: add bash.showUntrackedFiles optionMartin Erik Werner
Add a config option 'bash.showUntrackedFiles' which allows enabling the prompt showing untracked files on a per-repository basis. This is useful for some repositories where the 'git ls-files ...' command may take a long time. Signed-off-by: Martin Erik Werner <martinerikwerner@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2013-02-12Merge branch 'maint'Junio C Hamano
* maint: Replace filepattern with pathspec for consistency
2013-02-12rebase -i: respect core.commentcharJohn Keeping
Commit eff80a9 (Allow custom "comment char") introduced a custom comment character for commit messages but did not teach git-rebase--interactive to use it. Change git-rebase--interactive to read core.commentchar and use its value when generating commit messages and for the command list. Signed-off-by: John Keeping <john@keeping.me.uk> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2013-02-12combine-diff.c: teach combined diffs about line prefixJohn Keeping
When running "git log --graph --cc -p" the diff output for merges is not indented by the graph structure, unlike the diffs of non-merge commits (added in commit 7be5761 - diff.c: Output the text graph padding before each diff line). Fix this by teaching the combined diff code to output diff_line_prefix() before each line. Signed-off-by: John Keeping <john@keeping.me.uk> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2013-02-12diff.c: use diff_line_prefix() where applicableJohn Keeping
Signed-off-by: John Keeping <john@keeping.me.uk> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2013-02-12diff: add diff_line_prefix functionJohn Keeping
This is a helper function to call the diff output_prefix function and return its value as a C string, allowing us to greatly simplify everywhere that needs to get the output prefix. Signed-off-by: John Keeping <john@keeping.me.uk> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2013-02-12diff.c: make constant string arguments constJohn Keeping
Signed-off-by: John Keeping <john@keeping.me.uk> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2013-02-12diff: write prefix to the correct fileJohn Keeping
Write the prefix for an output line to the same file as the actual content. Signed-off-by: John Keeping <john@keeping.me.uk> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2013-02-12completion: support 'git config --local'Matthieu Moy
This needs to be done in two places: __git_config_get_set_variables to allow clever completion of "git config --local --get foo<tab>", and _git_config to allow "git config --loc<tab>" to complete to --local. While we're there, change the order of options in the code to match git-config.txt. Signed-off-by: Matthieu Moy <Matthieu.Moy@imag.fr> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2013-02-12Replace filepattern with pathspec for consistencyMatthieu Moy
pathspec is the most widely used term, and is the one defined in gitglossary.txt. <filepattern> was used only in the synopsys for git-add and git-commit, and in git-add.txt. Get rid of it. This patch is obtained with by running: perl -pi -e 's/filepattern/pathspec/' `git grep -l filepattern` Signed-off-by: Matthieu Moy <Matthieu.Moy@imag.fr> Signed-off-by: Junio C Hamano <gitster@pobox.com>