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

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

From
Junio C Hamano <gitster@pobox.com>
Date
May 6, 2011, 22:49 UTC
Message-ID
<7vhb97xx5g.fsf@alter.siamese.dyndns.org>
In-Reply-To
<4DC47242.6060205@web.de>
Jens Lehmann <Jens.Lehmann@web.de> writes:
> This option can be used to determine if checking out a branch or commit
> would touch files which are modified in the work tree. It doesn't change
> the work tree contents or the index, so it can only tell if the checkout
> would succeed using trivial merges.

I hated this patch when I saw it the first time. I thought you were joking and let it pass. But now you brought it again, I hate it even more now.

I do not see a merit in contaminating the checkout Porcelain with a half baked [*1*] "dry-run" code, when your ultimate motive to use it in submodule script and exercise only a small portion of checkout codepaths. You are only interested in branch switching, and not other things the Porcelain can do, like checking out a path out of the index or a tree, or re-checking out a conflicted path out of the index.

In other words, can't the check you need in submodule be scripted around the specific plumbing responsible for the branch switching, which is:

    $ git read-tree -m HEAD $other_branch
Show 9 quoted lines
> @@ -397,7 +400,7 @@ static int merge_working_tree(struct checkout_opts *opts,
>
>  		/* 2-way merge to the new branch */
>  		topts.initial_checkout = is_cache_unborn();
> -		topts.update = 1;
> +		topts.update = !opts->dry_run;
>  		topts.merge = 1;
>  		topts.gently = opts->merge && old->commit;
>  		topts.verbose_update = !opts->quiet;

What you are doing in this part of your patch is exactly that two-tree form of the "read-tree -m", no?

[Footnote]

*1* Look at how many places you say "are incompatible" when you really mean "I didn't bother to think deeply enough about implementing this combination".

Previous: Jens LehmannNext: Junio C Hamano
Message 2 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.