summaryrefslogtreecommitdiff
path: root/builtin-merge-recursive.c
AgeCommit message (Collapse)AuthorFilesLines
2009-05-23MinGW: Fix compiler warning in merge-recursiveLibravatar Johannes Schindelin1-2/+3
GCC 4.4.0 on Windows does not like the format %zu. It is quite unlikely, though, that we need more merge bases than a %d can display, so replace the %zu by a %d. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Steffen Prohaska <prohaska@zib.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2009-01-05remove trailing LF in die() messagesLibravatar Alexander Potashev1-1/+1
LF at the end of format strings given to die() is redundant because die already adds one on its own. Signed-off-by: Alexander Potashev <aspotashev@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-08-30merge-recursive: introduce merge_optionsLibravatar Miklos Vajna1-21/+22
This makes it possible to avoid passing the labels of branches as arguments to merge_recursive(), merge_trees() and merge_recursive_generic(). It also takes care of subtree merge, output buffering, verbosity, and rename limits - these were global variables till now in merge-recursive.c. A new function, named init_merge_options(), is introduced as well, it clears the struct merge_info, then initializes with default values, finally updates the default values based on the config and environment variables. Signed-off-by: Miklos Vajna <vmiklos@frugalware.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-08-30merge-recursive.c: Add more generic merge_recursive_generic()Libravatar Stephan Beyer1-45/+19
merge_recursive_generic() takes, in comparison to to merge_recursive(), no commit ("struct commit *") arguments but SHA ids ("unsigned char *"), and no commit list of bases but an array of refs ("const char **"). This makes it more generic in the case that it can also take the SHA of a tree to merge trees without commits, for the bases, the head and the remote. merge_recursive_generic() also handles locking and updating of the index, which is a common use case of merge_recursive(). This patch also rewrites builtin-merge-recursive.c to make use of merge_recursive_generic(). By doing this, I stumbled over the limitation of 20 bases and I've added a warning if this limitation is exceeded. This patch qualifies make_virtual_commit() as static again because this function is not needed anymore outside merge-recursive.c. Signed-off-by: Stephan Beyer <s-beyer@gmx.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-08-30Split out merge_recursive() to merge-recursive.cLibravatar Miklos Vajna1-1323/+4
Move most of the of code from builtin-merge-recursive.c to a new file merge-recursive.c and introduce merge_recursive_setup() in there so that builtin-merge-recursive and other builtins call it. Signed-off-by: Miklos Vajna <vmiklos@frugalware.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-08-22Revert "Convert output messages in merge-recursive to past tense."Libravatar Jonathan del Strother1-18/+18
During a conflicting merge, you would typically see: Auto-merged foo.txt CONFLICT (content): Merge conflict in foo.txt Recorded preimage for 'foo.txt' Automatic merge failed; fix conflicts and then commit the result. and left wondering what happened to "foo.txt". Did it succeed, and then conflicted, and then what? This is because historically there was a progress bar displayed before the auto-merge is mentioned, and it was expected to take long time, before we can say "Auto-merged foo.txt". It turns out it was not the case, and the original wording "Auto-merging foo.txt" we used to have before 89f40be (Convert output messages in merge-recursive to past tense., 2007-01-14) is better. Acked-by: Shawn O. Pearce <spearce@spearce.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-07-21Rename path_list to string_listLibravatar Johannes Schindelin1-48/+48
The name path_list was correct for the first usage of that data structure, but it really is a general-purpose string list. $ perl -i -pe 's/path-list/string-list/g' $(git grep -l path-list) $ perl -i -pe 's/path_list/string_list/g' $(git grep -l path_list) $ git mv path-list.h string-list.h $ git mv path-list.c string-list.c $ perl -i -pe 's/has_path/has_string/g' $(git grep -l has_path) $ perl -i -pe 's/path/string/g' string-list.[ch] $ git mv Documentation/technical/api-path-list.txt \ Documentation/technical/api-string-list.txt $ perl -i -pe 's/strdup_paths/strdup_strings/g' $(git grep -l strdup_paths) ... and then fix all users of string-list to access the member "string" instead of "path". Documentation/technical/api-string-list.txt needed some rewrapping, too. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-07-16Merge branch 'rs/archive'Libravatar Junio C Hamano1-2/+2
* rs/archive: archive: remove extra arguments parsing code archive: unify file attribute handling archive: centralize archive entry writing archive: add baselen member to struct archiver_args add context pointer to read_tree_recursive() archive: remove args member from struct archiver
2008-07-15add context pointer to read_tree_recursive()Libravatar René Scharfe1-2/+2
Add a pointer parameter to read_tree_recursive(), which is passed to the callback function. This allows callers of read_tree_recursive() to share data with the callback without resorting to global variables. All current callers pass NULL. Signed-off-by: Rene Scharfe <rene.scharfe@lsrfire.ath.cx> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-06-30Move commit_list_count() to commit.cLibravatar Miklos Vajna1-8/+0
This function is useful outside builtin-merge-recursive, for example in builtin-merge. Signed-off-by: Miklos Vajna <vmiklos@frugalware.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-06-24clone: create intermediate directories of destination repoLibravatar Jeff King1-11/+2
The shell version used to use "mkdir -p" to create the repo path, but the C version just calls "mkdir". Let's replicate the old behavior. We have to create the git and worktree leading dirs separately; while most of the time, the worktree dir contains the git dir (as .git), the user can override this using GIT_WORK_TREE. We can reuse safe_create_leading_directories, but we need to make a copy of our const buffer to do so. Since merge-recursive uses the same pattern, we can factor this out into a global function. This has two other cleanup advantages for merge-recursive: 1. mkdir_p wasn't a very good name. "mkdir -p foo/bar" actually creates bar, but this function just creates the leading directories. 2. mkdir_p took a mode argument, but it was completely ignored. Acked-by: Daniel Barkalow <barkalow@iabervon.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-06-09Merge branch 'js/merge-recursive'Libravatar Junio C Hamano1-0/+11
* js/merge-recursive: merge-recursive: respect core.autocrlf when writing out the result Add testcase for merging in a CRLF repo
2008-06-09merge-recursive: respect core.autocrlf when writing out the resultLibravatar Johannes Schindelin1-0/+11
The code forgot to convert the blob contents into work tree representation before writing it out. Also fixes leaks -- earlier the updated blobs were never freed. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-05-25Merge branch 'js/config-cb'Libravatar Junio C Hamano1-3/+3
* js/config-cb: Provide git_config with a callback-data parameter Conflicts: builtin-add.c builtin-cat-file.c
2008-05-14Provide git_config with a callback-data parameterLibravatar Johannes Schindelin1-3/+3
git_config() only had a function parameter, but no callback data parameter. This assumes that all callback functions only modify global variables. With this patch, every callback gets a void * parameter, and it is hoped that this will help the libification effort. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-05-03diff: make "too many files" rename warning optionalLibravatar Jeff King1-0/+1
In many cases, the warning ends up as clutter, because the diff is being done "behind the scenes" from the user (e.g., when generating a commit diffstat), and whether we show renames or not is not particularly interesting to the user. However, in the case of a merge (which is what motivated the warning in the first place), it is a useful hint as to why a merge with renames might have failed. This patch makes the warning optional based on the code calling into diffcore. We default to not showing the warning, but turn it on for merges. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-05-03bump rename limit defaultsLibravatar Jeff King1-1/+1
The current rename limit default of 100 was arbitrarily chosen. Testing[1] has shown that on modern hardware, a limit of 200 adds about a second of computation time, and a limit of 500 adds about 5 seconds of computation time. This patch bumps the default limit to 200 for viewing diffs, and to 500 for performing a merge. The limit for generating git-status templates is set independently; we bump it up to 200 here, as well, to match the diff limit. [1]: See <20080211113516.GB6344@coredump.intra.peff.net> Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-05-03add merge.renamelimit config optionLibravatar Jeff King1-3/+10
The point of rename limiting is to bound the amount of time we spend figuring out inexact renames. Currently we use a single value, diff.renamelimit, for all situations. However, it is probably the case that a user is willing to spend more time finding renames during a merge than they are while looking at git-log. This patch provides a way of setting those values separately (though for backwards compatibility, merge still falls back on the diff renamelimit). Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-03-14Merge branch 'maint'Libravatar Junio C Hamano1-2/+13
* maint: merge-file: handle empty files gracefully merge-recursive: handle file mode changes Minor wording changes in the keyboard descriptions in git-add --interactive. git fetch: Take '-n' to mean '--no-tags' quiltimport: fix misquoting of parsed -p<num> parameter git-quiltimport: better parser to grok "enhanced" series files.
2008-03-11Merge branch 'lt/unpack-trees'Libravatar Junio C Hamano1-0/+2
* lt/unpack-trees: unpack_trees(): fix diff-index regression. traverse_trees_recursive(): propagate merge errors up unpack_trees(): minor memory leak fix in unused destination index Make 'unpack_trees()' have a separate source and destination index Make 'unpack_trees()' take the index to work on as an argument Add 'const' where appropriate to index handling functions Fix tree-walking compare_entry() in the presense of --prefix Move 'unpack_trees()' over to 'traverse_trees()' interface Make 'traverse_trees()' traverse conflicting DF entries in parallel Add return value to 'traverse_tree()' callback Make 'traverse_tree()' use linked structure rather than 'const char *base' Add 'df_name_compare()' helper function
2008-03-11Merge branch 'jc/cherry-pick' (early part)Libravatar Junio C Hamano1-365/+12
* 'jc/cherry-pick' (early part): expose a helper function peel_to_type(). merge-recursive: split low-level merge functions out. Conflicts: Makefile builtin-merge-recursive.c sha1_name.c
2008-03-09Make 'unpack_trees()' have a separate source and destination indexLibravatar Linus Torvalds1-1/+2
We will always unpack into our own internal index, but we will take the source from wherever specified, and we will optionally write the result to a specified index (optionally, because not everybody even _wants_ any result: the index diffing really wants to just walk the tree and index in parallel). This ends up removing a fair number more lines than it adds, for the simple reason that we can now skip all the crud that tried to be oh-so-careful about maintaining our position in the index as we were traversing and modifying it. Since we don't actually modify the source index any more, we can just update the 'o->pos' pointer without worrying about whether an index entry got removed or replaced or added to. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-03-09Make 'unpack_trees()' take the index to work on as an argumentLibravatar Linus Torvalds1-0/+1
This is just a very mechanical conversion, and makes everybody set it to '&the_index' before calling, but at least it makes it more explicit where we work with the index. The next stage would be to split that index usage up into a 'source' and a 'destination' index, so that we can unpack into a different index than we started out from. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-02-27Merge branch 'db/checkout'Libravatar Junio C Hamano1-0/+1754
* db/checkout: (21 commits) checkout: error out when index is unmerged even with -m checkout: show progress when checkout takes long time while switching branches Add merge-subtree back checkout: updates to tracking report builtin-checkout.c: Remove unused prefix arguments in switch_branches path checkout: work from a subdirectory checkout: tone down the "forked status" diagnostic messages Clean up reporting differences on branch switch builtin-checkout.c: fix possible usage segfault checkout: notice when the switched branch is behind or forked Build in checkout Move code to clean up after a branch change to branch.c Library function to check for unmerged index entries Use diff -u instead of diff in t7201 Move create_branch into a library file Build-in merge-recursive Add "skip_unmerged" option to unpack_trees. Discard "deleted" cache entries after using them to update the working tree Send unpack-trees debugging output to stderr Add flag to make unpack_trees() not print errors. ... Conflicts: Makefile
2008-02-09Library function to check for unmerged index entriesLibravatar Daniel Barkalow1-13/+2
It's small, but it was in three places already, so it should be in the library. Signed-off-by: Daniel Barkalow <barkalow@iabervon.org>
2008-02-09Build-in merge-recursiveLibravatar Daniel Barkalow1-0/+1762
This makes write_tree_from_memory(), which writes the active cache as a tree and returns the struct tree for it, available to other code. It also makes available merge_trees(), which does the internal merge of two trees with a known base, and merge_recursive(), which does the recursive internal merge of two commits with a list of common ancestors. The first two of these will be used by checkout -m, and the third is presumably useful in general, although the implementation of checkout -m which entirely matches the behavior of the shell version does not use it (since it ignores the difference of ancestry between the old branch and the new branch). Signed-off-by: Daniel Barkalow <barkalow@iabervon.org>