{"thread":{"id":"63392","subject":"[Bug?] \"git show -s\" still worries about renameLimit?","startedAt":"2025-05-04T08:00:18Z","lastAt":"2025-05-04T08:27:17Z","messageCount":2,"participants":["Junio C Hamano","Jeff King"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"517185","messageId":"xmqq8qncst4f.fsf@gitster.g","threadId":"63392","inReplyTo":null,"subject":"[Bug?] \"git show -s\" still worries about renameLimit?","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2025-05-04T08:00:16Z","receivedAt":"2025-05-04T08:00:18Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"$ git show -s | cat\nwarning: exhaustive rename detection was skipped due to too many files.\nwarning: you may want to set your diff.renameLimit variable to at least 6123 and retry the command.\ncommit a3a9dd8be6b8767e690b014715aefa2ba39672e2 (HEAD -> master)\nAuthor: Junio C Hamano <gitster@pobox.com>\nDate:   Sat Apr 19 14:27:03 2025 -0700\n\n    Something something something\n\nAs we have -M (rename detection) on by default these days, and this\nparticular commit has very many deletions and creations, if we were\nasking to show some diff (not necessarily patch text output, but\njust \"--stat\" or even \"--raw\") it is fair to warn about rename\ndetection being limited by diff.renameLimit.\n\nBut the command knows that with \"-s\" the user declined to show any\ndiff computation, so it feels wrong to even _count_ how many\ndiff_filepairs there are and comparing with the renameLimit, in\norder to warn about busting the limit.\n\n"},{"id":"517187","messageId":"20250504082715.GA6257@coredump.intra.peff.net","threadId":"63392","inReplyTo":"xmqq8qncst4f.fsf@gitster.g","subject":"Re: [Bug?] \"git show -s\" still worries about renameLimit?","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2025-05-04T08:27:15Z","receivedAt":"2025-05-04T08:27:17Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Sun, May 04, 2025 at 01:00:16AM -0700, Junio C Hamano wrote:\n\n> $ git show -s | cat\n> warning: exhaustive rename detection was skipped due to too many files.\n> warning: you may want to set your diff.renameLimit variable to at least 6123 and retry the command.\n> commit a3a9dd8be6b8767e690b014715aefa2ba39672e2 (HEAD -> master)\n> Author: Junio C Hamano <gitster@pobox.com>\n> Date:   Sat Apr 19 14:27:03 2025 -0700\n> \n>     Something something something\n> \n> As we have -M (rename detection) on by default these days, and this\n> particular commit has very many deletions and creations, if we were\n> asking to show some diff (not necessarily patch text output, but\n> just \"--stat\" or even \"--raw\") it is fair to warn about rename\n> detection being limited by diff.renameLimit.\n> \n> But the command knows that with \"-s\" the user declined to show any\n> diff computation, so it feels wrong to even _count_ how many\n> diff_filepairs there are and comparing with the renameLimit, in\n> order to warn about busting the limit.\n\nThis seemed eerily familiar. See this thread:\n\n  https://lore.kernel.org/git/87h750q1b9.fsf@gnu.org/\n\nand in particular this proposal:\n\n  https://lore.kernel.org/git/YqI%2FTcZyXomxtXtN@coredump.intra.peff.net/\n\nI've been carrying that patch in my tree (reproduced below), but I don't\nremember why I never polished it. I wonder if it was the question about\n--exit-code below. Or maybe I was just nervous about other corner cases.\n\n-- >8 --\nSubject: [PATCH] show: skip diff when possible\n\nRunning:\n\n  git show -s $commit\n\nwill still compute a diff for $commit, even though we aren't going to\nshow it. This is wasted computation, since it cannot affect the output\nor exit code of the program.\n\nIn the more general case:\n\n  - if the requested diff format is NO_OUTPUT, then we won't change the\n    output of the diff itself\n\n  - if rev_info.always_show_header is set, then we will show the commit\n    regardless of whether the diff is empty (which is true for git-show,\n    for example, but not git-log)\n\n  - we don't use --exit-code here (should check?)\n\nSigned-off-by: Jeff King <peff@peff.net>\n---\n log-tree.c | 4 ++++\n 1 file changed, 4 insertions(+)\n\ndiff --git a/log-tree.c b/log-tree.c\nindex a4d4ab59ca..740219ce99 100644\n--- a/log-tree.c\n+++ b/log-tree.c\n@@ -1105,6 +1105,10 @@ static int log_tree_diff(struct rev_info *opt, struct commit *commit, struct log\n \tif (!all_need_diff && !opt->merges_need_diff)\n \t\treturn 0;\n \n+\tif (opt->diffopt.output_format == DIFF_FORMAT_NO_OUTPUT &&\n+\t    opt->always_show_header)\n+\t\treturn 0;\n+\n \tparse_commit_or_die(commit);\n \toid = get_commit_tree_oid(commit);\n \n-- \n2.49.0.754.gd827f9aa09\n\n"}]}