From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-Status: No, score=-3.6 required=3.0 tests=AWL,BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_PASS,SPF_PASS shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by dcvr.yhbt.net (Postfix) with ESMTP id F21671F4B4 for ; Fri, 15 Jan 2021 08:48:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730834AbhAOIpt (ORCPT ); Fri, 15 Jan 2021 03:45:49 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46486 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730750AbhAOIps (ORCPT ); Fri, 15 Jan 2021 03:45:48 -0500 Received: from mail-ej1-x62b.google.com (mail-ej1-x62b.google.com [IPv6:2a00:1450:4864:20::62b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 319DFC061757 for ; Fri, 15 Jan 2021 00:45:08 -0800 (PST) Received: by mail-ej1-x62b.google.com with SMTP id r12so810411ejb.9 for ; Fri, 15 Jan 2021 00:45:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=H3FGogfrOlZYzzJx7oyy5WGaDkXUqbYDBHhOjM1pxY8=; b=u9U4rX3nCvHaAkmzFTZZ100x7X9XazUW2hbsCozm7TplG+66iahcQOsruPhEd4z6L9 WE9gDhSLmlQ45ehGsH8OCeUlZrKMEhkLFcwrKRYGC/GqaTcuxvN0E3p5cXkl9lWe2vH2 G3t6wl3yWR/Gk304Gaj/j6cp319e3wWas9gbaT1yF7O2GmiHZ8iF5C1Reyl0ZcZbgCci ZjF5oDlo6CNL++u6BQ1jCwPVkKOl4rHT2aWHHv0b6UqEpClQXYpB1JZRGocLR5TFbFN3 JSllbci1P7Fd5xzcXfcP7U2iwC3C4gbK2OlDfVV9OqmqxOcnC4+ZNM7u2GmQzS7zlOzo Jk8g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=H3FGogfrOlZYzzJx7oyy5WGaDkXUqbYDBHhOjM1pxY8=; b=TjsKJov3FGxTmCC8gts0+M9RMnv+4zCwRmO8GanRKjqfqArc6KDE6ISH/2Ta33vEJT c+IA2zCxB5ZdhZo4ezch4BO9dKrjURf3Fgjw47CEbSe7JMcMhL60dtlqqWEO+UGNepIP gTuSnOmbNZjANC8rLN4MKcApVk1tGGc14BKAF+JExARgWFQqkw96T2BKD7QlL1RpWmMc O9SfIPHD/XIhCSoG1QTmPRCs/6yLPxCaECkOIynpeL6bqsvXG74+OAFLkT+RjO+Zz2ZO SrBQTszcohf8c7nagVPrqC6h/artU7X6H1/eS1dcKFXoXFGDE/dHKCeZKBM6bMffzDbM W9iA== X-Gm-Message-State: AOAM531Ve2CJfa56IK72aEQ89+AfRBF4u/1Yuq9Sd4G3RfL1NCzu523v duDB/mAWM04Kbork4elC60ZEioFtUjSsYoURFDo= X-Google-Smtp-Source: ABdhPJxpr4KLdFVLX/G+HRLnNe/5zS40qx7tyTGXkTbo7TzoRCNpqmAZNqAdK7pYfpAekZZz6g6OIZK01fiki5M/Wlo= X-Received: by 2002:a17:906:e212:: with SMTP id gf18mr8203859ejb.551.1610700306822; Fri, 15 Jan 2021 00:45:06 -0800 (PST) MIME-Version: 1.0 References: <20210108092345.2178-1-charvi077@gmail.com> <20210108092345.2178-4-charvi077@gmail.com> In-Reply-To: From: Christian Couder Date: Fri, 15 Jan 2021 09:44:54 +0100 Message-ID: Subject: Re: [RFC PATCH 3/9] rebase -i: comment out squash!/fixup! subjects from squash message To: Charvi Mendiratta Cc: Phillip Wood , Taylor Blau , git , Phillip Wood , Johannes Schindelin Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Hi Charvi, On Fri, Jan 15, 2021 at 9:35 AM Charvi Mendiratta wrote: > On Thu, 14 Jan 2021 at 15:59, Phillip Wood wrote: > > On 14/01/2021 08:27, Charvi Mendiratta wrote: > > > On Thu, 14 Jan 2021 at 00:31, Taylor Blau wrote: > > >> > > >> On Fri, Jan 08, 2021 at 02:53:41PM +0530, Charvi Mendiratta wrote: > > >>> From: Phillip Wood > > >>> +static size_t subject_length(const char *body) > > >>> +{ > > >>> + size_t i, len = 0; > > >>> + char c; > > >>> + int blank_line = 1; > > >>> + for (i = 0, c = body[i]; c; c = body[++i]) { > > >>> + if (c == '\n') { > > >>> + if (blank_line) > > >>> + return len; > > >>> + len = i + 1; > > >>> + blank_line = 1; > > >>> + } else if (!isspace(c)) { > > >>> + blank_line = 0; > > >>> + } > > >>> + } > > >>> + return blank_line ? len : i; > > >>> +} > > >> > > >> OK, so this gets the length of the subject in "body", which is defined > > >> as the run of characters before a newline and then a space character. > > > > The length of the subject is the run of characters before a line > > containing only whitespace, "hello\n there" would return 13 "hello\n > > \nthere" would return 5. Looking again at my code there must be a way of > > writing that function that is easier to follow. > > Okay. I will look into it once, thanks for explaining. You may want to look at other places in the code where we deal with the subject. For example there is find_commit_subject() in commit.c and find_trailer_start() in trailer.c that might have interesting code for our purpose. Best, Christian.