mbox series

[v3,0/2] branch: support for shortcuts like @{-1}, completed

Message ID 7abdb5a9-5707-7897-4196-8d2892beeb81@gmail.com (mailing list archive)
Headers show
Series branch: support for shortcuts like @{-1}, completed | expand

Message

Rubén Justo Sept. 8, 2022, 4:47 a.m. UTC
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 <rjusto@gmail.com>
     
      ## 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);