From: Junio C Hamano <junkio@cox.net>
To: "Shawn O. Pearce" <spearce@spearce.org>
Cc: git@vger.kernel.org
Subject: Re: [PATCH 2/2] Optionally check for uncommitted changes before switching branches.
Date: Thu, 07 Dec 2006 11:38:26 -0800 [thread overview]
Message-ID: <7vu007sdhp.fsf@assigned-by-dhcp.cox.net> (raw)
In-Reply-To: <20061207100224.GB12966@spearce.org> (Shawn O. Pearce's message of "Thu, 7 Dec 2006 05:02:24 -0500")
"Shawn O. Pearce" <spearce@spearce.org> writes:
> Git shouldn't cause the user to make mistakes when it can help to
> prevent them. So now users may set checkout.requireCleanDirectory
> to true in their config file to have git-checkout verify the working
> directory is clean before switching branches.
A lot of times the reason to switch branches is because the user
starts to make a trivial change in the worktree and realizes
that the change belongs to another branch. Other times it is
done by mistake and making it easier to notice that mistake is a
laudable goal.
Your patch allows -m to override this, but that destroys one
very useful feature of -m. In the above "ah, this trivial thing
belongs to the other branch, so let's switch to the branch to
commit only that trivial piece and come back to the current
branch to continue what I'm doing" workflow, I usually first say
"git checkout" without -m to switch, and if it does not allow me
to switch, it is an indication that "the trivial thing" I
thought was trivial was not trivial. I take it as a cue that I
should instead do it "the right way" (i.e. finish or stash away
what I am doing, switch to the branch in a clean state and fix
it properly).
Other times, when all (or most of) the changes in the work tree
logically should have started on a different branch, I do force
it with -m (and take the conflict markers in my worktree), but
being able to forbid the worktree merge by not giving -m is
important.
People with this new configuration set and has to override it
with a command line switch will lose this ability if you
overload that on '-m'.
next prev parent reply other threads:[~2006-12-07 19:38 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <6ed9774cb95e873e76a4ac406dd740caf954bd3b.1165485618.git.spearce@spearce.org>
2006-12-07 10:02 ` [PATCH 2/2] Optionally check for uncommitted changes before switching branches Shawn O. Pearce
2006-12-07 19:38 ` Junio C Hamano [this message]
2006-12-07 19:43 ` Shawn Pearce
2006-12-07 23:01 ` Junio C Hamano
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=7vu007sdhp.fsf@assigned-by-dhcp.cox.net \
--to=junkio@cox.net \
--cc=git@vger.kernel.org \
--cc=spearce@spearce.org \
/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;
as well as URLs for NNTP newsgroup(s).