summaryrefslogtreecommitdiff
path: root/builtin
AgeCommit message (Collapse)AuthorFilesLines
2015-02-25Merge branch 'dp/remove-duplicated-header-inclusion'Libravatar Junio C Hamano1-1/+0
Code clean-up. * dp/remove-duplicated-header-inclusion: do not include the same header twice
2015-02-22Merge branch 'ab/merge-file-prefix'Libravatar Junio C Hamano1-1/+2
"git merge-file" did not work correctly in a subdirectory. * ab/merge-file-prefix: merge-file: correctly open files when in a subdir
2015-02-22Merge branch 'es/blame-commit-info-fix'Libravatar Junio C Hamano1-3/+2
"git blame" died, trying to free an uninitialized piece of memory. * es/blame-commit-info-fix: builtin/blame: destroy initialized commit_info only
2015-02-17Merge branch 'mg/commit-author-no-match-malformed-message'Libravatar Junio C Hamano1-1/+1
The error message from "git commit", when a non-existing author name was given as value to the "--author=" parameter, has been reworded to avoid misunderstanding. * mg/commit-author-no-match-malformed-message: commit: reword --author error message
2015-02-17Merge branch 'jc/apply-ws-fix-expands'Libravatar Junio C Hamano1-3/+28
"git apply --whitespace=fix" used to under-allocate the memory when the fix resulted in a longer text than the original patch. * jc/apply-ws-fix-expands: apply: count the size of postimage correctly apply: make update_pre_post_images() sanity check the given postlen apply.c: typofix
2015-02-13do not include the same header twiceLibravatar Дилян Палаузов1-1/+0
A few files include the same header file directly more than once. As all these headers protect themselves against repeated inclusion by the "#ifndef FOO_H / #define FOO_H / ... / #endif" idiom, leave only the first inclusion and remove the later inclusion as a no-op clean-up. Signed-off-by: Дилян Палаузов <git-dpa@aegee.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2015-02-11Merge branch 'ah/usage-strings'Libravatar Junio C Hamano58-96/+96
* ah/usage-strings: standardize usage info string format
2015-02-11Merge branch 'jc/push-to-checkout'Libravatar Junio C Hamano1-25/+45
Extending the js/push-to-deploy topic, the behaviour of "git push" when updating the working tree and the index with an update to the branch that is checked out can be tweaked by push-to-checkout hook. * jc/push-to-checkout: receive-pack: support push-to-checkout hook receive-pack: refactor updateInstead codepath
2015-02-11Merge branch 'sb/atomic-push'Libravatar Junio C Hamano3-36/+140
"git push" has been taught a "--atomic" option that makes push to update more than one ref an "all-or-none" affair. * sb/atomic-push: Document receive.advertiseatomic t5543-atomic-push.sh: add basic tests for atomic pushes push.c: add an --atomic argument send-pack.c: add --atomic command line argument send-pack: rename ref_update_to_be_sent to check_to_send_update receive-pack.c: negotiate atomic push support receive-pack.c: add execute_commands_atomic function receive-pack.c: move transaction handling in a central place receive-pack.c: move iterating over all commands outside execute_commands receive-pack.c: die instead of error in case of possible future bug receive-pack.c: shorten the execute_commands loop over all commands
2015-02-11Merge branch 'mh/reflog-expire'Libravatar Junio C Hamano1-156/+103
Restructure "reflog expire" to fit the reflogs better with the recently updated ref API. Looked reasonable (except that some shortlog entries stood out like a sore thumb). * mh/reflog-expire: (24 commits) refs.c: let fprintf handle the formatting refs.c: don't expose the internal struct ref_lock in the header file lock_any_ref_for_update(): inline function refs.c: remove unlock_ref/close_ref/commit_ref from the refs api reflog_expire(): new function in the reference API expire_reflog(): treat the policy callback data as opaque Move newlog and last_kept_sha1 to "struct expire_reflog_cb" expire_reflog(): move rewrite to flags argument expire_reflog(): move verbose to flags argument expire_reflog(): pass flags through to expire_reflog_ent() struct expire_reflog_cb: a new callback data type Rename expire_reflog_cb to expire_reflog_policy_cb expire_reflog(): move updateref to flags argument expire_reflog(): move dry_run to flags argument expire_reflog(): add a "flags" argument expire_reflog(): extract two policy-related functions Extract function should_expire_reflog_ent() expire_reflog(): use a lock_file for rewriting the reflog file expire_reflog(): return early if the reference has no reflog expire_reflog(): rename "ref" parameter to "refname" ...
2015-02-11Merge branch 'dk/format-patch-ignore-diff-submodule'Libravatar Junio C Hamano1-1/+1
Setting diff.submodule to 'log' made "git format-patch" produce broken patches. * dk/format-patch-ignore-diff-submodule: format-patch: ignore diff.submodule setting t4255: test am submodule with diff.submodule
2015-02-11Merge branch 'jk/blame-commit-label'Libravatar Junio C Hamano3-24/+15
"git blame HEAD -- missing" failed to correctly say "HEAD" when it tried to say "No such path 'missing' in HEAD". * jk/blame-commit-label: blame.c: fix garbled error message use xstrdup_or_null to replace ternary conditionals builtin/commit.c: use xstrdup_or_null instead of envdup builtin/apply.c: use xstrdup_or_null instead of null_strdup git-compat-util: add xstrdup_or_null helper
2015-02-11merge-file: correctly open files when in a subdirLibravatar Aleksander Boruch-Gruszecki1-1/+2
run_setup_gently() is called before merge-file. This may result in changing current working directory, which wasn't taken into account when opening a file for writing. Fix by prepending the passed prefix. Previous var is left so that error messages keep referring to the file from the user's working directory perspective. Signed-off-by: Aleksander Boruch-Gruszecki <aleksander.boruchgruszecki@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2015-02-10builtin/blame: destroy initialized commit_info onlyLibravatar Eric Sunshine1-3/+2
Since ea02ffa3 (mailmap: simplify map_user() interface, 2013-01-05), find_alignment() has been invoking commit_info_destroy() on an uninitialized auto 'struct commit_info' (when METAINFO_SHOWN is not set). commit_info_destroy() calls strbuf_release() for each 'commit_info' strbuf member, which randomly invokes free() on whatever random stack value happens to reside in strbuf.buf, thus leading to periodic crashes. Reported-by: Dilyan Palauzov <dilyan.palauzov@aegee.org> Signed-off-by: Eric Sunshine <sunshine@sunshineco.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2015-01-26commit: reword --author error messageLibravatar Michael J Gruber1-1/+1
If an --author argument is specified but does not contain a '>' then git tries to find the argument within the existing authors; and gives the error message "No existing author found with '%s'" if there is no match. This is confusing for users who try to specify a valid complete author name. Rename the error message to make it clearer that the failure has two reasons in this case. (This codepath is touched only when we know already that the argument cannot be a completely wellformed author ident.) Signed-off-by: Michael J Gruber <git@drmicha.warpmail.net> Helped-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2015-01-22Merge branch 'ak/cat-file-clean-up'Libravatar Junio C Hamano1-2/+0
* ak/cat-file-clean-up: cat-file: use "type" and "size" from outer scope
2015-01-22apply: count the size of postimage correctlyLibravatar Junio C Hamano1-2/+21
Under --whitespace=fix option, match_fragment() function examines the preimage (the common context and the removed lines in the patch) and the file being patched and checks if they match after correcting all whitespace errors. When they are found to match, the common context lines in the preimage is replaced with the fixed copy, because these lines will then be copied to the corresponding place in the postimage by a later call to update_pre_post_images(). Lines that are added in the postimage, under --whitespace=fix, have their whitespace errors already fixed when apply_one_fragment() prepares the preimage and the postimage, so in the end, application of the patch can be done by replacing the block of text in the file being patched that matched the preimage with what is in the postimage that was updated by update_pre_post_images(). In the earlier days, fixing whitespace errors always resulted in reduction of size, either collapsing runs of spaces in the indent to a tab or removing the trailing whitespaces. These days, however, some whitespace error fix results in extending the size. 250b3c6c (apply --whitespace=fix: avoid running over the postimage buffer, 2013-03-22) tried to compute the final postimage size but its math was flawed. It counted the size of the block of text in the original being patched after fixing the whitespace errors on its lines that correspond to the preimage. That number does not have much to do with how big the final postimage would be. Instead count (1) the added lines in the postimage, whose size is the same as in the final patch result because their whitespace errors have already been corrected, and (2) the fixed size of the lines that are common. Signed-off-by: Junio C Hamano <gitster@pobox.com>
2015-01-22apply: make update_pre_post_images() sanity check the given postlenLibravatar Junio C Hamano1-0/+6
"git apply --whitespace=fix" used to be able to assume that fixing errors will always reduce the size by e.g. stripping whitespaces at the end of lines or collapsing runs of spaces into tabs at the beginning of lines. An update to accomodate fixes that lengthens the result by e.g. expanding leading tabs into spaces were made long time ago but the logic miscounted the necessary space after such whitespace fixes, leading to either under-allocation or over-usage of already allocated space. Illustrate this with a runtime sanity-check to protect us from future breakage. The test was stolen from Kyle McKay who helped to identify the problem. Helped-by: "Kyle J. McKay" <mackyle@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2015-01-22apply.c: typofixLibravatar Junio C Hamano1-1/+1
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2015-01-20Merge branch 'ak/show-branch-usage-string'Libravatar Junio C Hamano1-3/+3
* ak/show-branch-usage-string: show-branch: fix indentation of usage string
2015-01-20show-branch: fix indentation of usage stringLibravatar Ralf Thielow1-3/+3
Noticed-by: Jean-Noël Avila <jn.avila@free.fr> Signed-off-by: Ralf Thielow <ralf.thielow@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2015-01-14Merge branch 'rc/for-each-ref-tracking'Libravatar Junio C Hamano1-2/+9
* rc/for-each-ref-tracking: for-each-ref: always check stat_tracking_info()'s return value
2015-01-14Merge branch 'ak/fewer-includes'Libravatar Junio C Hamano1-4/+0
* ak/fewer-includes: cat-file: remove unused includes git.c: remove unnecessary #includes
2015-01-14Merge branch 'ak/show-branch-usage-string'Libravatar Junio C Hamano1-1/+4
* ak/show-branch-usage-string: show-branch: line-wrap show-branch usage
2015-01-14Merge branch 'km/log-usage-string-i18n'Libravatar Junio C Hamano1-2/+2
* km/log-usage-string-i18n: log.c: fix translation markings
2015-01-14Merge branch 'js/remote-add-with-insteadof'Libravatar Junio C Hamano1-1/+3
"git remote add $name $URL" is now allowed when "url.$URL.insteadOf" is already defined. * js/remote-add-with-insteadof: Add a regression test for 'git remote add <existing> <same-url>' git remote: allow adding remotes agreeing with url.<...>.insteadOf
2015-01-14standardize usage info string formatLibravatar Alex Henrie58-97/+97
This patch puts the usage info strings that were not already in docopt- like format into docopt-like format, which will be a litle easier for end users and a lot easier for translators. Changes include: - Placing angle brackets around fill-in-the-blank parameters - Putting dashes in multiword parameter names - Adding spaces to [-f|--foobar] to make [-f | --foobar] - Replacing <foobar>* with [<foobar>...] Signed-off-by: Alex Henrie <alexhenrie24@gmail.com> Reviewed-by: Matthieu Moy <Matthieu.Moy@imag.fr> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2015-01-13cat-file: use "type" and "size" from outer scopeLibravatar Alexander Kuleshov1-2/+0
In cat_one_file(), "type" and "size" variables are defined in the function scope, and then two variables of the same name are defined in a block in one of the if/else statement, hiding the definitions in the outer scope. Because the values of the outer variables before the control enters this scope, however, do not have to be preserved, we can remove useless definitions of variables from the inner scope safely without breaking anything. Signed-off-by: Alexander Kuleshov <kuleshovmail@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2015-01-13blame.c: fix garbled error messageLibravatar Lukas Fleischer1-5/+7
The helper functions prepare_final() and prepare_initial() return a pointer to a string that is a member of an object in the revs->pending array. This array is later rebuilt when running prepare_revision_walk() which potentially transforms the pointer target into a bogus string. Fix this by maintaining a copy of the original string. Signed-off-by: Lukas Fleischer <git@cryptocrack.de> Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2015-01-13builtin/commit.c: use xstrdup_or_null instead of envdupLibravatar Jeff King1-9/+3
The only reason for envdup to be its own function is that we have to save the result in a temporary string. With xstrdup_or_null, we can feed the result of getenv() directly. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2015-01-13builtin/apply.c: use xstrdup_or_null instead of null_strdupLibravatar Jeff King1-10/+5
This file had its own identical helper that predates xstrdup_or_null. Let's use the global one to avoid repetition. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2015-01-12for-each-ref: always check stat_tracking_info()'s return valueLibravatar Raphael Kubo da Costa1-2/+9
The code handling %(upstream:track) and %(upstream:trackshort) assumed that it always had a valid branch that had been sanitized earlier in populate_value(), and thus did not check the return value of the call to stat_tracking_info(). While there is indeed some sanitization code that basically corresponds to stat_tracking_info() returning 0 (no base branch set), the function can also return -1 when the base branch did exist but has since then been deleted. In this case, num_ours and num_theirs had undefined values and a call to `git for-each-ref --format="%(upstream:track)"` could print spurious values such as [behind -111794512] [ahead 38881640, behind 5103867] even for repositories with one single commit. Verify stat_tracking_info()'s return value and do not print anything if it returns -1. This behavior also matches the documentation ("has no effect if the ref does not have tracking information associated with it"). Helped-by: Eric Sunshine <sunshine@sunshineco.com> Helped-by: Jeff King <peff@peff.net> Signed-off-by: Raphael Kubo da Costa <raphael.kubo.da.costa@intel.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2015-01-12Merge branch 'mg/add-ignore-errors' into maintLibravatar Junio C Hamano1-1/+1
* mg/add-ignore-errors: add: ignore only ignored files
2015-01-12Merge branch 'bc/fetch-thin-less-aggressive-in-normal-repository'Libravatar Junio C Hamano1-1/+6
Earlier we made "rev-list --object-edge" more aggressively list the objects at the edge commits, in order to reduce number of objects fetched into a shallow repository, but the change affected cases other than "fetching into a shallow repository" and made it unusably slow (e.g. fetching into a normal repository should not have to suffer the overhead from extra processing). Limit it to a more specific case by introducing --objects-edge-aggressive, a new option to rev-list. * bc/fetch-thin-less-aggressive-in-normal-repository: pack-objects: use --objects-edge-aggressive for shallow repos rev-list: add an option to mark fewer edges as uninteresting Documentation: add missing article in rev-list-options.txt
2015-01-12Merge branch 'rs/simplify-parsing-commit-tree-S'Libravatar Junio C Hamano1-3/+1
* rs/simplify-parsing-commit-tree-S: commit-tree: simplify parsing of option -S using skip_prefix()
2015-01-12Merge branch 'rs/plug-strbuf-leak-in-merge'Libravatar Junio C Hamano1-0/+1
* rs/plug-strbuf-leak-in-merge: merge: release strbuf after use in suggest_conflicts()
2015-01-12Merge branch 'es/checkout-index-temp'Libravatar Junio C Hamano1-8/+8
"git checkout-index --temp=$target $path" did not work correctly for paths outside the current subdirectory in the project. * es/checkout-index-temp: checkout-index: fix --temp relative path mangling t2004: demonstrate broken relative path printing t2004: standardize file naming in symlink test t2004: drop unnecessary write-tree/read-tree t2004: modernize style
2015-01-09cat-file: remove unused includesLibravatar Alexander Kuleshov1-4/+0
- "exec_cmd.h" became unnecessary at b931aa5a (Call builtin ls-tree in git-cat-file -p, 2006-05-26), when it changed an earlier code that delegated tree display to "ls-tree" via the run_command() API (hence needing "exec_cmd.h") to call cmd_ls_tree() directly. We should have removed the include in the same commit, but we forgot to do so. - "diff.h" was added at e5fba602 (textconv: support for cat_file, 2010-06-15), together with "userdiff.h", but "userdiff.h" can be included without including "diff.h"; the header was unnecessary from the beginning. - "tag.h" and "tree.h" were necessary since 8e440259 (Use blob_, commit_, tag_, and tree_type throughout., 2006-04-02) to check the type of object by comparing typename with tree_type and tag_type (pointers to extern strings). 21666f1a (convert object type handling from a string to a number, 2007-02-26) made these <type>_type strings unnecessary, and it could have switched to include "object.h", which is necessary to use typename(), but it forgot to do so. Because "tag.h" and "tree.h" include "object.h", it did not need to explicitly include "object.h" in order to start using typename() itself. We do not even have to include "object.h" after removing these two #includes, because "builtin.h" includes "commit.h" which in turn includes "object.h" these days. This happened at 7b9c0a69 (git-commit-tree: make it usable from other builtins, 2008-07-01). Signed-off-by: Alexander Kuleshov <kuleshovmail@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2015-01-08receive-pack: support push-to-checkout hookLibravatar Junio C Hamano1-1/+18
When receive.denyCurrentBranch is set to updateInstead, a push that tries to update the branch that is currently checked out is accepted only when the index and the working tree exactly matches the currently checked out commit, in which case the index and the working tree are updated to match the pushed commit. Otherwise the push is refused. This hook can be used to customize this "push-to-deploy" logic. The hook receives the commit with which the tip of the current branch is going to be updated, and can decide what kind of local changes are acceptable and how to update the index and the working tree to match the updated tip of the current branch. For example, the hook can simply run `git read-tree -u -m HEAD "$1"` in order to emulate 'git fetch' that is run in the reverse direction with `git push`, as the two-tree form of `read-tree -u -m` is essentially the same as `git checkout` that switches branches while keeping the local changes in the working tree that do not interfere with the difference between the branches. Signed-off-by: Junio C Hamano <gitster@pobox.com>
2015-01-08show-branch: line-wrap show-branch usageLibravatar Alexander Kuleshov1-1/+4
Signed-off-by: Alexander Kuleshov <kuleshovmail@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2015-01-07push.c: add an --atomic argumentLibravatar Ronnie Sahlberg1-0/+5
Add a command line argument to the git push command to request atomic pushes. Signed-off-by: Ronnie Sahlberg <sahlberg@google.com> Signed-off-by: Stefan Beller <sbeller@google.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2015-01-07send-pack.c: add --atomic command line argumentLibravatar Ronnie Sahlberg1-1/+5
This adds support to send-pack to negotiate and use atomic pushes iff the server supports it. Atomic pushes are activated by a new command line flag --atomic. In order to do this we also need to change the semantics for send_pack() slightly. The existing send_pack() function actually doesn't send all the refs back to the server when multiple refs are involved, for example when using --all. Several of the failure modes for pushes can already be detected locally in the send_pack client based on the information from the initial server side list of all the refs as generated by receive-pack. Any such refs that we thus know would fail to push are thus pruned from the list of refs we send to the server to update. For atomic pushes, we have to deal thus with both failures that are detected locally as well as failures that are reported back from the server. In order to do so we treat all local failures as push failures too. We introduce a new status code REF_STATUS_ATOMIC_PUSH_FAILED so we can flag all refs that we would normally have tried to push to the server but we did not due to local failures. This is to improve the error message back to the end user to flag that "these refs failed to update since the atomic push operation failed." Signed-off-by: Ronnie Sahlberg <sahlberg@google.com> Signed-off-by: Stefan Beller <sbeller@google.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2015-01-07receive-pack.c: negotiate atomic push supportLibravatar Ronnie Sahlberg1-0/+11
This adds the atomic protocol option to allow receive-pack to inform the client that it has atomic push capability. This commit makes the functionality introduced in the previous commits go live for the serving side. The changes in documentation reflect the protocol capabilities of the server. Signed-off-by: Stefan Beller <sbeller@google.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2015-01-07receive-pack.c: add execute_commands_atomic functionLibravatar Stefan Beller1-1/+46
This introduces the new function execute_commands_atomic which will use one atomic transaction for all updates. The default behavior is still the old non atomic way, one ref at a time. This is to cause as little disruption as possible to existing clients. It is unknown if there are client scripts that depend on the old non-atomic behavior so we make it opt-in for now. A later patch will add the possibility to actually use the functionality added by this patch. For now use_atomic is always 0. Inspired-by: Ronnie Sahlberg <sahlberg@google.com> Helped-by: Eric Sunshine <sunshine@sunshineco.com> Signed-off-by: Stefan Beller <sbeller@google.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2015-01-07receive-pack.c: move transaction handling in a central placeLibravatar Stefan Beller1-14/+37
This moves all code related to transactions into the execute_commands_non_atomic function. This includes beginning and committing the transaction as well as dealing with the errors which may occur during the begin and commit phase of a transaction. No functional changes intended. Helped-by: Eric Sunshine <sunshine@sunshineco.com> Signed-off-by: Stefan Beller <sbeller@google.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2015-01-07receive-pack.c: move iterating over all commands outside execute_commandsLibravatar Stefan Beller1-6/+13
This commit allows us in a later patch to easily distinguish between the non atomic way to update the received refs and the atomic way which is introduced in a later patch. Signed-off-by: Stefan Beller <sbeller@google.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2015-01-07receive-pack.c: die instead of error in case of possible future bugLibravatar Stefan Beller1-3/+1
Discussion on the previous patch revealed we rather want to err on the safe side. To do so we need to stop receive-pack in case of the possible future bug when connectivity is not checked on a shallow push. Also while touching that code we considered that removing the reported refs may be harmful in some situations. Sound the message more like a "This Cannot Happen, Please Investigate!" instead of giving advice to remove refs. Suggested-by: Jonathan Nieder <jrnieder@gmail.com> Signed-off-by: Stefan Beller <sbeller@google.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2015-01-07receive-pack.c: shorten the execute_commands loop over all commandsLibravatar Stefan Beller1-16/+27
Make the main "execute_commands" loop in receive-pack easier to read by splitting out some steps into helper functions. The new helper 'should_process_cmd' checks if a ref update is unnecessary, whether due to an error having occurred or for another reason. The helper 'warn_if_skipped_connectivity_check' warns if we have forgotten to run a connectivity check on a ref which is shallow for the client which would be a bug. This will help us to duplicate less code in a later patch when we make a second copy of the "execute_commands" loop. No functional change intended. Signed-off-by: Stefan Beller <sbeller@google.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2015-01-07format-patch: ignore diff.submodule settingLibravatar Doug Kelly1-1/+1
diff.submodule when set to log produces output which git-am cannot handle. Ignore this setting when generating patch output. Signed-off-by: Doug Kelly <dougk.ff7@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2015-01-07Merge branch 'jc/merge-bases'Libravatar Junio C Hamano3-5/+5
The get_merge_bases*() API was easy to misuse by careless copy&paste coders, leaving object flags tainted in the commits that needed to be traversed. * jc/merge-bases: get_merge_bases(): always clean-up object flags bisect: clean flags after checking merge bases