summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVicent Marti <vicent@github.com>2014-04-24 05:24:46 -0700
committerVicent Marti <vicent@github.com>2014-04-24 05:24:46 -0700
commit87c9b741dfc5be7edc43625c84720841b65cd14e (patch)
tree0cb09f8ece8c243f1639440374dd20ed8f2e8cea
parent212b6205d70ff7c0f0f0b1eda6ac964c8d09d431 (diff)
parentbdc82e1c00776229b19688abaf08d6701f2dc41f (diff)
downloadlibgit2-87c9b741dfc5be7edc43625c84720841b65cd14e.tar.gz
Merge pull request #2295 from libgit2/cmn/fetchhead-quote
fetchhead: deal with quotes in branch names
-rw-r--r--src/fetchhead.c2
-rw-r--r--tests/fetchhead/fetchhead_data.h3
-rw-r--r--tests/fetchhead/nonetwork.c9
3 files changed, 13 insertions, 1 deletions
diff --git a/src/fetchhead.c b/src/fetchhead.c
index 4435454ef..a95ea4ca4 100644
--- a/src/fetchhead.c
+++ b/src/fetchhead.c
@@ -210,7 +210,7 @@ static int fetchhead_ref_parse(
name = desc + 1;
if (name) {
- if ((desc = strchr(name, '\'')) == NULL ||
+ if ((desc = strstr(name, "' ")) == NULL ||
git__prefixcmp(desc, "' of ") != 0) {
giterr_set(GITERR_FETCHHEAD,
"Invalid description in FETCH_HEAD line %d", line_num);
diff --git a/tests/fetchhead/fetchhead_data.h b/tests/fetchhead/fetchhead_data.h
index 34adb3d08..94402abd5 100644
--- a/tests/fetchhead/fetchhead_data.h
+++ b/tests/fetchhead/fetchhead_data.h
@@ -28,3 +28,6 @@
#define FETCH_HEAD_EXPLICIT_DATA \
"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"
diff --git a/tests/fetchhead/nonetwork.c b/tests/fetchhead/nonetwork.c
index d8c70e8b2..e7ff2ca30 100644
--- a/tests/fetchhead/nonetwork.c
+++ b/tests/fetchhead/nonetwork.c
@@ -343,3 +343,12 @@ void test_fetchhead_nonetwork__unborn_with_upstream(void)
git_repository_free(repo);
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));
+}