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

Re: [PATCH] scalar: make enlistment delete to work on all POSIX platforms

From
Johannes Schindelin <johannes.schindelin@gmx.de>
Date
May 18, 2024, 19:45 UTC
Message-ID
<fb20ebe4-e643-211e-29c8-2cbfb4b49abf@gmx.de>
In-Reply-To
<xmqqbk54go51.fsf@gitster.g>
Hi,
On Fri, 17 May 2024, Junio C Hamano wrote:
Show 40 quoted lines
> Marcel Telka <marcel@telka.sk> writes:
>
> > The ability to remove the current working directory is not guaranteed by
> > POSIX so it is better to go out of the directory we want to delete on
> > all platforms unconditionally.
> >
> > Signed-off-by: Marcel Telka <marcel@telka.sk>
> > ---
> >  scalar.c | 4 ----
> >  1 file changed, 4 deletions(-)
>
> Let's CC a few folks that had their hands in the delete_enlistment()
> function over the years for their opinions on this change.
>
> > diff --git a/scalar.c b/scalar.c
> > index 7234049a1b..331b91dbdb 100644
> > --- a/scalar.c
> > +++ b/scalar.c
> > @@ -361,16 +361,13 @@ static char *remote_default_branch(const char *url)
> >
> >  static int delete_enlistment(struct strbuf *enlistment)
> >  {
> > -#ifdef WIN32
> >  	struct strbuf parent = STRBUF_INIT;
> >  	size_t offset;
> >  	char *path_sep;
> > -#endif
> >
> >  	if (unregister_dir())
> >  		return error(_("failed to unregister repository"));
> >
> > -#ifdef WIN32
> >  	/*
> >  	 * Change the current directory to one outside of the enlistment so
> >  	 * that we may delete everything underneath it.
> > @@ -385,7 +382,6 @@ static int delete_enlistment(struct strbuf *enlistment)
> >  		return res;
> >  	}
> >  	strbuf_release(&parent);
> > -#endif

Basically, this turns the previously Windows-only logic to `chdir("..")` into the now-universal logic.

I like it!

Thank you, Johannes

> >
> >  	if (have_fsmonitor_support() && stop_fsmonitor_daemon())
> >  		return error(_("failed to stop the FSMonitor daemon"));
>
Previous: Junio C HamanoNext: Josh Steadmon
Message 3 of 5 in “scalar: make enlistment delete to work on all POSIX platforms”
  1. scalar: make enlistment delete to work on all POSIX platformsMarcel Telka, May 17, 2024
  2. Junio C HamanoMay 17, 2024
  3. Johannes SchindelinMay 18, 2024
  4. Josh SteadmonMay 30, 2024
  5. Junio C HamanoMay 30, 2024

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.