Skip to content

Commit 1155c8e

Browse files
committed
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
2 parents 48b754d + e288b3d commit 1155c8e

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

builtin/branch.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -599,10 +599,11 @@ static GIT_PATH_FUNC(edit_description, "EDIT_DESCRIPTION")
599599

600600
static int edit_branch_description(const char *branch_name)
601601
{
602+
int exists;
602603
struct strbuf buf = STRBUF_INIT;
603604
struct strbuf name = STRBUF_INIT;
604605

605-
read_branch_desc(&buf, branch_name);
606+
exists = !read_branch_desc(&buf, branch_name);
606607
if (!buf.len || buf.buf[buf.len-1] != '\n')
607608
strbuf_addch(&buf, '\n');
608609
strbuf_commented_addf(&buf,
@@ -619,7 +620,8 @@ static int edit_branch_description(const char *branch_name)
619620
strbuf_stripspace(&buf, 1);
620621

621622
strbuf_addf(&name, "branch.%s.description", branch_name);
622-
git_config_set(name.buf, buf.len ? buf.buf : NULL);
623+
if (buf.len || exists)
624+
git_config_set(name.buf, buf.len ? buf.buf : NULL);
623625
strbuf_release(&name);
624626
strbuf_release(&buf);
625627

t/t3200-branch.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1382,6 +1382,9 @@ test_expect_success 'branch --delete --force removes dangling branch' '
13821382
'
13831383

13841384
test_expect_success 'use --edit-description' '
1385+
EDITOR=: git branch --edit-description &&
1386+
test_must_fail git config branch.main.description &&
1387+
13851388
write_script editor <<-\EOF &&
13861389
echo "New contents" >"$1"
13871390
EOF

0 commit comments

Comments
 (0)