{"thread":{"id":"10716","subject":"[PATCH] git-checkout: Handle relative paths containing \"..\".","startedAt":"2007-11-08T02:33:12Z","lastAt":"2007-11-08T14:25:17Z","messageCount":4,"participants":["David Symonds","Junio C Hamano","Johannes Schindelin"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"58790","messageId":"1194489192-20021-1-git-send-email-dsymonds@gmail.com","threadId":"10716","inReplyTo":null,"subject":"[PATCH] git-checkout: Handle relative paths containing \"..\".","fromName":"David Symonds","fromEmail":"dsymonds@gmail.com","sentAt":"2007-11-08T02:33:12Z","receivedAt":"2007-11-08T02:33:12Z","isPatch":true,"sender":{"key":"dsymonds@gmail.com","avatar":"https://gravatar.com/avatar/b22f5051cbfc11836e36cf7a690e6cde4e225d835e13295ff98d15c7a9ee3c0f?d=mp&s=160"},"body":"Based on gitte's idea.\n\nSigned-off-by: David Symonds <dsymonds@gmail.com>\n---\n git-checkout.sh |    7 ++++---\n 1 files changed, 4 insertions(+), 3 deletions(-)\n\ndiff --git a/git-checkout.sh b/git-checkout.sh\nindex 8993920..b2c50aa 100755\n--- a/git-checkout.sh\n+++ b/git-checkout.sh\n@@ -134,9 +134,10 @@ Did you intend to checkout '$@' which can not be resolved as commit?\"\n \tfi\n \n \t# Make sure the request is about existing paths.\n-\tgit ls-files --error-unmatch -- \"$@\" >/dev/null || exit\n-\tgit ls-files -- \"$@\" |\n-\tgit checkout-index -f -u --stdin\n+\tgit ls-files --full-name --error-unmatch -- \"$@\" >/dev/null || exit\n+\tgit ls-files --full-name -- \"$@\" |\n+\t\t(cd \"$(git-rev-parse --show-cdup)\" &&\n+\t\t git checkout-index -f -u --stdin)\n \n         # Run a post-checkout hook -- the HEAD does not change so the\n         # current HEAD is passed in for both args\n-- \n1.5.3.5.1529.g69a1-dirty\n"},{"id":"58829","messageId":"7v4pfx3zs3.fsf@gitster.siamese.dyndns.org","threadId":"10716","inReplyTo":"1194489192-20021-1-git-send-email-dsymonds@gmail.com","subject":"Re: [PATCH] git-checkout: Handle relative paths containing \"..\".","fromName":"Junio C Hamano","fromEmail":"junio@pobox.com","sentAt":"2007-11-08T08:30:20Z","receivedAt":"2007-11-08T08:30:20Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"David Symonds <dsymonds@gmail.com> writes:\n\n> diff --git a/git-checkout.sh b/git-checkout.sh\n> index 8993920..b2c50aa 100755\n> --- a/git-checkout.sh\n> +++ b/git-checkout.sh\n> @@ -134,9 +134,10 @@ Did you intend to checkout '$@' which can not be resolved as commit?\"\n>  \tfi\n>  \n>  \t# Make sure the request is about existing paths.\n> -\tgit ls-files --error-unmatch -- \"$@\" >/dev/null || exit\n> -\tgit ls-files -- \"$@\" |\n> -\tgit checkout-index -f -u --stdin\n> +\tgit ls-files --full-name --error-unmatch -- \"$@\" >/dev/null || exit\n> +\tgit ls-files --full-name -- \"$@\" |\n> +\t\t(cd \"$(git-rev-parse --show-cdup)\" &&\n> +\t\t git checkout-index -f -u --stdin)\n\nHave you tested this patch from the toplevel of any tree, where\n\"git-rev-parse --show-cdup\" would yield an empty string?\n\nI also wonder how this patch (with an obvious fix to address the\nabove point) would interact with GIT_DIR and/or GIT_WORK_TREE in\nthe environment.\n"},{"id":"58877","messageId":"ee77f5c20711080510i138729b9vb0b9ad485cb2db3@mail.gmail.com","threadId":"10716","inReplyTo":"7v4pfx3zs3.fsf@gitster.siamese.dyndns.org","subject":"Re: [PATCH] git-checkout: Handle relative paths containing \"..\".","fromName":"David Symonds","fromEmail":"dsymonds@gmail.com","sentAt":"2007-11-08T13:10:20Z","receivedAt":"2007-11-08T13:10:20Z","isPatch":true,"sender":{"key":"dsymonds@gmail.com","avatar":"https://gravatar.com/avatar/b22f5051cbfc11836e36cf7a690e6cde4e225d835e13295ff98d15c7a9ee3c0f?d=mp&s=160"},"body":"On Nov 8, 2007 7:30 PM, Junio C Hamano <junio@pobox.com> wrote:\n>\n> Have you tested this patch from the toplevel of any tree, where\n> \"git-rev-parse --show-cdup\" would yield an empty string?\n\nNo, I didn't. Arguably, \"git-rev-parse --show-cdup\" should always\nreturn a path to the top-level, which would make this kind of\nconstruction much simpler. Is there anything that relies upon it\nreturning the empty string when you're in the top-level directory?\n\n> I also wonder how this patch (with an obvious fix to address the\n> above point) would interact with GIT_DIR and/or GIT_WORK_TREE in\n> the environment.\n\nNo idea. I'm still learning my way around the git codebase, so I was\nhoping for some review and feedback from more experienced Gits.\n\n\nDave.\n"},{"id":"58892","messageId":"Pine.LNX.4.64.0711081420570.4362@racer.site","threadId":"10716","inReplyTo":"ee77f5c20711080510i138729b9vb0b9ad485cb2db3@mail.gmail.com","subject":"Re: [PATCH] git-checkout: Handle relative paths containing \"..\".","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2007-11-08T14:25:17Z","receivedAt":"2007-11-08T14:25:17Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Fri, 9 Nov 2007, David Symonds wrote:\n\n> On Nov 8, 2007 7:30 PM, Junio C Hamano <junio@pobox.com> wrote:\n> >\n> > Have you tested this patch from the toplevel of any tree, where\n> > \"git-rev-parse --show-cdup\" would yield an empty string?\n> \n> No, I didn't. Arguably, \"git-rev-parse --show-cdup\" should always return \n> a path to the top-level, which would make this kind of construction much \n> simpler.\n\nAs it is, we have a convenience function for this, to make it much \nsimpler: cd_to_toplevel in git-sh-setup.\n\n> > I also wonder how this patch (with an obvious fix to address the above \n> > point) would interact with GIT_DIR and/or GIT_WORK_TREE in the \n> > environment.\n> \n> No idea. I'm still learning my way around the git codebase, so I was\n> hoping for some review and feedback from more experienced Gits.\n\nIt _should_ work with GIT_DIR/GIT_WORK_TREE, as the full name is relative \nto the project root, and that's exactly where cd_to_toplevel is jumping \nto.  And the first call to ls-files should make certain that the paths are \ncorrect, so there should be no confusion either.\n\nBut yes, I have been burnt by that work tree stuff too many times, so I'd \nappreciate tests for that (both positive and negative ones).\n\nCiao,\nDscho\n"}]}