summaryrefslogtreecommitdiff
AgeCommit message (Collapse)AuthorFilesLines
2015-06-28fsck: it is OK for a tag and a commit to lack the bodyLibravatar Junio C Hamano1-4/+13
When fsck validates a commit or a tag, it scans each line in the header of the object using helper functions such as "start_with()", etc. that work on a NUL terminated buffer, but before a1e920a0 (index-pack: terminate object buffers with NUL, 2014-12-08), the validation functions were fed the object data in a piece of memory that is not necessarily terminated with a NUL. We added a helper function require_end_of_header() to be called at the beginning of these validation functions to insist that the object data contains an empty line before its end. The theory is that the validating functions will notice and stop when it hits an empty line as a normal end of header (or a required header line that is missing) without scanning past the end of potentially not NUL-terminated buffer. But the theory forgot that in the older days, Git itself happily created objects with only the header lines without a body. This caused Git 2.2 and later to issue an unnecessary warning in some existing repositories. With a1e920a0, we do not need to require an empty line (or the body) in these objects to safely parse and validate them. Drop the offending "must have an empty line" check from this helper function, while keeping the other check to make sure that there is no NUL in the header part of the object, and adjust the name of the helper to what it does accordingly. Noticed-by: Wolfgang Denk <wd@denx.de> Helped-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2014-12-09index-pack: terminate object buffers with NULLibravatar Duy Nguyen2-3/+3
We have some tricky checks in fsck that rely on a side effect of require_end_of_header(), and would otherwise easily run outside non-NUL-terminated buffers. This is a bit brittle, so let's make sure that only NUL-terminated buffers are passed around to begin with. Jeff "Peff" King contributed the detailed analysis which call paths are involved and pointed out that we also have to patch the get_data() function in unpack-objects.c, which is what Johannes "Dscho" Schindelin implemented. Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> Analyzed-by: Jeff King <peff@peff.net> Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2014-12-09fsck: properly bound "invalid tag name" error messageLibravatar Jeff King2-3/+8
When we detect an invalid tag-name header in a tag object, like, "tag foo bar\n", we feed the pointer starting at "foo bar" to a printf "%s" formatter. This shows the name, as we want, but then it keeps printing the rest of the tag buffer, rather than stopping at the end of the line. Our tests did not notice because they look only for the matching line, but the bug is that we print much more than we wanted to. So we also adjust the test to be more exact. Note that when fscking tags with "index-pack --strict", this is even worse. index-pack does not add a trailing NUL-terminator after the object, so we may actually read past the buffer and print uninitialized memory. Running t5302 with valgrind does notice the bug for that reason. Signed-off-by: Jeff King <peff@peff.net> Acked-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2014-09-12Make sure that index-pack --strict checks tag objectsLibravatar Johannes Schindelin1-0/+19
One of the most important use cases for the strict tag object checking is when transfer.fsckobjects is set to true to catch invalid objects early on. This new regression test essentially tests the same code path by directly calling 'index-pack --strict' on a pack containing an tag object without a 'tagger' line. Technically, this test is not enough: it only exercises a code path that *warns*, not one that *fails*. The reason is that hash-object and pack-objects both insist on parsing the tag objects and would fail on invalid tag objects at this time. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2014-09-11Add regression tests for stricter tag fsck'ingLibravatar Johannes Schindelin1-0/+19
The intent of the new test case is to catch general breakages in the fsck_tag() function, not so much to test it extensively, trying to strike the proper balance between thoroughness and speed. While it *would* have been nice to test the code path where fsck_object() encounters an invalid tag object, this is not possible using git fsck: tag objects are parsed already before fsck'ing (and the parser already fails upon such objects). Even worse: we would not even be able write out invalid tag objects because git hash-object parses those objects, too, unless we resorted to really ugly hacks such as using something like this in the unit tests (essentially depending on Perl *and* Compress::Zlib): hash_invalid_object () { contents="$(printf '%s %d\0%s' "$1" ${#2} "$2")" && sha1=$(echo "$contents" | test-sha1) && suffix=${sha1#??} && mkdir -p .git/objects/${sha1%$suffix} && echo "$contents" | perl -MCompress::Zlib -e 'undef $/; print compress(<>)' \ > .git/objects/${sha1%$suffix}/$suffix && echo $sha1 } Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2014-09-11fsck: check tag objects' headersLibravatar Johannes Schindelin1-1/+85
We inspect commit objects pretty much in detail in git-fsck, but we just glanced over the tag objects. Let's be stricter. Since we do not want to limit 'tag' lines unduly, values that would fail the refname check only result in warnings, not errors. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2014-09-11Make sure fsck_commit_buffer() does not run out of the bufferLibravatar Johannes Schindelin1-0/+23
So far, we assumed that the buffer is NUL terminated, but this is not a safe assumption, now that we opened the fsck_object() API to pass a buffer directly. So let's make sure that there is at least an empty line in the buffer. That way, our checks would fail if the empty line was encountered prematurely, and consequently we can get away with the current string comparisons even with non-NUL-terminated buffers are passed to fsck_object(). Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2014-09-10fsck_object(): allow passing object data separately from the object itselfLibravatar Johannes Schindelin5-16/+31
When fsck'ing an incoming pack, we need to fsck objects that cannot be read via read_sha1_file() because they are not local yet (and might even be rejected if transfer.fsckobjects is set to 'true'). For commits, there is a hack in place: we basically cache commit objects' buffers anyway, but the same is not true, say, for tag objects. By refactoring fsck_object() to take the object buffer and size as optional arguments -- optional, because we still fall back to the previous method to look at the cached commit objects if the caller passes NULL -- we prepare the machinery for the upcoming handling of tag objects. The assumption that such buffers are inherently NUL terminated is now wrong, of course, hence we pass the size of the buffer so that we can add a sanity check later, to prevent running past the end of the buffer. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2014-09-10Refactor type_from_string() to allow continuing after detecting an errorLibravatar Johannes Schindelin2-3/+11
In the next commits, we will enhance the fsck_tag() function to check tag objects more thoroughly. To this end, we need a function to verify that a given string is a valid object type, but that does not die() in the negative case. While at it, prepare type_from_string() for counted strings, i.e. strings with an explicitly specified length rather than a NUL termination. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2014-09-09Update draft release notes to 2.2Libravatar Junio C Hamano1-3/+42
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2014-09-09Merge branch 'sp/pack-protocol-doc-on-shallow'Libravatar Junio C Hamano1-1/+1
* sp/pack-protocol-doc-on-shallow: Document LF appearing in shallow command during send-pack/receive-pack
2014-09-09Merge branch 'tf/imap-send-create'Libravatar Junio C Hamano2-51/+33
* tf/imap-send-create: imap-send: create target mailbox if it is missing imap-send: clarify CRAM-MD5 vs LOGIN documentation
2014-09-09Merge branch 'jk/prompt-stash-could-be-packed'Libravatar Junio C Hamano1-1/+2
The prompt script checked $GIT_DIR/ref/stash file to see if there is a stash, which was a no-no. * jk/prompt-stash-could-be-packed: git-prompt: do not look for refs/stash in $GIT_DIR
2014-09-09Merge branch 'tb/pretty-format-cd-date-format'Libravatar Junio C Hamano1-1/+1
Documentation update. * tb/pretty-format-cd-date-format: pretty: note that %cd respects the --date= option
2014-09-09Merge branch 'rs/inline-compat-path-macros'Libravatar Junio C Hamano1-6/+22
* rs/inline-compat-path-macros: turn path macros into inline function
2014-09-09Merge branch 'rs/clean-menu-item-defn'Libravatar Junio C Hamano1-1/+1
* rs/clean-menu-item-defn: clean: use f(void) instead of f() to declare a pointer to a function without arguments
2014-09-09Merge branch 'jc/config-mak-document-darwin-vs-macosx'Libravatar Junio C Hamano1-0/+5
* jc/config-mak-document-darwin-vs-macosx: config.mak.uname: add hint on uname_R for MacOS X config.mak.uname: set NO_APPLE_COMMON_CRYPTO on older systems
2014-09-09Merge branch 'sb/mailsplit-dead-code-removal'Libravatar Junio C Hamano1-11/+6
* sb/mailsplit-dead-code-removal: mailsplit.c: remove dead code
2014-09-09Merge branch 'so/rebase-doc'Libravatar Junio C Hamano1-5/+2
May need further updates to the description to explain what makes various modes of operation to decide that the request can become a "no-op". * so/rebase-doc: Documentation/git-rebase.txt: -f forces a rebase that would otherwise be a no-op
2014-09-09Merge branch 'sb/prepare-revision-walk-error-check'Libravatar Junio C Hamano3-3/+7
* sb/prepare-revision-walk-error-check: prepare_revision_walk(): check for return value in all places
2014-09-09Merge branch 'sb/blame-msg-i18n'Libravatar Junio C Hamano1-1/+1
* sb/blame-msg-i18n: builtin/blame.c: add translation to warning about failed revision walk
2014-09-09Merge branch 'nd/strbuf-utf8-replace'Libravatar Junio C Hamano2-0/+10
* nd/strbuf-utf8-replace: utf8.c: fix strbuf_utf8_replace() consuming data beyond input string
2014-09-09Merge branch 'sb/plug-leaks'Libravatar Junio C Hamano2-3/+5
* sb/plug-leaks: clone.c: don't leak memory in cmd_clone remote.c: don't leak the base branch name in format_tracking_info
2014-09-09Merge branch 'rs/refresh-beyond-symlink'Libravatar Junio C Hamano2-0/+51
"git add x" where x that used to be a directory has become a symbolic link to a directory misbehaved. * rs/refresh-beyond-symlink: read-cache: check for leading symlinks when refreshing index
2014-09-09Merge branch 'la/init-doc'Libravatar Junio C Hamano1-39/+46
* la/init-doc: Documentation: git-init: flesh out example Documentation: git-init: template directory: reword and cross-reference Documentation: git-init: reword parenthetical statements Documentation: git-init: --separate-git-dir: clarify Documentation: git-init: template directory: reword Documentation: git-init: list items facelift Documentation: git-init: typographical fixes
2014-09-09Merge branch 'jk/stash-list-p'Libravatar Junio C Hamano2-1/+43
Teach "git stash list -p" to show the difference between the base commit version and the working tree version, which is in line with what "git show" gives. * jk/stash-list-p: stash: default listing to working-tree diff
2014-09-09Merge branch 'mm/log-branch-desc-plug-leak'Libravatar Junio C Hamano1-0/+1
* mm/log-branch-desc-plug-leak: builtin/log.c: fix minor memory leak
2014-09-09Merge branch 'lf/bundle-exclusion'Libravatar Junio C Hamano2-3/+6
"git bundle create" with date-range specification were meant to exclude tags outside the range * lf/bundle-exclusion: bundle: fix exclusion of annotated tags
2014-09-09Merge branch 'jc/apply-ws-prefix'Libravatar Junio C Hamano3-63/+96
Applying a patch not generated by Git in a subdirectory used to check the whitespace breakage using the attributes for incorrect paths. Also whitespace checks were performed even for paths excluded via "git apply --exclude=<path>" mechanism. * jc/apply-ws-prefix: apply: omit ws check for excluded paths apply: hoist use_patch() helper for path exclusion up apply: use the right attribute for paths in non-Git patches
2014-09-09Merge branch 'jk/command-line-config-empty-string'Libravatar Junio C Hamano3-2/+26
"git -c section.var command" and "git -c section.var= command" should pass the configuration differently (the former should be a boolean true, the latter should be an empty string). * jk/command-line-config-empty-string: config: teach "git -c" to recognize an empty string
2014-09-09Merge branch 'bc/imap-send-doc'Libravatar Junio C Hamano1-4/+3
* bc/imap-send-doc: imap-send doc: omit confusing "to use imap-send" modifier
2014-09-09Merge branch 'jc/not-mingw-cygwin'Libravatar Junio C Hamano15-60/+56
We have been using NOT_{MINGW,CYGWIN} test prerequisites long before Peff invented support for negated prerequisites e.g. !MINGW and we still add more uses of the former. Convert them to the latter to avoid confusion. * jc/not-mingw-cygwin: test prerequisites: enumerate with commas test prerequisites: eradicate NOT_FOO
2014-09-02Start the post-2.1 cycleLibravatar Junio C Hamano3-2/+54
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2014-09-02Merge branch 'rs/strbuf-getcwd'Libravatar Junio C Hamano15-178/+191
Reduce the use of fixed sized buffer passed to getcwd() calls by introducing xgetcwd() helper. * rs/strbuf-getcwd: use strbuf_add_absolute_path() to add absolute paths abspath: convert absolute_path() to strbuf use xgetcwd() to set $GIT_DIR use xgetcwd() to get the current directory or die wrapper: add xgetcwd() abspath: convert real_path_internal() to strbuf abspath: use strbuf_getcwd() to remember original working directory setup: convert setup_git_directory_gently_1 et al. to strbuf unix-sockets: use strbuf_getcwd() strbuf: add strbuf_getcwd()
2014-09-02Merge branch 'ta/pretty-parse-config'Libravatar Junio C Hamano1-1/+3
* ta/pretty-parse-config: pretty.c: make git_pretty_formats_config return -1 on git_config_string failure
2014-09-02Merge branch 'bc/archive-pax-header-mode'Libravatar Junio C Hamano2-2/+7
Implementations of "tar" that do not understand an extended pax header would extract the contents of it in a regular file; make sure the permission bits of this file follows the same tar.umask configuration setting. * bc/archive-pax-header-mode: archive: honor tar.umask even for pax headers
2014-09-02Merge branch 'pr/remotes-in-hashmap'Libravatar Junio C Hamano2-17/+49
Optimize remotes configuration look-up in a repository with very many remotes defined. * pr/remotes-in-hashmap: use a hashmap to make remotes faster
2014-09-02Merge branch 'jk/pretty-empty-format'Libravatar Junio C Hamano5-6/+14
"git log --pretty/format=" with an empty format string did not mean the more obvious "No output whatsoever" but "Use default format", which was counterintuitive. * jk/pretty-empty-format: pretty: make empty userformats truly empty pretty: treat "--format=" as an empty userformat revision: drop useless string offset when parsing "--pretty"
2014-09-02Merge branch 'ta/config-set'Libravatar Junio C Hamano8-0/+801
Add in-core caching layer to let us avoid reading the same configuration files number of times. * ta/config-set: test-config: add tests for the config_set API add `config_set` API for caching config-like files
2014-09-02Merge branch 'rs/init-no-duplicate-real-path'Libravatar Junio C Hamano1-4/+4
* rs/init-no-duplicate-real-path: init: avoid superfluous real_path() calls
2014-09-02Merge branch 'mm/config-edit-global'Libravatar Junio C Hamano5-10/+69
Start "git config --edit --global" from a skeletal per-user configuration file contents, instead of a total blank, when the user does not already have any. This immediately reduces the need for a later "Have you forgotten setting core.user?" and we can add more to the template as we gain more experience. * mm/config-edit-global: commit: advertise config --global --edit on guessed identity home_config_paths(): let the caller ignore xdg path config --global --edit: create a template file if needed
2014-09-02Merge branch 'jc/reopen-lock-file'Libravatar Junio C Hamano2-0/+11
There are cases where you lock and open to write a file, close it to show the updated contents to external processes, and then have to update the file again while still holding the lock, but the lockfile API lacked support for such an access pattern. * jc/reopen-lock-file: lockfile: allow reopening a closed but still locked file
2014-08-29Merge git://github.com/git-l10n/git-poLibravatar Junio C Hamano2-1359/+1515
* git://github.com/git-l10n/git-po: po/TEAMS: add new members to German translation team l10n: de.po: translate 38 new messages
2014-08-29po/TEAMS: add new members to German translation teamLibravatar Ralf Thielow1-0/+2
Signed-off-by: Ralf Thielow <ralf.thielow@gmail.com>
2014-08-29l10n: de.po: translate 38 new messagesLibravatar Ralf Thielow1-1359/+1513
Translate 38 new messages came from git.pot update in fe05e19 (l10n: git.pot: v2.1.0 round 1 (38 new, 9 removed)). Signed-off-by: Ralf Thielow <ralf.thielow@gmail.com>
2014-08-28Document LF appearing in shallow command during send-pack/receive-packLibravatar Shawn Pearce1-1/+1
The implementation sends an LF, but the protocol documentation was missing this detail. Signed-off-by: Shawn Pearce <spearce@spearce.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2014-08-26Merge branch 'jk/diff-tree-t-fix'Libravatar Junio C Hamano2-1/+45
Fix (rarely used) "git diff-tree -t" regression in 2.0. * jk/diff-tree-t-fix: intersect_paths: respect mode in git's tree-sort
2014-08-26Merge branch 'jk/pack-shallow-always-without-bitmap'Libravatar Junio C Hamano2-0/+40
Reachability bitmaps do not work with shallow operations. Fixes regression in 2.0. * jk/pack-shallow-always-without-bitmap: pack-objects: turn off bitmaps when we see --shallow lines
2014-08-26Merge branch 'jk/fix-profile-feedback-build'Libravatar Junio C Hamano1-1/+5
Fix profile-feedback build broken in 2.1 for tarball releases. * jk/fix-profile-feedback-build: Makefile: make perf tests optional for profile build
2014-08-26use strbuf_add_absolute_path() to add absolute pathsLibravatar René Scharfe1-5/+1
Signed-off-by: Rene Scharfe <l.s.r@web.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>