From: Andrew Wong <andrew.kw.w@gmail.com>
To: git@vger.kernel.org
Cc: Andrew Wong <andrew.kw.w@gmail.com>
Subject: [PATCH 3/3] reset: Print a warning when user uses "git reset" during a merge
Date: Fri, 14 Mar 2014 00:37:52 -0400 [thread overview]
Message-ID: <1394771872-25940-4-git-send-email-andrew.kw.w@gmail.com> (raw)
In-Reply-To: <1394771872-25940-1-git-send-email-andrew.kw.w@gmail.com>
During a merge, "--mixed" is most likely not what the user wants. Using
"--mixed" during a merge would leave the merged changes and new files
mixed in with the local changes. The user would have to manually clean
up the work tree, which is non-trivial. In future releases, we want to
make "git reset" error out when used in the middle of a merge. For now,
we simply print out a warning to the user.
Signed-off-by: Andrew Wong <andrew.kw.w@gmail.com>
---
builtin/reset.c | 21 +++++++++++++++++++++
1 file changed, 21 insertions(+)
diff --git a/builtin/reset.c b/builtin/reset.c
index 4fd1c6c..04e8103 100644
--- a/builtin/reset.c
+++ b/builtin/reset.c
@@ -331,8 +331,29 @@ int cmd_reset(int argc, const char **argv, const char *prefix)
_(reset_type_names[reset_type]));
}
if (reset_type == NONE)
+ {
reset_type = MIXED; /* by default */
+ /* During a merge, "--mixed" is most likely not what the user
+ * wants. Using "--mixed" during a merge would leave the merged
+ * changes and new files mixed in with the local changes. The
+ * user would have to manually clean up the work tree, which is
+ * non-trivial. In future releases, we want to make "git reset"
+ * error out when used in the middle of a merge. For now, we
+ * simply print out a warning to the user. */
+ if (is_merge())
+ warning(_("You have used 'git reset' in the middle of a merge. 'git reset' defaults to\n"
+ "'git reset --mixed', which means git will not clean up any merged changes and\n"
+ "new files that were created in the work tree. It also becomes impossible for\n"
+ "git to automatically clean up the work tree later, so you would have to clean\n"
+ "up the work tree manually. To avoid this next time, you may want to use 'git\n"
+ "reset --merge', or equivalently 'git merge --abort'.\n"
+ "\n"
+ "In future releases, using 'git reset' in the middle of a merge will result in\n"
+ "an error."
+ ));
+ }
+
if (reset_type != SOFT && reset_type != MIXED)
setup_work_tree();
--
1.9.0.174.g6f75b8f
next prev parent reply other threads:[~2014-03-14 4:39 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-03-14 4:37 [PATCH 0/3] Make git more user-friendly during a merge conflict Andrew Wong
2014-03-14 4:37 ` [PATCH 1/3] wt-status: Make status messages more consistent with others Andrew Wong
2014-03-17 21:51 ` Junio C Hamano
2014-03-14 4:37 ` [PATCH 2/3] merge: Advise user to use "git merge --abort" to abort merges Andrew Wong
2014-03-17 21:58 ` Junio C Hamano
2014-03-14 4:37 ` Andrew Wong [this message]
2014-03-14 14:33 ` [PATCH 3/3] reset: Print a warning when user uses "git reset" during a merge Marc Branchaud
2014-03-14 17:04 ` Andrew Wong
2014-03-14 20:55 ` Junio C Hamano
2014-03-14 21:35 ` Andrew Wong
2014-03-15 19:23 ` Marc Branchaud
2014-03-17 21:54 ` Junio C Hamano
2014-03-17 23:04 ` [PATCH 0/3] Make git more user-friendly during a merge conflict Junio C Hamano
2014-03-17 23:25 ` Andrew Wong
2014-03-19 22:30 ` 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=1394771872-25940-4-git-send-email-andrew.kw.w@gmail.com \
--to=andrew.kw.w@gmail.com \
--cc=git@vger.kernel.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).