From: Kaartic Sivaraam <kaartic.sivaraam@gmail.com>
To: Junio C Hamano <gitster@pobox.com>,
Eric Sunshine <sunshine@sunshineco.com>
Cc: "Nguyễn Thái Ngọc Duy" <pclouds@gmail.com>,
"Git Mailing List" <git@vger.kernel.org>
Subject: Re: [RFC PATCH v2] builtin/worktree: enhance worktree removal
Date: Tue, 28 Nov 2017 22:16:44 +0530 [thread overview]
Message-ID: <c2e041ab-4c29-99a8-2de9-a68e986c225c@gmail.com> (raw)
In-Reply-To: <xmqqy3mr6ocp.fsf@gitster.mtv.corp.google.com>
On Tuesday 28 November 2017 09:34 AM, Junio C Hamano wrote:
> Eric Sunshine <sunshine@sunshineco.com> writes:
>
>> With this approach, validate_worktree() will print an error message
>> saying that the worktree directory is missing before the control info
>> is actually removed. Kaartic's original patch silenced the message
>> (and _all_ error messages from validate_worktree()) by passing 1 as
>> the second argument. That seemed heavy-handed, so I suggested keeping
>> the validate_worktree() call as-is but doing the directory-missing
>> check first as a special case.
>>
>> But perhaps that special case isn't necessary.
>
> I do not think the user minds to see "there is no such directory
> there"; actually that would be beneficial, even.
>
> But you are right; validate_worktree() would need to become aware of
> the possibility that it can be passed such a "corrupt" worktree to
> handle if that approach is followed.
>
> The case we are discussing, i.e. the user removed the directory
> without telling Git to give it a chance to remove control
> information, may be common enough that it becomes a worthwhile
> addition to make the "quiet" boolean that occupies a whole int to an
> unsigned that is a collection of bits, and pass "missing_ok" bit in
> that flag word to the validate_worktree() to tell that the caller
> can tolerate the "user removed it while we were looking the other
> way" case and can handle it gracefully. But that would be a lot
> larger change, and "the caller checks before calling validate" as
> done with this [RFC v2] may be a good way to add the feature with
> the least impact to the codebase.
>
>> I had envisioned a simple 'goto remove_control_info' rather than extra
>> nesting or refactoring, but that's a minor point.
>
> Yes, use of goto is also a good way to avoid having to worry about
> the future evolution of the codeflow in this function.
>
> So perhaps
>
> if (the directory is no longer there)
> goto cleanup;
> if (the worktree does not validate)
> return -1;
> ... the original code to (carefully) remove the
> ... worktree itself
>
> cleanup:
>
> ... remove control info
> ... free resources held in variables
> ... return from the function
>
> is what we want?
>
Probably but I'm not interested in going for a v3 that does that as I
just wanted to show that worktree remove could be enhanced in this
aspect and show how it could be done. So, I'll leave this in the
#leftoverbits for the person who would be re-rolling nd/worktree-move.
---
Kaartic
next prev parent reply other threads:[~2017-11-28 16:46 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-11-21 15:09 [RFC PATCH] builtin/worktree: enhance worktree removal Kaartic Sivaraam
2017-11-21 21:37 ` Eric Sunshine
2017-11-22 2:12 ` Junio C Hamano
2017-11-22 3:14 ` Eric Sunshine
2017-11-22 3:23 ` Eric Sunshine
2017-11-22 3:55 ` Junio C Hamano
2017-11-22 4:37 ` Eric Sunshine
2017-11-22 17:51 ` Kaartic Sivaraam
2017-11-27 17:36 ` [RFC PATCH v2] " Kaartic Sivaraam
2017-11-28 3:02 ` Junio C Hamano
2017-11-28 3:48 ` Eric Sunshine
2017-11-28 4:04 ` Junio C Hamano
2017-11-28 6:02 ` Eric Sunshine
2017-11-28 16:46 ` Kaartic Sivaraam [this message]
2017-11-22 17:13 ` [RFC PATCH] " Kaartic Sivaraam
2017-11-22 17:09 ` Kaartic Sivaraam
2017-11-22 18:05 ` Eric Sunshine
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=c2e041ab-4c29-99a8-2de9-a68e986c225c@gmail.com \
--to=kaartic.sivaraam@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=pclouds@gmail.com \
--cc=sunshine@sunshineco.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).