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

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

From
Matthieu Moy <matthieu.moy@grenoble-inp.fr>
Date
Mar 31, 2016, 15:09 UTC
Message-ID
<vpqwpoi1y72.fsf@anie.imag.fr>
In-Reply-To
<1459416327-795-1-git-send-email-elena.petrashen@gmail.com>
Elena Petrashen <elena.petrashen@gmail.com> writes:
Show 18 quoted lines
> --- a/advice.c
> +++ b/advice.c
> @@ -15,6 +15,7 @@ int advice_detached_head = 1;
>  int advice_set_upstream_failure = 1;
>  int advice_object_name_warning = 1;
>  int advice_rm_hints = 1;
> +int advice_delete_branch_via_at_ref = 1;
>  
>  static struct {
>  	const char *name;
> @@ -35,6 +36,7 @@ static struct {
>  	{ "setupstreamfailure", &advice_set_upstream_failure },
>  	{ "objectnamewarning", &advice_object_name_warning },
>  	{ "rmhints", &advice_rm_hints },
> +	{ "deletebranchviaatref", &advice_delete_branch_via_at_ref },
>  
>  	/* make this an alias for backward compatibility */
>  	{ "pushnonfastforward", &advice_push_update_rejected }
This is undocumented.
> +		expand_dash_shortcut (argv, i);
> +		if(!strncmp(argv[i], "@{-", strlen("@{-")))
Style: space after if.
We have a starts_with() function to avoid this strncmp(... strlen()) dance.
Show 7 quoted lines
> @@ -262,6 +275,9 @@ static int delete_branches(int argc, const char **argv, int force, int kinds,
>  			       (flags & REF_ISBROKEN) ? "broken"
>  			       : (flags & REF_ISSYMREF) ? target
>  			       : find_unique_abbrev(sha1, DEFAULT_ABBREV));
> +			if (at_shortcut && advice_delete_branch_via_at_ref)
> +			       delete_branch_advice (bname.buf,
> +				find_unique_abbrev(sha1, DEFAULT_ABBREV));
Style: 1-space indent is not sufficient. Either align the arguments (not
applicable here) or indent by one tab to mark "I'm not done with
argument list".
Also, no space between delete_branch_advice and '('.
Show 6 quoted lines
> +test_expect_success 'test deleting "-" deletes previous branch' '
> +	git checkout -b prev &&
> +	test_commit prev &&
> +	git checkout master &&
> +	git branch -D - >actual &&
> +	sha1=$(git rev-parse prev | cut -c 1-7) &&
Didn't this | cut ... turn into a --short in a previous version?
-- 
Matthieu Moy
http://www-verimag.imag.fr/~moy/
Previous: Elena PetrashenNext: Remi Galan Alfonso
Message 2 of 9 in “[Outreachy] branch -D: allow - as abbreviation of @{-1}”
  1. [Outreachy] branch -D: allow - as abbreviation of @{-1}Elena Petrashen, Mar 31, 2016
  2. Matthieu MoyMar 31, 2016
  3. Remi Galan AlfonsoMar 31, 2016
  4. elena petrashenApr 4, 2016
  5. Remi Galan AlfonsoApr 4, 2016
  6. elena petrashenApr 6, 2016
  7. Remi Galan AlfonsoApr 6, 2016
  8. Junio C HamanoMar 31, 2016
  9. elena petrashenApr 6, 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.