Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.kernel.org/pub/scm/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2022-10-18 00:56:35 +0300
committerJunio C Hamano <gitster@pobox.com>2022-10-18 00:56:35 +0300
commit4050354b1464d33b829f883ba7166d94d5dd7571 (patch)
tree70f89f66f85100e9b1fe3ce3c1b9bd6a03ebab71 /builtin
parenta2e618cb0fa76a453f41f2095653190e785f1c66 (diff)
parentbcfc82bd48f518c8939090748516ad21bb079720 (diff)
Merge branch 'rj/branch-edit-desc-unborn'
"git branch --edit-description" on an unborh branch misleadingly said that no such branch exists, which has been corrected. * rj/branch-edit-desc-unborn: branch: description for non-existent branch errors
Diffstat (limited to 'builtin')
-rw-r--r--builtin/branch.c14
1 files changed, 12 insertions, 2 deletions
diff --git a/builtin/branch.c b/builtin/branch.c
index c570fdb1ca..e0e0af4320 100644
--- a/builtin/branch.c
+++ b/builtin/branch.c
@@ -538,6 +538,13 @@ static void copy_or_rename_branch(const char *oldname, const char *newname, int
die(_("Invalid branch name: '%s'"), oldname);
}
+ if ((copy || strcmp(head, oldname)) && !ref_exists(oldref.buf)) {
+ if (copy && !strcmp(head, oldname))
+ die(_("No commit on branch '%s' yet."), oldname);
+ else
+ die(_("No branch named '%s'."), oldname);
+ }
+
/*
* A command like "git branch -M currentbranch currentbranch" cannot
* cause the worktree to become inconsistent with HEAD, so allow it.
@@ -807,7 +814,7 @@ int cmd_branch(int argc, const char **argv, const char *prefix)
if (!ref_exists(branch_ref.buf)) {
strbuf_release(&branch_ref);
- if (!argc)
+ if (!argc || !strcmp(head, branch_name))
return error(_("No commit on branch '%s' yet."),
branch_name);
else
@@ -850,8 +857,11 @@ int cmd_branch(int argc, const char **argv, const char *prefix)
die(_("no such branch '%s'"), argv[0]);
}
- if (!ref_exists(branch->refname))
+ if (!ref_exists(branch->refname)) {
+ if (!argc || !strcmp(head, branch->name))
+ die(_("No commit on branch '%s' yet."), branch->name);
die(_("branch '%s' does not exist"), branch->name);
+ }
dwim_and_setup_tracking(the_repository, branch->name,
new_upstream, BRANCH_TRACK_OVERRIDE,