{"thread":{"id":"58286","subject":"Bug: Git-Alias is callable from outside a git repo","startedAt":"2022-08-10T17:03:35Z","lastAt":"2022-08-12T21:09:33Z","messageCount":3,"participants":["Niklas","rsbecker@nexbridge.com","Johannes Schindelin"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"461006","messageId":"20220810170319.mxd6h2p5tm6y5xx3@imap.mailbox.org","threadId":"58286","inReplyTo":null,"subject":"Bug: Git-Alias is callable from outside a git repo","fromName":"Niklas","fromEmail":"git@nwuensche.com","sentAt":"2022-08-10T17:03:19Z","receivedAt":"2022-08-10T17:03:35Z","isPatch":false,"sender":{"key":"git@nwuensche.com","avatar":null},"body":"Steps to reproduce:\n\n1. Having the following global .gitconfig\n\n[alias]\n     f = \"!echo \"test\"\"\n\n2. Calling `git f` in a folder which does not belong to a git repo\n\nExpected Behavior: \n\nSeeing some message like like\n`fatal: not a git repository (or any parent up to mount point /)`\n\nActual Behavior:\n\nPrints \"test\"\n\nGit 2.37.1 under Arch Linux\n"},{"id":"461019","messageId":"000c01d8aced$6f67f460$4e37dd20$@nexbridge.com","threadId":"58286","inReplyTo":"20220810170319.mxd6h2p5tm6y5xx3@imap.mailbox.org","subject":"RE: Git-Alias is callable from outside a git repo","fromName":"","fromEmail":"rsbecker@nexbridge.com","sentAt":"2022-08-10T19:14:32Z","receivedAt":"2022-08-10T19:14:56Z","isPatch":false,"sender":{"key":"randall.becker@nexbridge.ca","avatar":"https://avatars.githubusercontent.com/u/28956764?v=4"},"body":"On August 10, 2022 1:03 PM, Niklas wrote:\n>Steps to reproduce:\n>\n>1. Having the following global .gitconfig\n>\n>[alias]\n>     f = \"!echo \"test\"\"\n>\n>2. Calling `git f` in a folder which does not belong to a git repo\n>\n>Expected Behavior:\n>\n>Seeing some message like like\n>`fatal: not a git repository (or any parent up to mount point /)`\n>\n>Actual Behavior:\n>\n>Prints \"test\"\n>\n>Git 2.37.1 under Arch Linux\n\nI do not think this is a bug. There are git commands that do not require\nrepositories, like git version. Git has know knowledge of what your alias is\ngoing to do without executing it. If your alias wanted to run git version or\ngit hash-object, it would not need a repository to do so.\n--Randall\n\n"},{"id":"461153","messageId":"s08qq38q-26po-r066-soo3-po7165167s31@tzk.qr","threadId":"58286","inReplyTo":"20220810170319.mxd6h2p5tm6y5xx3@imap.mailbox.org","subject":"Re: Bug: Git-Alias is callable from outside a git repo","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2022-08-12T21:09:04Z","receivedAt":"2022-08-12T21:09:33Z","isPatch":false,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi Niklas,\n\nOn Wed, 10 Aug 2022, Niklas wrote:\n\n> Steps to reproduce:\n>\n> 1. Having the following global .gitconfig\n>\n> [alias]\n>     f = \"!echo \"test\"\"\n\nThat quoting is a big bogus.\n\n>\n> 2. Calling `git f` in a folder which does not belong to a git repo\n>\n> Expected Behavior:\n> Seeing some message like like\n> `fatal: not a git repository (or any parent up to mount point /)`\n>\n> Actual Behavior:\n>\n> Prints \"test\"\n\nThis is by design, and definitely not a bug. It even allows you to build\nrelatively complex aliases that work on multiple worktrees, or even no\nworktree at all.\n\nWhy would a Git alias have to be bound to any specific Git repository?\n\nCiao,\nJohannes\n"}]}