git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH 3/3] reset: Print a warning when user uses "git reset" during a merge

From
Junio C Hamano <gitster@pobox.com>
Date
Mar 17, 2014, 21:54 UTC
Message-ID
<xmqqwqfsbif9.fsf@gitster.dls.corp.google.com>
In-Reply-To
<1394771872-25940-4-git-send-email-andrew.kw.w@gmail.com>
Andrew Wong <andrew.kw.w@gmail.com> writes:
Show 24 quoted lines
> 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
Two style niggles here.
> +		 * 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"
"we want"?  Has any of us decided on that?
Show 17 quoted lines
> +		 * 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();
Previous: Marc BranchaudNext: Junio C Hamano
Message 12 of 15 in “Make git more user-friendly during a merge conflict”
  1. 0/3 Make git more user-friendly during a merge conflictAndrew Wong, Mar 14, 2014
  2. 1/3 wt-status: Make status messages more consistent with othersAndrew Wong, Mar 14, 2014
  3. Junio C HamanoMar 17, 2014
  4. 2/3 merge: Advise user to use "git merge --abort" to abort mergesAndrew Wong, Mar 14, 2014
  5. Junio C HamanoMar 17, 2014
  6. 3/3 reset: Print a warning when user uses "git reset" during a mergeAndrew Wong, Mar 14, 2014
  7. Marc BranchaudMar 14, 2014
  8. Andrew WongMar 14, 2014
  9. Junio C HamanoMar 14, 2014
  10. Andrew WongMar 14, 2014
  11. Marc BranchaudMar 15, 2014
  12. Junio C HamanoMar 17, 2014
  13. Junio C HamanoMar 17, 2014
  14. Andrew WongMar 17, 2014
  15. Junio C HamanoMar 19, 2014

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.