Commit Diff


commit - 5fab8a45de8c63893f21c921fea101ddcc8750c9
commit + 2cf2727869f4962f1624068c72a409a05b7b5fc7
blob - 8bf26eabf2fe6945da88fe0dafc38214441646df
blob + 2f0107d30542ab7461e91e093a372fc1d8f9e8f7
--- lib/gitconfig.c
+++ lib/gitconfig.c
@@ -223,10 +223,6 @@ conf_parse_line(char **section, struct got_gitconfig *
 	char	*val;
 	size_t	 i;
 	int	 j;
-
-	/* Lines starting with '#' or ';' are comments.  */
-	if (*line == '#' || *line == ';')
-		return NULL;
 
 	/* '[section]' parsing...  */
 	if (*line == '[') {
@@ -249,6 +245,10 @@ conf_parse_line(char **section, struct got_gitconfig *
 		line++;
 		sz--;
 	}
+
+	/* Lines starting with '#' or ';' are comments.  */
+	if (*line == '#' || *line == ';')
+		return NULL;
 
 	/* Deal with assignments.  */
 	for (i = 0; i < sz; i++)
blob - 249a74ed96e20bcfec2a5b7b1fc8b1c2230b05a8
blob + a2032490522a301669166115d59f44d3cf4d93d0
--- 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,9 +992,20 @@ 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