{"thread":{"id":"61410","subject":"Combined diff format: Show all filenames by default?","startedAt":"2024-05-03T02:06:49Z","lastAt":"2024-05-03T22:25:48Z","messageCount":5,"participants":["Kang-Che Sung","Junio C Hamano"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"493953","messageId":"CADDzAfNz3R5yj1SdJYbBe0f8m3Sp-R+X6dRpYoJ8Foj6zijcDA@mail.gmail.com","threadId":"61410","inReplyTo":null,"subject":"Combined diff format: Show all filenames by default?","fromName":"Kang-Che Sung","fromEmail":"explorer09@gmail.com","sentAt":"2024-05-03T02:06:37Z","receivedAt":"2024-05-03T02:06:49Z","isPatch":false,"sender":{"key":"explorer09@gmail.com","avatar":null},"body":"Dear Git developers,\n\nI have a humble feature request, perhaps to address a usability\nproblem that annoyed me a lot.\n\nWhen Git shows merge commits, it often present a diff called a\n\"combined diff\" format. The documentation has an example\n(https://git-scm.com/docs/diff-format#_combined_diff_format)\n\n```\ndiff --combined describe.c\nindex fabadb8,cc95eb0..4866510\n--- a/describe.c\n+++ b/describe.c\n@@@ -98,10 -98,8 +98,10 @@@\nreturn (a_date > b_date) ? -1 : (a_date == b_date) ? 0 : 1;\n }\n\n- static void describe(char *arg)\n-static void describe(struct commit *cmit, int last_one)\n++static void describe(char *arg, int last_one)\n {\n+ unsigned char sha1[20];\n+ struct commit *cmit;\nstruct commit_list *list;\nstatic int initialized = 0;\nstruct commit_name *n;\n```\n\nThe from-file/to-file header is my main concern. It shows two lines by default:\n\n```\n--- a/describe.c\n+++ b/describe.c\n```\n\nAlthough the documentation says it allows `--combined-all-paths`\noption to show all N+1 lines:\n\n```\n--- a/file\n--- a/file\n--- a/file\n+++ b/file\n```\n\nWhy isn't this the default? I am requesting it to show the filenames\nof all parent by default, for the line-by-line combined diff format.\n\nMy reason for making it default:\n\n1. When the format is an N-way diff format, we can make it obvious\nthat the comparison is N-way, not two-way, by listing more than two\nfilenames.\n\n2. Even though the duplicated `--- a/file` filename lines might look\nredundant, it's the _number_ of those lines that matters - how many\nfiles are involved in a diff comparison. (In contrast, showing only\ntwo filenames is confusing.)\n\nAs the \"combined diff\" format is likely to last for a long time, it\nwould be good for Git to set a right default for presenting this\nformat.\n\nThank you.\n"},{"id":"494005","messageId":"xmqqmsp7aqoa.fsf@gitster.g","threadId":"61410","inReplyTo":"CADDzAfNz3R5yj1SdJYbBe0f8m3Sp-R+X6dRpYoJ8Foj6zijcDA@mail.gmail.com","subject":"Re: Combined diff format: Show all filenames by default?","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2024-05-03T14:57:57Z","receivedAt":"2024-05-03T14:58:06Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Kang-Che Sung <explorer09@gmail.com> writes:\n\n> My reason for making it default:\n> ...\n> As the \"combined diff\" format is likely to last for a long time, it\n> would be good for Git to set a right default for presenting this\n> format.\n\nAs the format HAS ALREADY lasted for a long time since its\nintroduction in d8f4790e (diff-tree --cc: denser combined diff\noutput for a merge commit., 2006-01-24), it is too late to change\nthe default.\n\nIf a scripted use wants to parse out all the pathnames, it can write\nthe option on the command line just once in the script file and\nforget about it.\n\nFor interactive use, the standard answer is \"you can alias only for\nyourself in ~/.git/config\", but unfortunately, because the alias\nworks at the command level (e.g., an alias that allows \"git lc\" to\nwork as \"git log --cc --combined-all-paths\" can be written), an\noptional behaviour like --combined-all-paths that is shared across a\nfamily of commands (e.g., \"log\" and \"show\" both would benefit) is a\nbit awkward to handle.  \n\nI wonder if introducing an \"aliases for options\" mechanism would\nimprove the situation.  Take an otherwise unused character sequence,\nsay, cccc, and when you say \"git <cmd> --cccc\", pretend as if you\nsaid \"git <cmd> --cc --combined-all-paths\" from the command line.\n\n"},{"id":"494046","messageId":"CADDzAfPbSv00AfzdJ5DZbXM8YjAr=po6Y_1Y0weyw5dvVA6qFg@mail.gmail.com","threadId":"61410","inReplyTo":"xmqqmsp7aqoa.fsf@gitster.g","subject":"Re: Combined diff format: Show all filenames by default?","fromName":"Kang-Che Sung","fromEmail":"explorer09@gmail.com","sentAt":"2024-05-03T19:11:06Z","receivedAt":"2024-05-03T19:11:20Z","isPatch":false,"sender":{"key":"explorer09@gmail.com","avatar":null},"body":"Hello.\n\nOn Fri, May 3, 2024 at 10:57 PM Junio C Hamano <gitster@pobox.com> wrote:\n>\n> Kang-Che Sung <explorer09@gmail.com> writes:\n>\n> > My reason for making it default:\n> > ...\n> > As the \"combined diff\" format is likely to last for a long time, it\n> > would be good for Git to set a right default for presenting this\n> > format.\n>\n> As the format HAS ALREADY lasted for a long time since its\n> introduction in d8f4790e (diff-tree --cc: denser combined diff\n> output for a merge commit., 2006-01-24), it is too late to change\n> the default.\n\nI wonder what things would break if we change the default behavior of this?\n\n> If a scripted use wants to parse out all the pathnames, it can write\n> the option on the command line just once in the script file and\n> forget about it.\n>\n> For interactive use, the standard answer is \"you can alias only for\n> yourself in ~/.git/config\", but unfortunately, because the alias\n> works at the command level (e.g., an alias that allows \"git lc\" to\n> work as \"git log --cc --combined-all-paths\" can be written), an\n> optional behaviour like --combined-all-paths that is shared across a\n> family of commands (e.g., \"log\" and \"show\" both would benefit) is a\n> bit awkward to handle.\n\nWell, I won't expect the default to be changed for uses in scripts or\nGUI frontends. I wish to change the default for interactive, terminal\nuses, so that usability comes in \"out of the box\".\n\nAnd I don't want the \"alias command\" workaround for a few reasons:\n\n1. It seems like the `--combined-all-paths` would also affect the\n\"file-by-file\" diff output (\"git diff-index\", \"git diff-tree\" and\nlike), and I am not requesting to change the default of this one.\n2. The combined diff format is used in many places - including \"git\ndiff\" when there is a conflict, and a \"git show\" of a merge commit\nwhen the merge was not trivial and human merging was involved.\n3. And this diff output style should ideally be a \"git config\" option\nthat users can tweak it for personal preference (including reverting\nto the old, \"`--no-combined-all-paths`\" behavior when needed).\n\nI know there would be compatibility problems with GUIs and scripts if\nwe change the default like this, but the GUIs and scripts should fix\nthem, as git is already able to output three filename header lines for\nthe merge/combined diff. I just request to make it the default.\n"},{"id":"494055","messageId":"xmqqjzka65ry.fsf@gitster.g","threadId":"61410","inReplyTo":"CADDzAfPbSv00AfzdJ5DZbXM8YjAr=po6Y_1Y0weyw5dvVA6qFg@mail.gmail.com","subject":"Re: Combined diff format: Show all filenames by default?","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2024-05-03T19:42:57Z","receivedAt":"2024-05-03T19:42:59Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Kang-Che Sung <explorer09@gmail.com> writes:\n\n>> As the format HAS ALREADY lasted for a long time since its\n>> introduction in d8f4790e (diff-tree --cc: denser combined diff\n>> output for a merge commit., 2006-01-24), it is too late to change\n>> the default.\n>\n> I wonder what things would break if we change the default behavior of this?\n\nHuman users who rarely if ever rename files will start complaining\nfor wasted vertical screen real estates taken by the extra lines.\n\nNothing is broken, and you are proposing to break things.  Be more\ngentle to existing users; \"what would break if we change?\" is an\nabsolutely wrong attitude to approach this.\n\n> Well, I won't expect the default to be changed for uses in scripts or\n> GUI frontends. I wish to change the default for interactive, terminal\n> uses, so that usability comes in \"out of the box\".\n\nHow would a script that is running by interactive users whose\nstandard input and output streams are connected to a terminal adjust\nto sudden change of the default?  The \"git\" invocation in such an\nenvironment would not be able to tell if you typed it or if you\ntyped the name of the script.\n\n"},{"id":"494067","messageId":"CADDzAfN4gXVcqUVdoA12Z+o63JbsTk8zUpNdiVFSFmTFZtrVzg@mail.gmail.com","threadId":"61410","inReplyTo":"xmqqjzka65ry.fsf@gitster.g","subject":"Re: Combined diff format: Show all filenames by default?","fromName":"Kang-Che Sung","fromEmail":"explorer09@gmail.com","sentAt":"2024-05-03T22:25:35Z","receivedAt":"2024-05-03T22:25:48Z","isPatch":false,"sender":{"key":"explorer09@gmail.com","avatar":null},"body":"On Sat, May 4, 2024 at 3:42 AM Junio C Hamano <gitster@pobox.com> wrote:\n>\n> >> As the format HAS ALREADY lasted for a long time since its\n> >> introduction in d8f4790e (diff-tree --cc: denser combined diff\n> >> output for a merge commit., 2006-01-24), it is too late to change\n> >> the default.\n> >\n> > I wonder what things would break if we change the default behavior of this?\n>\n> Human users who rarely if ever rename files will start complaining\n> for wasted vertical screen real estates taken by the extra lines.\n>\n> Nothing is broken, and you are proposing to break things.  Be more\n> gentle to existing users; \"what would break if we change?\" is an\n> absolutely wrong attitude to approach this.\n\nI would disagree with this.\n\n1. Most uses of diff command are on a scrollable terminal screen (with\n\"less\", \"vi\", or another text editor). It's just one line of vertical\nscreen taken - very subtle unless you have 4-way or more diffs. And\nit's not just about renames. It's a much easier indicator that the\ndiff is a multi-way comparison.\n2. It's a usability problem - like an Ok/Cancel dialog that took years\nto realize they are badly designed. I consider the two filename only\nheader lines a \"paper cut\" usability bug. Git is able to output more\nthan two filenames; it just doesn't have a way to make it the default\n(even as a per-user default option).\n\n>\n> > Well, I won't expect the default to be changed for uses in scripts or\n> > GUI frontends. I wish to change the default for interactive, terminal\n> > uses, so that usability comes in \"out of the box\".\n>\n> How would a script that is running by interactive users whose\n> standard input and output streams are connected to a terminal adjust\n> to sudden change of the default?  The \"git\" invocation in such an\n> environment would not be able to tell if you typed it or if you\n> typed the name of the script.\n>\n\nHow is it _not_ possible to tell? If user runs \"git diff\" from the\nscript, then it would just print to standard output without running a\n\"less\" pager. If I want to execute a set of commands with\ninteractivity, I would write a script and then \"source my-script-name\"\nrather than \"./my-script-name\", so it's still possible to tell.\n"}]}