{"thread":{"id":"30643","subject":"Alphabetize git config --list","startedAt":"2012-05-28T20:58:28Z","lastAt":"2012-05-29T08:49:40Z","messageCount":4,"participants":["Zach","Jeff King","Michael Haggerty"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"192400","messageId":"CAFus=5=cp62hpLM_Odog--Q0vER8kkT5Doqo28i-yZQyfvv4gQ@mail.gmail.com","threadId":"30643","inReplyTo":null,"subject":"Alphabetize git config --list","fromName":"Zach","fromEmail":"zach@letmesearchthat.com","sentAt":"2012-05-28T20:58:28Z","receivedAt":"2012-05-28T20:58:28Z","isPatch":false,"sender":{"key":"zach@letmesearchthat.com","avatar":null},"body":"I was wondering if it would be possible to alphabetically order git\nconfig --list by default.\n\nEssentially this\n$ git config --list | sort\n"},{"id":"192401","messageId":"20120528212309.GA4220@sigill.intra.peff.net","threadId":"30643","inReplyTo":"CAFus=5=cp62hpLM_Odog--Q0vER8kkT5Doqo28i-yZQyfvv4gQ@mail.gmail.com","subject":"Re: Alphabetize git config --list","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2012-05-28T21:23:09Z","receivedAt":"2012-05-28T21:23:09Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Mon, May 28, 2012 at 01:58:28PM -0700, Zach wrote:\n\n> I was wondering if it would be possible to alphabetically order git\n> config --list by default.\n> \n> Essentially this\n> $ git config --list | sort\n\nNo, it's not a good idea; the order of keys is important. For example,\nthis config:\n\n  [color]\n    ui = true\n    ui = false\n\nis different than this:\n\n  [color]\n    ui = false\n    ui = true\n\nWhile that seems like a contrived example, consider something like a\n.git/config repo-specific config file overriding a user-wide\n~/.gitconfig file. We do it by overwriting the old key.\n\nThere are also some \"multi\" values which accept multiple entries to\ncreate a list, and the list order may be relevant (I'd have to check,\nthough; the only one that comes to mind is refspecs, and I don't know\nthat order matters there).\n\n-Peff\n"},{"id":"192408","messageId":"4FC45CEB.4070808@alum.mit.edu","threadId":"30643","inReplyTo":"20120528212309.GA4220@sigill.intra.peff.net","subject":"Re: Alphabetize git config --list","fromName":"Michael Haggerty","fromEmail":"mhagger@alum.mit.edu","sentAt":"2012-05-29T05:21:47Z","receivedAt":"2012-05-29T05:21:47Z","isPatch":false,"sender":{"key":"mhagger@alum.mit.edu","avatar":"https://avatars.githubusercontent.com/u/119718?v=4"},"body":"On 05/28/2012 11:23 PM, Jeff King wrote:\n> On Mon, May 28, 2012 at 01:58:28PM -0700, Zach wrote:\n>\n>> I was wondering if it would be possible to alphabetically order git\n>> config --list by default.\n>>\n>> Essentially this\n>> $ git config --list | sort\n>\n> No, it's not a good idea; the order of keys is important. For example,\n> [...]\n\nIs the order of *keys* important, or only the order of *values* for a \ngiven key?  I believe that one could sort the output by key as long as \nthe values for each key are kept in their original order (i.e., sort \nstably by key).  This would indeed make it easier to read the output.\n\nMichael\n\n-- \nMichael Haggerty\nmhagger@alum.mit.edu\nhttp://softwareswirl.blogspot.com/\n"},{"id":"192409","messageId":"20120529084940.GA15145@sigill.intra.peff.net","threadId":"30643","inReplyTo":"4FC45CEB.4070808@alum.mit.edu","subject":"Re: Alphabetize git config --list","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2012-05-29T08:49:40Z","receivedAt":"2012-05-29T08:49:40Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Tue, May 29, 2012 at 07:21:47AM +0200, Michael Haggerty wrote:\n\n> >>Essentially this\n> >>$ git config --list | sort\n> >\n> >No, it's not a good idea; the order of keys is important. For example,\n> >[...]\n> \n> Is the order of *keys* important, or only the order of *values* for a\n> given key?  I believe that one could sort the output by key as long\n> as the values for each key are kept in their original order (i.e.,\n> sort stably by key).  This would indeed make it easier to read the\n> output.\n\nGood question. I was thinking of the order of values, but you're right\nthat a stable key-only sort would handle that.\n\nIn general, keys are independent, but there are two exceptions I can\nthink of:\n\n  1. We sometimes have aliased keys that get parsed to the same memory\n     location (usually this is to maintain backwards compatibility when\n     a key is renamed, or wants to grow incompatible features). For\n     example, \"diff.color\" and \"color.diff\" override each other, and\n     their order is important. Also, \"diff.funcname\" and \"diff.xfuncname\".\n     There may also be others.\n\n  2. Keys which involve pattern matching. The url.*.insteadOf keys seem\n     to be order-independent, as they the longest match is used, not the\n     first. The credential context-matching code takes all matches\n     (though technically, things like the order in which helpers are\n     called would be changed by a sort). I can't think of any others\n     offhand.\n\nSo yes, I think the key order does matter, though only in a few corner\ncases.\n\n-Peff\n"}]}