summaryrefslogtreecommitdiff
AgeCommit message (Collapse)AuthorFilesLines
2017-10-06cache.h: document `write_locked_index()`Libravatar Martin Ågren1-0/+16
The next patches will tweak the behavior of this function. Document it in order to establish a basis for those patches. Signed-off-by: Martin Ågren <martin.agren@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2017-10-06apply: remove `newfd` from `struct apply_state`Libravatar Martin Ågren2-13/+7
Similar to a previous patch, we do not need to use `newfd` to signal that we have a lockfile to clean up. We can just unconditionally call `rollback_lock_file`. If we do not hold the lock, it will be a no-op. Where we check `newfd` to decide whether we need to take the lock, we can instead use `is_lock_file_locked()`. Signed-off-by: Martin Ågren <martin.agren@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2017-10-06apply: move lockfile into `apply_state`Libravatar Martin Ågren4-17/+9
We have two users of `struct apply_state` and the related functionality in apply.c. Each user sets up its `apply_state` by handing over a pointer to its static `lock_file`. (Before 076aa2cbd (tempfile: auto-allocate tempfiles on heap, 2017-09-05), we could never free lockfiles, so making them static was a reasonable approach.) Other than that, they never directly access their `lock_file`s, which are instead handled by the functionality in apply.c. To make life easier for the caller and to make it less tempting for a future caller to mess with the lock, make apply.c fully responsible for setting up the `lock_file`. As mentioned above, it is now safe to free a `lock_file`, so we can make the `struct apply_state` contain an actual `struct lock_file` instead of a pointer to one. The user in builtin/apply.c is rather simple. For builtin/am.c, we might worry that the lock state is actually meant to be inherited across calls. But the lock is only taken as `apply_all_patches()` executes, and code inspection shows that it will always be released. Alternatively, we can observe that the lock itself is never queried directly. When we decide whether we should lock, we check a related variable `newfd`. That variable is not inherited, so from the point of view of apply.c, the state machine really is reset with each call to `init_apply_state()`. (It would be a bug if `newfd` and the lock status were not in sync. The duplication of information in `newfd` and the lock will be addressed in the next patch.) Signed-off-by: Martin Ågren <martin.agren@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2017-10-06cache-tree: simplify locking logicLibravatar Martin Ågren1-8/+4
After we have taken the lock using `LOCK_DIE_ON_ERROR`, we know that `newfd` is non-negative. So when we check for exactly that property before calling `write_locked_index()`, the outcome is guaranteed. If we write and commit successfully, we set `newfd = -1`, so that we can later avoid calling `rollback_lock_file` on an already-committed lock. But we might just as well unconditionally call `rollback_lock_file()` -- it will be a no-op if we have already committed. All in all, we use `newfd` as a bool and the only benefit we get from it is that we can avoid calling a no-op. Remove `newfd` so that we have one variable less to reason about. Signed-off-by: Martin Ågren <martin.agren@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2017-10-06checkout-index: simplify locking logicLibravatar Martin Ågren1-5/+3
`newfd` starts out negative. If we then take the lock, `newfd` will become non-negative. We later check for exactly that property before calling `write_locked_index()`. That is, we are simply using `newfd` as a boolean to keep track of whether we took the lock or not. (We always use `newfd` and `lock_file` together, so they really are mirroring each other.) Drop `newfd` and check with `is_lock_file_locked()` instead. While at it, move the `static struct lock_file` into `cmd_checkout_index()` and make it non-static. It is only used in this function, and after 076aa2cbd (tempfile: auto-allocate tempfiles on heap, 2017-09-05), we can have lockfiles on the stack. Signed-off-by: Martin Ågren <martin.agren@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2017-10-06tempfile: fix documentation on `delete_tempfile()`Libravatar Martin Ågren1-4/+4
The function has always been documented as returning 0 or -1. It is in fact `void`. Correct that. As part of the rearrangements we lose the mention that `delete_tempfile()` might set `errno`. Because there is no return value, the user can't really know whether it did anyway. Signed-off-by: Martin Ågren <martin.agren@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2017-10-06lockfile: fix documentation on `close_lock_file_gently()`Libravatar Martin Ågren1-2/+2
Commit 83a3069a3 (lockfile: do not rollback lock on failed close, 2017-09-05) forgot to update the documentation by the function definition to reflect that the lock is not rolled back in case closing fails. Signed-off-by: Martin Ågren <martin.agren@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2017-10-06treewide: prefer lockfiles on the stackLibravatar Martin Ågren8-49/+42
There is no longer any need to allocate and leak a `struct lock_file`. The previous patch addressed an instance where we needed a minor tweak alongside the trivial changes. Deal with the remaining instances where we allocate and leak a struct within a single function. Change them to have the `struct lock_file` on the stack instead. These instances were identified by running `git grep "^\s*struct lock_file\s*\*"`. Signed-off-by: Martin Ågren <martin.agren@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2017-10-06sha1_file: do not leak `lock_file`Libravatar Martin Ågren1-11/+8
There is no longer any need to allocate and leak a `struct lock_file`. Initialize it on the stack instead. Before this patch, we set `lock = NULL` to signal that we have already rolled back, and that we should not do any more work. We need to take another approach now that we cannot assign NULL. We could, e.g., use `is_lock_file_locked()`. But we already have another variable that we could use instead, `found`. Its scope is only too small. Bump `found` to the scope of the whole function and rearrange the "roll back or write?"-checks to a straightforward if-else on `found`. This also future-proves the code by making it obvious that we intend to take exactly one of these paths. Improved-by: Jeff King <peff@peff.net> Signed-off-by: Martin Ågren <martin.agren@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2017-09-29The eleventh batch for 2.15Libravatar Junio C Hamano1-0/+18
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2017-09-29Merge branch 'sb/doc-config-submodule-update'Libravatar Junio C Hamano1-4/+8
* sb/doc-config-submodule-update: Documentation/config: clarify the meaning of submodule.<name>.update
2017-09-29Merge branch 'ma/leakplugs'Libravatar Junio C Hamano17-35/+75
Memory leaks in various codepaths have been plugged. * ma/leakplugs: pack-bitmap[-write]: use `object_array_clear()`, don't leak object_array: add and use `object_array_pop()` object_array: use `object_array_clear()`, not `free()` leak_pending: use `object_array_clear()`, not `free()` commit: fix memory leak in `reduce_heads()` builtin/commit: fix memory leak in `prepare_index()`
2017-09-29Merge branch 'rj/no-sign-compare'Libravatar Junio C Hamano10-24/+25
Many codepaths have been updated to squelch -Wsign-compare warnings. * rj/no-sign-compare: ALLOC_GROW: avoid -Wsign-compare warnings cache.h: hex2chr() - avoid -Wsign-compare warnings commit-slab.h: avoid -Wsign-compare warnings git-compat-util.h: xsize_t() - avoid -Wsign-compare warnings
2017-09-29Merge branch 'sb/merge-commit-msg-hook'Libravatar Junio C Hamano1-5/+4
As "git commit" to conclude a conflicted "git merge" honors the commit-msg hook, "git merge" that records a merge commit that cleanly auto-merges should, but it didn't. * sb/merge-commit-msg-hook (2017-09-22) 1 commit (merged to 'next' on 2017-09-25 at 096e0502a8) + Documentation/githooks: mention merge in commit-msg hook Add documentation for a topic that has recently graduated to the 'master' branch. * sb/merge-commit-msg-hook: Documentation/githooks: mention merge in commit-msg hook
2017-09-29Merge branch 'jt/fast-export-copy-modify-fix'Libravatar Junio C Hamano2-15/+51
"git fast-export" with -M/-C option issued "copy" instruction on a path that is simultaneously modified, which was incorrect. * jt/fast-export-copy-modify-fix: fast-export: do not copy from modified file
2017-09-29Merge branch 'mk/describe-match-with-all'Libravatar Junio C Hamano3-22/+58
"git describe --match <pattern>" has been taught to play well with the "--all" option. * mk/describe-match-with-all: describe: teach --match to handle branches and remotes
2017-09-29Merge branch 'jm/status-ignored-directory-optim'Libravatar Junio C Hamano1-6/+41
"git status --ignored", when noticing that a directory without any tracked path is ignored, still enumerated all the ignored paths in the directory, which is unnecessary. The codepath has been optimized to avoid this overhead. * jm/status-ignored-directory-optim: Improve performance of git status --ignored
2017-09-28The tenth batch for 2.15Libravatar Junio C Hamano1-0/+47
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2017-09-28Merge branch 'js/win32-lazyload-dll'Libravatar Junio C Hamano1-0/+57
Add a helper in anticipation for its need in a future topic RSN. * js/win32-lazyload-dll: Win32: simplify loading of DLL functions
2017-09-28Merge branch 'jc/merge-x-theirs-docfix'Libravatar Junio C Hamano1-1/+2
The documentation for '-X<option>' for merges was misleadingly written to suggest that "-s theirs" exists, which is not the case. * jc/merge-x-theirs-docfix: merge-strategies: avoid implying that "-s theirs" exists
2017-09-28Merge branch 'ks/doc-use-camelcase-for-config-name'Libravatar Junio C Hamano2-3/+3
Doc update. * ks/doc-use-camelcase-for-config-name: doc: camelCase the config variables to improve readability
2017-09-28Merge branch 'mk/diff-delta-avoid-large-offset'Libravatar Junio C Hamano1-0/+3
The delta format used in the packfile cannot reference data at offset larger than what can be expressed in 4-byte, but the generator for the data failed to make sure the offset does not overflow. This has been corrected. * mk/diff-delta-avoid-large-offset: diff-delta: do not allow delta offset truncation
2017-09-28Merge branch 'mk/diff-delta-uint-may-be-shorter-than-ulong'Libravatar Junio C Hamano1-11/+13
The machinery to create xdelta used in pack files received the sizes of the data in size_t, but lost the higher bits of them by storing them in "unsigned int" during the computation, which is fixed. * mk/diff-delta-uint-may-be-shorter-than-ulong: diff-delta: fix encoding size that would not fit in "unsigned int"
2017-09-28Merge branch 'rs/resolve-ref-optional-result'Libravatar Junio C Hamano17-46/+29
Code clean-up. * rs/resolve-ref-optional-result: refs: pass NULL to resolve_ref_unsafe() if hash is not needed refs: pass NULL to refs_resolve_ref_unsafe() if hash is not needed refs: make sha1 output parameter of refs_resolve_ref_unsafe() optional
2017-09-28Merge branch 'rs/mailinfo-qp-decode-fix'Libravatar Junio C Hamano1-3/+8
"git mailinfo" was loose in decoding quoted printable and produced garbage when the two letters after the equal sign are not hexadecimal. This has been fixed. * rs/mailinfo-qp-decode-fix: mailinfo: don't decode invalid =XY quoted-printable sequences
2017-09-28Merge branch 'jk/doc-read-tree-table-asciidoctor-fix'Libravatar Junio C Hamano1-0/+2
A docfix. * jk/doc-read-tree-table-asciidoctor-fix: doc: put literal block delimiter around table
2017-09-28Merge branch 'ik/userdiff-html-h-element-fix'Libravatar Junio C Hamano1-1/+1
The built-in pattern to detect the "function header" for HTML did not match <H1>..<H6> elements without any attributes, which has been fixed. * ik/userdiff-html-h-element-fix: userdiff: fix HTML hunk header regexp
2017-09-28Merge branch 'jk/fallthrough'Libravatar Junio C Hamano15-28/+30
Many codepaths have been updated to squelch -Wimplicit-fallthrough warnings from Gcc 7 (which is a good code hygiene). * jk/fallthrough: consistently use "fallthrough" comments in switches curl_trace(): eliminate switch fallthrough test-line-buffer: simplify command parsing
2017-09-28Merge branch 'jk/diff-blob'Libravatar Junio C Hamano2-2/+7
"git cat-file --textconv" started segfaulting recently, which has been corrected. * jk/diff-blob: cat-file: handle NULL object_context.path
2017-09-28Merge branch 'hn/typofix'Libravatar Junio C Hamano1-1/+1
* hn/typofix: submodule.h: typofix
2017-09-28Merge branch 'ic/fix-filter-branch-to-handle-tag-without-tagger'Libravatar Junio C Hamano2-8/+94
"git filter-branch" cannot reproduce a history with a tag without the tagger field, which only ancient versions of Git allowed to be created. This has been corrected. * ic/fix-filter-branch-to-handle-tag-without-tagger: filter-branch: use hash-object instead of mktag filter-branch: stash away ref map in a branch filter-branch: preserve and restore $GIT_AUTHOR_* and $GIT_COMMITTER_* filter-branch: reset $GIT_* before cleaning up
2017-09-28Merge branch 'jk/describe-omit-some-refs'Libravatar Junio C Hamano2-4/+11
"git describe --match" learned to take multiple patterns in v2.13 series, but the feature ignored the patterns after the first one and did not work at all. This has been fixed. * jk/describe-omit-some-refs: describe: fix matching to actually match all patterns
2017-09-26Sync with 2.14.2Libravatar Junio C Hamano11-56/+183
* maint: Git 2.14.2 Git 2.13.6 Git 2.12.5 Git 2.11.4 Git 2.10.5 cvsimport: shell-quote variable used in backticks archimport: use safe_pipe_capture for user input shell: drop git-cvsserver support by default cvsserver: use safe_pipe_capture for `constant commands` as well cvsserver: use safe_pipe_capture instead of backticks cvsserver: move safe_pipe_capture() to the main package
2017-09-26Win32: simplify loading of DLL functionsLibravatar Johannes Schindelin1-0/+57
Dynamic loading of DLL functions is duplicated in several places in Git for Windows' source code. This patch adds a pair of macros to simplify the process: the DECLARE_PROC_ADDR(<dll>, <return-type>, <function-name>, ...<function-parameter-types>...) macro to be used at the beginning of a code block, and the INIT_PROC_ADDR(<function-name>) macro to call before using the declared function. The return value of the INIT_PROC_ADDR() call has to be checked; If it is NULL, the function was not found in the specified DLL. Example: DECLARE_PROC_ADDR(kernel32.dll, BOOL, CreateHardLinkW, LPCWSTR, LPCWSTR, LPSECURITY_ATTRIBUTES); if (!INIT_PROC_ADDR(CreateHardLinkW)) return error("Could not find CreateHardLinkW() function"; if (!CreateHardLinkW(source, target, NULL)) return error("could not create hardlink from %S to %S", source, target); return 0; Signed-off-by: Karsten Blees <blees@dcon.de> Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Reviewed-by: Jonathan Nieder <jrnieder@gmail.com> Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2017-09-25doc: camelCase the config variables to improve readabilityLibravatar Kaartic Sivaraam2-3/+3
References to multi-word configuration variable names in our documentation must consistently use camelCase to highlight where the word boundaries are, even though these are treated case insensitively. Fix a few places that spell them in all lowercase, which makes them harder to read. Signed-off-by: Kaartic Sivaraam <kaarticsivaraam91196@gmail.com> Reviewed-by: Jonathan Nieder <jrnieder@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2017-09-25The ninth batch for 2.15Libravatar Junio C Hamano1-0/+67
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2017-09-25Merge branch 'ks/test-readme-phrasofix'Libravatar Junio C Hamano1-3/+3
Doc updates. * ks/test-readme-phrasofix: t/README: fix typo and grammatically improve a sentence
2017-09-25Merge branch 'ow/rev-parse-is-shallow-repo'Libravatar Junio C Hamano3-0/+23
"git rev-parse" learned "--is-shallow-repository", that is to be used in a way similar to existing "--is-bare-repository" and friends. * ow/rev-parse-is-shallow-repo: rev-parse: rev-parse: add --is-shallow-repository
2017-09-25Merge branch 'rj/test-ulimit-on-windows'Libravatar Junio C Hamano5-40/+42
On Cygwin, "ulimit -s" does not report failure but it does not work at all, which causes an unexpected success of some tests that expect failures under a limited stack situation. This has been fixed. * rj/test-ulimit-on-windows: t9010-*.sh: skip all tests if the PIPE prereq is missing test-lib: use more compact expression in PIPE prerequisite test-lib: don't use ulimit in test prerequisites on cygwin
2017-09-25Merge branch 'jk/info-alternates-fix'Libravatar Junio C Hamano1-20/+11
A regression fix for 2.11 that made the code to read the list of alternate object stores overrun the end of the string. * jk/info-alternates-fix: read_info_alternates: warn on non-trivial errors read_info_alternates: read contents into strbuf
2017-09-25Merge branch 'mh/for-each-string-list-item-empty-fix'Libravatar Junio C Hamano1-2/+4
Code cmp.std.c nitpick. * mh/for-each-string-list-item-empty-fix: for_each_string_list_item: avoid undefined behavior for empty list
2017-09-25Merge branch 'tb/test-lint-echo-e'Libravatar Junio C Hamano1-1/+1
The test linter has been taught that we do not like "echo -e". * tb/test-lint-echo-e: test-lint: echo -e (or -E) is not portable
2017-09-25Merge branch 'jk/revision-remove-cmdline-pathspec'Libravatar Junio C Hamano3-32/+18
Code clean-up that also plugs memory leaks. * jk/revision-remove-cmdline-pathspec: pathspec doc: parse_pathspec does not maintain references to args revision: replace "struct cmdline_pathspec" with argv_array
2017-09-25Merge branch 'ls/travis-scriptify'Libravatar Junio C Hamano10-81/+154
The scripts to drive TravisCI has been reorganized and then an optimization to avoid spending cycles on a branch whose tip is tagged has been implemented. * ls/travis-scriptify: travis-ci: fix "skip_branch_tip_with_tag()" string comparison travis: dedent a few scripts that are indented overly deeply travis-ci: skip a branch build if equal tag is present travis-ci: move Travis CI code into dedicated scripts
2017-09-25Merge branch 'aw/gc-lockfile-fscanf-fix'Libravatar Junio C Hamano1-1/+1
"git gc" tries to avoid running two instances at the same time by reading and writing pid/host from and to a lock file; it used to use an incorrect fscanf() format when reading, which has been corrected. * aw/gc-lockfile-fscanf-fix: gc: call fscanf() with %<len>s, not %<len>c, when reading hostname
2017-09-25Merge branch 'hv/mv-nested-submodules-test'Libravatar Junio C Hamano1-0/+25
A test to demonstrate "git mv" failing to adjust nested submodules has been added. * hv/mv-nested-submodules-test: add test for bug in git-mv for recursive submodules
2017-09-25Merge branch 'bw/git-clang-format'Libravatar Junio C Hamano2-0/+169
"make style" runs git-clang-format to help developers by pointing out coding style issues. * bw/git-clang-format: Makefile: add style build rule clang-format: outline the git project's coding style
2017-09-25Merge branch 'nm/imap-send-with-curl'Libravatar Junio C Hamano1-20/+41
"git imap-send" has our own implementation of the protocol and also can use more recent libCurl with the imap protocol support. Update the latter so that it can use the credential subsystem, and then make it the default option to use, so that we can eventually deprecate and remove the former. * nm/imap-send-with-curl: imap-send: use curl by default when possible imap_send: setup_curl: retreive credentials if not set in config file imap-send: add wrapper to get server credentials if needed imap-send: return with error if curl failed
2017-09-25Merge branch 'ks/commit-do-not-touch-cut-line'Libravatar Junio C Hamano1-1/+1
The explanation of the cut-line in the commit log editor has been slightly tweaked. * ks/commit-do-not-touch-cut-line: commit-template: change a message to be more intuitive
2017-09-25Merge branch 'tg/refs-allowed-flags'Libravatar Junio C Hamano2-0/+10
API error-proofing which happens to also squelch warnings from GCC. * tg/refs-allowed-flags: refs: strip out not allowed flags from ref_transaction_update