Commit graph

43197 commits

Author SHA1 Message Date
Jeff King 0d2b664efd verify_signed_buffer: use pipe_command
This is shorter and should make the function easier to
follow. But more importantly, it removes the possibility of
any deadlocks based on reading or writing to gpg.

It's not clear if such a deadlock is possible in practice.

We do write the whole payload before reading anything, so we
could deadlock there. However, in practice gpg will need to
read our whole input to verify the signature, so it will
drain our payload first. It could write an error to stderr
before reading, but it's unlikely that such an error
wouldn't be followed by it immediately exiting, or that the
error would actually be larger than a pipe buffer.

On the writing side, we drain stderr (with the
human-readable output) in its entirety before reading stdout
(with the status-fd data). Running strace on "gpg --verify"
does show interleaved output on the two descriptors:

  write(2, "gpg: ", 5)                    = 5
  write(2, "Signature made Thu 16 Jun 2016 0"..., 73) = 73
  write(1, "[GNUPG:] SIG_ID tQw8KGcs9rBfLvAj"..., 66) = 66
  write(1, "[GNUPG:] GOODSIG 69808639F9430ED"..., 60) = 60
  write(2, "gpg: ", 5)                    = 5
  write(2, "Good signature from \"Jeff King <"..., 47) = 47
  write(2, "\n", 1)                       = 1
  write(2, "gpg: ", 5)                    = 5
  write(2, "                aka \"Jeff King <"..., 49) = 49
  write(2, "\n", 1)                       = 1
  write(1, "[GNUPG:] VALIDSIG C49CE24156AF08"..., 135) = 135
  write(1, "[GNUPG:] TRUST_ULTIMATE\n", 24) = 24

The second line written to stdout there contains the
signer's UID, which can be arbitrarily long. If it fills the
pipe buffer, then gpg would block writing to its stdout,
while we are blocked trying to read its stderr.

In practice, GPG seems to limit UIDs to 2048 bytes, so
unless your pipe buffer size is quite small, or unless gpg
does not enforce the limit under some conditions, this seems
unlikely in practice.

Still, it is not hard for us to be cautious and just use
pipe_command.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2016-06-17 17:03:57 -07:00
Jeff King 96335bcf4d run-command: add pipe_command helper
We already have capture_command(), which captures the stdout
of a command in a way that avoids deadlocks. But sometimes
we need to do more I/O, like capturing stderr as well, or
sending data to stdin. It's easy to write code that
deadlocks racily in these situations depending on how fast
the command reads its input, or in which order it writes its
output.

Let's give callers an easy interface for doing this the
right way, similar to what capture_command() did for the
simple case.

The whole thing is backed by a generic poll() loop that can
feed an arbitrary number of buffers to descriptors, and fill
an arbitrary number of strbufs from other descriptors. This
seems like overkill, but the resulting code is actually a
bit cleaner than just handling the three descriptors
(because the output code for stdout/stderr is effectively
duplicated, so being able to loop is a benefit).

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2016-06-17 17:03:56 -07:00
Jeff King 4322353bfb verify_signed_buffer: use tempfile object
We use git_mkstemp to create a temporary file, and try to
clean it up in all exit paths from the function. But that
misses any cases where we die by signal, or by calling die()
in a sub-function. In addition, we missed one of the exit
paths.

Let's convert to using a tempfile object, which handles the
hard cases for us, and add the missing cleanup call. Note
that we would not simply want to rely on program exit to
catch our missed cleanup, as this function may be called
many times in a single program (for the same reason, we use
a static tempfile instead of heap-allocating a new one; that
gives an upper bound on our memory usage).

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2016-06-17 17:03:56 -07:00
Jeff King c752fcc8e0 verify_signed_buffer: drop pbuf variable
If our caller gave us a non-NULL gpg_status parameter, we
write the gpg status into their strbuf. If they didn't, then
we write it to a temporary local strbuf (since we still need
to look at it).  The variable "pbuf" adds an extra layer of
indirection so that the rest of the function can just access
whichever is appropriate.

However, the name "pbuf" isn't very descriptive, and it's
easy to get confused about what is supposed to be in it
(especially because we are reading both "status" and
"output" from gpg).

Rather than give it a more descriptive name, we can just use
gpg_status as our indirection pointer. Either it points to
the caller's input, or we can point it directly to our
temporary buffer.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2016-06-17 17:03:56 -07:00
Jeff King aedb5dc343 gpg-interface: use child_process.args
Our argv allocations are relatively straightforward, but
this avoids us having to manually keep the count up to date
(or create new to-be-replaced slots in the declaration) when
we add new arguments.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2016-06-17 17:03:55 -07:00
Junio C Hamano 05219a1276 Git 2.9
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2016-06-13 10:42:13 -07:00
Junio C Hamano 25c7aeb1ad l10n-2.9.0-rc0
-----BEGIN PGP SIGNATURE-----
 Version: GnuPG v1
 
 iQIcBAABAgAGBQJXXIv4AAoJEMek6Rt1RHooVcAQAKmAWH7rpaYzTnnqQTeaLmUu
 M17SKUiC1sJgfz87aN/Uy7TJ6ScmFqU3JLbDiCG7FLhmzaNJAlyWiFquteRxdy8t
 t0GfAXwBnYAKI1wFgI80ncYqOpYU9TT8KQfN8SE9fel7ZThsEPWx9r7wJGQ4gpUK
 veh5VZxT82jUgX7afpe11PYKKxro5q3RMg7bvL8DCQ6/Ieo8FhZXNxc5FzycmTom
 LXG3A135tv0qyiCtSajtHLatV1ZzYvYh15sr0aVvORLcbn2Kgz75i39md2dU37BW
 fjoFlgAUnBVjARyyI2HSFLh9WQ12ScRndL2hfni0H3oEKF1x3l7hFoP6ZrDR0mMv
 gh/dK3h0bS/5/BpS9jGNBoLavPCtT59rcnf4z2WEs5aGDqlZR9yDYTYLviET7kXX
 5uU/bcmReOphwuY62UnV/DldA5FmcSeoufVeRSqpGdA7FHnSoYl96h5v+CrV+DyB
 mHLIhqNVn2pXFw8XELD0JY9Ywti3KKAN9etOnC+0ebEAwhr3VvSCOCqPTu4RM5Lz
 73pqpDYlz+7Bk/aAOnFo8nKOn6ASXD51ZqBFbU9lbjKkK+ze3ZJEjBNQ3uAVkX7S
 oraqywkDCtpGBzGV8qZWEZdmTXr1mCHGIflv8SQATLW147kOhIu5YUEFtQG7xTUS
 tRoe7Y55D3ITb5a6iFv9
 =mLXA
 -----END PGP SIGNATURE-----

Merge tag 'l10n-2.9.0-rc0' of git://github.com/git-l10n/git-po

l10n-2.9.0-rc0

* tag 'l10n-2.9.0-rc0' of git://github.com/git-l10n/git-po:
  l10n: ko.po: Update Korean translation
  l10n: ru.po: update Russian translation
  l10n: de.po: translate 104 new messages
  l10n: zh_CN: review for git v2.9.0 l10n round 1
  l10n: zh_CN: for git v2.9.0 l10n round 1
  l10n: pt_PT: update Portuguese translation
  l10n: pt_PT: update according to git-gui glossary
  l10n: pt_PT: merge git.pot file
  l10n: Updated Bulgarian translation of git (2597t,0f,0u)
  l10n: sv.po: Update Swedish translation (2597t0f0u)
  l10n: fr.po v2.9.0rnd1
  l10n: Updated Vietnamese translation (2597t)
  l10n: git.pot: v2.9.0 round 1 (104 new, 37 removed)
  l10n: fr.po Fixed grammar mistake
2016-06-12 18:00:57 -07:00
Changwoo Ryu ad583ebe08 l10n: ko.po: Update Korean translation 2016-06-12 01:25:58 +09:00
Jiang Xin 091a8f769d Merge branch 'russian-l10n' of https://github.com/DJm00n/git-po-ru
* 'russian-l10n' of https://github.com/DJm00n/git-po-ru:
  l10n: ru.po: update Russian translation
2016-06-11 20:21:52 +08:00
Dimitriy Ryazantcev 92c28525f6 l10n: ru.po: update Russian translation
Signed-off-by: Dimitriy Ryazantcev <dimitriy.ryazantcev@gmail.com>
2016-06-11 12:53:43 +03:00
Junio C Hamano a28705da92 Hopefully the final last-minute update before 2.9 final
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2016-06-10 15:30:19 -07:00
Junio C Hamano e5f7675544 Merge branch 'jk/diff-compact-heuristic'
It turns out that the earlier effort to update the heuristics may
want to use a bit more time to mature.  Turn it off by default.

* jk/diff-compact-heuristic:
  diff: disable compaction heuristic for now
2016-06-10 15:26:06 -07:00
Junio C Hamano 45c0c21eb9 Merge branch 'jk/shell-portability'
test fixes.

* jk/shell-portability:
  t5500 & t7403: lose bash-ism "local"
  test-lib: add in-shell "env" replacement
2016-06-10 15:26:05 -07:00
Junio C Hamano 8ffc9d26e4 Merge branch 'jc/t2300-setup'
A test fix.

* jc/t2300-setup:
  t2300: run git-sh-setup in an environment that better mimics the real life
2016-06-10 15:26:04 -07:00
Junio C Hamano 5580b271af diff: disable compaction heuristic for now
http://lkml.kernel.org/g/20160610075043.GA13411@sigill.intra.peff.net
reports that a change to add a new "function" with common ending
with the existing one at the end of the file is shown like this:

    def foo
      do_foo_stuff()

   +  common_ending()
   +end
   +
   +def bar
   +  do_bar_stuff()
   +
      common_ending()
    end

when the new heuristic is in use.  In reality, the change is to add
the blank line before "def bar" and everything below, which is what
the code without the new heuristic shows.

Disable the heuristics by default, and resurrect the documentation
for the option and the configuration variables, while clearly
marking the feature as still experimental.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
2016-06-10 13:45:23 -07:00
Ralf Thielow b0e098ce46 l10n: de.po: translate 104 new messages
Translate 104 new messages came from git.pot update in f517e50
(l10n: git.pot: v2.9.0 round 1 (104 new, 37 removed)).

Signed-off-by: Ralf Thielow <ralf.thielow@gmail.com>
2016-06-10 18:00:46 +02:00
Ray Chen aef18cc606 l10n: zh_CN: review for git v2.9.0 l10n round 1
Signed-off-by: Ray Chen <oldsharp@gmail.com>
Signed-off-by: Jiang Xin <worldhello.net@gmail.com>
2016-06-09 22:08:39 +08:00
Junio C Hamano 49fa3dc761 Git 2.9-rc2
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2016-06-06 14:34:52 -07:00
Junio C Hamano c42b5d8e69 Sync with 2.8.4
* maint:
  Git 2.8.4
2016-06-06 14:30:49 -07:00
Junio C Hamano 0b65a8dbdb Git 2.8.4
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2016-06-06 14:29:32 -07:00
Junio C Hamano 1676827c85 Merge branch 'kb/msys2-tty' into maint
The "are we talking with TTY, doing an interactive session?"
detection has been updated to work better for "Git for Windows".

* kb/msys2-tty:
  mingw: make isatty() recognize MSYS2's pseudo terminals (/dev/pty*)
2016-06-06 14:27:38 -07:00
Junio C Hamano 389c3289cf Merge branch 'da/difftool' into maint
"git difftool" learned to handle unmerged paths correctly in
dir-diff mode.

* da/difftool:
  difftool: handle unmerged files in dir-diff mode
  difftool: initialize variables for readability
2016-06-06 14:27:37 -07:00
Junio C Hamano 7dcbf891d9 Merge branch 'tb/core-eol-fix' into maint
A couple of bugs around core.autocrlf have been fixed.

* tb/core-eol-fix:
  convert.c: ident + core.autocrlf didn't work
  t0027: test cases for combined attributes
  convert: allow core.autocrlf=input and core.eol=crlf
  t0027: make commit_chk_wrnNNO() reliable
2016-06-06 14:27:36 -07:00
Junio C Hamano 05781d37fa Merge branch 'ar/diff-args-osx-precompose' into maint
Many commands normalize command line arguments from NFD to NFC
variant of UTF-8 on OSX, but commands in the "diff" family did
not, causing "git diff $path" to complain that no such path is
known to Git.  They have been taught to do the normalization.

* ar/diff-args-osx-precompose:
  diff: run arguments through precompose_argv
2016-06-06 14:27:35 -07:00
Junio C Hamano 283badc38e Merge branch 'sb/submodule-helper-relative-path'
A bash-ism "local" has been removed from "git submodule" scripted
Porcelain.

* sb/submodule-helper-relative-path:
  submodule: remove bashism from shell script
2016-06-06 14:18:55 -07:00
Junio C Hamano f6136f3c39 Merge branch 'sb/submodule-helper-list-signal-unmatch-via-exit-status'
The way how "submodule--helper list" signals unmatch error to its
callers has been updated.

* sb/submodule-helper-list-signal-unmatch-via-exit-status:
  submodule--helper: offer a consistent API
2016-06-06 14:18:55 -07:00
Jiang Xin 5b04ee3b95 l10n: zh_CN: for git v2.9.0 l10n round 1
Update 104 new translations (2596t1f0u) for git v2.9.0-rc0.

Signed-off-by: Jiang Xin <worldhello.net@gmail.com>
2016-06-06 22:33:59 +08:00
Junio C Hamano 6326f19925 Almost ready for 2.9-rc2
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2016-06-03 14:38:35 -07:00
Junio C Hamano bf523da2a2 Merge branch 'rs/apply-name-terminate'
Code clean-up.

* rs/apply-name-terminate:
  apply: remove unused parameters from name_terminate()
2016-06-03 14:38:04 -07:00
Junio C Hamano 29e54b019f Merge branch 'rs/patch-id-use-skip-prefix'
Code clean-up.

* rs/patch-id-use-skip-prefix:
  patch-id: use starts_with() and skip_prefix()
2016-06-03 14:38:03 -07:00
Junio C Hamano fb14575e10 Merge branch 'bd/readme.markdown-more'
The mark-up in the top-level README.md file has been updated to
typeset CLI command names differently from the body text.

* bd/readme.markdown-more:
  README.md: format CLI commands with code syntax
2016-06-03 14:38:02 -07:00
Junio C Hamano ec5ad66ee2 Merge branch 'mm/makefile-developer-can-be-in-config-mak'
"make DEVELOPER=1" worked as expected; setting DEVELOPER=1 in
config.mak didn't.

* mm/makefile-developer-can-be-in-config-mak:
  Makefile: add $(DEVELOPER_CFLAGS) variable
  Makefile: move 'ifdef DEVELOPER' after config.mak* inclusion
2016-06-03 14:38:02 -07:00
Junio C Hamano a8398b952d Merge branch 'em/man-bold-literal'
The manpage output of our documentation did not render well in
terminal; typeset literals in bold by default to make them stand
out more.

* em/man-bold-literal:
  Documentation: bold literals in man
2016-06-03 14:38:02 -07:00
Junio C Hamano 1df2d6e8df Merge branch 'pa/cherry-pick-doc-typo'
"git cherry-pick --help" had three instances of word "behavior",
one of which was spelled "behaviour", which is updated to match the
other two.

* pa/cherry-pick-doc-typo:
  git-cherry-pick.txt: correct a small typo
2016-06-03 14:38:02 -07:00
Junio C Hamano 160ef79cec Merge branch 'mr/send-email-doc-gmail-2fa'
Typofix.

* mr/send-email-doc-gmail-2fa:
  Documentation/git-send-email: fix typo in gmail 2FA section
2016-06-03 14:38:01 -07:00
Junio C Hamano 7267404dc5 Merge branch 'js/rebase-i-dedup-call-to-rerere'
"git rebase -i", after it fails to auto-resolve the conflict, had
an unnecessary call to "git rerere" from its very early days, which
was spotted recently; the call has been removed.

* js/rebase-i-dedup-call-to-rerere:
  rebase -i: remove an unnecessary 'rerere' invocation
2016-06-03 14:38:01 -07:00
Junio C Hamano be3ac81f0c Merge branch 'js/perf-rebase-i'
The one in 'master' has a brown-paper-bag bug that breaks the perf
test when used inside a usual Git repository with a working tree.

* js/perf-rebase-i:
  perf: make the tests work without a worktree
2016-06-03 14:38:00 -07:00
SZEDER Gábor 1df036ea25 Documentation/git-send-email: fix typo in gmail 2FA section
Signed-off-by: SZEDER Gábor <szeder@ira.uka.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2016-06-01 17:23:38 -07:00
Junio C Hamano fe17fc0006 t2300: run git-sh-setup in an environment that better mimics the real life
When we run scripted Porcelains, "git" potty has set up the $PATH by
prepending $GIT_EXEC_PATH, the path given by "git --exec-path=$there
$cmd", etc. already.  Because of this, scripted Porcelains can
dot-source shell script library like git-sh-setup with simple dot
without specifying any path.

t2300 however dot-sources git-sh-setup without adjusting $PATH like
the real "git" potty does.  This has not been a problem so far, but
once git-sh-setup wants to rely on the $PATH adjustment, just like
any scripted Porcelains already do, it would become one.  It cannot
for example dot-source another shell library without specifying the
full path to it by prefixing $(git --exec-path).

Signed-off-by: Junio C Hamano <gitster@pobox.com>
2016-06-01 14:15:17 -07:00
Junio C Hamano e256eec79d t5500 & t7403: lose bash-ism "local"
In t5500::check_prot_host_port_path(), diagport is not a variable
used elsewhere and the function is not recursively called so this
can simply lose the "local", which may not be supported by shell
(besides, the function liberally clobbers other variables without
making them "local").

t7403::reset_submodule_urls() overrides the "root" variable used
in the test framework for no good reason; its use is not about
temporarily relocating where the test repositories are created.
This assignment can be made not to clobber the variable by moving
them into the subshells it already uses.  Its value is always
$TRASH_DIRECTORY, so we could use it instead there, and this
function that is called only once and its two subshells may not be
necessary (instead, the caller can use "git -C $there config" and
set a value that is derived from $TRASH_DIRECTORY), but this is a
minimum fix that is needed to lose "local".

Helped-by: John Keeping <john@keeping.me.uk>
Helped-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2016-06-01 14:00:33 -07:00
Stefan Beller 44431df024 submodule: remove bashism from shell script
Junio pointed out `relative_path` was using bashisms via the
local variables. As the longer term goal is to rewrite most of the
submodule code in C, do it now.

Signed-off-by: Stefan Beller <sbeller@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2016-06-01 11:32:53 -07:00
Stefan Beller b0f4b40846 submodule--helper: offer a consistent API
In 48308681 (2016-02-29, git submodule update: have a dedicated helper
for cloning), the helper communicated errors back only via exit code,
and dance with printing '#unmatched' in case of error was left to
git-submodule.sh as it uses the output of the helper and pipes it into
shell commands. This change makes the helper consistent by never
printing '#unmatched' in the helper but always handling these piping
issues in the actual shell script.

Signed-off-by: Stefan Beller <sbeller@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2016-06-01 11:31:49 -07:00
Matthieu Moy 51dd3e81d4 Makefile: add $(DEVELOPER_CFLAGS) variable
This does not change the behavior, but allows the user to tweak
DEVELOPER_CFLAGS on the command-line or in a config.mak* file if
needed.

This also makes the code somewhat cleaner as it follows the pattern

<initialisation of variables>
<include statements>
<actual build logic>

by specifying which flags to activate in the first part, and actually
activating them in the last one.

Signed-off-by: Matthieu Moy <Matthieu.Moy@imag.fr>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2016-06-01 08:17:15 -07:00
Jeff King d2554c7207 test-lib: add in-shell "env" replacement
The one-shot environment variable syntax:

  FOO=BAR some-program

is unportable when some-program is actually a shell
function, like test_must_fail (on some shells FOO remains
set after the function returns, and on others it does not).

We sometimes get around this by using env, like:

  test_must_fail env FOO=BAR some-program

But that only works because test_must_fail's arguments are
themselves a command which can be run. You can't run:

  env FOO=BAR test_must_fail some-program

because env does not know about our shell functions. So
there is no equivalent for test_commit, for example, and one
must resort to:

  (
    FOO=BAR
    export FOO
    test_commit
  )

which is a bit verbose.  Let's add a version of "env" that
works _inside_ the shell, by creating a subshell, exporting
variables from its argument list, and running the command.

Its use is demonstrated on a currently-unportable case in
t4014.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2016-06-01 08:04:08 -07:00
Junio C Hamano 60bd4b1c51 Git 2.9-rc1
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2016-05-31 14:12:15 -07:00
Junio C Hamano 257f6f404b Merge branch 'maint'
* maint:
  More topics for 2.8.4
2016-05-31 14:12:08 -07:00
Junio C Hamano 4b0891ffe4 More topics for 2.8.4
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2016-05-31 14:11:38 -07:00
Junio C Hamano 3296e1a93a Merge branch 'sb/submodule-deinit-all' into maint
Correct faulty recommendation to use "git submodule deinit ." when
de-initialising all submodules, which would result in a strange
error message in a pathological corner case.

* sb/submodule-deinit-all:
  submodule deinit: require '--all' instead of '.' for all submodules
2016-05-31 14:09:46 -07:00
Junio C Hamano e646a82ce2 Merge branch 'bn/http-cookiefile-config' into maint
"http.cookieFile" configuration variable clearly wants a pathname,
but we forgot to treat it as such by e.g. applying tilde expansion.

* bn/http-cookiefile-config:
  http: expand http.cookieFile as a path
  Documentation: config: improve word ordering for http.cookieFile
2016-05-31 14:08:28 -07:00
Junio C Hamano 68a6e976a8 Merge branch 'jk/test-send-sh-x-trace-elsewhere' into maint
Running tests with '-x' option to trace the individual command
executions is a useful way to debug test scripts, but some tests
that capture the standard error stream and check what the command
said can be broken with the trace output mixed in.  When running
our tests under "bash", however, we can redirect the trace output
to another file descriptor to keep the standard error of programs
being tested intact.

* jk/test-send-sh-x-trace-elsewhere:
  test-lib: set BASH_XTRACEFD automatically
2016-05-31 14:08:27 -07:00