Re: [PATCH/WIP 03/11] t5403: avoid doing "git add foo/bar" where foo/.git exists
- From
Nguyen Thai Ngoc Duy <pclouds@gmail.com>
- Date
- Oct 30, 2011, 05:55 UTC
- Message-ID
- <CACsJy8DdQXXoYT2gB2L5z6pdCNU_vL2w7c8eJvKRGX2T9iAC3Q@mail.gmail.com>
- In-Reply-To
- <7vobx2z60w.fsf@alter.siamese.dyndns.org>
On Fri, Oct 28, 2011 at 12:41 AM, Junio C Hamano <gitster@pobox.com> wrote:
>> ... Should we stick with one way only? > > Whatever we have been doing should not change, especially in corner cases.
I disagree. If it's not right, then we should change it even though it may face unpleasant consequences from misusing it. And I don't think it's sane to behave like what we're doing now:
$ GIT_DIR=clone2/.git git ls-files --stage 100644 e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 0 1
$ ls -l clone2/2 3 -rw-r--r-- 1 pclouds users 0 Th10 30 12:40 3 -rw-r--r-- 1 pclouds users 0 Th10 30 12:40 clone2/2
$ GIT_DIR=clone2/.git git add clone2/2 3
$ GIT_DIR=clone2/.git git ls-files --stage 100644 e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 0 1 100644 e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 0 3
$ GIT_DIR=clone2/.git git add clone2/2
$ GIT_DIR=clone2/.git git ls-files --stage 100644 e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 0 1 100644 e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 0 3 100644 e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 0 clone2/2
"git add" behaves inconsistently when "clone2/2" and "3" are given and when clone2/2 is given alone. This is just bad to me.
Note that this has nothing to do with read_directory() discussion we had in the notes-merge patch, I agree we should keep the prefix. This is about the calculating common prefix automatically from pathspec. But prefix and pathspec are treated differently by read_directory(). In "git add clone2/2 3", common prefix is "" while in "git add clone2/2" common prefix is "clone2".
-- Duy