git/list[1] front-page[2] threads[3] people[4] search[5] about
 

gitk from subdirectory

From
JHJunio C Hamano <junkio@pobox.com>
Date
Aug 31, 2007, 04:29 UTC
Message-ID
<7vabs85ntg.fsf@gitster.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
Next: Junio C Hamano
Message 1 of 9 in “gitk from subdirectory”
  1. Junio C HamanoAug 31, 2007
  2. Junio C HamanoAug 31, 2007
  3. Linus TorvaldsAug 31, 2007
  4. Junio C HamanoAug 31, 2007
  5. Junio C HamanoAug 31, 2007
  6. Junio C HamanoAug 31, 2007
  7. Junio C HamanoAug 31, 2007
  8. Linus TorvaldsAug 31, 2007
  9. Junio C HamanoAug 31, 2007

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.