{"thread":{"id":"16320","subject":"[BUG] git ls-files -m --with-tree does double output","startedAt":"2008-11-13T21:53:48Z","lastAt":"2008-11-16T09:00:15Z","messageCount":6,"participants":["Anders Melchiorsen","Junio C Hamano"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"95729","messageId":"37512.N1gUGH5fRhE=.1226613228.squirrel@webmail.hotelhot.dk","threadId":"16320","inReplyTo":null,"subject":"[BUG] git ls-files -m --with-tree does double output","fromName":"Anders Melchiorsen","fromEmail":"mail@cup.kalibalik.dk","sentAt":"2008-11-13T21:53:48Z","receivedAt":"2008-11-13T21:53:48Z","isPatch":false,"sender":{"key":"mail@cup.kalibalik.dk","avatar":null},"body":"Junio, I am resending this one because I am not sure whether you ignored\nit on purpose, or it got lost during your vacation.\n\nThe combination of -m and --with-tree shows duplicate entries:\n\nand@dylle:~$ mkdir repo ; cd repo\nand@dylle:~/repo$ git init\nInitialized empty Git repository in /home/and/repo/.git/\nand@dylle:~/repo$ date >a ; git add a ; git commit -m'Add 1'\nCreated initial commit c027435: Add 1\n 1 files changed, 1 insertions(+), 0 deletions(-)\n create mode 100644 a\nand@dylle:~/repo$ date >a\nand@dylle:~/repo$ git ls-files -m --with-tree=HEAD\na\na\n\n\nJeff King added:\n\nI have confirmed this, and it looks like it has always been that way. It\nlooks like overlay_tree_on_cache just does a read_tree to pull the tree\ninto the index, and then we end up with duplicate entries.\n\nI'm not too familiar with the read_tree code, so I am cc'ing Junio (who\nis out of touch for a little while) and Linus, who are much more clueful\nin this area.\n\nIt isn't clear to me which code is _supposed_ to be pulling out such\nduplicates here. That is, is read_tree broken, or is\noverlay_tree_on_cache just calling it wrong?\n\n\n\nAnders.\n"},{"id":"95735","messageId":"7vod0jfe51.fsf@gitster.siamese.dyndns.org","threadId":"16320","inReplyTo":"37512.N1gUGH5fRhE=.1226613228.squirrel@webmail.hotelhot.dk","subject":"Re: [BUG] git ls-files -m --with-tree does double output","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2008-11-13T22:35:22Z","receivedAt":"2008-11-13T22:35:22Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"Anders Melchiorsen\" <mail@cup.kalibalik.dk> writes:\n\n> and@dylle:~/repo$ git ls-files -m --with-tree=HEAD\n> a\n> a\n>\n>\n> Jeff King added:\n> ...\n> It isn't clear to me which code is _supposed_ to be pulling out such\n> duplicates here. That is, is read_tree broken, or is\n> overlay_tree_on_cache just calling it wrong?\n\nI had to look up what -m meant in ls-files, as I never considered that\noption as part of the plumbing.\n\nWhat's the use case of using -m together with --with-tree to begin with?\nI think the only sensible other option that makes sense with --with-tree\nis --error-unmatch.\n"},{"id":"95736","messageId":"7vk5b7fdxp.fsf@gitster.siamese.dyndns.org","threadId":"16320","inReplyTo":"7vod0jfe51.fsf@gitster.siamese.dyndns.org","subject":"Re: [BUG] git ls-files -m --with-tree does double output","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2008-11-13T22:39:46Z","receivedAt":"2008-11-13T22:39:46Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Junio C Hamano <gitster@pobox.com> writes:\n\n> What's the use case of using -m together with --with-tree to begin with?\n> I think the only sensible other option that makes sense with --with-tree\n> is --error-unmatch.\n\nThe reason I ask this question is that the cleanest fix to the issue might\nturn out to be to forbid that combination of the options, if it turns out\nthat it does not make any sense.\n"},{"id":"95995","messageId":"57320.N1gUGH5fRhE=.1226617873.squirrel@webmail.hotelhot.dk","threadId":"16320","inReplyTo":"7vod0jfe51.fsf@gitster.siamese.dyndns.org","subject":"Re: [BUG] git ls-files -m --with-tree does double output","fromName":"Anders Melchiorsen","fromEmail":"mail@cup.kalibalik.dk","sentAt":"2008-11-13T23:11:13Z","receivedAt":"2008-11-13T23:11:13Z","isPatch":false,"sender":{"key":"mail@cup.kalibalik.dk","avatar":null},"body":"Junio C Hamano wrote:\n\n> What's the use case of using -m together with --with-tree to begin with?\n\nThe script runs\n\n   git ls-files -d -m -o -t --with-tree=HEAD\n\nto get a parseable \"git status\"-like output. If I leave out\n--with-tree=HEAD, I do not get information about staged changes.\n\nI could use \"git diff --name-status HEAD\", but then there was a problem\nabout untracked files, I think.\n\n\nThanks,\nAnders.\n"},{"id":"95929","messageId":"7vr65c3xn5.fsf@gitster.siamese.dyndns.org","threadId":"16320","inReplyTo":"57320.N1gUGH5fRhE=.1226617873.squirrel@webmail.hotelhot.dk","subject":"Re: [BUG] git ls-files -m --with-tree does double output","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2008-11-16T08:03:58Z","receivedAt":"2008-11-16T08:03:58Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"Anders Melchiorsen\" <mail@cup.kalibalik.dk> writes:\n\n> Junio C Hamano wrote:\n>\n>> What's the use case of using -m together with --with-tree to begin with?\n>\n> The script runs\n>\n>    git ls-files -d -m -o -t --with-tree=HEAD\n>\n> to get a parseable \"git status\"-like output. If I leave out\n> --with-tree=HEAD, I do not get information about staged changes.\n\nI think a machine parsable \"status equivalent\" is a good thing to have,\nbut I do not think the internal machinery of ls-files is equipped to do\nthat.  Didn't I send \"here is how you would do it\" patch some time ago, so\nthat interested parties can build on it to do that?\n\nI lack the context to interpret what you mean by \"The script\", but in any\ncase, the only use case --with-tree was designed for was to use it in\nconjunction with --error-unmatch inside the scripted version of \"git\ncommit\", to see if the paths given by the users make sense as a request to\ncreate a partial commit.  It is not entirely surprising if any other funny\noptions do not work with it at all.\n\nHaving said all that, I think this would fix it.\n\n builtin-ls-files.c |    2 ++\n 1 files changed, 2 insertions(+), 0 deletions(-)\n\ndiff --git c/builtin-ls-files.c i/builtin-ls-files.c\nindex b48327d..b28a185 100644\n--- c/builtin-ls-files.c\n+++ i/builtin-ls-files.c\n@@ -227,6 +227,8 @@ static void show_files(struct dir_struct *dir, const char *prefix)\n \t\t\tint dtype = ce_to_dtype(ce);\n \t\t\tif (excluded(dir, ce->name, &dtype) != dir->show_ignored)\n \t\t\t\tcontinue;\n+\t\t\tif (ce->ce_flags & CE_UPDATE)\n+\t\t\t\tcontinue;\n \t\t\terr = lstat(ce->name, &st);\n \t\t\tif (show_deleted && err)\n \t\t\t\tshow_ce_entry(tag_removed, ce);\n"},{"id":"95931","messageId":"58634.N1gUGH5fRhE=.1226826015.squirrel@webmail.hotelhot.dk","threadId":"16320","inReplyTo":"7vr65c3xn5.fsf@gitster.siamese.dyndns.org","subject":"Re: [BUG] git ls-files -m --with-tree does double output","fromName":"Anders Melchiorsen","fromEmail":"mail@cup.kalibalik.dk","sentAt":"2008-11-16T09:00:15Z","receivedAt":"2008-11-16T09:00:15Z","isPatch":false,"sender":{"key":"mail@cup.kalibalik.dk","avatar":null},"body":"Junio C Hamano wrote:\n> \"Anders Melchiorsen\" <mail@cup.kalibalik.dk> writes:\n>\n>> Junio C Hamano wrote:\n>>\n>>> What's the use case of using -m together with --with-tree to begin\n>>> with?\n>>\n>> The script runs\n>>\n>>    git ls-files -d -m -o -t --with-tree=HEAD\n>>\n>> to get a parseable \"git status\"-like output. If I leave out\n>> --with-tree=HEAD, I do not get information about staged changes.\n>\n\n> [...]\n\n> I lack the context to interpret what you mean by \"The script\", but in any\n> case, the only use case --with-tree was designed for was to use it in\n> conjunction with --error-unmatch inside the scripted version of \"git\n> commit\", to see if the paths given by the users make sense as a request to\n> create a partial commit.  It is not entirely surprising if any other funny\n> options do not work with it at all.\n\n\"The script\" is just a random script I was writing when I found this issue.\n\nIf --with-tree is only meant for --error-unmatch, maybe update the help to\nshow it like this,\n\n    [--error-unmatch [--with-tree=<tree-ish>]]\n\nI never read the description of --with-tree, I just found the parameter in\nthe top of the man page and tried it out. It did what I wanted, but gave\ndouble output. And so I reported that in this thread, as I believed it to\nbe an error.\n\nNow I understand that I am using ls-files in unintended ways, but I cannot\nreally fix that when no \"git status\" like plumbing tool is available.\n\n> Having said all that, I think this would fix it.\n\nThat sure seems to fix my test case.\n\n\nAnders.\n"}]}