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

Re: [PATCH] (trivial) add helpful "use --soft" for bare reset

From
Junio C Hamano <gitster@pobox.com>
Date
Jun 30, 2011, 20:06 UTC
Message-ID
<7vwrg3ozi5.fsf@alter.siamese.dyndns.org>
In-Reply-To
<20110630190608.GB26701@spacedout.fries.net>
David Fries <david@fries.net> writes:
Show 11 quoted lines
> diff --git a/builtin/reset.c b/builtin/reset.c
> index 98bca04..d0d4d66 100644
> --- a/builtin/reset.c
> +++ b/builtin/reset.c
> @@ -332,7 +332,7 @@ int cmd_reset(int argc, const char **argv, const char *prefix)
>  		setup_work_tree();
>  
>  	if (reset_type == MIXED && is_bare_repository())
> -		die(_("%s reset is not allowed in a bare repository"),
> +		die(_("%s reset is not allowed in a bare repository, see update-ref"),
>  		    _(reset_type_names[reset_type]));

There still is one thing that worries me remains here, even though I may be worried too much. I tend to think that giving an incorrect advice is far worse than not giving one.

Are you absolutely sure that the user wanted to update only the tip of a ref without affecting the index nor the working tree, when a mixed reset is issued in a bare repository, and there is _no other_ explanation why the user issued a forbidden command?

For example, I have ~/git.git and /pub/scm/git/git.git on a single machine somewhere. The former is with a working tree and the latter is a bare repository. I usually live in ~/git.git/ on that machine, but sometimes I would do things like:

	$ git repack -a -d ;# working area
	$ cd /pub/scm/git/git.git ;# clean up from time to time ...
        $ git repack -a -d ;# ... the public one as well

I may disconnect from my screen session to the machine after I do this, and I may have forgotten where I was the next time I come back to the machine. After I reconnect to the same screen session, I may say "git reset" to get back to a known state, which is what I often want to do in the working area repository ~/git.git, mistakenly thinking that I am in my usual ~/git.git directory.

In such a scenario, the mistake is not that I used a wrong command "reset" in an attempt to update the tip of the branch. The mistake is that I tried to use the right command to update the index, but I did it in a wrong place. "Did you mean to do that somewhere else?" would be a much more appropriate advice in that case.

Previous: David FriesNext: David Fries
Message 4 of 6 in “(trivial) add helpful "use --soft" for bare reset”
  1. (trivial) add helpful "use --soft" for bare resetDavid Fries, Jun 26, 2011
  2. Junio C HamanoJun 30, 2011
  3. David FriesJun 30, 2011
  4. Junio C HamanoJun 30, 2011
  5. David FriesJun 30, 2011
  6. Junio C HamanoJul 1, 2011

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.