mirror of
https://github.com/git/git.git
synced 2024-11-24 18:33:43 +08:00
Merge branch 'jc/branch-description-unset' into maint-2.38
"GIT_EDITOR=: git branch --edit-description" resulted in failure, which has been corrected. * jc/branch-description-unset: branch: do not fail a no-op --edit-desc
This commit is contained in:
commit
1155c8efbb
@ -599,10 +599,11 @@ static GIT_PATH_FUNC(edit_description, "EDIT_DESCRIPTION")
|
||||
|
||||
static int edit_branch_description(const char *branch_name)
|
||||
{
|
||||
int exists;
|
||||
struct strbuf buf = STRBUF_INIT;
|
||||
struct strbuf name = STRBUF_INIT;
|
||||
|
||||
read_branch_desc(&buf, branch_name);
|
||||
exists = !read_branch_desc(&buf, branch_name);
|
||||
if (!buf.len || buf.buf[buf.len-1] != '\n')
|
||||
strbuf_addch(&buf, '\n');
|
||||
strbuf_commented_addf(&buf,
|
||||
@ -619,6 +620,7 @@ static int edit_branch_description(const char *branch_name)
|
||||
strbuf_stripspace(&buf, 1);
|
||||
|
||||
strbuf_addf(&name, "branch.%s.description", branch_name);
|
||||
if (buf.len || exists)
|
||||
git_config_set(name.buf, buf.len ? buf.buf : NULL);
|
||||
strbuf_release(&name);
|
||||
strbuf_release(&buf);
|
||||
|
@ -1382,6 +1382,9 @@ test_expect_success 'branch --delete --force removes dangling branch' '
|
||||
'
|
||||
|
||||
test_expect_success 'use --edit-description' '
|
||||
EDITOR=: git branch --edit-description &&
|
||||
test_must_fail git config branch.main.description &&
|
||||
|
||||
write_script editor <<-\EOF &&
|
||||
echo "New contents" >"$1"
|
||||
EOF
|
||||
|
Loading…
Reference in New Issue
Block a user