{"thread":{"id":"61309","subject":"Short form of --force-with-lease","startedAt":"2024-04-11T17:16:37Z","lastAt":"2024-04-12T09:00:44Z","messageCount":7,"participants":["Wyatt Carpenter","Kipras Melnikovas","rsbecker@nexbridge.com","Kyle Lippincott","Junio C Hamano"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"492787","messageId":"CADwVmK293eQ5VFkn-J68tXQ=64u3H79ScMW7H_ukSmtwLwA4wA@mail.gmail.com","threadId":"61309","inReplyTo":null,"subject":"Short form of --force-with-lease","fromName":"Wyatt Carpenter","fromEmail":"wyattscarpenter@gmail.com","sentAt":"2024-04-11T17:16:26Z","receivedAt":"2024-04-11T17:16:37Z","isPatch":false,"sender":{"key":"wyattscarpenter@gmail.com","avatar":null},"body":"I often use git push --force-with-lease; it does exactly what I need.\nIs there a short form of the flag, like -f is for --force? If not, I\nwould like to propose -l be added as one. I don't believe git push has\nan -l flag currently, and l is of course the first letter of lease.\n"},{"id":"492788","messageId":"20240411173639.81152-2-kipras@kipras.org","threadId":"61309","inReplyTo":"CADwVmK293eQ5VFkn-J68tXQ=64u3H79ScMW7H_ukSmtwLwA4wA@mail.gmail.com","subject":"Re: Short form of --force-with-lease","fromName":"Kipras Melnikovas","fromEmail":"kipras@kipras.org","sentAt":"2024-04-11T17:36:40Z","receivedAt":"2024-04-11T17:36:52Z","isPatch":false,"sender":{"key":"kipras@kipras.org","avatar":"https://avatars.githubusercontent.com/u/29430509?v=4"},"body":"I have also thought about this.\n\nI'd suggest a config option \"push.forceFlagBehavior\" that would allow to\nconfigure the behavior, one of:\n- \"default\" / \"overwrite\", which is currently -f,\n- \"lease\" for --force-with-lease,\n- \"lease-includes\"  for --force-with-lease --force-if-includes,\n- possibly others.\n\nThen, upon `git push -f`, the config option would be consulted to determine the\nbehavior.\n\nTo get the default behavior, `-f -f` or `-F` could be used.\n\n"},{"id":"492797","messageId":"01e101da8c45$66d33240$347996c0$@nexbridge.com","threadId":"61309","inReplyTo":"20240411173639.81152-2-kipras@kipras.org","subject":"RE: Short form of --force-with-lease","fromName":"","fromEmail":"rsbecker@nexbridge.com","sentAt":"2024-04-11T19:21:00Z","receivedAt":"2024-04-11T19:21:18Z","isPatch":false,"sender":{"key":"randall.becker@nexbridge.ca","avatar":"https://avatars.githubusercontent.com/u/28956764?v=4"},"body":"On Thursday, April 11, 2024 1:37 PM, Kipras Melnikovas wrote:\n>I'd suggest a config option \"push.forceFlagBehavior\" that would allow to\nconfigure\n>the behavior, one of:\n>- \"default\" / \"overwrite\", which is currently -f,\n>- \"lease\" for --force-with-lease,\n>- \"lease-includes\"  for --force-with-lease --force-if-includes,\n>- possibly others.\n>\n>Then, upon `git push -f`, the config option would be consulted to determine\nthe\n>behavior.\n>\n>To get the default behavior, `-f -f` or `-F` could be used.\n\nIf this is mostly about saving typing, you could get a similar effect adding\nan alias. Something like\n\ngit config --global alias.pushfl 'push --force-with-lease'\n\n"},{"id":"492802","messageId":"20240411203225.82557-2-kipras@kipras.org","threadId":"61309","inReplyTo":"01e101da8c45$66d33240$347996c0$@nexbridge.com","subject":"Re: Short form of --force-with-lease","fromName":"Kipras Melnikovas","fromEmail":"kipras@kipras.org","sentAt":"2024-04-11T20:32:26Z","receivedAt":"2024-04-11T20:33:54Z","isPatch":false,"sender":{"key":"kipras@kipras.org","avatar":"https://avatars.githubusercontent.com/u/29430509?v=4"},"body":"> If this is mostly about saving typing, you could get a similar effect adding\n> an alias. Something like\n> \n> git config --global alias.pushfl 'push --force-with-lease'\n\nCorrect, and I already have an alias:\n'pf = push --force-with-lease --force-if-includes'.\n\nHowever, I see the config option more valuable - it would protect against\naccidental `push -f`, which, out of habit, is very probable to run on accident.\nWith the config option, would feel safe and wouldn't need the alias either.\n\nThanks.\n\n"},{"id":"492803","messageId":"CAO_smVhB0QUomdSxGqwvFKrb53NGMZE+y=3zbRnQX+ciLRZyOw@mail.gmail.com","threadId":"61309","inReplyTo":"20240411203225.82557-2-kipras@kipras.org","subject":"Re: Short form of --force-with-lease","fromName":"Kyle Lippincott","fromEmail":"spectral@google.com","sentAt":"2024-04-11T20:58:25Z","receivedAt":"2024-04-11T20:58:43Z","isPatch":false,"sender":{"key":"spectral@google.com","avatar":"https://avatars.githubusercontent.com/u/6371650?v=4"},"body":"On Thu, Apr 11, 2024 at 1:34 PM Kipras Melnikovas <kipras@kipras.org> wrote:\n>\n> > If this is mostly about saving typing, you could get a similar effect adding\n> > an alias. Something like\n> >\n> > git config --global alias.pushfl 'push --force-with-lease'\n>\n> Correct, and I already have an alias:\n> 'pf = push --force-with-lease --force-if-includes'.\n>\n> However, I see the config option more valuable - it would protect against\n> accidental `push -f`, which, out of habit, is very probable to run on accident.\n> With the config option, would feel safe and wouldn't need the alias either.\n\nIt would normalize the use of `push -f` in people's muscle memory,\nwhich would be a potential disaster if someone lost their\nconfiguration, but not this muscle memory. It also would break\nautomation/scripts - `git push` is likely used by both humans and\nautomation (custom one-off automation like a personal script, or\nautomation shared by many people) - if they're expecting `git push -f`\nto do the legacy behavior, then it'll break things if the meaning of\n`-f` changes. A separate flag (or just using an alias if it's for\nsaving typing) would be safer.\n\n>\n> Thanks.\n>\n>\n"},{"id":"492807","messageId":"xmqq7ch3r3i3.fsf@gitster.g","threadId":"61309","inReplyTo":"01e101da8c45$66d33240$347996c0$@nexbridge.com","subject":"Re: Short form of --force-with-lease","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2024-04-11T21:30:44Z","receivedAt":"2024-04-11T21:30:50Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"<rsbecker@nexbridge.com> writes:\n\n> If this is mostly about saving typing, you could get a similar effect adding\n> an alias. Something like\n>\n> git config --global alias.pushfl 'push --force-with-lease'\n\nThe use of --force-with-lease without specifying which commit you\ntook lease on is not all that safe [*], so I am not sure how useful\nsuch an alias will be.\n\nConfiguring how \"--force\" behaves and changing it to an unadorned\n\"--force-with-lease\" is to promote a not-so-safe feature as if it is\nsafe with false sense of safety, which is not something we would\nwant to do.\n\n\n[Footnote]\n\n * This of course highly depends on your workflow and third-party\n   companion tools.  If you (or your IDE in the background) fetch\n   from the remote after you started working on the commit to be\n   force-pushed, it would update the tip of the remote-tracking\n   branch, making --force-with-lease base its decision on a wrong\n   commit that your work is not based on.\n"},{"id":"492856","messageId":"20240412090035.87612-2-kipras@kipras.org","threadId":"61309","inReplyTo":"CAO_smVhB0QUomdSxGqwvFKrb53NGMZE+y=3zbRnQX+ciLRZyOw@mail.gmail.com","subject":"Re: Short form of --force-with-lease","fromName":"Kipras Melnikovas","fromEmail":"kipras@kipras.org","sentAt":"2024-04-12T09:00:36Z","receivedAt":"2024-04-12T09:00:44Z","isPatch":false,"sender":{"key":"kipras@kipras.org","avatar":"https://avatars.githubusercontent.com/u/29430509?v=4"},"body":"> > > If this is mostly about saving typing, you could get a similar effect adding\n> > > an alias. Something like\n> > >\n> > > git config --global alias.pushfl 'push --force-with-lease'\n> >\n> > Correct, and I already have an alias:\n> > 'pf = push --force-with-lease --force-if-includes'.\n> >\n> > However, I see the config option more valuable - it would protect against\n> > accidental `push -f`, which, out of habit, is very probable to run on accident.\n> > With the config option, would feel safe and wouldn't need the alias either.\n> \n> It would normalize the use of `push -f` in people's muscle memory,\n> which would be a potential disaster if someone lost their\n> configuration, but not this muscle memory. It also would break\n> automation/scripts - `git push` is likely used by both humans and\n> automation <...>. A separate flag (or just using an alias if it's for\n> saving typing) would be safer.\n\nFair point, I retract my config option proposal.\nA separate flag, as proposed by OP, would make more sense. Thanks.\n\n"}]}