# [BUG?] Path limiting in "git log" when run from another subdir

7 messages from 2012-09-24 to 2012-09-24. Participants: Johan Herland, Nguyen Thai Ngoc Duy.
Thread: https://gitlist.dev/t/31633

## Johan Herland, 2012-09-24 11:59

Subject: [BUG?] Path limiting in "git log" when run from another subdir
Message-ID: <CALKQrged+ptCQYm-=JKRborrAeKmaNFG=rDS8BQK5CNhwqjnkQ@mail.gmail.com>
URL: https://gitlist.dev/e/CALKQrged%2BptCQYm-%3DJKRborrAeKmaNFG%3DrDS8BQK5CNhwqjnkQ%40mail.gmail.com

```
The following works in the git.git repo:

$ cd t
$ git log -- /Documentation
[...]

but the following does not:

$ cd t
$ git log -- /Documentation/RelNotes
fatal: Could not switch to '/Documentation': No such file or directory


Is this the intended behavior?


...Johan

-- 
Johan Herland, <johan@herland.net>
www.herland.net

```

## Nguyen Thai Ngoc Duy, 2012-09-24 12:22

Subject: Re: [BUG?] Path limiting in "git log" when run from another subdir
Message-ID: <CACsJy8CECnFbkD6QFWiDMxz6J4mOngrmHPwjuXvsFBUXhNc1_w@mail.gmail.com>
URL: https://gitlist.dev/e/CACsJy8CECnFbkD6QFWiDMxz6J4mOngrmHPwjuXvsFBUXhNc1_w%40mail.gmail.com
In-Reply-To: <CALKQrged+ptCQYm-=JKRborrAeKmaNFG=rDS8BQK5CNhwqjnkQ@mail.gmail.com>

```
On Mon, Sep 24, 2012 at 6:59 PM, Johan Herland <johan@herland.net> wrote:
> The following works in the git.git repo:
>
> $ cd t
> $ git log -- /Documentation
> [...]
>

What version? Mine (recent master) does not work

~/w/git/t $ ../git log -- /Documentation
fatal: '/Documentation' is outside repository

> but the following does not:
>
> $ cd t
> $ git log -- /Documentation/RelNotes
> fatal: Could not switch to '/Documentation': No such file or directory
>
>
> Is this the intended behavior?
-- 
Duy

```

## Johan Herland, 2012-09-24 13:16

Subject: Re: [BUG?] Path limiting in "git log" when run from another subdir
Message-ID: <CALKQrgfb8qbeKmCzri27iA1qk9H8R4FgyA-YsUQf_JQRWvGK4g@mail.gmail.com>
URL: https://gitlist.dev/e/CALKQrgfb8qbeKmCzri27iA1qk9H8R4FgyA-YsUQf_JQRWvGK4g%40mail.gmail.com
In-Reply-To: <CACsJy8CECnFbkD6QFWiDMxz6J4mOngrmHPwjuXvsFBUXhNc1_w@mail.gmail.com>

```
On Mon, Sep 24, 2012 at 2:22 PM, Nguyen Thai Ngoc Duy <pclouds@gmail.com> wrote:
> On Mon, Sep 24, 2012 at 6:59 PM, Johan Herland <johan@herland.net> wrote:
>> The following works in the git.git repo:
>>
>> $ cd t
>> $ git log -- /Documentation
>> [...]
>>
>
> What version? Mine (recent master) does not work
>
> ~/w/git/t $ ../git log -- /Documentation
> fatal: '/Documentation' is outside repository

We initially found it on 1.7.9.5, and conrfirmed it on various 1.7.10
versions. A bisect reveals that this behavior changed in
v1.7.11.5-35-gf4c21e8 (Michael Haggerty: real_path(): properly handle
nonexistent top-level paths).

Does this mean that "git log -- /Documentation" never should have
worked in the first place (and was "fixed" by this commit), or that it
should work (but was broken by this commit)?

In any case, what is the _preferred_ way to path-limit "git log" to
Documentation/RelNotes, when my cwd is t/?


Thanks for your help,

...Johan

>> but the following does not:
>>
>> $ cd t
>> $ git log -- /Documentation/RelNotes
>> fatal: Could not switch to '/Documentation': No such file or directory
>>
>>
>> Is this the intended behavior?
> --
> Duy



-- 
Johan Herland, <johan@herland.net>
www.herland.net

```

## Nguyen Thai Ngoc Duy, 2012-09-24 13:30

Subject: Re: [BUG?] Path limiting in "git log" when run from another subdir
Message-ID: <CACsJy8A4-XC7AS4ZqZ1Whsoo-mztTNFvEnk810e10-rwXBkJHA@mail.gmail.com>
URL: https://gitlist.dev/e/CACsJy8A4-XC7AS4ZqZ1Whsoo-mztTNFvEnk810e10-rwXBkJHA%40mail.gmail.com
In-Reply-To: <CALKQrgfb8qbeKmCzri27iA1qk9H8R4FgyA-YsUQf_JQRWvGK4g@mail.gmail.com>

```
On Mon, Sep 24, 2012 at 8:16 PM, Johan Herland <johan@herland.net> wrote:
> On Mon, Sep 24, 2012 at 2:22 PM, Nguyen Thai Ngoc Duy <pclouds@gmail.com> wrote:
>> On Mon, Sep 24, 2012 at 6:59 PM, Johan Herland <johan@herland.net> wrote:
>>> The following works in the git.git repo:
>>>
>>> $ cd t
>>> $ git log -- /Documentation
>>> [...]
>>>
>>
>> What version? Mine (recent master) does not work
>>
>> ~/w/git/t $ ../git log -- /Documentation
>> fatal: '/Documentation' is outside repository
>
> We initially found it on 1.7.9.5, and conrfirmed it on various 1.7.10
> versions. A bisect reveals that this behavior changed in
> v1.7.11.5-35-gf4c21e8 (Michael Haggerty: real_path(): properly handle
> nonexistent top-level paths).

OK checking. I still don't know why it does not happen to me. Any
special in gitdir/worktree setting? That commit is in master.

> Does this mean that "git log -- /Documentation" never should have
> worked in the first place (and was "fixed" by this commit), or that it
> should work (but was broken by this commit)?

I think that should mean Documentation at root. "git log -- `chdir
../Documentation;pwd`" works and that clearly conflicts with
interpreting "/Documentation" as the directory at worktree's root.

> In any case, what is the _preferred_ way to path-limit "git log" to
> Documentation/RelNotes, when my cwd is t/?

If you want worktree root no matter where you stand, use "git log --
:/Documentation/RelNotes". The idea is ":" starts some "magic" in path
handling, but for now there is only ":/". Or if you don't like magic,
`git rev-parse --git-dir` should give you worktree's root to start
with.
-- 
Duy

```

## Nguyen Thai Ngoc Duy, 2012-09-24 13:39

Subject: Re: [BUG?] Path limiting in "git log" when run from another subdir
Message-ID: <CACsJy8AXonkSXNU_uUXh=d2wojOhAn+S1JW7eUMywxohnAOXjg@mail.gmail.com>
URL: https://gitlist.dev/e/CACsJy8AXonkSXNU_uUXh%3Dd2wojOhAn%2BS1JW7eUMywxohnAOXjg%40mail.gmail.com
In-Reply-To: <CACsJy8A4-XC7AS4ZqZ1Whsoo-mztTNFvEnk810e10-rwXBkJHA@mail.gmail.com>

```
On Mon, Sep 24, 2012 at 8:30 PM, Nguyen Thai Ngoc Duy <pclouds@gmail.com> wrote:
> Any special in gitdir/worktree setting?

What does "GIT_TRACE_SETUP=1 git log -- /Documentation" show?
-- 
Duy

```

## Johan Herland, 2012-09-24 14:04

Subject: Re: [BUG?] Path limiting in "git log" when run from another subdir
Message-ID: <CALKQrget=YpoZuH+aRdiey_S==37SPnJ+PvwiDpSM2701w602A@mail.gmail.com>
URL: https://gitlist.dev/e/CALKQrget%3DYpoZuH%2BaRdiey_S%3D%3D37SPnJ%2BPvwiDpSM2701w602A%40mail.gmail.com
In-Reply-To: <CACsJy8A4-XC7AS4ZqZ1Whsoo-mztTNFvEnk810e10-rwXBkJHA@mail.gmail.com>

```
On Mon, Sep 24, 2012 at 3:30 PM, Nguyen Thai Ngoc Duy <pclouds@gmail.com> wrote:
>> In any case, what is the _preferred_ way to path-limit "git log" to
>> Documentation/RelNotes, when my cwd is t/?
>
> If you want worktree root no matter where you stand, use "git log --
> :/Documentation/RelNotes". The idea is ":" starts some "magic" in path
> handling, but for now there is only ":/". Or if you don't like magic,
> `git rev-parse --git-dir` should give you worktree's root to start
> with.

Ah, ok, that's exactly what I wanted. Then I guess "cd t && git log --
/Documentation" should have never worked in the first place, and I
question about "git log -- /Documentation/RelNotes" was misguided.

Thanks for clearing up my confusion.


...Johan

-- 
Johan Herland, <johan@herland.net>
www.herland.net

```

## Johan Herland, 2012-09-24 14:11

Subject: Re: [BUG?] Path limiting in "git log" when run from another subdir
Message-ID: <CALKQrgdhFCUs+gqT=PrT3w7suGzvnj7Wo8GfipHHQm6b=TZF+A@mail.gmail.com>
URL: https://gitlist.dev/e/CALKQrgdhFCUs%2BgqT%3DPrT3w7suGzvnj7Wo8GfipHHQm6b%3DTZF%2BA%40mail.gmail.com
In-Reply-To: <CACsJy8AXonkSXNU_uUXh=d2wojOhAn+S1JW7eUMywxohnAOXjg@mail.gmail.com>

```
On Mon, Sep 24, 2012 at 3:39 PM, Nguyen Thai Ngoc Duy <pclouds@gmail.com> wrote:
> On Mon, Sep 24, 2012 at 8:30 PM, Nguyen Thai Ngoc Duy <pclouds@gmail.com> wrote:
>> Any special in gitdir/worktree setting?
>
> What does "GIT_TRACE_SETUP=1 git log -- /Documentation" show?

FWIW, this issue is resolved as far as I'm concerned. I was simply
using the wrong syntax...

Anyway, with current master:

$ GIT_TRACE_SETUP=1 ../git log -1 -- /Documentation
setup: git_dir: .git
setup: worktree: /home/jherland/git/git
setup: cwd: /home/jherland/git/git
setup: prefix: t/
fatal: '/Documentation' is outside repository

With v1.7.11:

$ GIT_TRACE_SETUP=1 ../git log -1 -- /Documentation
setup: git_dir: .git
setup: worktree: /home/jherland/git/git
setup: cwd: /home/jherland/git/git
setup: prefix: t/
commit 0ce2e396ee9fb0fa07e8381b338e49859dbf03db
Author: Junio C Hamano <gitster@pobox.com>
Date:   Sun Jun 17 14:07:15 2012 -0700

    Git 1.7.11

    Signed-off-by: Junio C Hamano <gitster@pobox.com>


...Johan

-- 
Johan Herland, <johan@herland.net>
www.herland.net

```
