git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: Would a config var for --force-with-lease be useful?

From
Junio C Hamano <gitster@pobox.com>
Date
Aug 27, 2018, 22:29 UTC
Message-ID
<xmqqd0u3igtu.fsf@gitster-ct.c.googlers.com>
In-Reply-To
<87k1obee0f.fsf@evledraar.gmail.com>
Ævar Arnfjörð Bjarmason <avarab@gmail.com> writes:
> I.e. making plain --force-with-lease harder to use by hiding it behind a
> config option gives the user fewer options than with --force to recover.

I agree with that. But I would consider it a good thing, if done properly (i.e. suggest --force-with-lease that is not a lzzy form).

Show 8 quoted lines
> So I think we should still recommend the longer and even safer variants
> of --force-with-lease, but being guaranteed to have the SHA-1 you just
> clobbered locally is *better*, and allows us to e.g. do this:
>
>     $ git push --force-with-lease
>     hint: You just clobbered <X> on <remote with <Y>. If you regret
>     hint: this you can (until the object gets pruned) do:
>     hint:     git push <remote> --force-with-lease=<refname>:<Y>

Until the object gets pruned, and until somebody else pushes there to make the damage bigger, you can recover from a mistake with that information. It probably is a bug that the lazy force-with-lease does not report what the remote tip you just overwrote was, and this would help great deal. It would be a good place to start.

One thing that I am still not clear how this line of thought truly would help users is how to help them decide their answer to "If you regret this". An unthinking naïve user would say "of course I meant it when I gave the option---why do you think I regret it?" without a bit more hint, namely, "<Y> was taken from the remote tracking branch, are you sure that is still what the newly prepared contents you built to replace? Did somebody clobber it while you are not watching?"

These three lines however will be felt too loud by those who would most benefit from them (i.e. those who do not know why they need protection); I do not think advise.* to allow them to be squelched would be appropriate.

Previous: Ævar Arnfjörð Bjarmason
Message 9 of 9 in “Would a config var for --force-with-lease be useful?”
  1. Scott JohnsonAug 24, 2018
  2. Constantin WeißerAug 25, 2018
  3. Johannes SchindelinAug 27, 2018
  4. Phillip WoodAug 28, 2018
  5. Junio C HamanoAug 27, 2018
  6. Ævar Arnfjörð BjarmasonAug 27, 2018
  7. Junio C HamanoAug 27, 2018
  8. Ævar Arnfjörð BjarmasonAug 27, 2018
  9. Junio C HamanoAug 27, 2018

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.