[PATCH v3 0/2] branch: support for shortcuts like @{-1}, completed
From: Rubén Justo <hidden>
Date: 2022-09-08 04:51:49
branch options: "edit-description", "set-upstream-to" and "unset-upstream"
don't handle shortcuts like @{-1}.
This patch address this problem.
Changes in v3 are about following code conventions to avoid unnecessary confusions, pointed out by Junio in <xmqq7d2fszhk.fsf@gitster.g>.
Thanks.
Rubén Justo (2):
branch: refactor "edit_description" code path
branch: support for shortcuts like @{-1} completed
builtin/branch.c | 44 ++++++++++++++++++---------
t/t3204-branch-name-interpretation.sh | 25 +++++++++++++++
2 files changed, 55 insertions(+), 14 deletions(-)
Range-diff:
1: ce14194187 ! 1: 0a69b6cf18 branch: refactor "edit_description" code path
@@ Commit message
Signed-off-by: Rubén Justo [off-list ref]
## builtin/branch.c ##
-@@ builtin/branch.c: static int edit_branch_description(const char *branch_name)
- strbuf_reset(&buf);
- if (launch_editor(edit_description(), &buf, NULL)) {
- strbuf_release(&buf);
-- return -1;
-+ return 1;
- }
- strbuf_stripspace(&buf, 1);
-
@@ builtin/branch.c: int cmd_branch(int argc, const char **argv, const char *prefix)
} else if (edit_description) {
const char *branch_name;
@@ builtin/branch.c: int cmd_branch(int argc, const char **argv, const char *prefix
branch_name);
- }
- strbuf_release(&branch_ref);
-+ } else
-+ ret = edit_branch_description(branch_name);
++ } else if (edit_branch_description(branch_name))
++ ret = 1;
- if (edit_branch_description(branch_name))
- return 1;
2: 3a591cab8a ! 2: 91b308b52a branch: support for shortcuts like @{-1} completed
@@ builtin/branch.c: int cmd_branch(int argc, const char **argv, const char *prefix
die(_("cannot edit description of more than one branch"));
@@ builtin/branch.c: int cmd_branch(int argc, const char **argv, const char *prefix)
- ret = edit_branch_description(branch_name);
+ ret = 1;
strbuf_release(&branch_ref);
+ strbuf_release(&buf);
--
2.36.1