From: Junio C Hamano Date: Fri, 21 Oct 2022 18:37:29 +0000 (-0700) Subject: Merge branch 'rj/branch-edit-description-with-nth-checkout' X-Git-Tag: v2.39.0-rc0~89 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=c2058ea237604d3ba7570f355c7832b9e467d6cb;p=thirdparty%2Fgit.git Merge branch 'rj/branch-edit-description-with-nth-checkout' "git branch --edit-description @{-1}" is now a way to edit branch description of the branch you were on before switching to the current branch. * rj/branch-edit-description-with-nth-checkout: branch: support for shortcuts like @{-1}, completed --- c2058ea237604d3ba7570f355c7832b9e467d6cb diff --cc builtin/branch.c index e0e0af4320,658c9f8741..407517ba68 --- a/builtin/branch.c +++ b/builtin/branch.c @@@ -805,26 -798,26 +807,26 @@@ int cmd_branch(int argc, const char **a if (filter.detached) die(_("Cannot give description to detached HEAD")); branch_name = head; - } else if (argc == 1) - branch_name = argv[0]; - else + } else if (argc == 1) { + strbuf_branchname(&buf, argv[0], INTERPRET_BRANCH_LOCAL); + branch_name = buf.buf; + } else { die(_("cannot edit description of more than one branch")); + } strbuf_addf(&branch_ref, "refs/heads/%s", branch_name); - if (!ref_exists(branch_ref.buf)) { - strbuf_release(&branch_ref); - - if (!argc || !strcmp(head, branch_name)) - return error(_("No commit on branch '%s' yet."), - branch_name); - else - return error(_("No branch named '%s'."), - branch_name); - } + if (!ref_exists(branch_ref.buf)) - ret = error(!argc ++ ret = error((!argc || !strcmp(head, branch_name)) + ? _("No commit on branch '%s' yet.") + : _("No branch named '%s'."), + branch_name); + else if (!edit_branch_description(branch_name)) + ret = 0; /* happy */ + strbuf_release(&branch_ref); + strbuf_release(&buf); - if (edit_branch_description(branch_name)) - return 1; + return ret; } else if (copy) { if (!argc) die(_("branch name required"));