summaryrefslogtreecommitdiff
path: root/builtin
AgeCommit message (Collapse)AuthorFilesLines
2014-09-11Merge branch 'nd/fetch-pass-quiet-to-gc-child-process'Libravatar Junio C Hamano1-4/+6
Progress output from "git gc --auto" was visible in "git fetch -q". * nd/fetch-pass-quiet-to-gc-child-process: fetch: silence git-gc if --quiet is given fetch: convert argv_gc_auto to struct argv_array
2014-09-11Merge branch 'dt/cache-tree-repair'Libravatar Junio C Hamano2-1/+19
Add a few more places in "commit" and "checkout" that make sure that the cache-tree is fully populated in the index. * dt/cache-tree-repair: cache-tree: do not try to use an invalidated subtree info to build a tree cache-tree: Write updated cache-tree after commit cache-tree: subdirectory tests test-dump-cache-tree: invalid trees are not errors cache-tree: create/update cache-tree on checkout
2014-09-11Merge branch 'rs/ref-transaction-1'Libravatar Junio C Hamano5-51/+81
The second batch of the transactional ref update series. * rs/ref-transaction-1: (22 commits) update-ref --stdin: pass transaction around explicitly update-ref --stdin: narrow scope of err strbuf refs.c: make delete_ref use a transaction refs.c: make prune_ref use a transaction to delete the ref refs.c: remove lock_ref_sha1 refs.c: remove the update_ref_write function refs.c: remove the update_ref_lock function refs.c: make lock_ref_sha1 static walker.c: use ref transaction for ref updates fast-import.c: use a ref transaction when dumping tags receive-pack.c: use a reference transaction for updating the refs refs.c: change update_ref to use a transaction branch.c: use ref transaction for all ref updates fast-import.c: change update_branch to use ref transactions sequencer.c: use ref transactions for all ref updates commit.c: use ref transactions for updates replace.c: use the ref transaction functions for updates tag.c: use ref transactions when doing updates refs.c: add transaction.status and track OPEN/CLOSED refs.c: make ref_transaction_begin take an err argument ...
2014-09-11Merge branch 'nd/mv-code-cleaning'Libravatar Junio C Hamano1-88/+86
Code clean-up. * nd/mv-code-cleaning: mv: no SP between function name and the first opening parenthese mv: combine two if(s) mv: unindent one level for directory move code mv: move index search code out mv: remove an "if" that's always true mv: split submodule move preparation code out mv: flatten error handling code block mv: mark strings for translations
2014-09-11Merge branch 'rs/child-process-init'Libravatar Junio C Hamano10-26/+14
Code clean-up. * rs/child-process-init: run-command: inline prepare_run_command_v_opt() run-command: call run_command_v_opt_cd_env() instead of duplicating it run-command: introduce child_process_init() run-command: introduce CHILD_PROCESS_INIT
2014-09-11Merge branch 'ta/config-set-2'Libravatar Junio C Hamano2-38/+25
Update git_config() users with callback functions for a very narrow scope with calls to config-set API that lets us query a single variable. * ta/config-set-2: builtin/apply.c: replace `git_config()` with `git_config_get_string_const()` merge-recursive.c: replace `git_config()` with `git_config_get_int()` ll-merge.c: refactor `read_merge_config()` to use `git_config_string()` fast-import.c: replace `git_config()` with `git_config_get_*()` family branch.c: replace `git_config()` with `git_config_get_string() alias.c: replace `git_config()` with `git_config_get_string()` imap-send.c: replace `git_config()` with `git_config_get_*()` family pager.c: replace `git_config()` with `git_config_get_value()` builtin/gc.c: replace `git_config()` with `git_config_get_*()` family rerere.c: replace `git_config()` with `git_config_get_*()` family fetchpack.c: replace `git_config()` with `git_config_get_*()` family archive.c: replace `git_config()` with `git_config_get_bool()` family read-cache.c: replace `git_config()` with `git_config_get_*()` family http-backend.c: replace `git_config()` with `git_config_get_bool()` family daemon.c: replace `git_config()` with `git_config_get_bool()` family
2014-09-09Merge branch 'rs/clean-menu-item-defn'Libravatar Junio C Hamano1-1/+1
* rs/clean-menu-item-defn: clean: use f(void) instead of f() to declare a pointer to a function without arguments
2014-09-09Merge branch 'sb/mailsplit-dead-code-removal'Libravatar Junio C Hamano1-11/+6
* sb/mailsplit-dead-code-removal: mailsplit.c: remove dead code
2014-09-09Merge branch 'sb/prepare-revision-walk-error-check'Libravatar Junio C Hamano2-2/+5
* sb/prepare-revision-walk-error-check: prepare_revision_walk(): check for return value in all places
2014-09-09Merge branch 'sb/blame-msg-i18n'Libravatar Junio C Hamano1-1/+1
* sb/blame-msg-i18n: builtin/blame.c: add translation to warning about failed revision walk
2014-09-09Merge branch 'sb/plug-leaks'Libravatar Junio C Hamano1-0/+2
* sb/plug-leaks: clone.c: don't leak memory in cmd_clone remote.c: don't leak the base branch name in format_tracking_info
2014-09-09Merge branch 'mm/log-branch-desc-plug-leak'Libravatar Junio C Hamano1-0/+1
* mm/log-branch-desc-plug-leak: builtin/log.c: fix minor memory leak
2014-09-09Merge branch 'jc/apply-ws-prefix'Libravatar Junio C Hamano1-63/+68
Applying a patch not generated by Git in a subdirectory used to check the whitespace breakage using the attributes for incorrect paths. Also whitespace checks were performed even for paths excluded via "git apply --exclude=<path>" mechanism. * jc/apply-ws-prefix: apply: omit ws check for excluded paths apply: hoist use_patch() helper for path exclusion up apply: use the right attribute for paths in non-Git patches
2014-09-03mv: no SP between function name and the first opening parentheseLibravatar Nguyễn Thái Ngọc Duy1-2/+2
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2014-09-03mv: combine two if(s)Libravatar Nguyễn Thái Ngọc Duy1-4/+3
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2014-09-03mv: unindent one level for directory move codeLibravatar Nguyễn Thái Ngọc Duy1-28/+21
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2014-09-03mv: move index search code outLibravatar Nguyễn Thái Ngọc Duy1-17/+25
"Huh?" is removed from die() message. Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2014-09-03mv: remove an "if" that's always trueLibravatar Nguyễn Thái Ngọc Duy1-15/+7
This is inside an "else" block of "if (last - first < 1)", so we know that "last - first >= 1" when we come here. No need to check "last - first > 0". While at there, save "argc + last - first" to a variable to shorten the statements a bit. Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2014-09-03mv: split submodule move preparation code outLibravatar Nguyễn Thái Ngọc Duy1-14/+22
"Huh?" is removed from die() message. Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2014-09-03update-ref --stdin: pass transaction around explicitlyLibravatar Jonathan Nieder1-12/+15
This makes it more obvious at a glance where the output of functions parsing the --stdin stream goes. No functional change intended. Signed-off-by: Jonathan Nieder <jrnieder@gmail.com> Reviewed-by: Michael Haggerty <mhagger@alum.mit.edu> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2014-09-03update-ref --stdin: narrow scope of err strbufLibravatar Jonathan Nieder1-1/+10
Making the strbuf local in each function that needs to print errors saves the reader from having to think about action at a distance, such as * errors piling up and being concatenated with no newline between them * errors unhandled in one function, to be later handled in another * concurrency issues, if this code starts using threads some day No functional change intended. Signed-off-by: Jonathan Nieder <jrnieder@gmail.com> Reviewed-by: Michael Haggerty <mhagger@alum.mit.edu> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2014-09-03receive-pack.c: use a reference transaction for updating the refsLibravatar Ronnie Sahlberg1-9/+16
Wrap all the ref updates inside a transaction. In the new API there is no distinction between failure to lock and failure to write a ref. Both can be permanent (e.g., a ref "refs/heads/topic" is blocking creation of the lock file "refs/heads/topic/1.lock") or transient (e.g., file system full) and there's no clear difference in how the client should respond, so replace the two statuses "failed to lock" and "failed to write" with a single status "failed to update ref". In both cases a more detailed message is sent by sideband to diagnose the problem. Example, before: error: there are still refs under 'refs/heads/topic' remote: error: failed to lock refs/heads/topic To foo ! [remote rejected] HEAD -> topic (failed to lock) After: error: there are still refs under 'refs/heads/topic' remote: error: Cannot lock the ref 'refs/heads/topic'. To foo ! [remote rejected] HEAD -> topic (failed to update ref) Signed-off-by: Ronnie Sahlberg <sahlberg@google.com> Reviewed-by: Michael Haggerty <mhagger@alum.mit.edu> Signed-off-by: Jonathan Nieder <jrnieder@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2014-09-03commit.c: use ref transactions for updatesLibravatar Ronnie Sahlberg1-13/+12
Change commit.c to use ref transactions for all ref updates. Make sure we pass a NULL pointer to ref_transaction_update if have_old is false. Signed-off-by: Ronnie Sahlberg <sahlberg@google.com> Reviewed-by: Michael Haggerty <mhagger@alum.mit.edu> Signed-off-by: Jonathan Nieder <jrnieder@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2014-09-03replace.c: use the ref transaction functions for updatesLibravatar Ronnie Sahlberg1-6/+8
Update replace.c to use ref transactions for updates. Signed-off-by: Ronnie Sahlberg <sahlberg@google.com> Reviewed-by: Michael Haggerty <mhagger@alum.mit.edu> Signed-off-by: Jonathan Nieder <jrnieder@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2014-09-03tag.c: use ref transactions when doing updatesLibravatar Ronnie Sahlberg1-6/+10
Change tag.c to use ref transactions for all ref updates. Signed-off-by: Ronnie Sahlberg <sahlberg@google.com> Reviewed-by: Michael Haggerty <mhagger@alum.mit.edu> Signed-off-by: Jonathan Nieder <jrnieder@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2014-09-03refs.c: make ref_transaction_begin take an err argumentLibravatar Ronnie Sahlberg1-1/+4
Add an err argument to _begin so that on non-fatal failures in future ref backends we can report a nice error back to the caller. While _begin can currently never fail for other reasons than OOM, in which case we die() anyway, we may add other types of backends in the future. For example, a hypothetical MySQL backend could fail in _begin with "Can not connect to MySQL server. No route to host". Signed-off-by: Ronnie Sahlberg <sahlberg@google.com> Reviewed-by: Michael Haggerty <mhagger@alum.mit.edu> Signed-off-by: Jonathan Nieder <jrnieder@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2014-09-03refs.c: update ref_transaction_delete to check for error and return statusLibravatar Ronnie Sahlberg1-2/+3
Change ref_transaction_delete() to do basic error checking and return non-zero on error. Update all callers to check the return for ref_transaction_delete(). There are currently no conditions in _delete that will return error but there will be in the future. Add an err argument that will be updated on failure. Signed-off-by: Ronnie Sahlberg <sahlberg@google.com> Reviewed-by: Michael Haggerty <mhagger@alum.mit.edu> Signed-off-by: Jonathan Nieder <jrnieder@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2014-09-03refs.c: change ref_transaction_create to do error checking and return statusLibravatar Ronnie Sahlberg1-1/+3
Do basic error checking in ref_transaction_create() and make it return non-zero on error. Update all callers to check the result of ref_transaction_create(). There are currently no conditions in _create that will return error but there will be in the future. Add an err argument that will be updated on failure. Signed-off-by: Ronnie Sahlberg <sahlberg@google.com> Reviewed-by: Michael Haggerty <mhagger@alum.mit.edu> Signed-off-by: Jonathan Nieder <jrnieder@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2014-09-02Merge branch 'rs/strbuf-getcwd'Libravatar Junio C Hamano2-16/+14
Reduce the use of fixed sized buffer passed to getcwd() calls by introducing xgetcwd() helper. * rs/strbuf-getcwd: use strbuf_add_absolute_path() to add absolute paths abspath: convert absolute_path() to strbuf use xgetcwd() to set $GIT_DIR use xgetcwd() to get the current directory or die wrapper: add xgetcwd() abspath: convert real_path_internal() to strbuf abspath: use strbuf_getcwd() to remember original working directory setup: convert setup_git_directory_gently_1 et al. to strbuf unix-sockets: use strbuf_getcwd() strbuf: add strbuf_getcwd()
2014-09-02Merge branch 'rs/init-no-duplicate-real-path'Libravatar Junio C Hamano1-4/+4
* rs/init-no-duplicate-real-path: init: avoid superfluous real_path() calls
2014-09-02Merge branch 'mm/config-edit-global'Libravatar Junio C Hamano2-5/+61
Start "git config --edit --global" from a skeletal per-user configuration file contents, instead of a total blank, when the user does not already have any. This immediately reduces the need for a later "Have you forgotten setting core.user?" and we can add more to the template as we gain more experience. * mm/config-edit-global: commit: advertise config --global --edit on guessed identity home_config_paths(): let the caller ignore xdg path config --global --edit: create a template file if needed
2014-08-26Merge branch 'jk/pack-shallow-always-without-bitmap'Libravatar Junio C Hamano1-0/+1
Reachability bitmaps do not work with shallow operations. Fixes regression in 2.0. * jk/pack-shallow-always-without-bitmap: pack-objects: turn off bitmaps when we see --shallow lines
2014-08-26use xgetcwd() to set $GIT_DIRLibravatar René Scharfe1-4/+3
Instead of dying of a segmentation fault if getcwd() returns NULL, use xgetcwd() to make sure to write a useful error message and then exit in an orderly fashion. Suggested-by: Jeff King <peff@peff.net> Signed-off-by: Rene Scharfe <l.s.r@web.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2014-08-26use xgetcwd() to get the current directory or dieLibravatar René Scharfe2-12/+11
Convert several calls of getcwd() and die() to use xgetcwd() instead. This way we get rid of fixed-size buffers (which can be too small depending on the used file system) and gain consistent error messages. Signed-off-by: Rene Scharfe <l.s.r@web.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2014-08-20run-command: introduce CHILD_PROCESS_INITLibravatar René Scharfe10-26/+14
Most struct child_process variables are cleared using memset first after declaration. Provide a macro, CHILD_PROCESS_INIT, that can be used to initialize them statically instead. That's shorter, doesn't require a function call and is slightly more readable (especially given that we already have STRBUF_INIT, ARGV_ARRAY_INIT etc.). Helped-by: Johannes Sixt <j6t@kdbg.org> Signed-off-by: Rene Scharfe <l.s.r@web.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2014-08-18fetch: silence git-gc if --quiet is givenLibravatar Nguyễn Thái Ngọc Duy1-0/+2
Noticed-by: Matthew Flaschen <mflaschen@wikimedia.org> Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2014-08-18fetch: convert argv_gc_auto to struct argv_arrayLibravatar Nguyễn Thái Ngọc Duy1-4/+4
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2014-08-18clean: use f(void) instead of f() to declare a pointer to a function without ↵Libravatar René Scharfe1-1/+1
arguments Explicitly state that menu_item functions like clean_cmd don't take any arguments by using void instead of an empty parameter list. Found using gcc -Wstrict-prototypes. Signed-off-by: Rene Scharfe <l.s.r@web.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2014-08-13builtin/apply.c: replace `git_config()` with `git_config_get_string_const()`Libravatar Tanay Abhra1-7/+5
Use `git_config_get_string_const()` instead of `git_config()` to take advantage of the config-set API which provides a cleaner control flow. Signed-off-by: Tanay Abhra <tanayabh@gmail.com> Reviewed-by: Matthieu Moy <Matthieu.Moy@imag.fr> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2014-08-13mailsplit.c: remove dead codeLibravatar Stefan Beller1-11/+6
This was found by coverity. (Id: 290001) The variable 'output' is assigned to a value after all gotos to the corrupt label. Remove the goto by moving the errorhandling code to the condition, which detects the error. Signed-off-by: Stefan Beller <stefanbeller@gmail.com> Helped-by: René Scharfe <l.s.r@web.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2014-08-12pack-objects: turn off bitmaps when we see --shallow linesLibravatar Jeff King1-0/+1
Reachability bitmaps do not work with shallow operations, because they cache a view of the object reachability that represents the true objects. Whereas a shallow repository (or a shallow operation in a repository) is inherently cutting off the object graph with a graft. We explicitly disallow the use of bitmaps in shallow repositories by checking is_repository_shallow(), and we should continue to do that. However, we also want to disallow bitmaps when we are serving a fetch to a shallow client, since we momentarily take on their grafted view of the world. It used to be enough to call is_repository_shallow at the start of pack-objects. Upload-pack wrote the other side's shallow state to a temporary file and pointed the whole pack-objects process at this state with "git --shallow-file", and from the perspective of pack-objects, we really were in a shallow repo. But since b790e0f (upload-pack: send shallow info over stdin to pack-objects, 2014-03-11), we do it differently: we send --shallow lines to pack-objects over stdin, and it registers them itself. This means that our is_repository_shallow check is way too early (we have not been told about the shallowness yet), and that it is insufficient (calling is_repository_shallow is not enough, as the shallow grafts we register do not change its return value). Instead, we can just turn off bitmaps explicitly when we see these lines. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2014-08-12builtin/blame.c: add translation to warning about failed revision walkLibravatar Stefan Beller1-1/+1
Signed-off-by: Stefan Beller <stefanbeller@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2014-08-12prepare_revision_walk(): check for return value in all placesLibravatar Stefan Beller2-2/+5
Even the documentation tells us: You should check if it returns any error (non-zero return code) and if it does not, you can start using get_revision() to do the iteration. In preparation for this commit, I grepped all occurrences of prepare_revision_walk and added error messages, when there were none. Signed-off-by: Stefan Beller <stefanbeller@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2014-08-11mv: flatten error handling code blockLibravatar Nguyễn Thái Ngọc Duy1-18/+16
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2014-08-11mv: mark strings for translationsLibravatar Nguyễn Thái Ngọc Duy1-1/+1
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2014-08-10clone.c: don't leak memory in cmd_cloneLibravatar Stefan Beller1-0/+2
Free the refspec. Found by scan.coverity.com (Id: 1127806) Signed-off-by: Stefan Beller <stefanbeller@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2014-08-07builtin/gc.c: replace `git_config()` with `git_config_get_*()` familyLibravatar Tanay Abhra1-31/+20
Use `git_config_get_*()` family instead of `git_config()` to take advantage of the config-set API which provides a cleaner control flow. Signed-off-by: Tanay Abhra <tanayabh@gmail.com> Reviewed-by: Matthieu Moy <Matthieu.Moy@imag.fr> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2014-08-07builtin/log.c: fix minor memory leakLibravatar Matthieu Moy1-0/+1
Signed-off-by: Matthieu Moy <Matthieu.Moy@imag.fr> Reviewed-by: Jonathan Nieder <jrnieder@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2014-08-07apply: omit ws check for excluded pathsLibravatar Junio C Hamano1-3/+6
Whitespace breakages are checked while the patch is being parsed. Disable them at the beginning of parse_chunk(), where each individual patch is parsed, immediately after we learn the name of the file the patch applies to and before we start parsing the diff contained in the patch. One may naively think that we should be able to not just skip the whitespace checks but simply fast-forward to the next patch without doing anything once use_patch() tells us that this patch is not going to be used. But in reality we cannot really skip much of the parsing in order to do such a "fast-forward", primarily because parsing "@@ -k,l +m,n @@" lines and counting the input lines is how we determine the boundaries of individual patches. Signed-off-by: Junio C Hamano <gitster@pobox.com>
2014-08-07apply: hoist use_patch() helper for path exclusion upLibravatar Junio C Hamano1-38/+43
We will be adding a caller to the function a bit earlier in this file in a later patch. Signed-off-by: Junio C Hamano <gitster@pobox.com>