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

Re: [RFC] pre-rebase: Refuse to rewrite commits that are reachable from upstream

From
Johan Herland <johan@herland.net>
Date
Feb 20, 2012, 21:21 UTC
Message-ID
<CALKQrgcY1dVNP0U0NsmDTuZwb6MLNKzmdHxuAb05UmnUcAXf4A@mail.gmail.com>
In-Reply-To
<1329772071-11301-1-git-send-email-johan@herland.net>
On Mon, Feb 20, 2012 at 22:07, Johan Herland <johan@herland.net> wrote:
Show 34 quoted lines
> Teach the pre-rebase sample hook to refuse rewriting commits on a branch
> that are present in that branch's @{upstream}. This is to prevent users
> from rewriting commits that have already been published.
>
> If the branch has no @{upstream}, or the commits-to-be-rebased are not
> reachable from the upstream (hence assumed to be unpublished), the rebase
> is not refused.
>
> This patch is not an ideal solution to the problem, for at least the
> following reasons:
>
>  - There is no way for the user to override this check, except skipping
>   the pre-rebase hook entirely with --no-verify.
>
>  - The check only works for branches with a configured upstream. If the
>   user's workflow does not rely on upstream branches, or uses some other
>   method of publishing commits, the check will produce false negatives
>   (i.e. allow rebases that should have been refused).
>
>  - The check only applies to rebase. I wanted to add the same check
>   on 'commit --amend', but there's no obvious way to detect --amend
>   from within the pre-commit hook.
>
>  - There may be other rewrite scenarios where we want to do this check,
>   such as 'git reset'. Maybe a pre-rewrite hook should be added?
>
>  - Some (including myself) want this check to be performed by default,
>   since it's mostly targeted at newbies that are less likely to enable
>   the pre-rebase (pre-rewrite) hook, so maybe the check should be added
>   to core git instead.
>
> Discussed-with: Jakub Narebski <jnareb@gmail.com>
> Signed-off-by: Johan Herland <johan@herland.net>
> ---

I forgot to explain that this patch is not really submitted for inclusion, but rather to continue the discussion of getting rewrite safety properly implemented in git. As such, the problems noted in the above commit message are probably more important than the patch itself...

Also, this implements only a small subset of what has been discussed regarding 'public' and 'secret' properties of commits in the preceding thread. However, I believe solving this part of the problem (preventing upstreamed commits from being rewritten) will make 90% of users happy, and that it's worth fixing on its own merits.

Have fun! :)
...Johan
-- 
Johan Herland, <johan@herland.net>
www.herland.net
Previous: Johan HerlandNext: Junio C Hamano
Message 23 of 34 in “[RFD] Rewriting safety - warn before/when rewriting published history”
  1. Jakub NarebskiFeb 4, 2012
  2. Ben WaltonFeb 5, 2012
  3. Jakub NarebskiFeb 5, 2012
  4. Steven MichalskeFeb 6, 2012
  5. Johan HerlandFeb 6, 2012
  6. Jakub NarebskiFeb 6, 2012
  7. Steven MichalskeApr 7, 2012
  8. Jakub NarebskiFeb 5, 2012
  9. Johan HerlandFeb 5, 2012
  10. Jakub NarebskiFeb 5, 2012
  11. Johan HerlandFeb 5, 2012
  12. Jakub NarebskiFeb 6, 2012
  13. Johan HerlandFeb 6, 2012
  14. Jakub NarebskiFeb 6, 2012
  15. Johan HerlandFeb 6, 2012
  16. Jakub NarebskiFeb 7, 2012
  17. Johan HerlandFeb 7, 2012
  18. Jakub NarebskiFeb 10, 2012
  19. Philip OakleyFeb 10, 2012
  20. Johan HerlandFeb 11, 2012
  21. Jakub NarebskiFeb 11, 2012
  22. [RFC] pre-rebase: Refuse to rewrite commits that are reachable from upstreamJohan Herland, Feb 20, 2012
  23. Johan HerlandFeb 20, 2012
  24. Junio C HamanoFeb 20, 2012
  25. Johan HerlandFeb 21, 2012
  26. Junio C HamanoFeb 21, 2012
  27. Johan HerlandFeb 21, 2012
  28. Junio C HamanoFeb 21, 2012
  29. Dave ZarzyckiFeb 21, 2012
  30. Jeff KingFeb 22, 2012
  31. Dave ZarzyckiFeb 22, 2012
  32. Steven MichalskeApr 7, 2012
  33. Steven MichalskeApr 7, 2012
  34. Ronan KeryellFeb 7, 2012

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.