Commit graph

44281 commits

Author SHA1 Message Date
Junio C Hamano 300e95f7df Merge branch 'js/regexec-buf' into maint
Some codepaths in "git diff" used regexec(3) on a buffer that was
mmap(2)ed, which may not have a terminating NUL, leading to a read
beyond the end of the mapped region.  This was fixed by introducing
a regexec_buf() helper that takes a <ptr,len> pair with REG_STARTEND
extension.

* js/regexec-buf:
  regex: use regexec_buf()
  regex: add regexec_buf() that can work on a non NUL-terminated string
  regex: -G<pattern> feeds a non NUL-terminated string to regexec() and fails
2016-09-29 16:49:45 -07:00
Junio C Hamano d336b67568 Merge branch 'nd/checkout-disambiguation' into maint
"git checkout <word>" does not follow the usual disambiguation
rules when the <word> can be both a rev and a path, to allow
checking out a branch 'foo' in a project that happens to have a
file 'foo' in the working tree without having to disambiguate.
This was poorly documented and the check was incorrect when the
command was run from a subdirectory.

* nd/checkout-disambiguation:
  checkout: fix ambiguity check in subdir
  checkout.txt: document a common case that ignores ambiguation rules
  checkout: add some spaces between code and comment
2016-09-29 16:49:44 -07:00
Junio C Hamano 7106584137 Merge branch 'ep/doc-check-ref-format-example' into maint
A shell script example in check-ref-format documentation has been
fixed.

* ep/doc-check-ref-format-example:
  git-check-ref-format.txt: fixup documentation
2016-09-29 16:49:43 -07:00
Junio C Hamano a74a3b7a0b Merge branch 'mm/config-color-ui-default-to-auto' into maint
Documentation for individual configuration variables to control use
of color (like `color.grep`) said that their default value is
'false', instead of saying their default is taken from `color.ui`.
When we updated the default value for color.ui from 'false' to
'auto' quite a while ago, all of them broke.  This has been
corrected.

* mm/config-color-ui-default-to-auto:
  Documentation/config: default for color.* is color.ui
2016-09-29 16:49:42 -07:00
Junio C Hamano eb293ac8d6 Merge branch 'jk/reduce-gc-aggressive-depth' into maint
"git gc --aggressive" used to limit the delta-chain length to 250,
which is way too deep for gaining additional space savings and is
detrimental for runtime performance.  The limit has been reduced to
50.

* jk/reduce-gc-aggressive-depth:
  gc: default aggressive depth to 50
2016-09-29 16:49:42 -07:00
Junio C Hamano e25e6f3947 Merge branch 'jk/rebase-i-drop-ident-check' into maint
Even when "git pull --rebase=preserve" (and the underlying "git
rebase --preserve") can complete without creating any new commit
(i.e. fast-forwards), it still insisted on having a usable ident
information (read: user.email is set correctly), which was less
than nice.  As the underlying commands used inside "git rebase"
would fail with a more meaningful error message and advice text
when the bogus ident matters, this extra check was removed.

* jk/rebase-i-drop-ident-check:
  rebase-interactive: drop early check for valid ident
2016-09-29 16:49:41 -07:00
Junio C Hamano 7b7e977b96 Merge branch 'jt/format-patch-base-info-above-sig' into maint
"git format-patch --base=..." feature that was recently added
showed the base commit information after "-- " e-mail signature
line, which turned out to be inconvenient.  The base information
has been moved above the signature line.

* jt/format-patch-base-info-above-sig:
  format-patch: show base info before email signature
2016-09-29 16:49:40 -07:00
Junio C Hamano 08d0f7a531 Merge branch 'ks/perf-build-with-autoconf' into maint
Performance tests done via "t/perf" did not use the same set of
build configuration if the user relied on autoconf generated
configuration.

* ks/perf-build-with-autoconf:
  t/perf/run: copy config.mak.autogen & friends to build area
2016-09-29 16:49:40 -07:00
Junio C Hamano ef4f0cad4b Merge branch 'rs/xdiff-merge-overlapping-hunks-for-W-context' into maint
"git diff -W" output needs to extend the context backward to
include the header line of the current function and also forward to
include the body of the entire current function up to the header
line of the next one.  This process may have to merge to adjacent
hunks, but the code forgot to do so in some cases.

* rs/xdiff-merge-overlapping-hunks-for-W-context:
  xdiff: fix merging of hunks with -W context and -u context
2016-09-29 16:49:39 -07:00
Junio C Hamano e007a094d4 Merge branch 'ew/http-do-not-forget-to-call-curl-multi-remove-handle' into maint
The http transport (with curl-multi option, which is the default
these days) failed to remove curl-easy handle from a curlm session,
which led to unnecessary API failures.

* ew/http-do-not-forget-to-call-curl-multi-remove-handle:
  http: always remove curl easy from curlm session on release
  http: consolidate #ifdefs for curl_multi_remove_handle
  http: warn on curl_multi_add_handle failures
2016-09-29 16:49:39 -07:00
Junio C Hamano 35ca3e538d Merge branch 'jk/patch-ids-no-merges' into maint
"git log --cherry-pick" used to include merge commits as candidates
to be matched up with other commits, resulting a lot of wasted time.
The patch-id generation logic has been updated to ignore merges to
avoid the wastage.

* jk/patch-ids-no-merges:
  patch-ids: refuse to compute patch-id for merge commit
  patch-ids: turn off rename detection
2016-09-29 16:49:38 -07:00
Junio C Hamano d7e74c940b Merge branch 'js/git-gui-commit-gpgsign' into maint
"git commit-tree" stopped reading commit.gpgsign configuration
variable that was meant for Porcelain "git commit" in Git 2.9; we
forgot to update "git gui" to look at the configuration to match
this change.

* js/git-gui-commit-gpgsign:
  git-gui: respect commit.gpgsign again
2016-09-29 16:49:38 -07:00
Junio C Hamano 35ec7fd479 Merge branch 'jk/fix-remote-curl-url-wo-proto' into maint
"git fetch http::/site/path" did not die correctly and segfaulted
instead.

* jk/fix-remote-curl-url-wo-proto:
  remote-curl: handle URLs without protocol
2016-09-29 16:49:38 -07:00
Junio C Hamano 8183592601 Merge branch 'sy/git-gui-i18n-ja' into maint
Update Japanese translation for "git-gui".

* sy/git-gui-i18n-ja:
  git-gui: update Japanese information
  git-gui: update Japanese translation
  git-gui: add Japanese language code
  git-gui: apply po template to Japanese translation
  git-gui: consistently use the same word for "blame" in Japanese
  git-gui: consistently use the same word for "remote" in Japanese
2016-09-29 16:49:37 -07:00
Junio C Hamano 73336299e1 Merge branch 'mr/vcs-svn-printf-ulong' into maint
Code cleanup.

* mr/vcs-svn-printf-ulong:
  vcs-svn/fast_export: fix timestamp fmt specifiers
2016-09-29 16:49:37 -07:00
Junio C Hamano 633212b246 Merge branch 'rs/unpack-trees-reduce-file-scope-global' into maint
Code cleanup.

* rs/unpack-trees-reduce-file-scope-global:
  unpack-trees: pass checkout state explicitly to check_updates()
2016-09-29 16:49:36 -07:00
Junio C Hamano b0af481993 Merge branch 'rs/strbuf-remove-fix' into maint
Code cleanup.

* rs/strbuf-remove-fix:
  strbuf: use valid pointer in strbuf_remove()
2016-09-29 16:49:35 -07:00
Junio C Hamano 3a3bb36514 Merge branch 'rs/checkout-some-states-are-const' into maint
Code cleanup.

* rs/checkout-some-states-are-const:
  checkout: constify parameters of checkout_stage() and checkout_merged()
2016-09-29 16:49:35 -07:00
Junio C Hamano 9e2c4fa5d3 Merge branch 'bw/pathspec-remove-unused-extern-decl' into maint
Code cleanup.

* bw/pathspec-remove-unused-extern-decl:
  pathspec: remove unnecessary function prototypes
2016-09-29 16:49:34 -07:00
Johannes Schindelin b7d36ffca0 regex: use regexec_buf()
The new regexec_buf() function operates on buffers with an explicitly
specified length, rather than NUL-terminated strings.

We need to use this function whenever the buffer we want to pass to
regexec(3) may have been mmap(2)ed (and is hence not NUL-terminated).

Note: the original motivation for this patch was to fix a bug where
`git diff -G <regex>` would crash. This patch converts more callers,
though, some of which allocated to construct NUL-terminated strings,
or worse, modified buffers to temporarily insert NULs while calling
regexec(3).  By converting them to use regexec_buf(), the code has
become much cleaner.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2016-09-21 13:56:15 -07:00
Johannes Schindelin 2f8952250a regex: add regexec_buf() that can work on a non NUL-terminated string
We just introduced a test that demonstrates that our sloppy use of
regexec() on a mmap()ed area can result in incorrect results or even
hard crashes.

So what we need to fix this is a function that calls regexec() on a
length-delimited, rather than a NUL-terminated, string.

Happily, there is an extension to regexec() introduced by the NetBSD
project and present in all major regex implementation including
Linux', MacOSX' and the one Git includes in compat/regex/: by using
the (non-POSIX) REG_STARTEND flag, it is possible to tell the
regexec() function that it should only look at the offsets between
pmatch[0].rm_so and pmatch[0].rm_eo.

That is exactly what we need.

Since support for REG_STARTEND is so widespread by now, let's just
introduce a helper function that always uses it, and tell people
on a platform whose regex library does not support it to use the
one from our compat/regex/ directory.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2016-09-21 13:56:15 -07:00
Johannes Schindelin db5dfa3314 regex: -G<pattern> feeds a non NUL-terminated string to regexec() and fails
When our pickaxe code feeds file contents to regexec(), it implicitly
assumes that the file contents are read into implicitly NUL-terminated
buffers (i.e. that we overallocate by 1, appending a single '\0').

This is not so.

In particular when the file contents are simply mmap()ed, we can be
virtually certain that the buffer is preceding uninitialized bytes, or
invalid pages.

Note that the test we add here is known to be flakey: we simply cannot
know whether the byte following the mmap()ed ones is a NUL or not.

Typically, on Linux the test passes. On Windows, it fails virtually
every time due to an access violation (that's a segmentation fault for
you Unix-y people out there). And Windows would be correct: the
regexec() call wants to operate on a regular, NUL-terminated string,
there is no NUL in the mmap()ed memory range, and it is undefined
whether the next byte is even legal to access.

When run with --valgrind it demonstrates quite clearly the breakage, of
course.

Being marked with `test_expect_failure`, this test will sometimes be
declare "TODO fixed", even if it only passes by mistake.

This test case represents a Minimal, Complete and Verifiable Example of
a breakage reported by Chris Sidi.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2016-09-21 13:56:15 -07:00
Elia Pinto 92dece7024 git-check-ref-format.txt: fixup documentation
die is not a standard shell function. Use
a different shell code for the example.

Signed-off-by: Elia Pinto <gitter.spiros@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2016-09-21 11:12:41 -07:00
Nguyễn Thái Ngọc Duy b829b9439a checkout: fix ambiguity check in subdir
The two functions in parse_branchname_arg(), verify_non_filename and
check_filename, need correct prefix in order to reconstruct the paths
and check for their existence. With NULL prefix, they just check paths
at top dir instead.

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2016-09-21 08:44:41 -07:00
Nguyễn Thái Ngọc Duy 19e5656345 checkout.txt: document a common case that ignores ambiguation rules
Normally we err on the safe side: if something can be seen as both an
SHA1 and a pathspec, we stop and scream. In checkout, there is one
exception added in 859fdab (git-checkout: improve error messages, detect
ambiguities. - 2008-07-23), to allow the common case "git checkout
branch". Let's document this exception.

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2016-09-21 08:44:41 -07:00
Junio C Hamano 7c0304af62 Start preparing for 2.10.1
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2016-09-19 13:54:50 -07:00
Junio C Hamano ddf8ee859f Merge branch 'sb/diff-cleanup' into maint
Code cleanup.

* sb/diff-cleanup:
  diff: remove dead code
  diff: omit found pointer from emit_callback
  diff.c: use diff_options directly
2016-09-19 13:51:45 -07:00
Junio C Hamano 9f3d73e8cb Merge branch 'ah/misc-message-fixes' into maint
Message cleanup.

* ah/misc-message-fixes:
  unpack-trees: do not capitalize "working"
  git-merge-octopus: do not capitalize "octopus"
  git-rebase--interactive: fix English grammar
  cat-file: put spaces around pipes in usage string
  am: put spaces around pipe in usage string
2016-09-19 13:51:45 -07:00
Junio C Hamano 0303939009 Merge branch 'sb/transport-report-missing-submodule-on-stderr' into maint
Message cleanup.

* sb/transport-report-missing-submodule-on-stderr:
  transport: report missing submodule pushes consistently on stderr
2016-09-19 13:51:45 -07:00
Junio C Hamano 51673a71e3 Merge branch 'sb/xdiff-remove-unused-static-decl' into maint
Code cleanup.

* sb/xdiff-remove-unused-static-decl:
  xdiff: remove unneeded declarations
2016-09-19 13:51:45 -07:00
Junio C Hamano 294573e6d7 Merge branch 'js/t9903-chaining' into maint
Test fix.

* js/t9903-chaining:
  t9903: fix broken && chain
2016-09-19 13:51:44 -07:00
Junio C Hamano c3befaeab9 Merge branch 'rs/hex2chr' into maint
Code cleanup.

* rs/hex2chr:
  introduce hex2chr() for converting two hexadecimal digits to a character
2016-09-19 13:51:43 -07:00
Junio C Hamano 815a73f714 Merge branch 'rs/compat-strdup' into maint
Code cleanup.

* rs/compat-strdup:
  compat: move strdup(3) replacement to its own file
2016-09-19 13:51:42 -07:00
Junio C Hamano 3d54b93f40 Merge branch 'jk/squelch-false-warning-from-gcc-o3' into maint
Compilation fix.

* jk/squelch-false-warning-from-gcc-o3:
  color_parse_mem: initialize "struct color" temporary
  error_errno: use constant return similar to error()
2016-09-19 13:51:41 -07:00
Junio C Hamano 1e28677e5b Merge branch 'ep/use-git-trace-curl-in-tests' into maint
Update a few tests that used to use GIT_CURL_VERBOSE to use the
newer GIT_TRACE_CURL.

* ep/use-git-trace-curl-in-tests:
  t5551-http-fetch-smart.sh: use the GIT_TRACE_CURL environment var
  t5550-http-fetch-dumb.sh: use the GIT_TRACE_CURL environment var
  test-lib.sh: preserve GIT_TRACE_CURL from the environment
  t5541-http-push-smart.sh: use the GIT_TRACE_CURL environment var
2016-09-19 13:51:41 -07:00
Junio C Hamano 8e26535866 Merge branch 'js/t6026-clean-up' into maint
A test spawned a short-lived background process, which sometimes
prevented the test directory from getting removed at the end of the
script on some platforms.

* js/t6026-clean-up:
  t6026-merge-attr: clean up background process at end of test case
2016-09-19 13:51:41 -07:00
Junio C Hamano d6645312ff Merge branch 'jc/forbid-symbolic-ref-d-HEAD' into maint
"git symbolic-ref -d HEAD" happily removes the symbolic ref, but
the resulting repository becomes an invalid one.  Teach the command
to forbid removal of HEAD.

* jc/forbid-symbolic-ref-d-HEAD:
  symbolic-ref -d: do not allow removal of HEAD
2016-09-19 13:51:41 -07:00
Junio C Hamano 4c10c31137 Merge branch 'jc/submodule-anchor-git-dir' into maint
Having a submodule whose ".git" repository is somehow corrupt
caused a few commands that recurse into submodules loop forever.

* jc/submodule-anchor-git-dir:
  submodule: avoid auto-discovery in prepare_submodule_repo_env()
2016-09-19 13:51:40 -07:00
Junio C Hamano 79b51ebf6f Merge branch 'jk/test-lib-drop-pid-from-results' into maint
The test framework left the number of tests and success/failure
count in the t/test-results directory, keyed by the name of the
test script plus the process ID.  The latter however turned out not
to serve any useful purpose.  The process ID part of the filename
has been removed.

* jk/test-lib-drop-pid-from-results:
  test-lib: drop PID from test-results/*.count
2016-09-19 13:51:39 -07:00
Junio C Hamano 276661ff85 Merge branch 'bh/diff-highlight-graph' into maint
"diff-highlight" script (in contrib/) learned to work better with
"git log -p --graph" output.

* bh/diff-highlight-graph:
  diff-highlight: avoid highlighting combined diffs
  diff-highlight: add multi-byte tests
  diff-highlight: ignore test cruft
  diff-highlight: add support for --graph output
  diff-highlight: add failing test for handling --graph output
  diff-highlight: add some tests
2016-09-19 13:51:38 -07:00
Junio C Hamano f0b2db228b Merge branch 'po/range-doc' into maint
Clarify various ways to specify the "revision ranges" in the
documentation.

* po/range-doc:
  doc: revisions: sort examples and fix alignment of the unchanged
  doc: revisions: show revision expansion in examples
  doc: revisions - clarify reachability examples
  doc: revisions - define `reachable`
  doc: gitrevisions - clarify 'latter case' is revision walk
  doc: gitrevisions - use 'reachable' in page description
  doc: revisions: single vs multi-parent notation comparison
  doc: revisions: extra clarification of <rev>^! notation effects
  doc: revisions: give headings for the two and three dot notations
  doc: show the actual left, right, and boundary marks
  doc: revisions - name the left and right sides
  doc: use 'symmetric difference' consistently
2016-09-19 13:51:38 -07:00
Matthieu Moy 14d16e2b35 Documentation/config: default for color.* is color.ui
Since 4c7f181 (make color.ui default to 'auto', 2013-06-10), the
default for color.* when nothing is set is 'auto' and we still claimed
that the default was 'false'. Be more precise by saying explicitly
that the default is to follow color.ui, and recall that the default is
'auto' to avoid one indirection for the reader.

Signed-off-by: Matthieu Moy <Matthieu.Moy@imag.fr>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2016-09-16 12:34:14 -07:00
Kirill Smelkov cd5c2812b6 t/perf/run: copy config.mak.autogen & friends to build area
Otherwise for people who use autotools-based configure in main worktree,
the performance testing results will be inconsistent as work and build
trees could be using e.g. different optimization levels.

See e.g.

	http://public-inbox.org/git/20160818175222.bmm3ivjheokf2qzl@sigill.intra.peff.net/

for example.

NOTE config.status has to be copied because otherwise without it the build
would want to run reconfigure this way loosing just copied config.mak.autogen.

Signed-off-by: Kirill Smelkov <kirr@nexedi.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2016-09-15 13:41:11 -07:00
Josh Triplett 480871e09e format-patch: show base info before email signature
Any text below the "-- " for the email signature gets treated as part of
the signature, and many mail clients will trim it from the quoted text
for a reply.  Move it above the signature, so people can reply to it
more easily.

Similarly, when producing the patch as a MIME attachment, the
original code placed the base info after the attached part, which
would be discarded.  Move the base info to the end of the part,
still inside the part boundary.

Add tests for the exact format of the email signature, and add tests
to ensure that the base info appears before the email signature when
producing a plain-text output, and that it appears before the part
boundary when producing a MIME attachment.

Signed-off-by: Josh Triplett <josh@joshtriplett.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2016-09-15 10:07:10 -07:00
René Scharfe 45d2f75f91 xdiff: fix merging of hunks with -W context and -u context
If the function context for a hunk (with -W) reaches the beginning of
the next hunk then we need to merge these two -- otherwise we'd show
some lines twice, which looks strange and even confuses git apply.  We
already do this checking and merging in xdl_emit_diff(), but forget to
consider regular context (with -u or -U).

Fix that by merging hunks already if function context of the first one
touches or overlaps regular context of the second one.

Signed-off-by: Rene Scharfe <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2016-09-14 16:07:21 -07:00
Mike Ralphson 5efc60c12f vcs-svn/fast_export: fix timestamp fmt specifiers
Two instances of %ld being used for unsigned longs

Signed-off-by: Mike Ralphson <mike.ralphson@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2016-09-14 08:56:50 -07:00
René Scharfe b56aa5b268 unpack-trees: pass checkout state explicitly to check_updates()
Add a parameter for the struct checkout variable to check_updates()
instead of using a static global variable.  Passing it explicitly makes
object ownership and usage more easily apparent.  And we get rid of a
static variable; those can be problematic in library-like code.

Signed-off-by: Rene Scharfe <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2016-09-13 16:26:12 -07:00
René Scharfe ce25e4c78d checkout: constify parameters of checkout_stage() and checkout_merged()
Document the fact that checkout_stage() and checkout_merged() don't
change the objects passed to them by adding the modifier const.

Signed-off-by: Rene Scharfe <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2016-09-13 16:12:28 -07:00
Brandon Williams e78d57ec8e pathspec: remove unnecessary function prototypes
A few functions were removed in 5a76aff1 ("add: convert to use
parse_pathspec", 2013-07-14), but we forgot to remove their external
declarations from pathspec.h while doing so.

Signed-off-by: Brandon Williams <bmwill@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2016-09-13 16:10:03 -07:00
René Scharfe a8342a417e strbuf: use valid pointer in strbuf_remove()
The fourth argument of strbuf_splice() is passed to memcpy(3), which is
not supposed to handle NULL pointers.  Let's be extra careful and use a
valid empty string instead.  It even shortens the source code. :)

Signed-off-by: Rene Scharfe <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2016-09-13 16:07:37 -07:00