Subject: Re: [PATCH 1/1] completion: dir-type optargs for am, format-patch

From: Junio C Hamano <[email-masked]>
Date: Mon, 08 Jan 2024 10:37:55 -0800

"Britton Leo Kerin" <[email-masked]> writes:

> +	local context_dir=$(__git rev-parse --show-toplevel --show-prefix 2>/dev/null | paste -s -d '/' 2>/dev/null)

Is there a practical difference with the above with

	context_dir=$(pwd)

other than that it will give an empty string outside a git working tree?

If not, I suspect

	local inside

	inside=$(__git rev-parse --is-inside-work-tree) &&
	test "$inside" = true || return

	local context_dir=$(pwd)

might be clearer on the intent.

> +	[ -d "$context_dir" ] || return
> +
> +	COMPREPLY=$(cd $context_dir 2>/dev/null && compgen -d -- "$cur_")

Can $context_dir contain $IFS whitespaces here?

> +}