rerere: drop want_sp parameter from is_cmarker()

As the nature of the conflict marker line determines if there should be a SP and label after it, the caller shouldn't have to pass the parameter redundantly. Signed-off-by: Junio C Hamano <gitster@pobox.com>

Junio C Hamano committed Jun 29, 2015 at 15:05 UTC 67711cdc399203ec1d70cde2c3cd71e37e43da70
1 file changed +22 -5
rerere.c
+22 -5
@@ -148,8 +148,25 @@ static int rerere_file_getline(struct strbuf *sb, struct rerere_io *io_)
148 return strbuf_getwholeline(sb, io->input, '\n');
149 }
150
151 -static int is_cmarker(char *buf, int marker_char, int marker_size, int want_sp)
151 +/*
152 + * Require the exact number of conflict marker letters, no more, no
153 + * less, followed by SP or any whitespace
154 + * (including LF).
155 + */
156 +static int is_cmarker(char *buf, int marker_char, int marker_size)
157 {
158 + int want_sp;
159 +
160 + /*
161 + * The beginning of our version and the end of their version
162 + * always are labeled like "<<<<< ours" or ">>>>> theirs",
163 + * hence we set want_sp for them. Note that the version from
164 + * the common ancestor in diff3-style output is not always
165 + * labelled (e.g. "||||| common" is often seen but "|||||"
166 + * alone is also valid), so we do not set want_sp.
167 + */
168 + want_sp = (marker_char == '<') || (marker_char == '>');
169 +
170 while (marker_size--)
171 if (*buf++ != marker_char)
172 return 0;
@@ -172,19 +189,19 @@ static int handle_path(unsigned char *sha1, struct rerere_io *io, int marker_siz
189 git_SHA1_Init(&ctx);
190
191 while (!io->getline(&buf, io)) {
175 - if (is_cmarker(buf.buf, '<', marker_size, 1)) {
192 + if (is_cmarker(buf.buf, '<', marker_size)) {
193 if (hunk != RR_CONTEXT)
194 goto bad;
195 hunk = RR_SIDE_1;
179 - } else if (is_cmarker(buf.buf, '|', marker_size, 0)) {
196 + } else if (is_cmarker(buf.buf, '|', marker_size)) {
197 if (hunk != RR_SIDE_1)
198 goto bad;
199 hunk = RR_ORIGINAL;
183 - } else if (is_cmarker(buf.buf, '=', marker_size, 0)) {
200 + } else if (is_cmarker(buf.buf, '=', marker_size)) {
201 if (hunk != RR_SIDE_1 && hunk != RR_ORIGINAL)
202 goto bad;
203 hunk = RR_SIDE_2;
187 - } else if (is_cmarker(buf.buf, '>', marker_size, 1)) {
204 + } else if (is_cmarker(buf.buf, '>', marker_size)) {
205 if (hunk != RR_SIDE_2)
206 goto bad;
207 if (strbuf_cmp(&one, &two) > 0)