summaryrefslogtreecommitdiff
AgeCommit message (Collapse)AuthorFilesLines
2016-07-01common-main: call sanitize_stdfds()Libravatar Jeff King4-17/+9
This is setup that should be done in every program for safety, but we never got around to adding it everywhere (so builtins benefited from the call in git.c, but any external commands did not). Putting it in the common main() gives us this safety everywhere. Note that the case in daemon.c is a little funny. We wait until we know whether we want to daemonize, and then either: - call daemonize(), which will close stdio and reopen it to /dev/null under the hood - sanitize_stdfds(), to fix up any odd cases But that is way too late; the point of sanitizing is to give us reliable descriptors on 0/1/2, and we will already have executed code, possibly called die(), etc. The sanitizing should be the very first thing that happens. With this patch, git-daemon will sanitize first, and can remove the call in the non-daemonize case. It does mean that daemonize() may just end up closing the descriptors we opened, but that's not a big deal (it's not wrong to do so, nor is it really less optimal than the case where our parent process redirected us from /dev/null ahead of time). Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2016-07-01common-main: call git_extract_argv0_path()Libravatar Jeff King12-19/+4
Every program which links against libgit.a must call this function, or risk hitting an assert() in system_path() that checks whether we have configured argv0_path (though only when RUNTIME_PREFIX is defined, so essentially only on Windows). Looking at the diff, you can see that putting it into the common main() saves us having to do it individually in each of the external commands. But what you can't see are the cases where we _should_ have been doing so, but weren't (e.g., git-credential-store, and all of the t/helper test programs). This has been an accident-waiting-to-happen for a long time, but wasn't triggered until recently because it involves one of those programs actually calling system_path(). That happened with git-credential-store in v2.8.0 with ae5f677 (lazily load core.sharedrepository, 2016-03-11). The program: - takes a lock file, which... - opens a tempfile, which... - calls adjust_shared_perm to fix permissions, which... - lazy-loads the config (as of ae5f677), which... - calls system_path() to find the location of /etc/gitconfig On systems with RUNTIME_PREFIX, this means credential-store reliably hits that assert() and cannot be used. We never noticed in the test suite, because we set GIT_CONFIG_NOSYSTEM there, which skips the system_path() lookup entirely. But if we were to tweak git_config() to find /etc/gitconfig even when we aren't going to open it, then the test suite shows multiple failures (for credential-store, and for some other test helpers). I didn't include that tweak here because it's way too specific to this particular call to be worth carrying around what is essentially dead code. The implementation is fairly straightforward, with one exception: there is exactly one caller (git.c) that actually cares about the result of the function, and not the side-effect of setting up argv0_path. We can accommodate that by simply replacing the value of argv[0] in the array we hand down to cmd_main(). Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2016-07-01add an extra level of indirection to main()Libravatar Jeff King52-69/+91
There are certain startup tasks that we expect every git process to do. In some cases this is just to improve the quality of the program (e.g., setting up gettext()). In others it is a requirement for using certain functions in libgit.a (e.g., system_path() expects that you have called git_extract_argv0_path()). Most commands are builtins and are covered by the git.c version of main(). However, there are still a few external commands that use their own main(). Each of these has to remember to include the correct startup sequence, and we are not always consistent. Rather than just fix the inconsistencies, let's make this harder to get wrong by providing a common main() that can run this standard startup. We basically have two options to do this: - the compat/mingw.h file already does something like this by adding a #define that replaces the definition of main with a wrapper that calls mingw_startup(). The upside is that the code in each program doesn't need to be changed at all; it's rewritten on the fly by the preprocessor. The downside is that it may make debugging of the startup sequence a bit more confusing, as the preprocessor is quietly inserting new code. - the builtin functions are all of the form cmd_foo(), and git.c's main() calls them. This is much more explicit, which may make things more obvious to somebody reading the code. It's also more flexible (because of course we have to figure out _which_ cmd_foo() to call). The downside is that each of the builtins must define cmd_foo(), instead of just main(). This patch chooses the latter option, preferring the more explicit approach, even though it is more invasive. We introduce a new file common-main.c, with the "real" main. It expects to call cmd_main() from whatever other objects it is linked against. We link common-main.o against anything that links against libgit.a, since we know that such programs will need to do this setup. Note that common-main.o can't actually go inside libgit.a, as the linker would not pick up its main() function automatically (it has no callers). The rest of the patch is just adjusting all of the various external programs (mostly in t/helper) to use cmd_main(). I've provided a global declaration for cmd_main(), which means that all of the programs also need to match its signature. In particular, many functions need to switch to "const char **" instead of "char **" for argv. This effect ripples out to a few other variables and functions, as well. This makes the patch even more invasive, but the end result is much better. We should be treating argv strings as const anyway, and now all programs conform to the same signature (which also matches the way builtins are defined). Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2016-06-06Git 2.8.4Libravatar Junio C Hamano4-3/+18
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2016-06-06Merge branch 'kb/msys2-tty' into maintLibravatar Junio C Hamano2-5/+56
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-06Merge branch 'da/difftool' into maintLibravatar Junio C Hamano2-2/+30
"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-06Merge branch 'tb/core-eol-fix' into maintLibravatar Junio C Hamano4-189/+141
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-06Merge branch 'ar/diff-args-osx-precompose' into maintLibravatar Junio C Hamano5-0/+47
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-05-31More topics for 2.8.4Libravatar Junio C Hamano1-0/+28
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2016-05-31Merge branch 'sb/submodule-deinit-all' into maintLibravatar Junio C Hamano3-10/+48
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-31Merge branch 'bn/http-cookiefile-config' into maintLibravatar Junio C Hamano2-3/+4
"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-31Merge branch 'jk/test-send-sh-x-trace-elsewhere' into maintLibravatar Junio C Hamano2-3/+16
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-31Merge branch 'js/name-rev-use-oldest-ref' into maintLibravatar Junio C Hamano2-7/+14
"git describe --contains" often made a hard-to-justify choice of tag to give name to a given commit, because it tried to come up with a name with smallest number of hops from a tag, causing an old commit whose close descendant that is recently tagged were not described with respect to an old tag but with a newer tag. It did not help that its computation of "hop" count was further tweaked to penalize being on a side branch of a merge. The logic has been updated to favor using the tag with the oldest tagger date, which is a lot easier to explain to the end users: "We describe a commit in terms of the (chronologically) oldest tag that contains the commit." * js/name-rev-use-oldest-ref: name-rev: include taggerdate in considering the best name
2016-05-26Start preparing for 2.8.4Libravatar Junio C Hamano1-0/+27
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2016-05-26Merge branch 'jc/linkgit-fix' into maintLibravatar Junio C Hamano8-10/+10
Many 'linkgit:<git documentation page>' references were broken, which are all fixed with this. * jc/linkgit-fix: Documentation: fix linkgit references
2016-05-26Merge branch 'ls/travis-build-doc' into maintLibravatar Junio C Hamano2-0/+29
CI test was taught to build documentation pages. * ls/travis-build-doc: travis-ci: build documentation
2016-05-26Merge branch 'jc/fsck-nul-in-commit' into maintLibravatar Junio C Hamano2-3/+31
"git fsck" learned to catch NUL byte in a commit object as potential error and warn. * jc/fsck-nul-in-commit: fsck: detect and warn a commit with embedded NUL fsck_commit_buffer(): do not special case the last validation
2016-05-26Merge branch 'jk/rebase-interative-eval-fix' into maintLibravatar Junio C Hamano1-0/+1
Portability enhancement for "rebase -i" to help platforms whose shell does not like "for i in <empty>" (which is not POSIX-kosher). * jk/rebase-interative-eval-fix: rebase--interactive: avoid empty list in shell for-loop
2016-05-26Merge branch 'js/windows-dotgit' into maintLibravatar Junio C Hamano8-3/+147
On Windows, .git and optionally any files whose name starts with a dot are now marked as hidden, with a core.hideDotFiles knob to customize this behaviour. * js/windows-dotgit: mingw: remove unnecessary definition mingw: introduce the 'core.hideDotFiles' setting
2016-05-26Merge branch 'kf/gpg-sig-verification-doc' into maintLibravatar Junio C Hamano2-4/+7
Documentation for "git merge --verify-signatures" has been updated to clarify that the signature of only the commit at the tip is verified. Also the phrasing used for signature and key validity is adjusted to align with that used by OpenPGP. * kf/gpg-sig-verification-doc: Documentation: clarify signature verification
2016-05-26Merge branch 'lp/typofixes' into maintLibravatar Junio C Hamano12-14/+14
Typofixes. * lp/typofixes: typofix: assorted typofixes in comments, documentation and messages
2016-05-26Merge branch 'sb/z-is-gnutar-ism' into maintLibravatar Junio C Hamano2-4/+4
Test fix. * sb/z-is-gnutar-ism: t6041: do not compress backup tar file t3513: do not compress backup tar file
2016-05-26Merge branch 'va/i18n-misc-updates' into maintLibravatar Junio C Hamano8-61/+111
Mark several messages for translation. * va/i18n-misc-updates: i18n: unpack-trees: avoid substituting only a verb in sentences i18n: builtin/pull.c: split strings marked for translation i18n: builtin/pull.c: mark placeholders for translation i18n: git-parse-remote.sh: mark strings for translation i18n: branch: move comment for translators i18n: branch: unmark string for translation i18n: builtin/rm.c: remove a comma ',' from string i18n: unpack-trees: mark strings for translation i18n: builtin/branch.c: mark option for translation i18n: index-pack: use plural string instead of normal one
2016-05-26Merge branch 'bn/config-doc-tt-varnames' into maintLibravatar Junio C Hamano1-21/+29
Doc formatting fixes. * bn/config-doc-tt-varnames: config: consistently format $variables in monospaced font config: describe 'pathname' value type
2016-05-26Merge branch 'nd/remote-plural-ours-plus-theirs' into maintLibravatar Junio C Hamano1-1/+1
Message fix. * nd/remote-plural-ours-plus-theirs: remote.c: specify correct plural form in "commit diverge" message
2016-05-26Merge branch 'ak/t4151-ls-files-could-be-empty' into maintLibravatar Junio C Hamano1-1/+1
Test fix. * ak/t4151-ls-files-could-be-empty: t4151: make sure argument to 'test -z' is given
2016-05-26Merge branch 'jc/test-seq' into maintLibravatar Junio C Hamano1-15/+13
Test fix. * jc/test-seq: test-lib-functions.sh: rewrite test_seq without Perl test-lib-functions.sh: remove misleading comment on test_seq
2016-05-26Merge branch 'tb/t5601-sed-fix' into maintLibravatar Junio C Hamano1-1/+1
Test fix. * tb/t5601-sed-fix: t5601: Remove trailing space in sed expression
2016-05-26Merge branch 'va/i18n-remote-comment-to-align' into maintLibravatar Junio C Hamano1-0/+2
Message fix. * va/i18n-remote-comment-to-align: i18n: remote: add comment for translators
2016-05-26Merge branch 'va/mailinfo-doc-typofix' into maintLibravatar Junio C Hamano1-1/+1
Typofix. * va/mailinfo-doc-typofix: Documentation/git-mailinfo: fix typo
2016-05-26Merge branch 'maint-2.7' into maintLibravatar Junio C Hamano1-1/+1
* maint-2.7: archive-tar: convert snprintf to xsnprintf
2016-05-26mingw: make isatty() recognize MSYS2's pseudo terminals (/dev/pty*)Libravatar Karsten Blees2-5/+56
MSYS2 emulates pseudo terminals via named pipes, and isatty() returns 0 for such file descriptors. Therefore, some interactive functionality (such as launching a pager, asking if a failed unlink should be repeated etc.) doesn't work when run in a terminal emulator that uses MSYS2's ptys (such as mintty). However, MSYS2 uses special names for its pty pipes ('msys-*-pty*'), which allows us to distinguish them from normal piped input / output. On startup, check if stdin / stdout / stderr are connected to such pipes using the NtQueryObject API from NTDll.dll. If the names match, adjust the flags in MSVCRT's ioinfo structure accordingly. Signed-off-by: Karsten Blees <blees@dcon.de> Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2016-05-26Merge branch 'jk/war-on-sprintf' into maint-2.7Libravatar Junio C Hamano1-1/+1
* jk/war-on-sprintf: archive-tar: convert snprintf to xsnprintf
2016-05-26archive-tar: convert snprintf to xsnprintfLibravatar Jeff King1-1/+1
Commit f2f0267 (archive-tar: use xsnprintf for trivial formatting, 2015-09-24) converted cases of "sprintf" to "xsnprintf", but accidentally left one as just "snprintf". This meant that we could silently truncate the resulting buffer instead of flagging an error. In practice, this is impossible to achieve, as we are formatting a ustar checksum, which can be at most 7 characters. But the point of xsnprintf is to document and check for "should be impossible" conditions; this site was just accidentally mis-converted during f2f0267. Noticed-by: Paul Green <Paul.Green@stratus.com> Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2016-05-18Git 2.8.3Libravatar Junio C Hamano4-5/+37
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2016-05-18Merge branch 'sb/misc-cleanups' into HEADLibravatar Junio C Hamano6-21/+29
* sb/misc-cleanups: submodule-config: don't shadow `cache` config.c: drop local variable credential-cache, send_request: close fd when done bundle: don't leak an fd in case of early return abbrev_sha1_in_line: don't leak memory notes: don't leak memory in git_config_get_notes_strategy
2016-05-18Merge branch 'ew/doc-split-pack-disables-bitmap' into HEADLibravatar Junio C Hamano4-9/+23
Doc update. * ew/doc-split-pack-disables-bitmap: pack-objects: warn on split packs disabling bitmaps
2016-05-18Merge branch 'sb/clean-test-fix' into HEADLibravatar Junio C Hamano1-1/+1
* sb/clean-test-fix: t7300: mark test with SANITY
2016-05-18Merge branch 'rn/glossary-typofix' into HEADLibravatar Junio C Hamano1-1/+1
* rn/glossary-typofix: Documentation: fix typo 'In such these cases'
2016-05-18Merge branch 'ew/normal-to-e' into HEADLibravatar Junio C Hamano1-0/+1
* ew/normal-to-e: .mailmap: update to my shorter email address
2016-05-18Merge branch 'sb/config-exit-status-list' into HEADLibravatar Junio C Hamano1-3/+3
Doc update. * sb/config-exit-status-list: config doc: improve exit code listing
2016-05-18Merge branch 'rt/string-list-lookup-cleanup' into HEADLibravatar Junio C Hamano1-4/+4
Code cleanup. * rt/string-list-lookup-cleanup: string_list: use string-list API in unsorted_string_list_lookup()
2016-05-18Merge branch 'jk/fix-attribute-macro-in-2.5' into HEADLibravatar Junio C Hamano1-1/+1
Code fixup. * jk/fix-attribute-macro-in-2.5: remote.c: spell __attribute__ correctly
2016-05-18Merge branch 'sg/test-lib-simplify-expr-away' into HEADLibravatar Junio C Hamano1-5/+5
Code cleanup. * sg/test-lib-simplify-expr-away: test-lib: simplify '--option=value' parsing
2016-05-18Merge branch 'nd/remove-unused' into HEADLibravatar Junio C Hamano4-27/+0
Code cleanup. * nd/remove-unused: wrapper.c: delete dead function git_mkstemps() dir.c: remove dead function fnmatch_icase()
2016-05-18Merge branch 'sk/gitweb-highlight-encoding' into HEADLibravatar Junio C Hamano1-0/+3
Some multi-byte encoding can have a backslash byte as a later part of one letter, which would confuse "highlight" filter used in gitweb. * sk/gitweb-highlight-encoding: gitweb: apply fallback encoding before highlight
2016-05-18Merge branch 'ls/travis-submitting-patches' into HEADLibravatar Junio C Hamano1-17/+63
* ls/travis-submitting-patches: Documentation: add setup instructions for Travis CI
2016-05-18Merge branch 'js/close-packs-before-gc' into HEADLibravatar Junio C Hamano1-0/+1
* js/close-packs-before-gc: t5510: run auto-gc in the foreground
2016-05-18Merge branch 'ls/p4-lfs' into HEADLibravatar Junio C Hamano3-10/+24
Recent update to Git LFS broke "git p4" by changing the output from its "lfs pointer" subcommand. * ls/p4-lfs: git-p4: fix Git LFS pointer parsing travis-ci: express Linux/OS X dependency versions more clearly travis-ci: update Git-LFS and P4 to the latest version
2016-05-18Merge branch 'ls/p4-lfs-test-fix-2.7.0' into HEADLibravatar Junio C Hamano1-1/+1
Fix a broken test. * ls/p4-lfs-test-fix-2.7.0: t9824: fix wrong reference value t9824: fix broken &&-chain in a subshell