git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Phillip Wood <phillip.wood123@gmail.com>
To: Junio C Hamano <gitster@pobox.com>,
	Wesley Schwengle <wesleys@opperschaap.net>
Cc: git@vger.kernel.org
Subject: Re: [PATCH v2 2/3] builtin/rebase.c: Emit warning when rebasing without a forkpoint
Date: Mon, 4 Sep 2023 11:16:28 +0100	[thread overview]
Message-ID: <d9710161-ddb8-4b0a-9729-6b54cd56427d@gmail.com> (raw)
In-Reply-To: <xmqqlednuagl.fsf@gitster.g>

On 03/09/2023 05:50, Junio C Hamano wrote:
> Junio C Hamano <gitster@pobox.com> writes:
> 
>> If you rewind to lose commits from the branch you are (re)building
>> against, and what was rewound and discarded was part of the work you
>> are building, whether it is on a local branch or on a remote branch
>> that contains what you have already pushed, they will be discarded,
>> it is by design, and it is a known deficiency with the fork-point
>> heuristics.  How the fork-point heuristics breaks down is rather
>> well known ...
> 
> Another tangent, this time very closely related to this topic, is
> that it may be worth warning when the fork-point heuristics chooses
> the base commit that is different from the original upstream,
> regardless of how we ended up using fork-point heuristics.

I think that is a good idea and would help to mitigate the surprise that 
some users have expressed when --fork-point kicks and they didn't know 
about it. I think we may want to compare "branch_base" which holds the 
merge-base of HEAD and upstream with "restrict_revision" to decide when 
to warn.

Best Wishes

Phillip

> Experienced users may not be confused when the heuristics kicks in
> and when it does not (e.g. because they configured, because they
> used the "lazy" form, or because they gave "--fork-point" from the
> command line explicitly), but they still may get surprising results
> if a reflog entry chosen to be used as the base by the heuristics is
> not what they expected to be used, and can lose their work that way.
> Imagine that you pushed your work to the remote that is a shared
> repository, and then continued building on top of it, while others
> rewound the remote branch to eject your work, and your "git fetch"
> updated the remote-tracking branch.  You'll be pretty much in the
> same situation you had in your reproduction recipe that rewound your
> own local branch that you used to build your derived work on and
> would lose your work the same way, if you do not notice that the
> remote branch has been rewound (and the fork-point heuristics chose
> a "wrong" commit from the reflog of your remote-tracking branch.
> 
> Perhaps something along the lines of this (not even compile tested,
> though)...  It might even be useful to show a shortlog between the
> .restrict_revision and .upstream, which is the list of commits that
> is potentially lost, but that might turn out to be excessively loud
> and noisy in the workflow of those who do benefit from the
> fork-point heuristics because their project rewinds branches too
> often and too wildly for them to manually keep track of.  I dunno.
> 
> 
>   builtin/rebase.c | 8 +++++++-
>   1 file changed, 7 insertions(+), 1 deletion(-)
> 
> diff --git c/builtin/rebase.c w/builtin/rebase.c
> index 50cb85751f..432a97e205 100644
> --- c/builtin/rebase.c
> +++ w/builtin/rebase.c
> @@ -1721,9 +1721,15 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
>   	if (keep_base && options.reapply_cherry_picks)
>   		options.upstream = options.onto;
>   
> -	if (options.fork_point > 0)
> +	if (options.fork_point > 0) {
>   		options.restrict_revision =
>   			get_fork_point(options.upstream_name, options.orig_head);
> +		if (options.restrict_revision &&
> +		    options.restrict_revision != options.upstream)
> +			warning(_("fork-point heuristics using %s from the reflog of %s"),
> +				oid_to_hex(&options.restrict_revision->object.oid),
> +				options.upstream_name);
> +	}
>   
>   	if (repo_read_index(the_repository) < 0)
>   		die(_("could not read index"));
> 


  parent reply	other threads:[~2023-09-04 10:16 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-08-19 20:34 [PATCH 1/2] builtin/rebase.c: Emit warning when rebasing without a forkpoint Wesley Schwengle
2023-08-19 20:34 ` Wesley Schwengle
2023-08-31 20:57   ` Junio C Hamano
2023-08-31 21:52     ` Junio C Hamano
2023-09-01 13:33       ` Phillip Wood
2023-09-01 16:48         ` Junio C Hamano
2023-09-02 22:16       ` [PATCH v2] " Wesley Schwengle
2023-09-02 22:16         ` [PATCH v2 1/3] rebase.c: Make a distiction between rebase.forkpoint and --fork-point arguments Wesley Schwengle
2023-09-02 22:16         ` [PATCH v2 2/3] builtin/rebase.c: Emit warning when rebasing without a forkpoint Wesley Schwengle
2023-09-02 23:37           ` Junio C Hamano
2023-09-03  2:29             ` Wesley
2023-09-03  4:50             ` Junio C Hamano
2023-09-03 12:34               ` Wesley Schwengle
2023-09-05 22:01                 ` Junio C Hamano
2023-09-04 10:16               ` Phillip Wood [this message]
2023-09-02 22:16         ` [PATCH v2 3/3] git-rebase.txt: Add deprecation notice to the --fork-point options Wesley Schwengle
2023-09-01 13:19   ` [PATCH 1/2] builtin/rebase.c: Emit warning when rebasing without a forkpoint Phillip Wood
2023-09-01 17:13     ` Wesley
2023-09-01 18:10       ` Junio C Hamano
2023-09-02  1:35         ` Wesley
2023-09-02 22:36           ` Junio C Hamano
2023-08-19 20:34 ` [PATCH 2/2] git-rebase.txt: Add deprecation notice to the --fork-point options Wesley Schwengle
2023-08-31 14:44 ` [PATCH 1/2] builtin/rebase.c: Emit warning when rebasing without a forkpoint Wesley Schwengle

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=d9710161-ddb8-4b0a-9729-6b54cd56427d@gmail.com \
    --to=phillip.wood123@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=phillip.wood@dunelm.org.uk \
    --cc=wesleys@opperschaap.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).