While at there, do not stop user from editing a branch description
when the unrelated HEAD is detached.
---
builtin/branch.c | 12 ++++++------
t/t3200-branch.sh | 4 ++--
2 files changed, 8 insertions(+), 8 deletions(-)
@@ -852,14 +852,14 @@ int cmd_branch(int argc, const char **argv, const char *prefix)constchar*branch_name;structstrbufbranch_ref=STRBUF_INIT;-if(detached)-die("Cannot give description to detached HEAD");-if(!argc)+if(!argc){+if(detached)+die("Cannot give description to detached HEAD");branch_name=head;-elseif(argc==1)+}elseif(argc==1)branch_name=argv[0];else-usage_with_options(builtin_branch_usage,options);+die(_("cannot edit description of more than one branch"));strbuf_addf(&branch_ref,"refs/heads/%s",branch_name);if(!ref_exists(branch_ref.buf)){
@@ -881,7 +881,7 @@ int cmd_branch(int argc, const char **argv, const char *prefix)elseif(argc==2)rename_branch(argv[0],argv[1],rename>1);else-usage_with_options(builtin_branch_usage,options);+die(_("too many branches for a rename operation"));}elseif(new_upstream){structbranch*branch=branch_get(argv[0]);
@@ -590,7 +590,7 @@ static int print_ref_list(int kinds, int detached, int verbose, int abbrev, strustructcommit*filter;filter=lookup_commit_reference_gently(merge_filter_ref,0);if(!filter)-die("object '%s' does not point to a commit",+die(_("object '%s' does not point to a commit"),sha1_to_hex(merge_filter_ref));filter->object.flags|=UNINTERESTING;
@@ -854,7 +854,7 @@ int cmd_branch(int argc, const char **argv, const char *prefix)if(!argc){if(detached)-die("Cannot give description to detached HEAD");+die(_("Cannot give description to detached HEAD"));branch_name=head;}elseif(argc==1)branch_name=argv[0];
@@ -866,10 +866,11 @@ int cmd_branch(int argc, const char **argv, const char *prefix)strbuf_release(&branch_ref);if(!argc)-returnerror("No commit on branch '%s' yet.",+returnerror(_("No commit on branch '%s' yet."),branch_name);else-returnerror("No such branch '%s'.",branch_name);+returnerror(_("No branch named '%s'."),+branch_name);}strbuf_release(&branch_ref);
From: Jonathan Nieder <hidden> Date: 2016-06-15 22:55:55
Nguyễn Thái Ngọc Duy wrote:
quoted hunk
--- a/builtin/branch.c+++ b/builtin/branch.c
@@ -852,14 +852,14 @@ int cmd_branch(int argc, const char **argv, const char *prefix)constchar*branch_name;structstrbufbranch_ref=STRBUF_INIT;-if(detached)-die("Cannot give description to detached HEAD");-if(!argc)+if(!argc){+if(detached)+die("Cannot give description to detached HEAD");
Good catch. Shouldn't this bugfix be a separate patch, so it can also
be included in maint?
This worried me for a second --- is it an actual message that gets
emitted, a placeholder used only in code, or some combination of
the two?
Luckily it really is just a message (or rather, a value for the commit
message column in the " f7c0c00 [ahead 58, behind 197] vcs-svn: drop
obj_pool.h" message).
For what it's worth, assuming this passes tests,
Reviewed-by: Jonathan Nieder <redacted>
@@ -859,7 +859,7 @@ int cmd_branch(int argc, const char **argv, const char *prefix)}elseif(argc==1)branch_name=argv[0];else-usage_with_options(builtin_branch_usage,options);+die(_("cannot edit description of more than one branch"));strbuf_addf(&branch_ref,"refs/heads/%s",branch_name);if(!ref_exists(branch_ref.buf)){
@@ -881,7 +881,7 @@ int cmd_branch(int argc, const char **argv, const char *prefix)elseif(argc==2)rename_branch(argv[0],argv[1],rename>1);else-usage_with_options(builtin_branch_usage,options);+die(_("too many branches for a rename operation"));}elseif(new_upstream){structbranch*branch=branch_get(argv[0]);
Reviewed-by: Jonathan Nieder <redacted>
Signed-off-by: Nguyễn Thái Ngọc Duy <redacted>
---
On Sun, Jan 27, 2013 at 6:55 PM, Jonathan Nieder [off-list ref] wrote:
> For what it's worth, assuming this passes tests,
It passes the tests. Although I doubt the tests are written to catch
this.
builtin/branch.c | 11 ++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)
@@ -590,7 +590,7 @@ static int print_ref_list(int kinds, int detached, int verbose, int abbrev, strustructcommit*filter;filter=lookup_commit_reference_gently(merge_filter_ref,0);if(!filter)-die("object '%s' does not point to a commit",+die(_("object '%s' does not point to a commit"),sha1_to_hex(merge_filter_ref));filter->object.flags|=UNINTERESTING;
@@ -854,7 +854,7 @@ int cmd_branch(int argc, const char **argv, const char *prefix)if(!argc){if(detached)-die("Cannot give description to detached HEAD");+die(_("Cannot give description to detached HEAD"));branch_name=head;}elseif(argc==1)branch_name=argv[0];
@@ -866,10 +866,11 @@ int cmd_branch(int argc, const char **argv, const char *prefix)strbuf_release(&branch_ref);if(!argc)-returnerror("No commit on branch '%s' yet.",+returnerror(_("No commit on branch '%s' yet."),branch_name);else-returnerror("No such branch '%s'.",branch_name);+returnerror(_("No branch named '%s'."),+branch_name);}strbuf_release(&branch_ref);
@@ -850,11 +850,11 @@ int cmd_branch(int argc, const char **argv, const char *prefix)constchar*branch_name;structstrbufbranch_ref=STRBUF_INIT;-if(detached)-die("Cannot give description to detached HEAD");-if(!argc)+if(!argc){+if(detached)+die("Cannot give description to detached HEAD");branch_name=head;-elseif(argc==1)+}elseif(argc==1)branch_name=argv[0];elseusage_with_options(builtin_branch_usage,options);