git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH 07/11] t6428: new test for SKIP_WORKTREE handling and conflicts

From
Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Date
Mar 8, 2021, 13:03 UTC
Message-ID
<874khlkdb0.fsf@evledraar.gmail.com>
In-Reply-To
<6ccb24b557fc9c9d8e3d307d3e142d8393920414.1614905738.git.gitgitgadget@gmail.com>
On Fri, Mar 05 2021, Elijah Newren via GitGitGadget wrote:
Show 61 quoted lines
> From: Elijah Newren <newren@gmail.com>
>
> If there is a conflict during a merge for a SKIP_WORKTREE entry, we
> expect that file to be written to the working copy and have the
> SKIP_WORKTREE bit cleared in the index.  If the user had manually
> created a file in the working tree despite SKIP_WORKTREE being set, we
> do not want to clobber their changes to that file, but want to move it
> out of the way.  Add tests that check for these behaviors.
>
> Signed-off-by: Elijah Newren <newren@gmail.com>
> ---
>  t/t6428-merge-conflicts-sparse.sh | 158 ++++++++++++++++++++++++++++++
>  1 file changed, 158 insertions(+)
>  create mode 100755 t/t6428-merge-conflicts-sparse.sh
>
> diff --git a/t/t6428-merge-conflicts-sparse.sh b/t/t6428-merge-conflicts-sparse.sh
> new file mode 100755
> index 000000000000..1bb52ff6f38c
> --- /dev/null
> +++ b/t/t6428-merge-conflicts-sparse.sh
> @@ -0,0 +1,158 @@
> +#!/bin/sh
> +
> +test_description="merge cases"
> +
> +# The setup for all of them, pictorially, is:
> +#
> +#      A
> +#      o
> +#     / \
> +#  O o   ?
> +#     \ /
> +#      o
> +#      B
> +#
> +# To help make it easier to follow the flow of tests, they have been
> +# divided into sections and each test will start with a quick explanation
> +# of what commits O, A, and B contain.
> +#
> +# Notation:
> +#    z/{b,c}   means  files z/b and z/c both exist
> +#    x/d_1     means  file x/d exists with content d1.  (Purpose of the
> +#                     underscore notation is to differentiate different
> +#                     files that might be renamed into each other's paths.)
> +
> +. ./test-lib.sh
> +. "$TEST_DIRECTORY"/lib-merge.sh
> +
> +
> +# Testcase basic, conflicting changes in 'numerals'
> +
> +test_setup_numerals () {
> +	test_create_repo numerals_$1 &&
> +	(
> +		cd numerals_$1 &&
> +
> +		>README &&
> +		test_write_lines I II III >numerals &&
> +		git add README numerals &&
> +		test_tick &&
> +		git commit -m "O" &&

As an aside this could use the --printf option to test_commit I've got in next, but that's also a bit painful to use since you can't use test_write_lines.

I've wanted to just support something like this for this use-case of using an existing file:

    test_write_lines A B C D >lines &&
    test_commit --add O lines &&
Show 40 quoted lines
> +
> +		git branch O &&
> +		git branch A &&
> +		git branch B &&
> +
> +		git checkout A &&
> +		test_write_lines I II III IIII >numerals &&
> +		git add numerals &&
> +		test_tick &&
> +		git commit -m "A" &&
> +
> +		git checkout B &&
> +		test_write_lines I II III IV >numerals &&
> +		git add numerals &&
> +		test_tick &&
> +		git commit -m "B" &&
> +
> +		cat <<-EOF >expected-index &&
> +		H README
> +		M numerals
> +		M numerals
> +		M numerals
> +		EOF
> +
> +		cat <<-EOF >expected-merge
> +		I
> +		II
> +		III
> +		<<<<<<< HEAD
> +		IIII
> +		=======
> +		IV
> +		>>>>>>> B^0
> +		EOF
> +
> +	)
> +}
> +
> +test_expect_merge_algorithm success failure 'conflicting entries written to worktree even if sparse' '
> +	test_setup_numerals plain &&

A small nit, but makes it easier to debug things: I think having what you have in "test_setup_numerals" above in a test_expect_success is a better pattern, then if it fails we can see where exactly.

Then instead of calling "test_setup_numerals" here you'd do:
    cp -R template plain &&

To just copy over that existing setup template, or re-use it and have have the tests call a small helper to "test_when_finish" reset --hard back as appropriate.

Previous: Elijah Newren via GitGitGadgetNext: Elijah Newren
Message 13 of 44 in “Complete merge-ort implementation...almost”
  1. 00/11 Complete merge-ort implementation...almostElijah Newren via GitGitGadget, Mar 5, 2021
  2. 01/11 merge-ort: use STABLE_QSORT instead of QSORT where requiredElijah Newren via GitGitGadget, Mar 5, 2021
  3. 02/11 merge-ort: add a special minimal index just for renormalizationElijah Newren via GitGitGadget, Mar 5, 2021
  4. 03/11 merge-ort: add a function for initializing our special attr_indexElijah Newren via GitGitGadget, Mar 5, 2021
  5. Ævar Arnfjörð BjarmasonMar 8, 2021
  6. 04/11 merge-ort: have ll_merge() calls use the attr_index for renormalizationElijah Newren via GitGitGadget, Mar 5, 2021
  7. Ævar Arnfjörð BjarmasonMar 8, 2021
  8. Elijah NewrenMar 9, 2021
  9. 05/11 merge-ort: let renormalization change modify/delete into clean deleteElijah Newren via GitGitGadget, Mar 5, 2021
  10. Ævar Arnfjörð BjarmasonMar 8, 2021
  11. 06/11 merge-ort: support subtree shiftingElijah Newren via GitGitGadget, Mar 5, 2021
  12. 07/11 t6428: new test for SKIP_WORKTREE handling and conflictsElijah Newren via GitGitGadget, Mar 5, 2021
  13. Ævar Arnfjörð BjarmasonMar 8, 2021
  14. Elijah NewrenMar 8, 2021
  15. 08/11 merge-ort: implement CE_SKIP_WORKTREE handling with conflicted entriesElijah Newren via GitGitGadget, Mar 5, 2021
  16. Ævar Arnfjörð BjarmasonMar 8, 2021
  17. Elijah NewrenMar 8, 2021
  18. 09/11 t: mark several submodule merging tests as fixed under merge-ortElijah Newren via GitGitGadget, Mar 5, 2021
  19. Ævar Arnfjörð BjarmasonMar 8, 2021
  20. 10/11 merge-ort: write $GIT_DIR/AUTO_MERGE whenever we hit a conflictElijah Newren via GitGitGadget, Mar 5, 2021
  21. Ævar Arnfjörð BjarmasonMar 8, 2021
  22. Elijah NewrenMar 8, 2021
  23. 11/11 merge-recursive: add a bunch of FIXME comments documenting known bugsElijah Newren via GitGitGadget, Mar 5, 2021
  24. Ævar Arnfjörð BjarmasonMar 8, 2021
  25. Ævar Arnfjörð BjarmasonMar 8, 2021
  26. Elijah NewrenMar 8, 2021
  27. 00/10 Complete merge-ort implementation...almostElijah Newren via GitGitGadget, Mar 9, 2021
  28. 01/10 merge-ort: use STABLE_QSORT instead of QSORT where requiredElijah Newren via GitGitGadget, Mar 9, 2021
  29. 02/10 merge-ort: add a special minimal index just for renormalizationElijah Newren via GitGitGadget, Mar 9, 2021
  30. Derrick StoleeMar 11, 2021
  31. 05/10 merge-ort: support subtree shiftingElijah Newren via GitGitGadget, Mar 9, 2021
  32. 04/10 merge-ort: let renormalization change modify/delete into clean deleteElijah Newren via GitGitGadget, Mar 9, 2021
  33. 06/10 t6428: new test for SKIP_WORKTREE handling and conflictsElijah Newren via GitGitGadget, Mar 9, 2021
  34. Derrick StoleeMar 11, 2021
  35. 03/10 merge-ort: have ll_merge() use a special attr_index for renormalizationElijah Newren via GitGitGadget, Mar 9, 2021
  36. Derrick StoleeMar 11, 2021
  37. 07/10 merge-ort: implement CE_SKIP_WORKTREE handling with conflicted entriesElijah Newren via GitGitGadget, Mar 9, 2021
  38. 09/10 merge-ort: write $GIT_DIR/AUTO_MERGE whenever we hit a conflictElijah Newren via GitGitGadget, Mar 9, 2021
  39. 08/10 t: mark several submodule merging tests as fixed under merge-ortElijah Newren via GitGitGadget, Mar 9, 2021
  40. Derrick StoleeMar 11, 2021
  41. 10/10 merge-recursive: add a bunch of FIXME comments documenting known bugsElijah Newren via GitGitGadget, Mar 9, 2021
  42. Derrick StoleeMar 11, 2021
  43. Elijah NewrenMar 11, 2021
  44. Elijah NewrenMar 17, 2021

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.