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

difference in behavior bw ls-files and ls-tree on paths in submodules

From
Yaroslav O Halchenko <debian@onerussian.com>
Date
Jul 3, 2019, 19:33 UTC
Message-ID
<20190703193305.GF21553@hopa.kiewit.dartmouth.edu>
Dear Git gurus,

A quick question on either such difference in behavior is intended or ideally should be "fixed" by making it more consistent.

	# prep demo usecase with a submodule sub/ containing a file 123
	$> mkdir /tmp/testrepo; cd /tmp/testrepo; git init; touch 123; git add 123; git commit -m 123
	Initialized empty Git repository in /tmp/testrepo/.git/
	[master (root-commit) 00864cd] 123
	 1 file changed, 0 insertions(+), 0 deletions(-)
	  create mode 100644 123
	$> git submodule add $PWD ./sub && git commit -m 'added self as a submodule'
	Cloning into '/tmp/testrepo/sub'...                                         
	done.
	[master e92dd9a] added self as a submodule
	 2 files changed, 4 insertions(+)
	 create mode 100644 .gitmodules
	 create mode 160000 su

ls-tree provides information on the submodule if I point it to the file within submodule (even without -r):

	$> git ls-tree HEAD -l sub/123                                              
	160000 commit 00864cd776e8c870feb89db28c5e9ad185ed2a8e       -	sub

whenever ls-files provides no output for a path within submodule and only if I point to the submodule directory directly:

	$> git ls-files --stage sub/123
	$> git ls-files --stage sub/   
	160000 00864cd776e8c870feb89db28c5e9ad185ed2a8e 0	sub
I wonder 
- if that is somehow intended (so there is a good reason for such a
behavior)?
- is there a good/quick way to figure out "parent path as known to git"
similarly as ls-tree behaves, but for "ls-files" (i.e. a worktree, which might
have submodules renamed but not yet committed etc)?
Thank you in advance!
-- 
Yaroslav O. Halchenko
Center for Open Neuroscience     http://centerforopenneuroscience.org
Dartmouth College, 419 Moore Hall, Hinman Box 6207, Hanover, NH 03755
Phone: +1 (603) 646-9834                       Fax: +1 (603) 646-1419
WWW:   http://www.linkedin.com/in/yarik        
Message 1 of 1 in “difference in behavior bw ls-files and ls-tree on paths in submodules”
  1. Yaroslav O HalchenkoJul 3, 2019

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.