From: Junio C Hamano <gitster@pobox.com>
To: "Arsh Srivastava via GitGitGadget" <gitgitgadget@gmail.com>
Cc: git@vger.kernel.org, Phillip Wood <phillip.wood123@gmail.com>,
Arsh Srivastava <arshsrivastava00@gmail.com>,
Patrick Steinhardt <ps@pks.im>,
Karthik Nayak <karthik.188@gmail.com>
Subject: Re: [PATCH v7] unpack-trees: suggest using 'git stash' when checkout fails
Date: Thu, 12 Mar 2026 15:40:23 -0700 [thread overview]
Message-ID: <xmqqldfwacyw.fsf@gitster.g> (raw)
In-Reply-To: <pull.2233.v7.git.git.1773345901659.gitgitgadget@gmail.com> (Arsh Srivastava via GitGitGadget's message of "Thu, 12 Mar 2026 20:05:01 +0000")
"Arsh Srivastava via GitGitGadget" <gitgitgadget@gmail.com> writes:
> When a branch switch fails due to local changes and
> new users who are not familiar with the error message often
> get confused about how to move ahead and resolve the issue as
> the previous error message only suggests to commit or stash the changes
> but doesn't explain how to do that or what the next steps are.
The first paragraph is a bit of a run-on and has a misplaced "and";
I cannot quite read and understand this overly long single sentence.
Perhaps the early part can become a bit easier to read with
punctuations, and cutting the sentence into two, e.g.,
When a branch switch fails due to local changes, new users who
are unfamiliar with the error message often get confused about how
to move ahead and resolve the issue.
Also it is misleading to say "previous" error message. We talk
about the current code in the present tense, to highlight what the
problem in the current code is. The _current_ message stops at
hinting the commands to be used without giving wordy instructions
that are best left to manuals. You may view it as a weakness (which
may motivate this patch to be written). But I personally am not so
sure that adding words to the existing message would necessarily
make it more clear.
> This patch enhances the error message with more specific
> instructions in a concise manner to help users understand
> how to resolve the issue and move their local changes
> safely to the other branch using stash.
As Documentation/SubmittingPatches says, let's instruct the code to
"be like so" in imperative mood. E.g., "Enhance the error
message..." instead of "This patch enhances...".
By the way, the updated message seems much less concise than the
original.
> msg = advice_enabled(ADVICE_COMMIT_BEFORE_MERGE)
> ? _("Your local changes to the following files would be overwritten by checkout:\n%%s"
> - "Please commit your changes or stash them before you switch branches.")
> - : _("Your local changes to the following files would be overwritten by checkout:\n%%s");
> + "To move you local changes safely to the other branch,\n"
> + "Please try 'git stash' followed by 'git checkout <branch>' followed by 'git stash pop' for safe merge."
> + )
> + : _("Your local changes to the following files would be overwritten by checkout:\n%%s"
> + "Please commit your changes or stash them before you switch branches.");
These were already overly long, but the updated one is way too long
to be read on end-user's terminal. The source lines are overly
long, too.
The original was this:
msg = advice_enabled(ADVICE_COMMIT_BEFORE_MERGE)
? _("Your local changes to the following files would be overwritten by checkout:\n%%s"
"Please commit your changes or stash them before you switch branches.")
: _("Your local changes to the following files would be overwritten by checkout:\n%%s");
Note that when advice is *NOT* enabled, we only gave
_("Your local changes to the following files would be overwritten by checkout:\n%%s");
without any "advise" in the output. That is what !advice_enabled() means.
The updated code does this:
msg = advice_enabled(ADVICE_COMMIT_BEFORE_MERGE)
? _("Your local changes to the following files would be overwritten by checkout:\n%%s"
"To move you local changes safely to the other branch,\n"
"Please try 'git stash' followed by 'git checkout <branch>' followed by 'git stash pop' for safe merge."
)
: _("Your local changes to the following files would be overwritten by checkout:\n%%s"
"Please commit your changes or stash them before you switch branches.");
to those users who decline the advice, we now show "Please
commit...". That is not what !advice_enabled() should trigger, is
it?
Also "To move you" -> "To move your".
Also the advice lost the other possiblity of first committing the
work in progress on the original branch before switching, yet the
new advice message is quite wordy.
Also, using "for safe merge" when the user is performing a
"checkout" might be slightly confusing, even if 'stash pop' involves
a merge under the hood.
A more concise version might say:
Try 'git stash && git checkout <branch> && git stash pop' to carry
your changes to the new branch, or commit your work before switching.
But as I already said, I think the current text may already strike
the right balance between being clear and being concise.
Thanks.
next prev parent reply other threads:[~2026-03-12 22:40 UTC|newest]
Thread overview: 62+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-10 8:51 [PATCH 0/5] Advice on checkout dirty files Arsh Srivastava via GitGitGadget
2026-03-10 8:51 ` [PATCH 1/5] diff: handle ANSI escape codes in prefix when calculating diffstat width LorenzoPegorari via GitGitGadget
2026-03-10 8:51 ` [PATCH 2/5] t4052: test for diffstat width when prefix contains ANSI escape codes LorenzoPegorari via GitGitGadget
2026-03-10 8:51 ` [PATCH 3/5] repo: remove unnecessary variable shadow K Jayatheerth via GitGitGadget
2026-03-10 8:51 ` [PATCH 4/5] The 13th batch Junio C Hamano via GitGitGadget
2026-03-10 8:51 ` [PATCH 5/5] advice: add stashBeforeCheckout advice for dirty branch switches Arsh Srivastava via GitGitGadget
2026-03-10 10:33 ` [PATCH 0/5] Advice on checkout dirty files Phillip Wood
2026-03-10 10:42 ` Arsh Srivastava
2026-03-10 10:45 ` Arsh Srivastava
2026-03-10 13:36 ` Junio C Hamano
2026-03-10 13:40 ` Arsh Srivastava
2026-03-10 15:40 ` Junio C Hamano
2026-03-10 16:05 ` Arsh Srivastava
2026-03-10 16:08 ` Arsh Srivastava
2026-03-10 10:59 ` [PATCH v2] advice: add stashBeforeCheckout advice for dirty branch switches Arsh Srivastava via GitGitGadget
[not found] ` <CAOAgETOebObfZNWA5LWMDxYv8YXYpbrb9L3_ASs_AbQjiQZYZw@mail.gmail.com>
2026-03-10 11:04 ` Arsh Srivastava
2026-03-10 13:16 ` Patrick Steinhardt
2026-03-10 13:36 ` Arsh Srivastava
2026-03-10 14:24 ` Patrick Steinhardt
2026-03-10 13:28 ` [PATCH v3 0/2] Advice on checkout dirty files Arsh Srivastava via GitGitGadget
2026-03-10 13:28 ` [PATCH v3 1/2] advice: add stashBeforeCheckout advice for dirty branch switches Arsh Srivastava via GitGitGadget
2026-03-10 13:43 ` Arsh Srivastava
2026-03-10 13:28 ` [PATCH v3 2/2] advice: add stashBeforeCheckout advice for dirty branch switches [GSOC] Arsh Srivastava via GitGitGadget
2026-03-11 8:50 ` [PATCH v4 0/5] Advice on checkout dirty files Arsh Srivastava via GitGitGadget
2026-03-11 8:50 ` [PATCH v4 1/5] advice: add stashBeforeCheckout advice for dirty branch switches Arsh Srivastava via GitGitGadget
2026-03-11 8:50 ` [PATCH v4 2/5] advice: add stashBeforeCheckout advice for dirty branch switches [GSOC] Arsh Srivastava via GitGitGadget
2026-03-11 8:50 ` [PATCH v4 3/5] unpack-trees: suggesting 'git checkout -m <branch>' with its repercussions Arsh Srivastava via GitGitGadget
2026-03-11 8:50 ` [PATCH v4 4/5] Updating tests and unpack-tress.c [GSOC] Arsh Srivastava via GitGitGadget
2026-03-11 8:50 ` [PATCH v4 5/5] File updation [GSOC] Arsh Srivastava via GitGitGadget
2026-03-11 16:38 ` [PATCH v4 0/5] Advice on checkout dirty files Junio C Hamano
2026-03-11 17:06 ` Arsh Srivastava
2026-03-11 17:49 ` [PATCH v5 0/3] " Arsh Srivastava via GitGitGadget
2026-03-11 17:49 ` [PATCH v5 1/3] advice: add stashBeforeCheckout advice for dirty branch switches Arsh Srivastava via GitGitGadget
2026-03-11 17:49 ` [PATCH v5 2/3] advice: add stashBeforeCheckout advice for dirty branch switches [GSOC] Arsh Srivastava via GitGitGadget
2026-03-11 17:49 ` [PATCH v5 3/3] unpack-trees: suggesting 'git checkout -m <branch>' with its repercussions Arsh Srivastava via GitGitGadget
2026-03-12 1:02 ` [PATCH v5 0/3] Advice on checkout dirty files Junio C Hamano
2026-03-12 3:32 ` Arsh Srivastava
2026-03-12 4:00 ` [PATCH v6] unpack-trees: suggesting 'git checkout -m' with its repercussions Arsh Srivastava via GitGitGadget
2026-03-12 16:06 ` Junio C Hamano
2026-03-12 18:13 ` Arsh Srivastava
2026-03-12 18:56 ` Junio C Hamano
2026-03-12 19:03 ` Arsh Srivastava
2026-03-12 19:07 ` Junio C Hamano
2026-03-12 19:12 ` Arsh Srivastava
2026-03-12 20:05 ` [PATCH v7] unpack-trees: suggest using 'git stash' when checkout fails Arsh Srivastava via GitGitGadget
2026-03-12 22:40 ` Junio C Hamano [this message]
2026-03-13 3:13 ` Arsh Srivastava
2026-03-13 10:43 ` Karthik Nayak
2026-03-13 11:02 ` Arsh Srivastava
2026-03-13 22:05 ` Junio C Hamano
2026-03-13 10:49 ` Arsh Srivastava
2026-03-13 11:04 ` Arsh Srivastava
2026-03-10 14:31 ` [PATCH v2] advice: add stashBeforeCheckout advice for dirty branch switches Karthik Nayak
2026-03-10 14:37 ` Arsh Srivastava
2026-03-10 14:40 ` Arsh Srivastava
2026-03-10 17:15 ` Karthik Nayak
2026-03-10 18:00 ` Arsh Srivastava
2026-03-10 14:41 ` Arsh Srivastava
2026-03-10 16:48 ` Junio C Hamano
2026-03-10 17:09 ` Karthik Nayak
2026-03-14 4:27 ` Konstantin Ryabitsev
2026-03-10 17:56 ` Arsh Srivastava
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=xmqqldfwacyw.fsf@gitster.g \
--to=gitster@pobox.com \
--cc=arshsrivastava00@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitgitgadget@gmail.com \
--cc=karthik.188@gmail.com \
--cc=phillip.wood123@gmail.com \
--cc=ps@pks.im \
/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.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox