Re: [RFC PATCH] unpack-trees: add check_worktree flag to enable dry-run functionality
- From
Jens Lehmann <jens.lehmann@web.de>
- Date
- May 19, 2011, 18:21 UTC
- Message-ID
- <4DD55FC0.4000505@web.de>
- In-Reply-To
- <7vei3u7e25.fsf@alter.siamese.dyndns.org>
Am 19.05.2011 20:14, schrieb Junio C Hamano:
Show 36 quoted lines
> Jens Lehmann <Jens.Lehmann@web.de> writes:
>
>>>> + if (opts.update && dry_run)
>>>> + opts.update = 0;
>>>
>>> ... this hunk must go, right?
>>
>> But this is the "don't update the work tree when -n is used together
>> with -u" part, so it is needed, no? With this patch applied first and
>> opts.check_worktree set to 1 inside that if() added there all tests
>> succeed.
>
> I would say the natural way to do your "dry-run" would be to change the
> inner guts of unpack_trees() codepath that currently does
>
> if (opts.update) {
> if (do something to the work tree and get non-zero on failure)
> die("... cannot update '%s'", path);
> }
>
> with your "-n" work to
>
> if (opts.update) {
> if (opts.dry_run) {
> if (would the work tree operation fail?)
> say("... update would fail because ... '%s'", path);
> } else {
> if (do something to the work tree and get non-zero on failure)
> die("... cannot update '%s'", path);
> }
> }
>
> and that was why I thought you would want to keep the original value of
> opts.update. I wouldn't think of a good way to make the code that kicks
> in when both update and dry_run are set if you clear update that early in
> the codepath.Ah, now I get it ... Thanks, will add a dry_run flag that keeps update from changing anything.