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

Re: gitk does not show path file list

From
Junio C Hamano <gitster@pobox.com>
Date
Nov 24, 2009, 07:22 UTC
Message-ID
<7v3a44l752.fsf@alter.siamese.dyndns.org>
In-Reply-To
<loom.20091124T060334-836@post.gmane.org>
Mark Blakeney <markb@berlios.de> writes:
Show 5 quoted lines
> ... why does gitk (usually) not show the subset list of files affected
> when you give it a path?
>
> E.g. If I am in a src dir then "gitk ." does not list files. Neither does "gitk
> $PWD" nor "gitk ../src". However "cd ..; git src" does list files!?

Paul, I do not read Tcl very well, but it appears that path_filter procedure is at fault.

The call chain involved in this seems to be:
    gettreediffs
     - arranges gettreediffline to be fed output from "diff-tree $commit ."
 ->
    gettreediffline
     - finds the path (note that diff output is _always_ relative to the
       top of the work tree) from the patch;
     - calls path_filter with $vfilelimit($curview) and each filename
       In this case, the $vfilelimit($curview) is "." (dot)
 ->
    path_filter
     - compares strings in $filter and the $name; in this case, $filter is
       a dot "." and $name begins with "src/"
I see at least two problems in path_filter used this way:
 - A dot "." never would match anything from "diff-tree" (or any "diff"
   variant) after stripping a/ and b/ prefix.  gitk should prefix the
   current directory to each of the pathspec from command line (run
   "rev-parse --show-prefix" to learn where you are).
 - There is another callsite to path_filter for filtering output from
   "ls-files -u".  But the output from "ls-files" is relative to the cwd
   by default.  gitk should probably run it with --full-name option, so
   that it would get the same semantics as "diff" output.

It _might_ be the easiest to do an equivalent of (sorry, I do not talk Tcl so this is in shell):

	prefix=$(git rev-parse --show-prefix)
	if test -n "$prefix"
        then
        	cd $(git rev-parse --show-cdup)
	fi

and then prepend prefix to all the pathspecs you would use from the command line before doing anything else. This "prepending" obviously need to be aware of the ".", ".." and friends.

Previous: Mark BlakeneyNext: Johannes Sixt
Message 3 of 5 in “gitk does not show path file list”
  1. Mark BlakeneyNov 17, 2009
  2. Mark BlakeneyNov 24, 2009
  3. Junio C HamanoNov 24, 2009
  4. Johannes SixtNov 24, 2009
  5. Junio C HamanoNov 24, 2009

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.