{"thread":{"id":"61656","subject":"Bug: Git Maintenance does not register multiple repos","startedAt":"2024-06-20T13:16:36Z","lastAt":"2024-06-21T10:10:30Z","messageCount":4,"participants":["Shubham Kanodia","Kristoffer Haugsbakk","Phillip Wood"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"497399","messageId":"CAG=Um+0LXVRHmvKdTB9WHJujjh9agK_ZHdv45ffzMsqX65NLVw@mail.gmail.com","threadId":"61656","inReplyTo":null,"subject":"Bug: Git Maintenance does not register multiple repos","fromName":"Shubham Kanodia","fromEmail":"shubham.kanodia10@gmail.com","sentAt":"2024-06-20T13:15:57Z","receivedAt":"2024-06-20T13:16:36Z","isPatch":false,"sender":{"key":"shubham.kanodia10@gmail.com","avatar":"https://avatars.githubusercontent.com/u/8946207?v=4"},"body":"When I run — `git maintenance register` to register a particular\nrepository for maintenance,\nit appends a new entry to `~/.gitconfig` with the repo name.\n\n```\n[maintenance]\n       repo = /path/to/repo-1\n       repo = /path/to/repo-2\n```\n\nNow, since git uses the INI format for these files, this would imply that\nrepo-2 actually overrides repo 1 for maintenance.\n\nThis implies that a user can only register a single repository on\ntheir system for\nmaintenance.\n\nWhat did you expect to happen? (Expected behavior)\nI expected that multiple repositories on the system could be setup for\nmaintenance using this command.\nWhich would mean, the `repo` filed would be an array.\n\n```\n[maintenance]\n       repo[] = /path/to/repo-1\n       repo[] = /path/to/repo-2\n```\nWhat happened instead? (Actual behavior)\nIt appended an entry with the same key, which would mean only the last\nkey wins, and a user cannot have\nmultiple repos as a part of maintenance.\n\nWhat's different between what you expected and what actually happened?\nMentioned earlier.\n\nAnything else you want to add:\nNo.\n\nPlease review the rest of the bug report below.\nYou can delete any lines you don't wish to share.\n\n\n[System Info]\ngit version:\ngit version 2.39.3 (Apple Git-146)\ncpu: arm64\nno commit associated with this build\nsizeof-long: 8\nsizeof-size_t: 8\nshell-path: /bin/sh\nfeature: fsmonitor--daemon\nuname: Darwin 23.5.0 Darwin Kernel Version 23.5.0: Wed May  1 20:12:58\nPDT 2024; root:xnu-10063.121.3~5/RELEASE_ARM64_T6000 arm64\ncompiler info: clang: 15.0.0 (clang-1500.3.9.4)\nlibc info: no libc information available\n$SHELL (typically, interactive shell): /opt/homebrew/bin/fish\n\n\n[Enabled Hooks]\npost-checkout\npost-commit\npost-merge\npre-push\n"},{"id":"497401","messageId":"665f77a0-f301-40ae-ab94-2920d15fcc8d@app.fastmail.com","threadId":"61656","inReplyTo":"CAG=Um+0LXVRHmvKdTB9WHJujjh9agK_ZHdv45ffzMsqX65NLVw@mail.gmail.com","subject":"Re: Bug: Git Maintenance does not register multiple repos","fromName":"Kristoffer Haugsbakk","fromEmail":"code@khaugsbakk.name","sentAt":"2024-06-20T13:54:00Z","receivedAt":"2024-06-20T13:55:38Z","isPatch":false,"sender":{"key":"code@khaugsbakk.name","avatar":"https://avatars.githubusercontent.com/u/2229597?v=4"},"body":"Hi\n\nOn Thu, Jun 20, 2024, at 15:15, Shubham Kanodia wrote:\n> When I run — `git maintenance register` to register a particular\n> repository for maintenance,\n> it appends a new entry to `~/.gitconfig` with the repo name.\n>\n> ```\n> [maintenance]\n>        repo = /path/to/repo-1\n>        repo = /path/to/repo-2\n> ```\n>\n> Now, since git uses the INI format for these files, this would imply that\n> repo-2 actually overrides repo 1 for maintenance.\n>\n> This implies that a user can only register a single repository on\n> their system for\n> maintenance.\n\nImply? Did you test this? From memory this is a multi-valued config, and\nmulti-valued configs are sometimes listed by using `=` multiple times\nfor the same config variable. That’s also what [this] email says:\n\n  “ The 'git maintenance [un]register' commands set or unset the multi-\n    valued maintenance.repo config key with the absolute path of the\n    current repository. These are set in the global config file.\n\n🔗 this: https://lore.kernel.org/git/5aa9cc1d6b93b5ad3d66ac01a4518a91ced39bcb.1664287021.git.gitgitgadget@gmail.com/\n\nI’ve never seen that git config uses the INI format. I’ve had the\nimpression that it is a bespoke format that simply looks like the INI\nformat. (But is the INI format even standardized?)\n\nI have two repositories registered. When I run this:\n\n```\ngit for-each-repo --config=maintenance.repo maintenance run\n```\n\nWell, it doesn’t tell me what repositories are being manipulated, but I do get two of these lines:\n\n```\nEnumerating objects: […]\n```\n\nSo I surmise that this command is being run twice.\n\n-- \nKristoffer Haugsbakk\n\n"},{"id":"497468","messageId":"4480de3f-851f-4cf7-889f-b5ab7c4e0223@app.fastmail.com","threadId":"61656","inReplyTo":"CAG=Um+1EyB08n7oH6rgqPmmn0OWndUdv4vEsY5Hcv3aaf-BHxg@mail.gmail.com","subject":"Re: Bug: Git Maintenance does not register multiple repos","fromName":"Kristoffer Haugsbakk","fromEmail":"code@khaugsbakk.name","sentAt":"2024-06-21T06:58:08Z","receivedAt":"2024-06-21T06:58:30Z","isPatch":false,"sender":{"key":"code@khaugsbakk.name","avatar":"https://avatars.githubusercontent.com/u/2229597?v=4"},"body":"On Thu, Jun 20, 2024, at 17:34, Shubham Kanodia wrote:\n> I've seen libraries in a few language ecosystems use `ini` parsers for\n> parsing the config file, and there's several blogs (that perhaps\n> incorrectly?) state so, so\n> I assumed that might be true. But you're right in that I don't see it\n> be mentioned on git's official site.\n\nI see no warrant for such an assumption.\n\nIn my experience, plenty of syntaxes are described as like-X”. Java and\nC# are C-like. That doesn’t mean you can use a C parser on those other\nlanguages. Config files are simpler but the same principle applies.\n\n> 1. What spec does the config file follow?\n\nApparently there isn’t a spec because it is bespoke.\n\nhttps://stackoverflow.com/a/68461700/1725151\n\n> 2. What is the correct way then to get an \"effective\" git config\n> value? Typically, I assumed that if a value appeared twice in the git\n> config, the second would override the first (for say, `core.editor`).\n>   How does git parse \"overrides\" vs \"arrays\" if they are defined using\n> the same syntax?\n\nThere are two dimensions\n\n1. How config variables are parsed\n2. What is expected of the specific config variable\n\n`core.editor` is a single value. You can test with\n\n```\n[core]\n\teditor=vim\n\teditor=nano\n```\n\nThe last one wins here. `core.editor` expects a single value.\n\nBut you can define a multi-valued variable\n\n```\n[customsection]\n    mycustomvariable = value1\n    mycustomvariable = value2\n    mycustomvariable = value3\n```\n\n```\n$ git config --global --get-all customsection.mycustomvariable\nvalue1\nvalue2\nvalue3\n```\n\n-- \nKristoffer Haugsbakk\n"},{"id":"497474","messageId":"d0deaa08-2894-4e89-ba51-7bed8e785ef3@gmail.com","threadId":"61656","inReplyTo":"4480de3f-851f-4cf7-889f-b5ab7c4e0223@app.fastmail.com","subject":"Re: Bug: Git Maintenance does not register multiple repos","fromName":"Phillip Wood","fromEmail":"phillip.wood123@gmail.com","sentAt":"2024-06-21T10:10:27Z","receivedAt":"2024-06-21T10:10:30Z","isPatch":false,"sender":{"key":"phillip.wood@dunelm.org.uk","avatar":null},"body":"On 21/06/2024 07:58, Kristoffer Haugsbakk wrote:\n> On Thu, Jun 20, 2024, at 17:34, Shubham Kanodia wrote:\n>> 1. What spec does the config file follow?\n> \n> Apparently there isn’t a spec because it is bespoke.\n\nThe syntax is documented on the \"git config\" man page.\n\n>> 2. What is the correct way then to get an \"effective\" git config\n>> value? Typically, I assumed that if a value appeared twice in the git\n>> config, the second would override the first (for say, `core.editor`).\n>>    How does git parse \"overrides\" vs \"arrays\" if they are defined using\n>> the same syntax?\n> \n> There are two dimensions\n> \n> 1. How config variables are parsed\n> 2. What is expected of the specific config variable\n\nTo expand a little on what Kristoffer has said - this means that you \nneed to know in advance what type of variable you are checking. You can \ndo that by reading the documentation for that variable on the \"git \nconfig\" man page. \"git config\" also offers the --type=<type> option to \nnormalize values to the expected type.\n\nBest Wishes\n\nPhillip\n\n> `core.editor` is a single value. You can test with\n> \n> ```\n> [core]\n> \teditor=vim\n> \teditor=nano\n> ```\n> \n> The last one wins here. `core.editor` expects a single value.\n> \n> But you can define a multi-valued variable\n> \n> ```\n> [customsection]\n>      mycustomvariable = value1\n>      mycustomvariable = value2\n>      mycustomvariable = value3\n> ```\n> \n> ```\n> $ git config --global --get-all customsection.mycustomvariable\n> value1\n> value2\n> value3\n> ```\n> \n\n"}]}