Re: [PATCH] dir.c: do not trip over difference in "/"
- From
Nguyen Thai Ngoc Duy <pclouds@gmail.com>
- Date
- Mar 26, 2011, 07:59 UTC
- Message-ID
- <AANLkTi=s1+BhwWrG_8S6kaF+_m9FHKdBEUMT5hgUGSvu@mail.gmail.com>
- In-Reply-To
- <b28c22b42c43f5dced45bee8ba4c76965b736d9a.1301068238.git.git@drmicha.warpmail.net>
2011/3/25 Michael J Gruber <git@drmicha.warpmail.net>:
Show 6 quoted lines
> 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).
Show 24 quoted lines
> 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