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

Re: [PATCH] Teach checkout the -n|--dry-run option

From
Jens Lehmann <jens.lehmann@web.de>
Date
May 8, 2011, 21:41 UTC
Message-ID
<4DC70E1A.6060702@web.de>
In-Reply-To
<7vwri0ric1.fsf@alter.siamese.dyndns.org>
Am 08.05.2011 23:30, schrieb Junio C Hamano:
Show 26 quoted lines
> Jens Lehmann <Jens.Lehmann@web.de> writes:
> 
>> diff --git a/t/t1000-read-tree-m-3way.sh b/t/t1000-read-tree-m-3way.sh
>> index ca8a409..bcfb5e6 100755
>> --- a/t/t1000-read-tree-m-3way.sh
>> +++ b/t/t1000-read-tree-m-3way.sh
>> @@ -259,6 +259,8 @@ test_expect_success \
>>      "rm -f .git/index AA &&
>>       cp .orig-A/AA AA &&
>>       git update-index --add AA &&
>> +     git read-tree -n -m $tree_O $tree_A $tree_B &&
>> +     test_must_fail check_result &&
> 
> That's a rather sloppy way to test that the command did not do anything to
> compare one possible outcome, instead of verifying that the result is
> identical to the original condition, no?
> 
> How about
> 
> 	...
> 	git update_index --add AA &&
>         git ls-files -s >pre-dry-run &&
>         git read-tree -n -m $tree_O $tree_A $tree_B &&
>         git ls-files -s >post-dry-run &&
>         test_cmp pre-dry-run post-dry-run &&
>         ...
Yeah, that is much better than my first sketch.
Show 38 quoted lines
> We also should be checking that the command reports it is going to fail
> when it should as well.  Always remember to check both sides of the coin.
> 
>>       git read-tree -m $tree_O $tree_A $tree_B &&
>>       check_result"
> 
> I suspect that it would make sense to replace
> 
> 	git read-tree $args && check_result
> 
> with
>         
> 	read_tree_must_succeed $args
> 
> and
> 
> 	test_must_fail git read-tree $args
> 
> with
> 
> 	read_tree_must_fail $args
> 
> and implement two shell wrappers, perhaps like this.
> 
> read_tree_must_succeed () {
> 	git ls-files -s >pre-dry-run &&
> 	git read-tree -n "$@" &&
>         git ls-files -s >post-dry-run &&
>         test_cmp pre-dry-run post-dry-run &&
>         git read-tree "$@"
> }
> 
> read_tree_must_fail () {
> 	git ls-files -s >pre-dry-run &&
> 	test_must_fail git read-tree -n "$@" &&
>         git ls-files -s >post-dry-run &&
> 	test_must_fail git read-tree "$@"
> }
Thanks, will send an updated patch with better test cases soon ...
Previous: Junio C HamanoNext: Jens Lehmann
Message 7 of 9 in “Teach checkout the -n|--dry-run option”
  1. Teach checkout the -n|--dry-run optionJens Lehmann, May 6, 2011
  2. Junio C HamanoMay 6, 2011
  3. Junio C HamanoMay 7, 2011
  4. Jens LehmannMay 8, 2011
  5. Jens LehmannMay 8, 2011
  6. Junio C HamanoMay 8, 2011
  7. Jens LehmannMay 8, 2011
  8. Teach read-tree the -n|--dry-run optionJens Lehmann, May 11, 2011
  9. Junio C HamanoMay 11, 2011

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.