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

Re: [BUG] git ls-files -m --with-tree does double output

From
Junio C Hamano <gitster@pobox.com>
Date
Nov 16, 2008, 08:03 UTC
Message-ID
<7vr65c3xn5.fsf@gitster.siamese.dyndns.org>
In-Reply-To
<57320.N1gUGH5fRhE=.1226617873.squirrel@webmail.hotelhot.dk>
"Anders Melchiorsen" <mail@cup.kalibalik.dk> writes:
Show 10 quoted lines
> Junio C Hamano wrote:
>
>> What's the use case of using -m together with --with-tree to begin with?
>
> The script runs
>
>    git ls-files -d -m -o -t --with-tree=HEAD
>
> to get a parseable "git status"-like output. If I leave out
> --with-tree=HEAD, I do not get information about staged changes.

I think a machine parsable "status equivalent" is a good thing to have, but I do not think the internal machinery of ls-files is equipped to do that. Didn't I send "here is how you would do it" patch some time ago, so that interested parties can build on it to do that?

I lack the context to interpret what you mean by "The script", but in any case, the only use case --with-tree was designed for was to use it in conjunction with --error-unmatch inside the scripted version of "git commit", to see if the paths given by the users make sense as a request to create a partial commit. It is not entirely surprising if any other funny options do not work with it at all.

Having said all that, I think this would fix it.
 builtin-ls-files.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)
diff --git c/builtin-ls-files.c i/builtin-ls-files.c
index b48327d..b28a185 100644
--- c/builtin-ls-files.c
+++ i/builtin-ls-files.c
@@ -227,6 +227,8 @@ static void show_files(struct dir_struct *dir, const char *prefix)
 			int dtype = ce_to_dtype(ce);
 			if (excluded(dir, ce->name, &dtype) != dir->show_ignored)
 				continue;
+			if (ce->ce_flags & CE_UPDATE)
+				continue;
 			err = lstat(ce->name, &st);
 			if (show_deleted && err)
 				show_ce_entry(tag_removed, ce);
Previous: Anders MelchiorsenNext: Anders Melchiorsen
Message 5 of 6 in “[BUG] git ls-files -m --with-tree does double output”
  1. Anders MelchiorsenNov 13, 2008
  2. Junio C HamanoNov 13, 2008
  3. Junio C HamanoNov 13, 2008
  4. Anders MelchiorsenNov 13, 2008
  5. Junio C HamanoNov 16, 2008
  6. Anders MelchiorsenNov 16, 2008

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.