Commit 87c9b741 by Vicent Marti

Merge pull request #2295 from libgit2/cmn/fetchhead-quote

fetchhead: deal with quotes in branch names
parents 212b6205 bdc82e1c
...@@ -210,7 +210,7 @@ static int fetchhead_ref_parse( ...@@ -210,7 +210,7 @@ static int fetchhead_ref_parse(
name = desc + 1; name = desc + 1;
if (name) { if (name) {
if ((desc = strchr(name, '\'')) == NULL || if ((desc = strstr(name, "' ")) == NULL ||
git__prefixcmp(desc, "' of ") != 0) { git__prefixcmp(desc, "' of ") != 0) {
giterr_set(GITERR_FETCHHEAD, giterr_set(GITERR_FETCHHEAD,
"Invalid description in FETCH_HEAD line %d", line_num); "Invalid description in FETCH_HEAD line %d", line_num);
......
...@@ -28,3 +28,6 @@ ...@@ -28,3 +28,6 @@
#define FETCH_HEAD_EXPLICIT_DATA \ #define FETCH_HEAD_EXPLICIT_DATA \
"0966a434eb1a025db6b71485ab63a3bfbea520b6\t\tbranch 'first-merge' of git://github.com/libgit2/TestGitRepository\n" "0966a434eb1a025db6b71485ab63a3bfbea520b6\t\tbranch 'first-merge' of git://github.com/libgit2/TestGitRepository\n"
#define FETCH_HEAD_QUOTE_DATA \
"0966a434eb1a025db6b71485ab63a3bfbea520b6\t\tbranch 'first's-merge' of git://github.com/libgit2/TestGitRepository\n"
...@@ -343,3 +343,12 @@ void test_fetchhead_nonetwork__unborn_with_upstream(void) ...@@ -343,3 +343,12 @@ void test_fetchhead_nonetwork__unborn_with_upstream(void)
git_repository_free(repo); git_repository_free(repo);
cl_fixture_cleanup("./repowithunborn"); cl_fixture_cleanup("./repowithunborn");
} }
void test_fetchhead_nonetwork__quote_in_branch_name(void)
{
cl_set_cleanup(&cleanup_repository, "./test1");
cl_git_pass(git_repository_init(&g_repo, "./test1", 0));
cl_git_rewritefile("./test1/.git/FETCH_HEAD", FETCH_HEAD_QUOTE_DATA);
cl_git_pass(git_repository_fetchhead_foreach(g_repo, read_noop, NULL));
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment