Skip to content

Commit c2796ac

Browse files
committed
Merge branch 'bc/push-cas-cquoted-refname' into master
Pushing a ref whose name contains non-ASCII character with the "--force-with-lease" option did not work over smart HTTP protocol, which has been corrected. * bc/push-cas-cquoted-refname: remote-curl: make --force-with-lease work with non-ASCII ref names
2 parents be53706 + cd85b44 commit c2796ac

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

remote-curl.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,11 @@ static int set_option(const char *name, const char *value)
121121
}
122122
else if (!strcmp(name, "cas")) {
123123
struct strbuf val = STRBUF_INIT;
124-
strbuf_addf(&val, "--" CAS_OPT_NAME "=%s", value);
124+
strbuf_addstr(&val, "--force-with-lease=");
125+
if (*value != '"')
126+
strbuf_addstr(&val, value);
127+
else if (unquote_c_style(&val, value, NULL))
128+
return -1;
125129
string_list_append(&cas_options, val.buf);
126130
strbuf_release(&val);
127131
return 0;

t/t5541-http-push-smart.sh

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -479,6 +479,21 @@ test_expect_success 'clone/fetch scrubs password from reflogs' '
479479
! grep "$HTTPD_URL_USER_PASS" reflog
480480
'
481481

482+
test_expect_success 'Non-ASCII branch name can be used with --force-with-lease' '
483+
cd "$ROOT_PATH" &&
484+
git clone "$HTTPD_URL_USER_PASS/smart/test_repo.git" non-ascii &&
485+
cd non-ascii &&
486+
git checkout -b rama-de-árbol &&
487+
test_commit F &&
488+
git push --force-with-lease origin rama-de-árbol &&
489+
git ls-remote origin refs/heads/rama-de-árbol >actual &&
490+
git ls-remote . refs/heads/rama-de-árbol >expect &&
491+
test_cmp expect actual &&
492+
git push --delete --force-with-lease origin rama-de-árbol &&
493+
git ls-remote origin refs/heads/rama-de-árbol >actual &&
494+
test_must_be_empty actual
495+
'
496+
482497
test_expect_success 'colorize errors/hints' '
483498
cd "$ROOT_PATH"/test_repo_clone &&
484499
test_must_fail git -c color.transport=always -c color.advice=always \

0 commit comments

Comments
 (0)