summaryrefslogtreecommitdiff
AgeCommit message (Collapse)AuthorFilesLines
2016-04-14Merge branch 'sb/submodule-helper-clone-regression-fix' into sb/submodule-initLibravatar Junio C Hamano2-23/+59
* sb/submodule-helper-clone-regression-fix: submodule--helper, module_clone: catch fprintf failure submodule--helper: do not borrow absolute_path() result for too long submodule--helper, module_clone: always operate on absolute paths submodule--helper clone: create the submodule path just once submodule--helper: fix potential NULL-dereference recursive submodules: test for relative paths
2016-04-01submodule--helper, module_clone: catch fprintf failureLibravatar Stefan Beller1-2/+2
The return value of fprintf is unchecked, which may lead to unreported errors. Use fprintf_or_die to report the error to the user. Signed-off-by: Stefan Beller <sbeller@google.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2016-04-01submodule--helper: do not borrow absolute_path() result for too longLibravatar Junio C Hamano1-5/+4
absolute_path() is designed to allow its callers to take a brief peek of the result (typically, to be fed to functions like strbuf_add() and relative_path() as a parameter) without having to worry about freeing it, but the other side of the coin of that memory model is that the caller shouldn't rely too much on the result living forever--there may be a helper function the caller subsequently calls that makes its own call to absolute_path(), invalidating the earlier result. Use xstrdup() to make our own copy, and free(3) it when we are done. While at it, remove an unnecessary sm_gitdir_rel variable that was only used to as a parameter to call absolute_path() and never used again. Signed-off-by: Junio C Hamano <gitster@pobox.com>
2016-04-01submodule--helper, module_clone: always operate on absolute pathsLibravatar Stefan Beller2-15/+15
When giving relative paths to `relative_path` to compute a relative path from one directory to another, this may fail in `relative_path`. Make sure both arguments to `relative_path` are always absolute. Signed-off-by: Stefan Beller <sbeller@google.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2016-03-31submodule--helper clone: create the submodule path just onceLibravatar Stefan Beller1-4/+0
We make sure that the parent directory of path exists (or create it otherwise) and then do the same for path + "/.git". That is equivalent to just making sure that the parent directory of path + "/.git" exists (or create it otherwise). Signed-off-by: Stefan Beller <sbeller@google.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2016-03-31submodule--helper: fix potential NULL-dereferenceLibravatar Stefan Beller1-4/+4
Don't dereference NULL 'path' if it was never assigned. Also protect against an empty --path argument. Signed-off-by: Stefan Beller <sbeller@google.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2016-03-31recursive submodules: test for relative pathsLibravatar Stefan Beller1-0/+41
"git submodule update --init --recursive" uses full path to refer to the true location of the repository in the "gitdir:" pointer for nested submodules; the command used to use relative paths. This was reported by Norio Nomura in $gmane/290280. The root cause for that bug is in using recursive submodules as their relative path handling was broken in ee8838d (2015-09-08, submodule: rewrite `module_clone` shell function in C). Signed-off-by: Stefan Beller <sbeller@google.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2016-03-01clone: allow an explicit argument for parallel submodule clonesLibravatar Stefan Beller3-7/+33
Just pass it along to "git submodule update", which may pick reasonable defaults if you don't specify an explicit number. Reviewed-by: Jonathan Nieder <jrnieder@gmail.com> Signed-off-by: Stefan Beller <sbeller@google.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2016-03-01submodule update: expose parallelism to the userLibravatar Stefan Beller4-2/+34
Expose possible parallelism either via the "--jobs" CLI parameter or the "submodule.fetchJobs" setting. By having the variable initialized to -1, we make sure 0 can be passed into the parallel processing machine, which will then pick as many parallel workers as there are CPUs. Reviewed-by: Jonathan Nieder <jrnieder@gmail.com> Signed-off-by: Stefan Beller <sbeller@google.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2016-03-01submodule helper: remove double 'fatal: ' prefixLibravatar Stefan Beller1-2/+2
The prefix is added by die(...), so we don't have to do it. Signed-off-by: Stefan Beller <sbeller@google.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2016-03-01git submodule update: have a dedicated helper for cloningLibravatar Stefan Beller2-34/+259
This introduces a new helper function in git submodule--helper which takes care of cloning all submodules, which we want to parallelize eventually. Some tests (such as empty URL, update_mode=none) are required in the helper to make the decision for cloning. These checks have been moved into the C function as well (no need to repeat them in the shell script). Reviewed-by: Jonathan Nieder <jrnieder@gmail.com> Signed-off-by: Stefan Beller <sbeller@google.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2016-03-01run_processes_parallel: rename parameters for the callbacksLibravatar Stefan Beller2-7/+7
The refs code has a similar pattern of passing around 'struct strbuf *err', which is strictly used for error reporting. This is not the case here, as the strbuf is used to accumulate all the output (whether it is error or not) for the user. Rename it to 'out'. Suggested-by: Jonathan Nieder <jrnieder@gmail.com> Reviewed-by: Jonathan Nieder <jrnieder@gmail.com> Signed-off-by: Stefan Beller <sbeller@google.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2016-03-01run_processes_parallel: treat output of children as byte arrayLibravatar Stefan Beller3-4/+16
We do not want the output to be interrupted by a NUL byte, so we cannot use raw fputs. Introduce strbuf_write to avoid having long arguments in run-command.c. Reviewed-by: Jonathan Nieder <jrnieder@gmail.com> Signed-off-by: Stefan Beller <sbeller@google.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2016-03-01submodule update: direct error message to stderrLibravatar Stefan Beller2-4/+4
Reroute the error message for specified but initialized submodules to stderr instead of stdout. Reviewed-by: Jonathan Nieder <jrnieder@gmail.com> Signed-off-by: Stefan Beller <sbeller@google.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2016-03-01fetching submodules: respect `submodule.fetchJobs` config optionLibravatar Stefan Beller5-2/+38
This allows to configure fetching and updating in parallel without having the command line option. This moved the responsibility to determine how many parallel processes to start from builtin/fetch to submodule.c as we need a way to communicate "The user did not specify the number of parallel processes in the command line options" in the builtin fetch. The submodule code takes care of the precedence (CLI > config > default). Reviewed-by: Jonathan Nieder <jrnieder@gmail.com> Signed-off-by: Stefan Beller <sbeller@google.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2016-03-01submodule-config: drop check against NULLLibravatar Stefan Beller1-3/+3
Adhere to the common coding style of Git and not check explicitly for NULL throughout the file. There are still other occurrences in the code base but that is usually inside of conditions with side effects. Reviewed-by: Jonathan Nieder <jrnieder@gmail.com> Signed-off-by: Stefan Beller <sbeller@google.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2016-03-01submodule-config: keep update strategy aroundLibravatar Stefan Beller4-0/+52
Currently submodule.<name>.update is only handled by git-submodule.sh. C code will start to need to make use of that value as more of the functionality of git-submodule.sh moves into library code in C. Add the update field to 'struct submodule' and populate it so it can be read as sm->update or from sm->update_command. Reviewed-by: Jonathan Nieder <jrnieder@gmail.com> Signed-off-by: Stefan Beller <sbeller@google.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2016-03-01run-command: do not pass child process data into callbacksLibravatar Stefan Beller4-32/+9
The expected way to pass data into the callback is to pass them via the customizable callback pointer. The error reporting in default_{start_failure, task_finished} is not user friendly enough, that we want to encourage using the child data for such purposes. Furthermore the struct child data is cleaned by the run-command API, before we access them in the callbacks, leading to use-after-free situations. Signed-off-by: Stefan Beller <sbeller@google.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2015-12-16submodules: allow parallel fetching, add tests and documentationLibravatar Stefan Beller6-4/+40
This enables the work of the previous patches. Signed-off-by: Stefan Beller <sbeller@google.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2015-12-16fetch_populated_submodules: use new parallel job processingLibravatar Stefan Beller1-44/+98
In a later patch we enable parallel processing of submodules, this only adds the possibility for it. So this change should not change any user facing behavior. Signed-off-by: Stefan Beller <sbeller@google.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2015-12-16run-command: add an asynchronous parallel child processorLibravatar Stefan Beller4-1/+522
This allows to run external commands in parallel with ordered output on stderr. If we run external commands in parallel we cannot pipe the output directly to the our stdout/err as it would mix up. So each process's output will flow through a pipe, which we buffer. One subprocess can be directly piped to out stdout/err for a low latency feedback to the user. Example: Let's assume we have 5 submodules A,B,C,D,E and each fetch takes a different amount of time as the different submodules vary in size, then the output of fetches in sequential order might look like this: time --> output: |---A---| |-B-| |-------C-------| |-D-| |-E-| When we schedule these submodules into maximal two parallel processes, a schedule and sample output over time may look like this: process 1: |---A---| |-D-| |-E-| process 2: |-B-| |-------C-------| output: |---A---|B|---C-------|DE So A will be perceived as it would run normally in the single child version. As B has finished by the time A is done, we can dump its whole progress buffer on stderr, such that it looks like it finished in no time. Once that is done, C is determined to be the visible child and its progress will be reported in real time. So this way of output is really good for human consumption, as it only changes the timing, not the actual output. For machine consumption the output needs to be prepared in the tasks, by either having a prefix per line or per block to indicate whose tasks output is displayed, because the output order may not follow the original sequential ordering: |----A----| |--B--| |-C-| will be scheduled to be all parallel: process 1: |----A----| process 2: |--B--| process 3: |-C-| output: |----A----|CB This happens because C finished before B did, so it will be queued for output before B. To detect when a child has finished executing, we check interleaved with other actions (such as checking the liveliness of children or starting new processes) whether the stderr pipe still exists. Once a child closed its stderr stream, we assume it is terminating very soon, and use `finish_command()` from the single external process execution interface to collect the exit status. By maintaining the strong assumption of stderr being open until the very end of a child process, we can avoid other hassle such as an implementation using `waitpid(-1)`, which is not implemented in Windows. Signed-off-by: Stefan Beller <sbeller@google.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2015-12-16sigchain: add command to pop all common signalsLibravatar Stefan Beller2-0/+10
The new method removes all common signal handlers that were installed by sigchain_push. CC: Jeff King <peff@peff.net> Signed-off-by: Stefan Beller <sbeller@google.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2015-12-16strbuf: add strbuf_read_once to read without blockingLibravatar Stefan Beller2-0/+19
The new call will read from a file descriptor into a strbuf once. The underlying call xread is just run once. xread only reattempts reading in case of EINTR, which makes it suitable to use for a nonblocking read. Signed-off-by: Stefan Beller <sbeller@google.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2015-12-16xread: poll on non blocking fdsLibravatar Stefan Beller1-2/+18
The man page of read(2) says: EAGAIN The file descriptor fd refers to a file other than a socket and has been marked nonblocking (O_NONBLOCK), and the read would block. EAGAIN or EWOULDBLOCK The file descriptor fd refers to a socket and has been marked nonblocking (O_NONBLOCK), and the read would block. POSIX.1-2001 allows either error to be returned for this case, and does not require these constants to have the same value, so a portable application should check for both possibilities. If we get an EAGAIN or EWOULDBLOCK the fd must have set O_NONBLOCK. As the intent of xread is to read as much as possible either until the fd is EOF or an actual error occurs, we can ease the feeder of the fd by not spinning the whole time, but rather wait for it politely by not busy waiting. We should not care if the call to poll failed, as we're in an infinite loop and can only get out with the correct read(). Signed-off-by: Stefan Beller <sbeller@google.com> Acked-by: Johannes Sixt <j6t@kdbg.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2015-12-16submodule.c: write "Fetching submodule <foo>" to stderrLibravatar Jonathan Nieder2-26/+27
The "Pushing submodule <foo>" progress output correctly goes to stderr, but "Fetching submodule <foo>" is going to stdout by mistake. Fix it to write to stderr. Noticed while trying to implement a parallel submodule fetch. When this particular output line went to a different file descriptor, it was buffered separately, resulting in wrongly interleaved output if we copied it to the terminal naively. Signed-off-by: Jonathan Nieder <jrnieder@gmail.com> Signed-off-by: Stefan Beller <sbeller@google.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2015-12-11Update release notes to 2.7Libravatar Junio C Hamano1-65/+1
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2015-12-11Merge branch 'maint'Libravatar Junio C Hamano1-0/+25
* maint: Prepare for 2.6.5
2015-12-11Prepare for 2.6.5Libravatar Junio C Hamano2-1/+26
This back-merges hopefully the last batch of trivially correct fixes to the 2.6.x maintenance track from the master branch. Signed-off-by: Junio C Hamano <gitster@pobox.com>
2015-12-11Merge branch 'sn/null-pointer-arith-in-mark-tree-uninteresting' into maintLibravatar Junio C Hamano1-1/+3
mark_tree_uninteresting() has code to handle the case where it gets passed a NULL pointer in its 'tree' parameter, but the function had 'object = &tree->object' assignment before checking if tree is NULL. This gives a compiler an excuse to declare that tree will never be NULL and apply a wrong optimization. Avoid it. * sn/null-pointer-arith-in-mark-tree-uninteresting: revision.c: fix possible null pointer arithmetic
2015-12-11Merge branch 'sg/lock-file-commit-error' into maintLibravatar Junio C Hamano4-5/+8
Cosmetic improvement to lock-file error messages. * sg/lock-file-commit-error: Make error message after failing commit_lock_file() less confusing
2015-12-11Merge branch 'cb/t3404-shellquote' into maintLibravatar Junio C Hamano1-1/+1
* cb/t3404-shellquote: t3404: fix quoting of redirect for some versions of bash
2015-12-11Merge branch 'sb/doc-submodule-sync-recursive' into maintLibravatar Junio C Hamano1-1/+4
* sb/doc-submodule-sync-recursive: document submodule sync --recursive
2015-12-11Merge branch 'nd/doc-check-ref-format-typo' into maintLibravatar Junio C Hamano1-1/+1
* nd/doc-check-ref-format-typo: git-check-ref-format.txt: typo, s/avoids/avoid/
2015-12-11Merge branch 'rs/show-branch-argv-array' into maintLibravatar Junio C Hamano1-16/+8
Code simplification. * rs/show-branch-argv-array: show-branch: use argv_array for default arguments
2015-12-11Merge branch 'rs/pop-commit' into maintLibravatar Junio C Hamano10-92/+31
Code simplification. * rs/pop-commit: use pop_commit() for consuming the first entry of a struct commit_list
2015-12-11Merge branch 'as/subtree-with-spaces' into maintLibravatar Junio C Hamano2-74/+124
Update "git subtree" (in contrib/) so that it can take whitespaces in the pathnames, not only in the in-tree pathname but the name of the directory that the repository is in. * as/subtree-with-spaces: contrib/subtree: respect spaces in a repository path t7900-subtree: test the "space in a subdirectory name" case
2015-12-11Merge branch 'jk/test-lint-forbid-when-finished-in-subshell' into maintLibravatar Junio C Hamano4-16/+31
Because "test_when_finished" in our test framework queues the clean-up tasks to be done in a shell variable, it should not be used inside a subshell. Add a mechanism to allow 'bash' to catch such uses, and fix the ones that were found. * jk/test-lint-forbid-when-finished-in-subshell: test-lib-functions: detect test_when_finished in subshell t7800: don't use test_config in a subshell test-lib-functions: support "test_config -C <dir> ..." t5801: don't use test_when_finished in a subshell t7610: don't use test_config in a subshell
2015-12-11Merge branch 'sn/null-pointer-arith-in-mark-tree-uninteresting'Libravatar Junio C Hamano1-1/+3
mark_tree_uninteresting() has code to handle the case where it gets passed a NULL pointer in its 'tree' parameter, but the function had 'object = &tree->object' assignment before checking if tree is NULL. This gives a compiler an excuse to declare that tree will never be NULL and apply a wrong optimization. Avoid it. * sn/null-pointer-arith-in-mark-tree-uninteresting: revision.c: fix possible null pointer arithmetic
2015-12-11Merge branch 'sb/doc-submodule-sync-recursive'Libravatar Junio C Hamano1-1/+4
* sb/doc-submodule-sync-recursive: document submodule sync --recursive
2015-12-11Merge branch 'cb/t3404-shellquote'Libravatar Junio C Hamano1-1/+1
* cb/t3404-shellquote: t3404: fix quoting of redirect for some versions of bash
2015-12-11Merge branch 'sg/lock-file-commit-error'Libravatar Junio C Hamano4-5/+8
Cosmetic improvement to lock-file error messages. * sg/lock-file-commit-error: Make error message after failing commit_lock_file() less confusing
2015-12-10Git 2.7-rc0Libravatar Junio C Hamano1-1/+1
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2015-12-10Sync with maintLibravatar Junio C Hamano1-0/+1
* maint: Documentation/git-update-index: add missing opts to synopsis
2015-12-10Update release notes to 2.7Libravatar Junio C Hamano1-0/+19
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2015-12-10Merge branch 'nd/doc-check-ref-format-typo'Libravatar Junio C Hamano1-1/+1
* nd/doc-check-ref-format-typo: git-check-ref-format.txt: typo, s/avoids/avoid/
2015-12-10Merge branch 'bc/object-id'Libravatar Junio C Hamano88-704/+716
More transition from "unsigned char[40]" to "struct object_id". This needed a few merge fixups, but is mostly disentangled from other topics. * bc/object-id: remote: convert functions to struct object_id Remove get_object_hash. Convert struct object to object_id Add several uses of get_object_hash. object: introduce get_object_hash macro. ref_newer: convert to use struct object_id push_refs_with_export: convert to struct object_id get_remote_heads: convert to struct object_id parse_fetch: convert to use struct object_id add_sought_entry_mem: convert to struct object_id Convert struct ref to use object_id. sha1_file: introduce has_object_file helper.
2015-12-10Merge branch 'dt/fsck-verify-pack-error'Libravatar Junio C Hamano1-1/+1
The exit code of git-fsck didnot reflect some types of errors found in packed objects, which has been corrected. * dt/fsck-verify-pack-error: verify_pack: do not ignore return value of verification function
2015-12-10Merge branch 'ls/travis-yaml'Libravatar Junio C Hamano1-0/+91
The necessary infrastructure to build topics using the free Travis CI has been added. Developers forking from this topic (and enabling Travis) can do their own builds, and we can turn on auto-builds for git/git (including build-status for pull requests that people open). * ls/travis-yaml: Add Travis CI support
2015-12-10Documentation/git-update-index: add missing opts to synopsisLibravatar Christian Couder1-0/+1
Split index related options should appear in the 'SYNOPSIS' section. These options are already documented in the 'OPTIONS' section. Signed-off-by: Christian Couder <chriscool@tuxfamily.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2015-12-08Merge branch 'ep/ident-with-getaddrinfo'Libravatar Junio C Hamano1-4/+27
A build without NO_IPv6 used to use gethostbyname() when guessing user's hostname, instead of getaddrinfo() that is used in other codepaths in such a build. * ep/ident-with-getaddrinfo: ident.c: add support for IPv6