# gitk from subdirectory

9 messages from 2007-08-31 to 2007-08-31. Participants: Junio C Hamano, Linus Torvalds.
Thread: https://gitlist.dev/t/9716

## Junio C Hamano, 2007-08-31 04:29

Subject: gitk from subdirectory
Message-ID: <7vabs85ntg.fsf@gitster.siamese.dyndns.org>
URL: https://gitlist.dev/e/7vabs85ntg.fsf%40gitster.siamese.dyndns.org

```
Since commit cdaee5db165ba8bae8d3b524950e61666fc36a84 (gitk:
Improve handling of -- and ambiguous arguments), running gitk
from a subdirectory limits the displayed history with the
current directory as the path limiter, because it always passes
the "--" to the underlying git-rev-list.

One obvious side effect of this is if you create a new directory
and cd to it, gitk will not show anything because no commit in
the history has touched the path you are currently in.

I am wondering if this was intended behaviour change.  I think
it makes sense to want an easy way to say "what changed stuff in
the directory I am in?" because presumably you are there because
you are interested in stuff in there.  But if you hard code "--"
it is not easy to disable that and get the global log.

You always can say "gitk -- ." to limit commits to the current
directory, so it might have been just an oversight.  In which
case, the attached patch may be needed to restore the old
behaviour.

Signed-off-by: Junio C Hamano <junkio@pobox.com>
---
 gitk |    7 ++++++-
 1 files changed, 6 insertions(+), 1 deletions(-)

diff --git a/gitk b/gitk
index 300fdce..b95b313 100755
--- a/gitk
+++ b/gitk
@@ -92,8 +92,13 @@ proc start_rev_list {view} {
 	set order "--date-order"
     }
     if {[catch {
+	if {[llength $viewfiles($view)] == 0} {
+	    set rlpaths {}
+	} else {
+	    set rlpaths [list "--" $viewfiles($view)]
+	}
 	set fd [open [concat | git log -z --pretty=raw $order --parents \
-			 --boundary $viewargs($view) "--" $viewfiles($view)] r]
+			 --boundary $viewargs($view) $rlpaths] r]
     } err]} {
 	error_popup "Error executing git rev-list: $err"
 	exit 1

```

## Junio C Hamano, 2007-08-31 04:33

Subject: Re: gitk from subdirectory
Message-ID: <7v642w5nmd.fsf@gitster.siamese.dyndns.org>
URL: https://gitlist.dev/e/7v642w5nmd.fsf%40gitster.siamese.dyndns.org
In-Reply-To: <7vabs85ntg.fsf@gitster.siamese.dyndns.org>

```
Junio C Hamano <junkio@pobox.com> writes:

> Since commit cdaee5db165ba8bae8d3b524950e61666fc36a84 (gitk:
> Improve handling of -- and ambiguous arguments), running gitk
> from a subdirectory limits the displayed history with the ...

FYI, I picked up your wish in the kernel list and have been
experimenting with this 5-liner whenever I refer to a commit in
the past:

        #!/bin/sh
        for commit
        do
                git show -s --pretty=oneline "$commit"
        done |
        sed -e 's/^[^ ]* /&(/' -e 's/$/)/'

```

## Linus Torvalds, 2007-08-31 05:08

Subject: Re: gitk from subdirectory
Message-ID: <alpine.LFD.0.999.0708302200160.25853@woody.linux-foundation.org>
URL: https://gitlist.dev/e/alpine.LFD.0.999.0708302200160.25853%40woody.linux-foundation.org
In-Reply-To: <7vabs85ntg.fsf@gitster.siamese.dyndns.org>

```


On Thu, 30 Aug 2007, Junio C Hamano wrote:
> 
> I am wondering if this was intended behaviour change.  I think
> it makes sense to want an easy way to say "what changed stuff in
> the directory I am in?" because presumably you are there because
> you are interested in stuff in there.  But if you hard code "--"
> it is not easy to disable that and get the global log.

Hmm. My reaction to this would be that it was a mistake to have a 
difference between 

	git log --

and

	git log

and that we should instead fix this at the argument parsing level. 

And then anybody who depended on the old "--" behaviour can just add a "." 
at the end.

That way there are no special cases.

I realize that the "--" behaviour of git log was intentional, but seeing 
what it results in I think the intention was good, but stupid.

		Linus

```

## Junio C Hamano, 2007-08-31 05:29

Subject: Re: gitk from subdirectory
Message-ID: <7vsl6046gn.fsf@gitster.siamese.dyndns.org>
URL: https://gitlist.dev/e/7vsl6046gn.fsf%40gitster.siamese.dyndns.org
In-Reply-To: <alpine.LFD.0.999.0708302200160.25853@woody.linux-foundation.org>

```
Linus Torvalds <torvalds@linux-foundation.org> writes:

> On Thu, 30 Aug 2007, Junio C Hamano wrote:
>> 
>> I am wondering if this was intended behaviour change.  I think
>> it makes sense to want an easy way to say "what changed stuff in
>> the directory I am in?" because presumably you are there because
>> you are interested in stuff in there.  But if you hard code "--"
>> it is not easy to disable that and get the global log.
>
> Hmm. My reaction to this would be that it was a mistake to have a 
> difference between 
>
> 	git log --
>
> and
>
> 	git log
>
> and that we should instead fix this at the argument parsing level. 
>
> And then anybody who depended on the old "--" behaviour can just add a "." 
> at the end.
>
> That way there are no special cases.
>
> I realize that the "--" behaviour of git log was intentional, but seeing 
> what it results in I think the intention was good, but stupid.

I haven't finished analysis yet, but I was reaching the same
conclusion.

v1.2.0 used to limit "git rev-list" to the current working
directory, v1.3.0 and newer does not.  But they do when "--" is
given.  This makes it impossible to do:

	cd Documentation
	echo >master
	git rev-list master
        ... get "ambiguous -- which do you mean?  rev, or
	... limited to path?" error message
        git rev-list master --
        ... I do mean unlimited and dig from 'master'

```

## Junio C Hamano, 2007-08-31 05:32

Subject: Re: gitk from subdirectory
Message-ID: <7vir6w46bk.fsf@gitster.siamese.dyndns.org>
URL: https://gitlist.dev/e/7vir6w46bk.fsf%40gitster.siamese.dyndns.org
In-Reply-To: <7vsl6046gn.fsf@gitster.siamese.dyndns.org>

```
Junio C Hamano <gitster@pobox.com> writes:

> Linus Torvalds <torvalds@linux-foundation.org> writes:
>
>> I realize that the "--" behaviour of git log was intentional, but seeing 
>> what it results in I think the intention was good, but stupid.
>
> I haven't finished analysis yet, but I was reaching the same
> conclusion.
>
> v1.2.0 used to limit "git rev-list" to the current working
> directory, v1.3.0 and newer does not.  But they do when "--" is
> given.  This makes it impossible to do:
>
> 	cd Documentation
> 	echo >master
> 	git rev-list master
>         ... get "ambiguous -- which do you mean?  rev, or
> 	... limited to path?" error message
>         git rev-list master --
>         ... I do mean unlimited and dig from 'master'

FWIW bisect points at your commit ae563542bf10fa8c33abd2a354e4b28aca4264d7
(First cut at libifying revlist generation) ;-).

```

## Junio C Hamano, 2007-08-31 05:45

Subject: Re: gitk from subdirectory
Message-ID: <7vejhk45q5.fsf@gitster.siamese.dyndns.org>
URL: https://gitlist.dev/e/7vejhk45q5.fsf%40gitster.siamese.dyndns.org
In-Reply-To: <alpine.LFD.0.999.0708302200160.25853@woody.linux-foundation.org>

```
"git log" family of commands, even when run from a subdirectory,
do not limit the revision range with the current directory as
the path limiter, but with double-dash without any paths after
it, i.e. "git log --" do so.  It was a mistake to have a
difference between "git log --" and "git log" introduced in
commit ae563542bf10fa8c33abd2a354e4b28aca4264d7 (First cut at
libifying revlist generation).

Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
 revision.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/revision.c b/revision.c
index 51fff0e..c193c3e 100644
--- a/revision.c
+++ b/revision.c
@@ -896,7 +896,8 @@ int setup_revisions(int argc, const char **argv, struct rev_info *revs, const ch
 			continue;
 		argv[i] = NULL;
 		argc = i;
-		revs->prune_data = get_pathspec(revs->prefix, argv + i + 1);
+		if (argv[i + 1])
+			revs->prune_data = get_pathspec(revs->prefix, argv + i + 1);
 		seen_dashdash = 1;
 		break;
 	}

```

## Junio C Hamano, 2007-08-31 05:51

Subject: Re: gitk from subdirectory
Message-ID: <7vabs845h3.fsf@gitster.siamese.dyndns.org>
URL: https://gitlist.dev/e/7vabs845h3.fsf%40gitster.siamese.dyndns.org
In-Reply-To: <7vejhk45q5.fsf@gitster.siamese.dyndns.org>

```
Junio C Hamano <gitster@pobox.com> writes:

> "git log" family of commands, even when run from a subdirectory,
> do not limit the revision range with the current directory as
> the path limiter, but with double-dash without any paths after
> it, i.e. "git log --" do so.  It was a mistake to have a
> difference between "git log --" and "git log" introduced in
> commit ae563542bf10fa8c33abd2a354e4b28aca4264d7 (First cut at
> libifying revlist generation).
>
> Signed-off-by: Junio C Hamano <gitster@pobox.com>

In case it was not obvious, this patch is meant to make the
previous patch from me to change gitk unneeded.

```

## Linus Torvalds, 2007-08-31 07:38

Subject: Re: gitk from subdirectory
Message-ID: <alpine.LFD.0.999.0708310038080.25853@woody.linux-foundation.org>
URL: https://gitlist.dev/e/alpine.LFD.0.999.0708310038080.25853%40woody.linux-foundation.org
In-Reply-To: <7vejhk45q5.fsf@gitster.siamese.dyndns.org>

```


On Thu, 30 Aug 2007, Junio C Hamano wrote:

> "git log" family of commands, even when run from a subdirectory,
> do not limit the revision range with the current directory as
> the path limiter, but with double-dash without any paths after
> it, i.e. "git log --" do so.  It was a mistake to have a
> difference between "git log --" and "git log" introduced in
> commit ae563542bf10fa8c33abd2a354e4b28aca4264d7 (First cut at
> libifying revlist generation).
> 
> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Looks obviously correct.

Acked-by: Linus Torvalds <torvalds@linux-foundation.org>

		Linus

```

## Junio C Hamano, 2007-08-31 07:40

Subject: Re: gitk from subdirectory
Message-ID: <7vk5rc2lv0.fsf@gitster.siamese.dyndns.org>
URL: https://gitlist.dev/e/7vk5rc2lv0.fsf%40gitster.siamese.dyndns.org
In-Reply-To: <alpine.LFD.0.999.0708310038080.25853@woody.linux-foundation.org>

```
Linus Torvalds <torvalds@linux-foundation.org> writes:

> On Thu, 30 Aug 2007, Junio C Hamano wrote:
>
>> "git log" family of commands, even when run from a subdirectory,
>> do not limit the revision range with the current directory as
>> the path limiter, but with double-dash without any paths after
>> it, i.e. "git log --" do so.  It was a mistake to have a
>> difference between "git log --" and "git log" introduced in
>> commit ae563542bf10fa8c33abd2a354e4b28aca4264d7 (First cut at
>> libifying revlist generation).
>> 
>> Signed-off-by: Junio C Hamano <gitster@pobox.com>
>
> Looks obviously correct.
>
> Acked-by: Linus Torvalds <torvalds@linux-foundation.org>

Thanks.

```
