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

Re: [PATCH 1/5] t7607: use test_commit and test_must_fail

From
Jonathan Nieder <jrnieder@gmail.com>
Date
Oct 10, 2010, 06:35 UTC
Message-ID
<20101010063527.GC23100@burratino>
In-Reply-To
<1286632380-7002-2-git-send-email-drizzd@aon.at>
Clemens Buchacher wrote:
Show 5 quoted lines
> [Subject: t7607: use test_commit and test_must_fail]
>
> Also make sure that aborted merges do not leave
> MERGE_HEAD except in the "will not overwrite
> removed file" test, where we cannot do so.
Motivation?
> See
> also the discussion in the following thread.
>
> http://mid.gmane.org/7vskopwxej.fsf@gitster.siamese.dyndns.org

That subthread is about teaching merge-recursive to write its results to the index first without touching the worktree for robustness. It is not immediately obvious what that has to do with not leaving MERGE_HEAD. Could you summarize the relevant part for the commit message so the reader does not have to track it down?

Show 11 quoted lines
> --- a/t/t7607-merge-overwrite.sh
> +++ b/t/t7607-merge-overwrite.sh
> @@ -7,81 +7,73 @@ Do not overwrite changes.'
>  . ./test-lib.sh
>  
>  test_expect_success 'setup' '
> -	echo c0 > c0.c &&
> -	git add c0.c &&
> -	git commit -m c0 &&
> -	git tag c0 &&
> +	test_commit c0 &&
Behavior changes:
 . filename is c0.t instead of c0.c
 . uses test_tick for timestamp
Sounds good.
Show 5 quoted lines
> -	echo c1 > c1.c &&
> -	git add c1.c &&
> -	git commit -m c1 &&
> -	git tag c1 &&
> +	test_commit c1 &&
Another almost-noop (good).
Show 13 quoted lines
> -	git reset --hard c0 &&
> -	echo c2 > c2.c &&
> -	git add c2.c &&
> -	git commit -m c2 &&
> -	git tag c2 &&
> -	git reset --hard c1 &&
> -	echo "c1 a" > c1.c &&
> -	git add c1.c &&
> -	git commit -m "c1 a" &&
> -	git tag c1a &&
> +	test_commit "c1a" "c1.t" "c1 a" &&
> +	git reset --hard c0 &&
> +	test_commit c2 &&

The reader might not remember the c1.t filename. Maybe it would be good to be explicit in the 'test_commit c1' line:

	test_commit c1 c1.t
?  Or maybe a comment could help?
	# Commit rewriting the file from c1
Show 12 quoted lines
>  	echo "VERY IMPORTANT CHANGES" > important
>  '
>  
>  test_expect_success 'will not overwrite untracked file' '
>  	git reset --hard c1 &&
> -	cat important > c2.c &&
> +	cp important c2.t &&
>  	test_must_fail git merge c2 &&
> -	test_cmp important c2.c
> +	! test -f .git/MERGE_HEAD &&
> +	test_cmp important c2.t
>  '
Nit: if backportability is not important, maybe
	test_path_is_missing .git/MERGE_HEAD &&

for better error messages when running tests with -v and the file is present?

[...]
Show 6 quoted lines
> -	cat important > c2.c &&
> -	git add c2.c &&
> -	rm c2.c &&
> +	cp important c2.t &&
> +	git add c2.t &&
> +	rm c2.t &&

These changes make for a lot of noise. Why not specify the filenames in the setup test to keep the .c extension?

The main change (checking that MERGE_HEAD is not present for a merge that fails due to pre-merge checks) seems good. Thanks.

Previous: Clemens BuchacherNext: Clemens Buchacher
Message 15 of 39 in “git merge, .gitignore, and silently overwriting untracked files”
  1. Joshua JensenAug 17, 2010
  2. Junio C HamanoAug 17, 2010
  3. optionally disable overwriting of ignored filesClemens Buchacher, Aug 18, 2010
  4. Jakub NarebskiAug 19, 2010
  5. Clemens BuchacherAug 20, 2010
  6. Joshua JensenAug 20, 2010
  7. Junio C HamanoAug 20, 2010
  8. Clemens BuchacherAug 21, 2010
  9. Junio C HamanoAug 22, 2010
  10. Clemens BuchacherAug 22, 2010
  11. Kevin BallardOct 9, 2010
  12. Clemens BuchacherAug 21, 2010
  13. 0/5 do not overwrite untracked files in leading pathClemens Buchacher, Oct 9, 2010
  14. 1/5 t7607: use test_commit and test_must_failClemens Buchacher, Oct 9, 2010
  15. Jonathan NiederOct 10, 2010
  16. 1/5 t7607: use test-lib functions and check MERGE_HEADClemens Buchacher, Oct 10, 2010
  17. Junio C HamanoOct 13, 2010
  18. Junio C HamanoOct 13, 2010
  19. 2/5 t7607: add leading-path testsClemens Buchacher, Oct 9, 2010
  20. Johannes SixtOct 9, 2010
  21. 2/5 t7607: add leading-path testsClemens Buchacher, Oct 10, 2010
  22. 3/5 add function check_ok_to_remove()Clemens Buchacher, Oct 9, 2010
  23. Junio C HamanoOct 13, 2010
  24. 4/5 lstat_cache: optionally return match_lenClemens Buchacher, Oct 9, 2010
  25. 5/5 do not overwrite files in leading pathClemens Buchacher, Oct 9, 2010
  26. Junio C HamanoOct 13, 2010
  27. Clemens BuchacherOct 13, 2010
  28. Clemens BuchacherOct 15, 2010
  29. Junio C HamanoOct 15, 2010
  30. Junio C HamanoAug 20, 2010
  31. optionally disable overwriting of ignored filesClemens Buchacher, Aug 21, 2010
  32. Matthieu MoyAug 23, 2010
  33. Heiko VoigtAug 31, 2010
  34. Matthieu MoyAug 23, 2010
  35. Holger HellmuthAug 23, 2010
  36. Clemens BuchacherAug 23, 2010
  37. Junio C HamanoAug 23, 2010
  38. Clemens BuchacherAug 24, 2010
  39. Junio C HamanoAug 24, 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.