summaryrefslogtreecommitdiff
path: root/builtin-merge.c
AgeCommit message (Collapse)Author
2008-08-29Remove useless memset of static command name lists in builtin-merge.cAlex Riesen
The statics are always initialized with 0 Signed-off-by: Alex Riesen <raa.lkml@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-08-29Remove calculation of the longest command name from where it is not usedAlex Riesen
Just calculate it where it is needed - it is cheap and trivial, as all the lengths are already there (stored when creating the command lists). Signed-off-by: Alex Riesen <raa.lkml@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-08-28Merge branch 'mv/merge-custom'Junio C Hamano
* mv/merge-custom: t7606: fix custom merge test Fix "git-merge -s bogo" help text Update .gitignore to ignore git-help Builtin git-help. builtin-help: always load_command_list() in cmd_help() Add a second testcase for handling invalid strategies in git-merge Add a new test for using a custom merge strategy builtin-merge: allow using a custom strategy builtin-help: make some internal functions available to other builtins Conflicts: help.c
2008-08-24Merge branch 'maint' to sync with 1.6.0.1Junio C Hamano
2008-08-24merge: fix numerus bugs around "trivial merge" areaJunio C Hamano
The "trivial merge" codepath wants to optimize itself by making an internal call to the read-tree machinery, but it does not read the index before doing so, and the codepath is never exercised. Incidentally, this failure to read the index upfront means that the safety to refuse doing anything when the index is unmerged does not kick in, either. These two problem are fixed by using read_cache_unmerged() that does read the index before checking if it is unmerged at the beginning of cmd_merge(). The primary logic of the merge, however, assumes that the process never reads the index in-core, and the call to write_cache_as_tree() it makes from write_tree_trivial() will always read from the on-disk index that is prepared the strategy back-ends. This assumption is now broken by the above fix. To fix this issue, we now call discard_cache() before calling write_tree_trivial() when it wants to write the on-disk index as a tree. When multiple strategies are tried, their results are evaluated by reading the resulting index and inspecting it. The codepath needs to make a call to read_cache() for each successful strategy, and for that to work, they need to discard_cache() the one read by the previous round. Also the "trivial merge" forgot that the current commit is one of the parents of the resulting commit. Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-08-22provide more errors for the "merge into empty head" casePaolo Bonzini
A squash merge into an unborn branch could be implemented by building the index from the merged-from branch, and doing a single commit, but this is not supported yet. A non-fast-forward merge into an unborn branch does not make any sense, because you cannot make a merge commit if you don't have a commit to use as the parent. Signed-off-by: Paolo Bonzini <bonzini@gnu.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-08-21Fix "git-merge -s bogo" help textJunio C Hamano
It does not make much sense to reuse the output code from "git help" to show the list of commands to the standard output while giving the error message before that to the standard error stream. This makes the output consistent to that of the 1.6.0 version of "git merge". Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-08-20"git-merge": allow fast-forwarding in a stat-dirty treeJunio C Hamano
We used to refresh the index to clear stat-dirtyness before a fast-forward merge. Recent C rewrite forgot to do this. Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-07-30Fix merge name generation in "merge in C"Junio C Hamano
When merging an early part of a branch, e.g. "git merge xyzzy~20", we were supposed to say "branch 'xyzzy' (early part)", but it incorrectly said "branch 'refs/heads/xy' (early part)" instead. The logic was supposed to first strip away "~20" part to make sure that what follows "~" is a non-zero posint, prefix it with "refs/heads/" and ask resolve_ref() if it is a ref. If it is, then we know xyzzy was a branch, and we can give the correct message. However, there were a few bugs. First of all, the logic to build this "true branch refname" did not count the characters correctly. At this point of the code, "len" is the number of trailing, non-name part of the given extended SHA-1 expression given by the user, i.e. number of bytes in "~20" in the above example. In addition, the message forgot to skip "refs/heads/" it prefixed from the output. Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-07-30builtin-merge: allow using a custom strategyMiklos Vajna
Allow using a custom strategy, as long as it's named git-merge-foo. The error handling is now done using is_git_command(). The list of available strategies is now shown by list_commands(). If an invalid strategy is supplied, like -s foobar, then git-merge would list all git-merge-* commands. This is not perfect, since for example git-merge-index is not a valid strategy. These are removed from the output by scanning the list of main commands; if the git-merge-foo command is listed in the all_strategy list, then it's shown, otherwise excluded. This does not exclude commands somewhere else in the PATH, where custom strategies are expected. Signed-off-by: Miklos Vajna <vmiklos@frugalware.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-07-24Make non-static functions, that may be static, staticStephan Beyer
Signed-off-by: Stephan Beyer <s-beyer@gmx.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-07-22builtin-merge: add missing structure initializationPierre Habouzit
The parameter that is eventually passed to read_directory() to scan the working tree should be properly initialized. Signed-off-by: Pierre Habouzit <madcoder@debian.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-07-22builtin-merge: give a proper error message for invalid strategies in configMiklos Vajna
'git merge -s foobar' diagnosed invalid "foobar" strategy and errored out with a message, but foobar in pull.twohead or pull.octopus was just silently ignored. This makes invalid strategy both on the command line and in the configuration file to trigger the same error. Signed-off-by: Miklos Vajna <vmiklos@frugalware.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-07-20builtin-merge.c: Fix option parsingMichele Ballabio
Now "git merge -m" needs a message, and errors out with the usage text if none is given. This way, t7600-merge.sh is fixed. Signed-off-by: Michele Ballabio <barra_cuda@katamail.com> Acked-by: Miklos Vajna <vmiklos@frugalware.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-07-20Teach 'git merge' that some merge strategies no longer existMiklos Vajna
'recur' co-existed with 'recursive' when rewriting it in C, but it no longer available. 'stupid' was also recently removed. "git merge -s confused origin" still includes them in the list of available merge strategies. [jc: this is a squash of two micropatches] Signed-off-by: Miklos Vajna <vmiklos@frugalware.org> Signed-off-by: Nanako Shiraishi <nanako3@lavabit.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-07-16Merge branch 'mv/merge-in-c'Junio C Hamano
* mv/merge-in-c: reduce_heads(): protect from duplicate input reduce_heads(): thinkofix Add a new test for git-merge-resolve t6021: add a new test for git-merge-resolve Teach merge.log to "git-merge" again Build in merge Fix t7601-merge-pull-config.sh on AIX git-commit-tree: make it usable from other builtins Add new test case to ensure git-merge prepends the custom merge message Add new test case to ensure git-merge reduces octopus parents when possible Introduce reduce_heads() Introduce get_merge_bases_many() Add new test to ensure git-merge handles more than 25 refs. Introduce get_octopus_merge_bases() in commit.c git-fmt-merge-msg: make it usable from other builtins Move read_cache_unmerged() to read-cache.c Add new test to ensure git-merge handles pull.twohead and pull.octopus Move parse-options's skip_prefix() to git-compat-util.h Move commit_list_count() to commit.c Move split_cmdline() to alias.c Conflicts: Makefile parse-options.c
2008-07-10Teach merge.log to "git-merge" againJunio C Hamano
The command forgot the configuration variable when rewritten in C. Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-07-08Build in mergeMiklos Vajna
Mentored-by: Johannes Schindelin <Johannes.Schindelin@gmx.de> Signed-off-by: Miklos Vajna <vmiklos@frugalware.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>