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

Re: [PATCH] git-checkout: Handle relative paths containing "..".

From
Junio C Hamano <junio@pobox.com>
Date
Nov 8, 2007, 08:30 UTC
Message-ID
<7v4pfx3zs3.fsf@gitster.siamese.dyndns.org>
In-Reply-To
<1194489192-20021-1-git-send-email-dsymonds@gmail.com>
David Symonds <dsymonds@gmail.com> writes:
Show 15 quoted lines
> diff --git a/git-checkout.sh b/git-checkout.sh
> index 8993920..b2c50aa 100755
> --- a/git-checkout.sh
> +++ b/git-checkout.sh
> @@ -134,9 +134,10 @@ Did you intend to checkout '$@' which can not be resolved as commit?"
>  	fi
>  
>  	# Make sure the request is about existing paths.
> -	git ls-files --error-unmatch -- "$@" >/dev/null || exit
> -	git ls-files -- "$@" |
> -	git checkout-index -f -u --stdin
> +	git ls-files --full-name --error-unmatch -- "$@" >/dev/null || exit
> +	git ls-files --full-name -- "$@" |
> +		(cd "$(git-rev-parse --show-cdup)" &&
> +		 git checkout-index -f -u --stdin)

Have you tested this patch from the toplevel of any tree, where "git-rev-parse --show-cdup" would yield an empty string?

I also wonder how this patch (with an obvious fix to address the above point) would interact with GIT_DIR and/or GIT_WORK_TREE in the environment.

Previous: David SymondsNext: David Symonds
Message 2 of 4 in “git-checkout: Handle relative paths containing "..".”
  1. git-checkout: Handle relative paths containing "..".David Symonds, Nov 8, 2007
  2. Junio C HamanoNov 8, 2007
  3. David SymondsNov 8, 2007
  4. Johannes SchindelinNov 8, 2007

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.