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

Re: [PATCH v6 3/4] reset: add a few tests for "git reset --merge"

From
Junio C Hamano <gitster@pobox.com>
Date
Jan 1, 2010, 05:15 UTC
Message-ID
<7v7hs2o16j.fsf@alter.siamese.dyndns.org>
In-Reply-To
<20091230055448.4475.42383.chriscool@tuxfamily.org>
Christian Couder <chriscool@tuxfamily.org> writes:
Show 11 quoted lines
> Commit 9e8eceab ("Add 'merge' mode to 'git reset'", 2008-12-01),
> added the --merge option to git reset, but there were no test cases
> for it.
>
> This was not a big problem because "git reset" was just forking and
> execing "git read-tree", but this will change in a following patch.
>
> So let's add a few test cases to make sure that there will be no
> regression.
>
> Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
Looks good.
Show 30 quoted lines
> +# The next test will test the following:
> +#
> +#           working index HEAD target         working index HEAD
> +#           ----------------------------------------------------
> +# file1:     C       C     C    D     --merge  D       D     D
> +# file2:     C       D     D    D     --merge  C       D     D
> +test_expect_success 'reset --merge is ok with changes in file it does not touch' '
> +    git reset --merge HEAD^ &&
> +    ! grep 4 file1 &&
> +    grep 4 file2 &&
> +    test "$(git rev-parse HEAD)" = "$(git rev-parse initial)" &&
> +    test -z "$(git diff --cached)"
> +'
> ...
> +# The next test will test the following:
> +#
> +#           working index HEAD target         working index HEAD
> +#           ----------------------------------------------------
> +# file1:     C       C     C    D     --merge  D       D     D
> +# file2:     C       C     D    D     --merge  D       D     D
> +test_expect_success 'reset --merge discards changes added to index (2)' '
> +    git reset --hard second &&
> +    echo "line 4" >> file2 &&
> +    git add file2 &&
> +    git reset --merge HEAD^ &&
> +    ! grep 4 file2 &&
> +    test "$(git rev-parse HEAD)" = "$(git rev-parse initial)" &&
> +    test -z "$(git diff)" &&
> +    test -z "$(git diff --cached)"
> +'
These two seem to duplicate the same case for file1; is it necessary?

I am not pointing it out as something that needs to be removed; I am just puzzled and wondering if there is some interaction between the ways two paths are handled and the test is trying to check that (which I do not think is the case).

Previous: Christian CouderNext: Christian Couder
Message 7 of 14 in “"git reset --merge" related improvements”
  1. 0/4 "git reset --merge" related improvementsChristian Couder, Dec 30, 2009
  2. 1/4 reset: improve mixed reset error message when in a bare repoChristian Couder, Dec 30, 2009
  3. 2/4 Documentation: reset: add some tables to describe the different optionsChristian Couder, Dec 30, 2009
  4. Junio C HamanoJan 1, 2010
  5. Christian CouderJan 2, 2010
  6. 3/4 reset: add a few tests for "git reset --merge"Christian Couder, Dec 30, 2009
  7. Junio C HamanoJan 1, 2010
  8. Christian CouderJan 2, 2010
  9. 4/4 reset: use "unpack_trees()" directly instead of "git read-tree"Christian Couder, Dec 30, 2009
  10. Junio C HamanoJan 1, 2010
  11. Junio C HamanoJan 1, 2010
  12. Christian CouderJan 2, 2010
  13. Linus TorvaldsJan 1, 2010
  14. Junio C HamanoJan 1, 2010

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.