Re: [PATCH v3][Outreachy] branch -D: allow - as abbreviation of @{-1}
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 }> + 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/