Commit Diff


commit - 1dda2072ee3eb04988c80d2a72522e489a606914
commit + de51a12a5befe30cf15a089998d0136d52856dc2
blob - de21419fc5de70a18f027cbc1a65c38a5049e912
blob + 5af728df10a622bad125d0bc41ba804acfc9ccca
--- lib/gitconfig.c
+++ lib/gitconfig.c
@@ -222,10 +222,6 @@ conf_parse_line(char **section, struct got_gitconfig *
 	size_t	 i;
 	int	 j;
 
-	/* Lines starting with '#' or ';' are comments.  */
-	if (*line == '#' || *line == ';')
-		return NULL;
-
 	/* '[section]' parsing...  */
 	if (*line == '[') {
 		for (i = 1; i < sz; i++)
@@ -248,6 +244,10 @@ conf_parse_line(char **section, struct got_gitconfig *
 		sz--;
 	}
 
+	/* Lines starting with '#' or ';' are comments.  */
+	if (*line == '#' || *line == ';')
+		return NULL;
+
 	/* Deal with assignments.  */
 	for (i = 0; i < sz; i++)
 		if (line[i] == '=') {
blob - 62bcb9f3f02f060aa7096a6fd0d8eb9f6ded5382
blob + 8ab732f77ce0d79d8a050bfedb50712fa26428d2
--- regress/cmdline/commit.sh
+++ regress/cmdline/commit.sh
@@ -982,6 +982,9 @@ test_commit_gitconfig_author() {
 
 	# retry with spaces in the git config
 	ed -s "$testroot/repo/.git/config" <<EOF
+/^\[user/ a
+    # it's me!
+.
 ,s/	/    /g
 wq
 EOF
@@ -989,13 +992,24 @@ EOF
 
 	# unset in a subshell to avoid affecting our environment
 	(unset GOT_IGNORE_GITCONFIG && cd "$testroot/wt" && \
-		got commit -m 'test gitconfig author again' >/dev/null)
+		got commit -m 'test gitconfig author again' \
+		>/dev/null 2>$testroot/stderr)
 	ret=$?
 	if [ $ret -ne 0 ]; then
 		test_done "$testroot" "$ret"
 		return 1
 	fi
 
+	# shouldn't have triggered any parsing error
+	echo -n > $testroot/stderr.expected
+	cmp -s $testroot/stderr.expected $testroot/stderr
+	ret=$?
+	if [ $ret -ne 0 ]; then
+		diff -u $testroot/stderr.expected $testroot/stderr
+		test_done "$testroot" "$ret"
+		return 1
+	fi
+
 	(cd "$testroot/repo" && got log -l1 | grep ^from: > $testroot/stdout)
 	ret=$?
 	if [ $ret -ne 0 ]; then