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

Re: [WIP PATCH] Teach read-tree the -n|--dry-run option

From
Junio C Hamano <gitster@pobox.com>
Date
May 17, 2011, 22:47 UTC
Message-ID
<7vpqnheygi.fsf@alter.siamese.dyndns.org>
In-Reply-To
<4DD2CFD4.7060508@web.de>
Jens Lehmann <Jens.Lehmann@web.de> writes:
Show 9 quoted lines
>> I think the change to the implementation would be trivial, but you would
>> probably want to update the tests in 1002 (remove the one at the end that
>> checks -u/-n incompatibility, and perhaps make sure "-n -u" combination
>> does not touch anything as advertised).
>
> I added two convenience functions read_tree_u_must_[succeed|fail]() which
> work pretty much the way read_tree_must_[succeed|fail]() do but with the
> added functionality that they check git diff-files before and after the
> read-tree -n too.
Sounds sensible.
Show 6 quoted lines
> The only exceptions where I could not make that replacement without
> breaking a test were:
>
> * t1001:381 (#25) new file conflicts with untracked directory
>   This should have been detected by verify_absent_1(), but that function
>   is left early when opts->update is 0. Will look into that.

Thanks. This is the kind of corner case I was worried about when I said "we might have a case where read-tree -m succeeds but read-tree -m -u doesn't". Fixing it would mean that ...

Show 9 quoted lines
> @@ -183,6 +184,8 @@ int cmd_read_tree(int argc, const char **argv, const char *unused_prefix)
>  		die("--exclude-per-directory is meaningless unless -u");
>  	if (opts.merge && !opts.index_only)
>  		setup_work_tree();
> +	if (opts.update && dry_run)
> +		opts.update = 0;
>
>  	if (opts.merge) {
>  		if (stage < 2)
... this hunk must go, right?
Show 15 quoted lines
> diff --git a/t/t1001-read-tree-m-2way.sh b/t/t1001-read-tree-m-2way.sh
> index 680d992..54e69ce 100755
> --- a/t/t1001-read-tree-m-2way.sh
> +++ b/t/t1001-read-tree-m-2way.sh
> @@ -48,6 +48,25 @@ check_cache_at () {
>  	esac
>  }
>
> +read_tree_must_succeed () {
> +...
> +}
> +
> +read_tree_u_must_succeed () {
> +...
> +}

Now at this point wouldn't it make more sense to move these helpers to lib-read-tree.sh or something and .-source it from all nine tests?

Previous: Jens LehmannNext: Jens Lehmann
Message 9 of 12 in “What's cooking in git.git (May 2011, #06; Fri, 13)”
  1. Junio C HamanoMay 13, 2011
  2. Nguyen Thai Ngoc DuyMay 14, 2011
  3. Junio C HamanoMay 14, 2011
  4. Nguyen Thai Ngoc DuyMay 15, 2011
  5. Jens LehmannMay 15, 2011
  6. Junio C HamanoMay 15, 2011
  7. Teach read-tree the -n|--dry-run optionJens Lehmann, May 17, 2011
  8. Jens LehmannMay 17, 2011
  9. Junio C HamanoMay 17, 2011
  10. unpack-trees: add check_worktree flag to enable dry-run functionalityJens Lehmann, May 19, 2011
  11. Junio C HamanoMay 19, 2011
  12. Jens LehmannMay 19, 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.