1
0
Fork 0
mirror of https://github.com/git/git.git synced 2024-11-07 17:53:12 +01:00
Commit graph

23342 commits

Author SHA1 Message Date
Elijah Newren
ef02b31721 merge-recursive: Make room for directories in D/F conflicts
When there are unmerged entries present, make sure to check for D/F
conflicts first and remove any files present in HEAD that would be in the
way of creating files below the correspondingly named directory.  Such
files will be processed again at the end of the merge in
process_df_entry(); at that time we will be able to tell if we need to
and can reinstate the file, whether we need to place its contents in a
different file due to the directory still being present, etc.

Signed-off-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-09-29 17:37:05 -07:00
Elijah Newren
84a08a47b9 handle_delete_modify(): Check whether D/F conflicts are still present
If all the paths below some directory involved in a D/F conflict were not
removed during the rest of the merge, then the contents of the file whose
path conflicted needs to be recorded in file with an alternative filename.

Signed-off-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-09-29 17:37:05 -07:00
Elijah Newren
4ab9a157d0 merge_content(): Check whether D/F conflicts are still present
If all the paths below some directory involved in a D/F conflict were not
removed during the rest of the merge, then the contents of the file whose
path conflicted needs to be recorded in file with an alternative filename.

Signed-off-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-09-29 17:37:05 -07:00
Elijah Newren
2adc7dcc11 conflict_rename_rename_1to2(): Fix checks for presence of D/F conflicts
This function is called from process_df_entry(), near the end of the merge.
Rather than just checking whether one of the sides of the merge had a
directory at the same path as one of our files, check whether that
directory is still present by this point of our merge.

Signed-off-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-09-29 17:37:05 -07:00
Elijah Newren
a0de2f6bd3 conflict_rename_delete(): Check whether D/F conflicts are still present
If all the paths below some directory involved in a D/F conflict were not
removed during the rest of the merge, then the contents of the file whose
path conflicted needs to be recorded in file with an alternative filename.

Signed-off-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-09-29 17:37:04 -07:00
Elijah Newren
71f7ffcc02 merge-recursive: Delay modify/delete conflicts if D/F conflict present
When handling merges with modify/delete conflicts, if the modified path is
involved in a D/F conflict, handle the issue in process_df_entry() rather
than process_entry().

Signed-off-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-09-29 17:37:04 -07:00
Elijah Newren
882fd11aff merge-recursive: Delay content merging for renames
Move the handling of content merging for renames from process_renames() to
process_df_entry().

Signed-off-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-09-29 17:37:04 -07:00
Elijah Newren
3b130adf9c merge-recursive: Delay handling of rename/delete conflicts
Move the handling of rename/delete conflicts from process_renames() to
process_df_entry().

Signed-off-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-09-29 17:37:04 -07:00
Elijah Newren
161cf7f949 merge-recursive: Move handling of double rename of one file to other file
Move the handling of rename/rename conflicts where one file is renamed on
both sides to the same file, from process_renames() to process_entry().
Here we avoid the three way merge logic by just using
update_stages_and_entry() to move the higher stage entries in the index
from the rename source to the rename destination, and then allow
process_entry() to do its magic.

Signed-off-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-09-29 17:37:04 -07:00
Elijah Newren
07413c5a31 merge-recursive: Move handling of double rename of one file to two
Move the handling of rename/rename conflicts where one file is renamed to
two different files, from process_renames() to process_df_entry().

Signed-off-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-09-29 17:37:04 -07:00
Elijah Newren
2a669c341a merge-recursive: Avoid doubly merging rename/add conflict contents
When a commit moves A to B while another commit created B (or moved C to
B), and these two different commits serve as different merge-bases for a
later merge, c94736a (merge-recursive: don't segfault while handling
rename clashes 2009-07-30) added some special code to avoid segfaults.
Since that commit, the two versions of B are merged in place (which could
be potentially conflicting) and the intermediate result is used as the
virtual ancestor.

However, right before this special merge, try_merge was turned on, meaning
that process_renames() would try an alternative merge that ignores the
'add' part of the conflict, and, if the merge is clean, store that as the
new virtual ancestor.  This could cause incorrect merging of criss-cross
merges; it would typically result in just recording a slightly confusing
merge base, but in some cases it could cause silent acceptance of one side
of a merge as the final resolution when a conflict should have been
flagged.

When we do a special merge for such a rename/add conflict between
merge-bases, turn try_merge off to avoid an inappropriate second merge.

Signed-off-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-09-29 17:37:04 -07:00
Elijah Newren
61b8bcae2d merge-recursive: Update merge_content() call signature
Enable calling merge_content() and providing more information about renames
and D/F conflicts (which we will want to do from process_df_entry()).

Signed-off-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-09-29 17:37:03 -07:00
Elijah Newren
36de17048a merge-recursive: Update conflict_rename_rename_1to2() call signature
To facilitate having this function called later using information stored
in a rename_df_conflict_info struct, accept a diff_filepair instead of a
rename.

Signed-off-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-09-29 17:37:03 -07:00
Elijah Newren
9c0bbb50f0 merge-recursive: Structure process_df_entry() to handle more cases
Modify process_df_entry() (mostly just indentation level changes) to
get it ready for handling more D/F conflict type cases.

Signed-off-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-09-29 17:37:03 -07:00
Elijah Newren
384c166807 merge-recursive: Have process_entry() skip D/F or rename entries
If an entry has an associated rename_df_conflict_info, skip it and allow
it to be processed by process_df_entry().

Signed-off-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-09-29 17:37:03 -07:00
Elijah Newren
2ff739f9d2 merge-recursive: New function to assist resolving renames in-core only
process_renames() and process_entry() have nearly identical code for
doing three-way file merging to resolve content changes.  Since we are
already deferring some of the current rename handling in order to better
handle D/F conflicts, it seems to make sense to defer content merging as
well and remove the (nearly) duplicated code sections for handling this
merging.

To facilitate this process, add a new update_stages_and_entry() function
which will map the higher stage index entries from two files involved in a
rename into the resulting rename destination's index entries, and update
the associated stage_data structure.

Signed-off-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-09-29 17:37:03 -07:00
Elijah Newren
25c3936349 merge-recursive: New data structures for deferring of D/F conflicts
Since we need to resolve paths (including renames) in-core first and defer
checking of D/F conflicts (namely waiting to see if directories are still
in the way after all paths are resolved) before updating files involved in
D/F conflicts, we will need to first process_renames, then record some
information about the rename needed at D/F resolution time, and then make
use of that information when resolving D/F conflicts at the end.

This commit adds some relevant data structures for storing the necessary
information.

Signed-off-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-09-29 17:32:38 -07:00
Elijah Newren
0c4918d1c1 merge-recursive: Move process_entry's content merging into a function
This move is in preparation for merge_content growing and being called from
multiple places in order to handle D/F conflicts.

I also snuck in a small change to the output in the case that the merged
content for the file matches the current file contents, to make it better
match (and thus more able to take over) how other merge_file() calls in
process_renames() are handled.

Signed-off-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-09-29 17:32:38 -07:00
Elijah Newren
5e3ce663b0 merge-recursive: Move delete/modify handling into dedicated function
This move is in preparation for the function being called from multiple
places in order to handle D/F conflicts.

Signed-off-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-09-29 17:32:38 -07:00
Elijah Newren
6ef2cb008f merge-recursive: Move rename/delete handling into dedicated function
This move is in preparation for the function growing and being called from
multiple places in order to handle D/F conflicts.

Signed-off-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-09-29 17:32:38 -07:00
Elijah Newren
605c1bcfc4 merge-recursive: Nuke rename/directory conflict detection
Since we want to resolve merges in-core and then detect at the end whether
D/F conflicts remain in the way, we should just apply renames in-core and
let logic elsewhere check for D/F conflicts.

Signed-off-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-09-29 17:32:38 -07:00
Elijah Newren
09c01f856f merge-recursive: Rename conflict_rename_rename*() for clarity
The names conflict_rename_rename and conflict_rename_rename_2 did not make
it clear what they were handling.  Since the first of these handles one
file being renamed in both branches to different files, while the latter
handles two different files being renamed to the same thing, add a little
'1to2' and '2to1' suffix on these and an explanatory comment to make their
intent clearer.

Signed-off-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-09-29 17:32:37 -07:00
Elijah Newren
41d70bd6a9 merge-recursive: Small code clarification -- variable name and comments
process_renames() had a variable named "stage" and derived variables
src_other and dst_other whose purpose was not immediately obvious; also,
I want to extend the scope of this variable and use it later, so it should
have a more descriptive name.  Do so, and add a brief comment explaining
how it is used and what it relates to.

Signed-off-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-09-29 17:32:37 -07:00
Elijah Newren
f63622c0a9 t6036: Add testcase for undetected conflict
If merging two lines of development involves a rename/add conflict, and two
different people make such a merge but resolve it differently, and then
someone tries to merge the resulting two merges, then they should clearly
get a conflict due to the different resolutions from the previous
developers.  However, in some such cases the conflict would not be detected
and git would silently accept one of the two versions being merged as the
final merge resolution.

Signed-off-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-09-29 17:32:37 -07:00
Elijah Newren
583942df09 t6036: Add a second testcase similar to the first but with content changes
c94736a (merge-recursive: don't segfault while handling rename clashes
2009-07-30) added t6036 with a testcase that involved dual renames and a
criss-cross merge.  Add a test that is nearly identical, but which also
involves content modification -- a case git currently does not merge
correctly.

Signed-off-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-09-29 17:32:37 -07:00
Elijah Newren
c976260d0f t6036: Test index and worktree state, not just that merge fails
c94736a (merge-recursive: don't segfault while handling rename clashes
2009-07-30) added this testcase with an interesting corner case test,
which previously had cased git to segfault.  This test ensures that the
segfault does not return and that the merge correctly fails; just add
some checks that verify the state of the index and worktree after the merge
are correct.

Signed-off-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-09-29 17:32:37 -07:00
Elijah Newren
fa0ae3b1dd t6020: Add a testcase for modify/delete + directory/file conflict
Signed-off-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-09-29 17:32:37 -07:00
Elijah Newren
d09c0a3935 t6020: Modernize style a bit
Signed-off-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-09-29 17:32:37 -07:00
Elijah Newren
707983484b t6022: Add tests for rename/rename combined with D/F conflicts
Add tests where one file is renamed to two different paths in different
sides of history, and where each of the new files matches the name of a
directory from the opposite side of history.  Include tests for both the
case where the merge results in those directories not being cleanly
removed, and where those directories are cleanly removed during the merge.

Signed-off-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-09-29 17:32:36 -07:00
Elijah Newren
52304ecddf t6022: Add paired rename+D/F conflict: (two/file, one/file) -> (one, two)
An interesting testcase is having two files each in their own subdirectory
getting renamed to the toplevel at the directory pathname of the other.
Questions arise as to whether the order of operations matters and whether
the directories can correctly get out of the way and make room for the
new files.

Signed-off-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-09-29 17:32:36 -07:00
Elijah Newren
588504b694 t6022: Add tests with both rename source & dest involved in D/F conflicts
Having the source of a rename be involved in a directory/file conflict does
not currently pose any difficulties to the current merge-recursive
algorithm (in contrast to destinations of renames and D/F conflicts).
However, combining the two seemed like good testcases to include for
completeness.

Signed-off-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-09-29 17:32:36 -07:00
Elijah Newren
3398f2f583 t6022: Add tests for reversing order of merges when D/F conflicts present
When merging two branches with some path involved in a D/F conflict, the
choice of which branch to merge into the other matters for (at least) two
reasons: (1) whether the working copy has a directory full of files that
is in the way of a file, or a file exists that is in the way of a
directory of files, (2) when the directory full of files does not disappear
due to the merge, what files at the same paths should be renamed to
(e.g. filename~HEAD vs. filename~otherbranch).

Add some tests that reverse the merge order of two other tests, and which
verify the contents are as expected (namely, that the results are identical
other than modified-for-uniqueness filenames involving branch names).

Signed-off-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-09-29 17:32:36 -07:00
Elijah Newren
af6e175199 t6022: Add test combinations of {content conflict?, D/F conflict remains?}
Add testing of the various ways that a renamed file to a path involved in
a directory/file conflict may be involved in.  This includes whether or not
there are conflicts of the contents of the renamed file (if the file was
modified on both sides of history), and whether the directory from the
other side of the merge will disappear as a result of the merge or not.

Signed-off-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-09-29 17:32:36 -07:00
Elijah Newren
df0b99f004 t6032: Add a test checking for excessive output from merge
Previous D/F fixes I submitted (5a2580d and ae74548) had caused merge to
become excessively spammy, which was fixed in 96ecac6 (merge-recursive:
Avoid excessive output for and reprocessing of renames 2010-08-20).  Add a
new test to avoid repeating that mistake with my several upcoming changes.

Signed-off-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-09-29 17:32:36 -07:00
Junio C Hamano
7edba4c45c merge-recursive: Restructure showing how to chain more process_* functions
In 3734893 (merge-recursive: Fix D/F conflicts 2010-07-09),
process_df_entry() was added to process_renames() and process_entry() but
in a somewhat restrictive manner.  Modify the code slightly to make it
clearer how we could chain more such functions if necessary, and alter
process_df_entry() to handle such chaining.

Signed-off-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-09-29 17:32:36 -07:00
Schalk, Ken
8a1c0d322e t3030: Add a testcase for resolvable rename/add conflict with symlinks
d5af510 (RE: [PATCH] Avoid rename/add conflict when contents are identical
2010-09-01) avoided erroring out in a rename/add conflict when the contents
were identical.  A simpler fix could have handled that particular testcase,
but it would not correctly handle the case where a symlink is involved.
Add another testcase using symlinks, to avoid breaking that case.

Signed-off-by: Ken Schalk <ken.schalk@intel.com>
Signed-off-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-09-29 17:32:35 -07:00
Junio C Hamano
a1155adc2d Merge branch 'en/rename-d-f' into en/merge-recursive
* en/rename-d-f:
  merge-recursive: D/F conflicts where was_a_dir/file -> was_a_dir
  t3509: Add rename + D/F conflict testcase that recursive strategy fails
2010-09-29 17:25:28 -07:00
Junio C Hamano
87b50542a0 Git 1.7.3
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-09-18 14:55:08 -07:00
Junio C Hamano
1125297ca1 Merge branch 'js/ls-files-x-doc'
* js/ls-files-x-doc:
  ls-files documentation: reword for consistency
  git-ls-files.txt: clarify -x/--exclude option

Conflicts:
	Documentation/git-ls-files.txt
2010-09-18 14:46:44 -07:00
Chris Johnsen
14d872987a git-rebase--interactive.sh: replace cut with ${v%% *}
Some versions of cut do not cope well with lines that do not end in
an LF. In this case, we can completely avoid cut by using the
${var%% *} parameter expansion (suggested by Brandon Casey).

I found this problem when t3404's "avoid unnecessary reset" failed
due to the "rebase -i" not avoiding updating the tested timestamp.

On a Mac OS X 10.4.11 system:

    % printf '%s' 'foo bar' | /usr/bin/cut -d ' ' -f 1
    cut: stdin: Illegal byte sequence

Signed-off-by: Chris Johnsen <chris_johnsen@pobox.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-09-17 14:58:08 -07:00
Brandon Casey
84d694027f t/t7300: workaround ancient touch by rearranging arguments
The ancient touch on Solaris 7 thinks that a decimal number supplied as
the first argument specifies a date_time to give to the files specified by
the remaining arguments.  In this case, it fails to parse '1' as a proper
date_time and exits with a failure status.  Workaround this flaw by
rearranging the arguments supplied to touch so that a non-digit appears
first and touch will not be confused.

Signed-off-by: Brandon Casey <casey@nrlssc.navy.mil>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-09-17 14:42:13 -07:00
Junio C Hamano
02567e88ee Merge branch 'bg/fix-t7003'
* bg/fix-t7003:
  t7003: Use test_commit instead of custom function
2010-09-16 07:43:41 -07:00
Junio C Hamano
4c608520ed ls-files documentation: reword for consistency
Similar to descriptions of other options, state what -x does in imperative
mood.  Start sentences for -X and --exclude-per-directory options in
capital letters.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-09-15 17:38:50 -07:00
Jay Soffian
75609a0d44 git-ls-files.txt: clarify -x/--exclude option
Since b5227d8, -x/--exclude does not apply to cached files.
This is easy to miss unless you read the discussion in the
EXCLUDE PATTERNS section. Clarify that the option applies
to untracked files and direct the reader to EXCLUDE PATTERNS.

Signed-off-by: Jay Soffian <jaysoffian@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-09-15 17:30:36 -07:00
Junio C Hamano
7e100effc6 Git 1.7.3 rc2 2010-09-15 12:47:37 -07:00
Junio C Hamano
2e1e96126f Merge branch 'dr/maint-ls-tree-prefix-recursion-fix'
* dr/maint-ls-tree-prefix-recursion-fix:
  ls-tree $di $dir: do not mistakenly recurse into directories
2010-09-15 12:41:13 -07:00
Junio C Hamano
0c61c6de34 Merge branch 'os/fix-rebase-diff-no-prefix'
* os/fix-rebase-diff-no-prefix:
  Add --src/dst-prefix to git-formt-patch in git-rebase.sh
2010-09-15 12:40:33 -07:00
Junio C Hamano
e3f213c7af Merge branch 'jl/fix-test'
* jl/fix-test:
  t1020: Get rid of 'cd "$HERE"' at the start of each test
  t2016 (checkout -p): add missing &&
  t1302 (core.repositoryversion): style tweaks
  t2105 (gitfile): add missing &&
  t1450 (fsck): remove dangling objects
  tests: subshell indentation stylefix
  Several tests: cd inside subshell instead of around
2010-09-15 12:40:12 -07:00
Junio C Hamano
43d268e9dd Merge branch 'ch/filter-branch-deprecate-remap-to-ancestor'
* ch/filter-branch-deprecate-remap-to-ancestor:
  filter-branch: retire --remap-to-ancestor
2010-09-15 12:39:32 -07:00
Junio C Hamano
d42cb5804f Merge branch 'ch/maint-cannot-create-bundle-error'
* ch/maint-cannot-create-bundle-error:
  bundle: detect if bundle file cannot be created
2010-09-15 12:39:22 -07:00