From: Nguyen Thai Ngoc Duy Date: Sat, 26 Mar 2011 07:59:52 GMT Subject: Re: [PATCH] dir.c: do not trip over difference in "/" Message-ID: In-Reply-To: 2011/3/25 Michael J Gruber : > get_relative_cwd() tries to determine a common prefix for dir and cwd. > The fix in > 490544b (get_cwd_relative(): do not misinterpret suffix as subdirectory, 2010-05-22) > made the logic less naive (so that foo-bar is not misdetected as being > within foo) but broke some other cases, in particular foo not being > detected as being within foo/ any more. I'd rather kill this function off. It's only used in is_inside_dir(), we can be replaced with is_subdir_or_same() in my previous patch (more or less the same function with get_relative_cwd, but less cryptic). > diff --git a/t/t1501-worktree.sh b/t/t1501-worktree.sh > index bd8b607..f0dbdd8 100755 > --- a/t/t1501-worktree.sh > +++ b/t/t1501-worktree.sh > @@ -63,6 +63,19 @@ cd sub/dir || exit 1 >  test_rev_parse 'subdirectory' false false true sub/dir/ >  cd ../../.. || exit 1 > > +say "core.worktree = absolute path/" > +GIT_DIR=$(pwd)/repo.git > +GIT_CONFIG=$GIT_DIR/config > +git config core.worktree "$(pwd)/work/" > +test_rev_parse 'outside'      false false false > +cd work2 > +test_rev_parse 'outside2'     false false false > +cd ../work || exit 1 > +test_rev_parse 'inside'       false false true '' > +cd sub/dir || exit 1 > +test_rev_parse 'subdirectory' false false true sub/dir/ > +cd ../../.. || exit 1 > + >  say "GIT_WORK_TREE=relative path (override core.worktree)" >  GIT_DIR=$(pwd)/repo.git >  GIT_CONFIG=$GIT_DIR/config I tried something similar (basically core.worktree = $(pwd)/work/) but could not reproduce. Note that worktree will be normalized by real_path() (or get_absolute_path() earlier) and the trailing '/' may have been removed. -- Duy