summaryrefslogtreecommitdiff
path: root/merge-recursive.c
AgeCommit message (Collapse)Author
2009-08-21Merge branch 'jc/maint-merge-recursive-fix' into maintJunio C Hamano
* jc/maint-merge-recursive-fix: merge-recursive: don't segfault while handling rename clashes
2009-07-31merge-recursive: don't segfault while handling rename clashesJunio C Hamano
When a branch moves A to B while the other branch created B (or moved C to B), the code tried to rename one of them to B~something to preserve both versions, and failed to register temporary resolution for the original path B at stage#0 during virtual ancestor computation. This left the index in unmerged state and caused a segfault. A better solution is to merge these two versions of B's in place and use the (potentially conflicting) result as the intermediate merge result in the virtual ancestor. Signed-off-by: Junio C Hamano <gitster@pobox.com>
2009-07-06Merge branch 'tr/die_errno'Junio C Hamano
* tr/die_errno: Use die_errno() instead of die() when checking syscalls Convert existing die(..., strerror(errno)) to die_errno() die_errno(): double % in strerror() output just in case Introduce die_errno() that appends strerror(errno) to die()
2009-07-02Remove filename from conflict markersMartin Renold
Put filenames into the conflict markers only when they are different. Otherwise they are redundant information clutter. Print the filename explicitely when warning about a binary conflict. Signed-off-by: Martin Renold <martinxyz@gmx.ch> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2009-06-27Convert existing die(..., strerror(errno)) to die_errno()Thomas Rast
Change calls to die(..., strerror(errno)) to use the new die_errno(). In the process, also make slight style adjustments: at least state _something_ about the function that failed (instead of just printing the pathname), and put paths in single quotes. Signed-off-by: Thomas Rast <trast@student.ethz.ch> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2009-06-21Fix various sparse warnings in the git source codeLinus Torvalds
There are a few remaining ones, but this fixes the trivial ones. It boils down to two main issues that sparse complains about: - warning: Using plain integer as NULL pointer Sparse doesn't like you using '0' instead of 'NULL'. For various good reasons, not the least of which is just the visual confusion. A NULL pointer is not an integer, and that whole "0 works as NULL" is a historical accident and not very pretty. A few of these remain: zlib is a total mess, and Z_NULL is just a 0. I didn't touch those. - warning: symbol 'xyz' was not declared. Should it be static? Sparse wants to see declarations for any functions you export. A lack of a declaration tends to mean that you should either add one, or you should mark the function 'static' to show that it's in file scope. A few of these remain: I only did the ones that should obviously just be made static. That 'wt_status_submodule_summary' one is debatable. It has a few related flags (like 'wt_status_use_color') which _are_ declared, and are used by builtin-commit.c. So maybe we'd like to export it at some point, but it's not declared now, and not used outside of that file, so 'static' it is in this patch. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2009-05-23Merge branch 'do/maint-merge-recursive-fix'Junio C Hamano
* do/maint-merge-recursive-fix: merge-recursive: never leave index unmerged while recursing
2009-05-10merge-recursive: never leave index unmerged while recursingDave Olszewski
When you are trying to come up with the final result (i.e. depth=0), you want to record how the conflict arose by registering the state of the common ancestor, your branch and the other branch in the index, hence you want to do update_stages(). When you are merging with positive depth, that is because of a criss-cross merge situation. In such a case, you would need to record the tentative result, with conflict markers and all, as if the merge went cleanly, even if there are conflicts, in order to write it out as a tree object later to be used as a common ancestor tree. update_file() calls update_file_flags() with update_cache=1 to signal that the result needs to be written to the index at stage #0 (i.e. merged), and the code should not clobber the index further by calling update_stages(). The codepath to deal with rename/delete conflict in a recursive merge however left the index unmerged. Signed-off-by: Dave Olszewski <cxreg@pobox.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2009-04-29merge-recursive: do not die on a conflicting submoduleJunio C Hamano
We cannot represent the 3-way conflicted state in the work tree for these entries, but it is normal not to have commit objects for them in our repository. Just update the index and the life will be good. Signed-off-by: Junio C Hamano <gitster@pobox.com>
2009-04-08Merge branch 'cb/maint-merge-recursive-submodule-fix'Junio C Hamano
* cb/maint-merge-recursive-submodule-fix: simplify output of conflicting merge update cache for conflicting submodule entries add tests for merging with submodules
2009-04-05simplify output of conflicting mergeClemens Buchacher
This simplifies the code without changing the semantics and removes the unhelpful "needs $sha1" part of the conflicting submodule message. Signed-off-by: Clemens Buchacher <drizzd@aon.at> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2009-04-05update cache for conflicting submodule entriesClemens Buchacher
When merging merge bases during a recursive merge we do not want to leave any unmerged entries. Otherwise we cannot create a temporary tree for the recursive merge to work with. We failed to do so in case of a submodule conflict between merge bases, causing a NULL pointer dereference in the next step of the recursive merge. Signed-off-by: Clemens Buchacher <drizzd@aon.at> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2009-03-16Fix various dead stores found by the clang static analyzerBenjamin Kramer
http-push.c::finish_request(): request is initialized by the for loop index-pack.c::free_base_data(): b is initialized by the for loop merge-recursive.c::process_renames(): move compare to narrower scope, and remove unused assignments to it remove unused variable renames2 xdiff/xdiffi.c::xdl_recs_cmp(): remove unused variable ec xdiff/xemit.c::xdl_emit_diff(): xche is always overwritten Signed-off-by: Benjamin Kramer <benny.kra@googlemail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2009-02-07tree.c: allow read_tree_recursive() to traverse gitlink entriesLars Hjemli
When the callback function invoked from read_tree_recursive() returns the value `READ_TREE_RECURSIVE` for a gitlink entry, the traversal will now continue into the tree connected to the gitlinked commit. This functionality can be used to allow inter-repository operations, but since the current users of read_tree_recursive() does not yet support such operations, they have been modified where necessary to make sure that they never return READ_TREE_RECURSIVE for gitlink entries (hence no change in behaviour should be introduces by this patch alone). Signed-off-by: Lars Hjemli <hjemli@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2009-01-13Merge branch 'js/maint-merge-recursive-r-d-conflict' into maintJunio C Hamano
* js/maint-merge-recursive-r-d-conflict: merge-recursive: mark rename/delete conflict as unmerged
2009-01-13Merge branch 'cb/maint-merge-recursive-fix' into maintJunio C Hamano
* cb/maint-merge-recursive-fix: merge-recursive: do not clobber untracked working tree garbage modify/delete conflict resolution overwrites untracked file Conflicts: builtin-merge-recursive.c
2009-01-07Merge branch 'js/maint-merge-recursive-r-d-conflict'Junio C Hamano
* js/maint-merge-recursive-r-d-conflict: merge-recursive: mark rename/delete conflict as unmerged
2008-12-25merge-recursive: mark rename/delete conflict as unmergedJohannes Schindelin
When a file was renamed in one branch, but deleted in the other, one should expect the index to contain an unmerged entry, namely the target of the rename. Make it so. Noticed by Constantine Plotnikov. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-12-15Merge branch 'cb/maint-merge-recursive-fix' into cb/merge-recursive-fixJunio C Hamano
* cb/maint-merge-recursive-fix: merge-recursive: do not clobber untracked working tree garbage modify/delete conflict resolution overwrites untracked file
2008-12-05Report symlink failures in merge-recursiveAlex Riesen
Signed-off-by: Alex Riesen <raa.lkml@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-11-24merge-recursive: use strbuf_expand() instead of interpolate()René Scharfe
Signed-off-by: Rene Scharfe <rene.scharfe@lsrfire.ath.cx> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-10-19git-merge-recursive: honor merge.conflictstyle once againMatt McCutchen
This was originally implemented in c236bcd06138bcbc929b86ad1a513635bf4847b2 but was lost to a mismerge in 9ba929ed652f5ed7707f1c684999af4ad02c4925. Signed-off-by: Matt McCutchen <matt@mattmccutchen.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-10-12Replace calls to strbuf_init(&foo, 0) with STRBUF_INIT initializerBrandon Casey
Many call sites use strbuf_init(&foo, 0) to initialize local strbuf variable "foo" which has not been accessed since its declaration. These can be replaced with a static initialization using the STRBUF_INIT macro which is just as readable, saves a function call, and takes up fewer lines. Signed-off-by: Brandon Casey <casey@nrlssc.navy.mil> Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2008-09-29Merge branch 'bc/master-diff-hunk-header-fix'Shawn O. Pearce
* bc/master-diff-hunk-header-fix: Clarify commit error message for unmerged files Use strchrnul() instead of strchr() plus manual workaround Use remove_path from dir.c instead of own implementation Add remove_path: a function to remove as much as possible of a path git-submodule: Fix "Unable to checkout" for the initial 'update' Clarify how the user can satisfy stash's 'dirty state' check. t4018-diff-funcname: test syntax of builtin xfuncname patterns t4018-diff-funcname: test syntax of builtin xfuncname patterns make "git remote" report multiple URLs diff hunk pattern: fix misconverted "\{" tex macro introducers diff: fix "multiple regexp" semantics to find hunk header comment diff: use extended regexp to find hunk headers diff: use extended regexp to find hunk headers diff.*.xfuncname which uses "extended" regex's for hunk header selection diff.c: associate a flag with each pattern and use it for compiling regex diff.c: return pattern entry pointer rather than just the hunk header pattern Conflicts: builtin-merge-recursive.c t/t7201-co.sh xdiff-interface.h
2008-09-26Merge branch 'maint'Shawn O. Pearce
* maint: Remove empty directories in recursive merge Documentation: clarify the details of overriding LESS via core.pager Conflicts: builtin-merge-recursive.c
2008-09-26Cleanup remove_pathAlex Riesen
Signed-off-by: Alex Riesen <raa.lkml@gmail.com> Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2008-09-05merge-recursive: get rid of virtual_idMiklos Vajna
We now just leave the object->sha1 field of virtual commits 0{40} as it is initialized, as a unique hash is not necessary in case of virtual commits. Signed-off-by: Miklos Vajna <vmiklos@frugalware.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-09-05merge-recursive: move current_{file,directory}_set to struct merge_optionsMiklos Vajna
Signed-off-by: Miklos Vajna <vmiklos@frugalware.org>
2008-09-05merge-recursive: move the global obuf to struct merge_optionsMiklos Vajna
Signed-off-by: Miklos Vajna <vmiklos@frugalware.org>
2008-09-05merge-recursive: get rid of the index_only global variableMiklos Vajna
struct merge_options already has a call_depth member, and index_only global variable always equals to !!call_depth. We always use index_only as a condition, so we can just use call_depth instead of index_only. Signed-off-by: Miklos Vajna <vmiklos@frugalware.org>
2008-09-04merge-recursive: move call_depth to struct merge_optionsMiklos Vajna
Signed-off-by: Miklos Vajna <vmiklos@frugalware.org>
2008-08-31merge-recursive: introduce merge_optionsMiklos Vajna
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-31merge-recursive.c: Add more generic merge_recursive_generic()Stephan Beyer
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-31Split out merge_recursive() to merge-recursive.cMiklos Vajna
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-02-10Build-in merge-recursiveDaniel Barkalow
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>
2008-01-21Make on-disk index representation separate from in-core oneLinus Torvalds
This converts the index explicitly on read and write to its on-disk format, allowing the in-core format to contain more flags, and be simpler. In particular, the in-core format is now host-endian (as opposed to the on-disk one that is network endian in order to be able to be shared across machines) and as a result we can dispense with all the htonl/ntohl on accesses to the cache_entry fields. This will make it easier to make use of various temporary flags that do not exist in the on-disk format. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2008-01-16Improve use of lockfile APIBrandon Casey
Remove remaining double close(2)'s. i.e. close() before commit_locked_index() or commit_lock_file(). Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-01-03Fix grammar nits in documentation and in code comments.Jim Meyering
Signed-off-by: Jim Meyering <meyering@redhat.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2007-12-20Improved submodule merge supportFinn Arne Gangstad
When merging conflicting submodule changes from a supermodule, generate a conflict message saying what went wrong. Also leave the tree in a state where git status shows the conflict, and git submodule status gives the user enough information to do the merge manally. Previously this would just fail. Signed-off-by: Finn Arne Gangstad <finnag@pvv.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2007-12-11Support a merge with conflicting gitlink changeJunio C Hamano
merge-recursive did not support merging trees that have conflicting changes in submodules they contain, and died. Support it exactly the same way as how it handles conflicting symbolic link changes --- mark it as a conflict, take the tentative result from the current side, and letting the caller resolve the conflict, without dying in merge_file() function. Also reword the error message issued when merge_file() has to die because it sees a tree entry of type it does not support yet. [jc: fixed up initial draft by Finn Arne Gangstad] Signed-off-by: Junio C Hamano <gitster@pobox.com>
2007-11-12Make the diff_options bitfields be an unsigned with explicit masks.Pierre Habouzit
reverse_diff was a bit-value in disguise, it's merged in the flags now. Signed-off-by: Pierre Habouzit <madcoder@debian.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2007-10-29Merge branch 'maint'Junio C Hamano
* maint: RelNotes-1.5.3.5: describe recent fixes merge-recursive.c: mrtree in merge() is not used before set sha1_file.c: avoid gcc signed overflow warnings Fix a small memory leak in builtin-add honor the http.sslVerify option in shell scripts
2007-10-29merge-recursive.c: mrtree in merge() is not used before setJunio C Hamano
The called function merge_trees() sets its *result, to which the address of the variable mrtree in merge() function is passed, only when index_only is set. But that is Ok as the function uses the value in the variable only under index_only iteration. However, recent gcc does not realize this. Work it around by adding a fake initializer. Signed-off-by: Junio C Hamano <gitster@pobox.com>
2007-10-03Merge branch 'ph/strbuf'Junio C Hamano
* ph/strbuf: (44 commits) Make read_patch_file work on a strbuf. strbuf_read_file enhancement, and use it. strbuf change: be sure ->buf is never ever NULL. double free in builtin-update-index.c Clean up stripspace a bit, use strbuf even more. Add strbuf_read_file(). rerere: Fix use of an empty strbuf.buf Small cache_tree_write refactor. Make builtin-rerere use of strbuf nicer and more efficient. Add strbuf_cmp. strbuf_setlen(): do not barf on setting length of an empty buffer to 0 sq_quote_argv and add_to_string rework with strbuf's. Full rework of quote_c_style and write_name_quoted. Rework unquote_c_style to work on a strbuf. strbuf API additions and enhancements. nfv?asprintf are broken without va_copy, workaround them. Fix the expansion pattern of the pseudo-static path buffer. builtin-for-each-ref.c::copy_name() - do not overstep the buffer. builtin-apply.c: fix a tiny leak introduced during xmemdupz() conversion. Use xmemdupz() in many places. ...
2007-09-26Move make_cache_entry() from merge-recursive.c into read-cache.cCarlos Rica
The function make_cache_entry() is too useful to be hidden away in merge-recursive. So move it to libgit.a (exposing it via cache.h). Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2007-09-26Make merge-recursive honor diff.renamelimitLars Hjemli
It might be a sign of source code management gone bad, but when two branches has diverged almost beyond recognition and time has come for the branches to merge, the user is going to need all the help his tool can give him. Honoring diff.renamelimit has great potential as a painkiller in such situations. The painkiller effect could have been achieved by e.g. 'merge.renamelimit', but the flexibility gained by a separate option is questionable: our user would probably expect git to detect renames equally good when merging as when diffing (I known I did). Signed-off-by: Lars Hjemli <hjemli@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2007-09-21nfv?asprintf are broken without va_copy, workaround them.Pierre Habouzit
* drop nfasprintf. * move nfvasprintf into imap-send.c back, and let it work on a 8k buffer, and die() in case of overflow. It should be enough for imap commands, if someone cares about imap-send, he's welcomed to fix it properly. * replace nfvasprintf use in merge-recursive with a copy of the strbuf_addf logic, it's one place, we'll live with it. To ease the change, output_buffer string list is replaced with a strbuf ;) * rework trace.c to call vsnprintf itself. It's used to format strerror()s and git command names, it should never be more than a few octets long, let it work on a 8k static buffer with vsnprintf or die loudly. Signed-off-by: Pierre Habouzit <madcoder@debian.org>
2007-09-19Use xmemdupz() in many places.Pierre Habouzit
Signed-off-by: Pierre Habouzit <madcoder@debian.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2007-09-12Move make_cache_entry() from merge-recursive.c into read-cache.cCarlos Rica
The function make_cache_entry() is too useful to be hidden away in merge-recursive. So move it to libgit.a (exposing it via cache.h). Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2007-08-15Use xmkstemp() instead of mkstemp()Luiz Fernando N. Capitulino
xmkstemp() performs error checking and prints a standard error message when an error occur. Signed-off-by: Luiz Fernando N. Capitulino <lcapitulino@mandriva.com.br> Signed-off-by: Junio C Hamano <gitster@pobox.com>