git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] merge & sequencer: turn "Conflicts:" hint into a comment

From
Christian Couder <christian.couder@gmail.com>
Date
Oct 28, 2014, 06:51 UTC
Message-ID
<CAP8UFD28mXm2nKRbah=Nv+2Tcuvvax+NdHdp7niiekbfk-i+9w@mail.gmail.com>
In-Reply-To
<xmqqegttfmg0.fsf@gitster.dls.corp.google.com>
On Mon, Oct 27, 2014 at 6:32 PM, Junio C Hamano <gitster@pobox.com> wrote:
Show 13 quoted lines
> Jeff King <peff@peff.net> writes:
>
>> If that is the only casualty, I think it is probably a net-win. We may
>> want better tooling around viewing the merge later, but that can wait
>> until somebody steps up with a real use case (because even that conflict
>> list may not be completely what they want; they may also want the list
>> of files that were auto-merged successfully, for example).
>
> Yup.
>
> Also Christian's "trailer" series may want to learn the same trick
> we did to builtin/commit.c in this series, if it does not already
> know about possible trailing comment and blank lines.

The trailer series already tries to ignore comments and blank lines. This is the relevant function:

/*
 * Return the (0 based) index of the first trailer line or count if
 * there are no trailers. Trailers are searched only in the lines from
 * index (count - 1) down to index 0.
 */
static int find_trailer_start(struct strbuf **lines, int count)
{
    int start, only_spaces = 1;
    /*
     * Get the start of the trailers by looking starting from the end
     * for a line with only spaces before lines with one separator.
     */
    for (start = count - 1; start >= 0; start--) {
        if (lines[start]->buf[0] == comment_line_char)
            continue;
        if (contains_only_spaces(lines[start]->buf)) {
            if (only_spaces)
                continue;
            return start + 1;
        }
        if (strcspn(lines[start]->buf, separators) < lines[start]->len) {
            if (only_spaces)
                only_spaces = 0;
            continue;
        }
        return count;
    }
    return only_spaces ? count : 0;
}

But I am not sure sure that it does all of what you do to builtin/commit.c in the above patch. I will have a look. Anyway I would be happy to use an existing function or to refactor some existing code into a shared function if possible.

Thanks, Christian.

Previous: Jeff KingNext: Jonathan Nieder
Message 9 of 11 in “builtin/merge.c: drop a parameter that is never used”
  1. builtin/merge.c: drop a parameter that is never usedJunio C Hamano, Oct 24, 2014
  2. Jonathan NiederOct 24, 2014
  3. merge & sequencer: unify codepaths that write "Conflicts:" hintJunio C Hamano, Oct 24, 2014
  4. merge & sequencer: turn "Conflicts:" hint into a commentJunio C Hamano, Oct 24, 2014
  5. Jeff KingOct 26, 2014
  6. Junio C HamanoOct 27, 2014
  7. Junio C HamanoOct 27, 2014
  8. Jeff KingOct 28, 2014
  9. Christian CouderOct 28, 2014
  10. Jonathan NiederOct 27, 2014
  11. Jeff KingOct 28, 2014

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.