Re: [PATCH v2] advice: add stashBeforeCheckout advice for dirty branch switches
- From
Patrick Steinhardt <ps@pks.im>
- Date
- Mar 10, 2026, 14:24 UTC
- Message-ID
- <abApu_JDG4im9vwT@pks.im>
- In-Reply-To
- <CAOAgETMe_yGyuaV4Eo9WDNYBa+eG-SEYDTCDoV45itNh_TE_GA@mail.gmail.com>
On Tue, Mar 10, 2026 at 07:06:39PM +0530, Arsh Srivastava wrote:
Show 29 quoted lines
> On Tue, 10 Mar 2026 at 18:46, Patrick Steinhardt <ps@pks.im> wrote:
> > On Tue, Mar 10, 2026 at 10:59:24AM +0000, Arsh Srivastava via GitGitGadget wrote:
> > > diff --git a/advice.c b/advice.c
> > > index 0018501b7b..e1264f525c 100644
> > > --- a/advice.c
> > > +++ b/advice.c
> > > @@ -81,6 +81,7 @@ static struct {
> > > [ADVICE_SET_UPSTREAM_FAILURE] = { "setUpstreamFailure" },
> > > [ADVICE_SKIPPED_CHERRY_PICKS] = { "skippedCherryPicks" },
> > > [ADVICE_SPARSE_INDEX_EXPANDED] = { "sparseIndexExpanded" },
> > > + [ADVICE_STASH_BEFORE_CHECKOUT] = { "stashBeforeCheckout" },
> > > [ADVICE_STATUS_AHEAD_BEHIND_WARNING] = { "statusAheadBehindWarning" },
> > > [ADVICE_STATUS_HINTS] = { "statusHints" },
> > > [ADVICE_STATUS_U_OPTION] = { "statusUoption" },
> > > @@ -312,3 +313,29 @@ void advise_on_moving_dirty_path(struct string_list *pathspec_list)
> > > "* Use \"git add --sparse <paths>\" to update the index\n"
> > > "* Use \"git sparse-checkout reapply\" to apply the sparsity rules"));
> > > }
> > > +
> > > +void advise_on_checkout_dirty_files(struct string_list *file_list)
> >
> > Huh. So this patch wires up a new function and advice, but we don't ever
> > seem to use it. Am I missing something?
>
> Thank you so much for looking into my PR and i believe advice.h is
> used in the add.c file. And advice really helps young developers
> understand what's wrong in their files because navigating git and
> trying to find solutions is very difficult, causing them to go to ai
> models making them copy pasting machines.(Please note that we prefer bottom posting on this mailing list, where your answer goes below the quoted context.)
It is used in "add.c", but not magically so. The function that you have introduced is the only site that uses the new advice, but the function is never called as far as I can see. So ultimately, the proposed change does not have any effect on the user-observable behaviour.
Patrick