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

Re: [PATCH v2] branch -D: allow - as abbreviation of '@{-1}'

From
Matthieu Moy <matthieu.moy@grenoble-inp.fr>
Date
Mar 22, 2016, 10:00 UTC
Message-ID
<vpqegb2omrb.fsf@anie.imag.fr>
In-Reply-To
<1458635056-26633-1-git-send-email-elena.petrashen@gmail.com>
Hi, and thanks for the quick reroll.

A small advice: don't hesitate to reply to reviewers in the thread for v1. As a reviewer, I appreciate a quick reply like "OK, will do in v2", or even "I disagree, I think my version is better because: ..." (I'm not _always_ right ;-) ).

Elena Petrashen <elena.petrashen@gmail.com> writes:
Show 15 quoted lines
> Signed-off-by: Elena Petrashen <elena.petrashen@gmail.com>
> ---
> This micro-patch is meant to allow “-“ as a short-hand for
> “@{-1} for branch -D (Cf. $gmane/230828):
>
> * based on the discussion on the previous version of the patch,
> added the advice on how to restore the deleted branch using
> git branch deleted_name sha1 - to ensure safety and 
> newbie-friendliness
>
> * git branch (-d | -D) is not supposed to accept any other
> arguments except for branch name so it makes sense to replace
> the argv[i] with @{-1}. We will not lose the opportunity to
> use it for something different for other git branch uses if
> we will decide it’s required.

As much as possible, try to distinguish new things in this version and general remarks on your patch. Here, the first point is new and could appear below "Changes since v1". The second is not new, I think you can either consider that it is a followup to previous discussion (as Eric interpreted it in v1) and remove the comment from v2, or consider it as a justification of why your patch is sensible and include it in the commit message (what I suggested in v1, but Eric more or less convinced me that I was wrong).

> * if there’s no previous branch in the repository yet, a
> specific warning message is given

As I said in v1, I think this is a separate topic and should be moved to a separate patch. As I said above, you are free to disagree (and it's not terribly important), but avoid leaving discussions open.

One point in favor of splitting the patch is that it's a good exercice for a newcommer ;-).

> +	if (!strcmp(argv[dash_position], "-")){
Style: space between ) and {.
Show 7 quoted lines
> @@ -213,7 +223,8 @@ static int delete_branches(int argc, const char **argv, int force, int kinds,
>  	for (i = 0; i < argc; i++, strbuf_release(&bname)) {
>  		const char *target;
>  		int flags = 0;
> -
> +		if (expand_dash_shortcut (argv, i))
> +			dash_shortcut = 1;
Nit: the blank line removal is not needed.
> +			if (dash_shortcut == 1)
> +			       printf( _("\nIf that happened by mistake, you may want to restore"
Style: no space after (.
> +				" it with:\n\ngit branch %s %s\n"), bname.buf,
> +				find_unique_abbrev(sha1, DEFAULT_ABBREV));

I think the message is overly long (4 '\n', and I think "If that happened by mistake" is not needed, just "to restore the branch, run ..." would be enough).

A rule that is usually applied for messages with Git:
* If the message is triggered by a user-error, then it's OK to have a
  long and possibly scary message: advanced users are not supposed to
  see it.
* If the message is seen by normal users in daily usage, then
  - we try to keep it as short as possible.
  - if it's not short enough, we allow disabling it with an advice.*
    configuration variable.
-- 
Matthieu Moy
http://www-verimag.imag.fr/~moy/
Previous: Elena PetrashenNext: Junio C Hamano
Message 2 of 6 in “branch -D: allow - as abbreviation of '@{-1}'”
  1. branch -D: allow - as abbreviation of '@{-1}'Elena Petrashen, Mar 22, 2016
  2. Matthieu MoyMar 22, 2016
  3. Junio C HamanoMar 22, 2016
  4. Junio C HamanoMar 22, 2016
  5. Eric SunshineMar 22, 2016
  6. elena petrashenMar 24, 2016

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.