From patchwork Thu Jan 24 13:11:34 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff King X-Patchwork-Id: 10778943 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 3EB3991E for ; Thu, 24 Jan 2019 13:11:38 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 243932F457 for ; Thu, 24 Jan 2019 13:11:38 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2276C2F468; Thu, 24 Jan 2019 13:11:38 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AADBC2F460 for ; Thu, 24 Jan 2019 13:11:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728017AbfAXNLg (ORCPT ); Thu, 24 Jan 2019 08:11:36 -0500 Received: from cloud.peff.net ([104.130.231.41]:47178 "HELO cloud.peff.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with SMTP id S1726105AbfAXNLg (ORCPT ); Thu, 24 Jan 2019 08:11:36 -0500 Received: (qmail 27422 invoked by uid 109); 24 Jan 2019 13:11:35 -0000 Received: from Unknown (HELO peff.net) (10.0.1.2) by cloud.peff.net (qpsmtpd/0.94) with SMTP; Thu, 24 Jan 2019 13:11:35 +0000 Authentication-Results: cloud.peff.net; auth=none Received: (qmail 28231 invoked by uid 111); 24 Jan 2019 13:11:40 -0000 Received: from sigill.intra.peff.net (HELO sigill.intra.peff.net) (10.0.0.7) by peff.net (qpsmtpd/0.94) with (ECDHE-RSA-AES256-GCM-SHA384 encrypted) SMTP; Thu, 24 Jan 2019 08:11:40 -0500 Authentication-Results: peff.net; auth=none Received: by sigill.intra.peff.net (sSMTP sendmail emulation); Thu, 24 Jan 2019 08:11:34 -0500 Date: Thu, 24 Jan 2019 08:11:34 -0500 From: Jeff King To: git@vger.kernel.org Subject: [PATCH 1/8] match-trees: drop unused path parameter from score functions Message-ID: <20190124131133.GA22398@sigill.intra.peff.net> References: <20190124131104.GA24017@sigill.intra.peff.net> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20190124131104.GA24017@sigill.intra.peff.net> Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The scores do not take the particular path into account at all. It's possible they could, but these are all static file-local functions. It won't be a big deal to re-add the parameter if they ever need it. Signed-off-by: Jeff King --- match-trees.c | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/match-trees.c b/match-trees.c index 2b6d31ef9d..e65e665bf5 100644 --- a/match-trees.c +++ b/match-trees.c @@ -3,7 +3,7 @@ #include "tree-walk.h" #include "object-store.h" -static int score_missing(unsigned mode, const char *path) +static int score_missing(unsigned mode) { int score; @@ -16,7 +16,7 @@ static int score_missing(unsigned mode, const char *path) return score; } -static int score_differs(unsigned mode1, unsigned mode2, const char *path) +static int score_differs(unsigned mode1, unsigned mode2) { int score; @@ -29,7 +29,7 @@ static int score_differs(unsigned mode1, unsigned mode2, const char *path) return score; } -static int score_matches(unsigned mode1, unsigned mode2, const char *path) +static int score_matches(unsigned mode1, unsigned mode2) { int score; @@ -98,24 +98,22 @@ static int score_trees(const struct object_id *hash1, const struct object_id *ha if (cmp < 0) { /* path1 does not appear in two */ - score += score_missing(one.entry.mode, one.entry.path); + score += score_missing(one.entry.mode); update_tree_entry(&one); } else if (cmp > 0) { /* path2 does not appear in one */ - score += score_missing(two.entry.mode, two.entry.path); + score += score_missing(two.entry.mode); update_tree_entry(&two); } else { /* path appears in both */ if (!oideq(one.entry.oid, two.entry.oid)) { /* they are different */ score += score_differs(one.entry.mode, - two.entry.mode, - one.entry.path); + two.entry.mode); } else { /* same subtree or blob */ score += score_matches(one.entry.mode, - two.entry.mode, - one.entry.path); + two.entry.mode); } update_tree_entry(&one); update_tree_entry(&two); From patchwork Thu Jan 24 13:11:42 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff King X-Patchwork-Id: 10778945 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 3C28E91E for ; Thu, 24 Jan 2019 13:11:46 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 064E62F451 for ; Thu, 24 Jan 2019 13:11:46 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 046CB2F476; Thu, 24 Jan 2019 13:11:46 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A11862F451 for ; Thu, 24 Jan 2019 13:11:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728020AbfAXNLo (ORCPT ); Thu, 24 Jan 2019 08:11:44 -0500 Received: from cloud.peff.net ([104.130.231.41]:47184 "HELO cloud.peff.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with SMTP id S1726105AbfAXNLo (ORCPT ); Thu, 24 Jan 2019 08:11:44 -0500 Received: (qmail 27428 invoked by uid 109); 24 Jan 2019 13:11:44 -0000 Received: from Unknown (HELO peff.net) (10.0.1.2) by cloud.peff.net (qpsmtpd/0.94) with SMTP; Thu, 24 Jan 2019 13:11:44 +0000 Authentication-Results: cloud.peff.net; auth=none Received: (qmail 28247 invoked by uid 111); 24 Jan 2019 13:11:48 -0000 Received: from sigill.intra.peff.net (HELO sigill.intra.peff.net) (10.0.0.7) by peff.net (qpsmtpd/0.94) with (ECDHE-RSA-AES256-GCM-SHA384 encrypted) SMTP; Thu, 24 Jan 2019 08:11:48 -0500 Authentication-Results: peff.net; auth=none Received: by sigill.intra.peff.net (sSMTP sendmail emulation); Thu, 24 Jan 2019 08:11:42 -0500 Date: Thu, 24 Jan 2019 08:11:42 -0500 From: Jeff King To: git@vger.kernel.org Subject: [PATCH 2/8] apply: drop unused "def" parameter from find_name_gnu() Message-ID: <20190124131142.GB22398@sigill.intra.peff.net> References: <20190124131104.GA24017@sigill.intra.peff.net> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20190124131104.GA24017@sigill.intra.peff.net> Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP We use the "def" parameter in find_name_common() for some heuristics, but they are not necessary with the less-ambiguous GNU format. Let's drop this unused parameter. Signed-off-by: Jeff King --- apply.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/apply.c b/apply.c index 3703bfc8d0..ccab7e7907 100644 --- a/apply.c +++ b/apply.c @@ -467,7 +467,6 @@ static char *squash_slash(char *name) static char *find_name_gnu(struct apply_state *state, const char *line, - const char *def, int p_value) { struct strbuf name = STRBUF_INIT; @@ -714,7 +713,7 @@ static char *find_name(struct apply_state *state, int terminate) { if (*line == '"') { - char *name = find_name_gnu(state, line, def, p_value); + char *name = find_name_gnu(state, line, p_value); if (name) return name; } @@ -731,7 +730,7 @@ static char *find_name_traditional(struct apply_state *state, size_t date_len; if (*line == '"') { - char *name = find_name_gnu(state, line, def, p_value); + char *name = find_name_gnu(state, line, p_value); if (name) return name; } From patchwork Thu Jan 24 13:11:51 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff King X-Patchwork-Id: 10778947 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 2D2AC91E for ; Thu, 24 Jan 2019 13:11:56 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EC2532F461 for ; Thu, 24 Jan 2019 13:11:55 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E9D362F487; Thu, 24 Jan 2019 13:11:55 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 946F72F461 for ; Thu, 24 Jan 2019 13:11:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728052AbfAXNLy (ORCPT ); Thu, 24 Jan 2019 08:11:54 -0500 Received: from cloud.peff.net ([104.130.231.41]:47190 "HELO cloud.peff.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with SMTP id S1726105AbfAXNLx (ORCPT ); Thu, 24 Jan 2019 08:11:53 -0500 Received: (qmail 27437 invoked by uid 109); 24 Jan 2019 13:11:53 -0000 Received: from Unknown (HELO peff.net) (10.0.1.2) by cloud.peff.net (qpsmtpd/0.94) with SMTP; Thu, 24 Jan 2019 13:11:53 +0000 Authentication-Results: cloud.peff.net; auth=none Received: (qmail 28264 invoked by uid 111); 24 Jan 2019 13:11:58 -0000 Received: from sigill.intra.peff.net (HELO sigill.intra.peff.net) (10.0.0.7) by peff.net (qpsmtpd/0.94) with (ECDHE-RSA-AES256-GCM-SHA384 encrypted) SMTP; Thu, 24 Jan 2019 08:11:58 -0500 Authentication-Results: peff.net; auth=none Received: by sigill.intra.peff.net (sSMTP sendmail emulation); Thu, 24 Jan 2019 08:11:51 -0500 Date: Thu, 24 Jan 2019 08:11:51 -0500 From: Jeff King To: git@vger.kernel.org Subject: [PATCH 3/8] create_bundle(): drop unused "header" parameter Message-ID: <20190124131151.GC22398@sigill.intra.peff.net> References: <20190124131104.GA24017@sigill.intra.peff.net> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20190124131104.GA24017@sigill.intra.peff.net> Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP There's no need to pass a header struct to create_bundle(); it writes the header information directly to a descriptor (and does not report back details to the caller). Signed-off-by: Jeff King --- builtin/bundle.c | 3 +-- bundle.c | 4 ++-- bundle.h | 4 ++-- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/builtin/bundle.c b/builtin/bundle.c index 9e9c65d9c6..1ea4bfdfc1 100644 --- a/builtin/bundle.c +++ b/builtin/bundle.c @@ -56,8 +56,7 @@ int cmd_bundle(int argc, const char **argv, const char *prefix) } if (!startup_info->have_repository) die(_("Need a repository to create a bundle.")); - return !!create_bundle(the_repository, &header, - bundle_file, argc, argv); + return !!create_bundle(the_repository, bundle_file, argc, argv); } else if (!strcmp(cmd, "unbundle")) { if (!startup_info->have_repository) die(_("Need a repository to unbundle.")); diff --git a/bundle.c b/bundle.c index 37b1daa691..b45666c49b 100644 --- a/bundle.c +++ b/bundle.c @@ -424,8 +424,8 @@ static int write_bundle_refs(int bundle_fd, struct rev_info *revs) return ref_count; } -int create_bundle(struct repository *r, struct bundle_header *header, - const char *path, int argc, const char **argv) +int create_bundle(struct repository *r, const char *path, + int argc, const char **argv) { struct lock_file lock = LOCK_INIT; int bundle_fd = -1; diff --git a/bundle.h b/bundle.h index 781e6f5c3a..37c37d7f65 100644 --- a/bundle.h +++ b/bundle.h @@ -18,8 +18,8 @@ struct bundle_header { int is_bundle(const char *path, int quiet); int read_bundle_header(const char *path, struct bundle_header *header); -int create_bundle(struct repository *r, struct bundle_header *header, - const char *path, int argc, const char **argv); +int create_bundle(struct repository *r, const char *path, + int argc, const char **argv); int verify_bundle(struct repository *r, struct bundle_header *header, int verbose); #define BUNDLE_VERBOSE 1 int unbundle(struct repository *r, struct bundle_header *header, From patchwork Thu Jan 24 13:11:59 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff King X-Patchwork-Id: 10778951 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C17FF91E for ; Thu, 24 Jan 2019 13:12:02 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 74A332F451 for ; Thu, 24 Jan 2019 13:12:02 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7351F2F475; Thu, 24 Jan 2019 13:12:02 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 232B92F476 for ; Thu, 24 Jan 2019 13:12:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728067AbfAXNMB (ORCPT ); Thu, 24 Jan 2019 08:12:01 -0500 Received: from cloud.peff.net ([104.130.231.41]:47196 "HELO cloud.peff.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with SMTP id S1728066AbfAXNMA (ORCPT ); Thu, 24 Jan 2019 08:12:00 -0500 Received: (qmail 27445 invoked by uid 109); 24 Jan 2019 13:12:00 -0000 Received: from Unknown (HELO peff.net) (10.0.1.2) by cloud.peff.net (qpsmtpd/0.94) with SMTP; Thu, 24 Jan 2019 13:12:00 +0000 Authentication-Results: cloud.peff.net; auth=none Received: (qmail 28281 invoked by uid 111); 24 Jan 2019 13:12:05 -0000 Received: from sigill.intra.peff.net (HELO sigill.intra.peff.net) (10.0.0.7) by peff.net (qpsmtpd/0.94) with (ECDHE-RSA-AES256-GCM-SHA384 encrypted) SMTP; Thu, 24 Jan 2019 08:12:05 -0500 Authentication-Results: peff.net; auth=none Received: by sigill.intra.peff.net (sSMTP sendmail emulation); Thu, 24 Jan 2019 08:11:59 -0500 Date: Thu, 24 Jan 2019 08:11:59 -0500 From: Jeff King To: git@vger.kernel.org Subject: [PATCH 4/8] column: drop unused "opts" parameter in item_length() Message-ID: <20190124131158.GD22398@sigill.intra.peff.net> References: <20190124131104.GA24017@sigill.intra.peff.net> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20190124131104.GA24017@sigill.intra.peff.net> Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP There are no column options which impact the length computation. In theory there might be, but this is a file-local function, so it will be trivial to re-add the parameter should it ever be useful. Signed-off-by: Jeff King --- column.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/column.c b/column.c index 2165297608..7a17c14b82 100644 --- a/column.c +++ b/column.c @@ -21,7 +21,7 @@ struct column_data { }; /* return length of 's' in letters, ANSI escapes stripped */ -static int item_length(unsigned int colopts, const char *s) +static int item_length(const char *s) { int len, i = 0; struct strbuf str = STRBUF_INIT; @@ -167,7 +167,7 @@ static void display_table(const struct string_list *list, ALLOC_ARRAY(data.len, list->nr); for (i = 0; i < list->nr; i++) - data.len[i] = item_length(colopts, list->items[i].string); + data.len[i] = item_length(list->items[i].string); layout(&data, &initial_width); From patchwork Thu Jan 24 13:12:21 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff King X-Patchwork-Id: 10778953 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id ED66017F0 for ; Thu, 24 Jan 2019 13:12:25 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C0F6B2F493 for ; Thu, 24 Jan 2019 13:12:25 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BF8302F491; Thu, 24 Jan 2019 13:12:25 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 67FA72F498 for ; Thu, 24 Jan 2019 13:12:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728083AbfAXNMY (ORCPT ); Thu, 24 Jan 2019 08:12:24 -0500 Received: from cloud.peff.net ([104.130.231.41]:47202 "HELO cloud.peff.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with SMTP id S1727798AbfAXNMX (ORCPT ); Thu, 24 Jan 2019 08:12:23 -0500 Received: (qmail 27481 invoked by uid 109); 24 Jan 2019 13:12:23 -0000 Received: from Unknown (HELO peff.net) (10.0.1.2) by cloud.peff.net (qpsmtpd/0.94) with SMTP; Thu, 24 Jan 2019 13:12:23 +0000 Authentication-Results: cloud.peff.net; auth=none Received: (qmail 28297 invoked by uid 111); 24 Jan 2019 13:12:28 -0000 Received: from sigill.intra.peff.net (HELO sigill.intra.peff.net) (10.0.0.7) by peff.net (qpsmtpd/0.94) with (ECDHE-RSA-AES256-GCM-SHA384 encrypted) SMTP; Thu, 24 Jan 2019 08:12:28 -0500 Authentication-Results: peff.net; auth=none Received: by sigill.intra.peff.net (sSMTP sendmail emulation); Thu, 24 Jan 2019 08:12:21 -0500 Date: Thu, 24 Jan 2019 08:12:21 -0500 From: Jeff King To: git@vger.kernel.org Subject: [PATCH 5/8] show_date_relative(): drop unused "tz" parameter Message-ID: <20190124131221.GE22398@sigill.intra.peff.net> References: <20190124131104.GA24017@sigill.intra.peff.net> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20190124131104.GA24017@sigill.intra.peff.net> Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The timestamp we receive is in epoch time, so there's no need for a timezone parameter to interpret it. The matching show_date() uses "tz" to show dates in author local time, but relative dates show only the absolute time difference. The author's location is irrelevant, barring relativistic effects from using Git close to the speed of light. Signed-off-by: Jeff King --- cache.h | 2 +- date.c | 8 ++++---- t/helper/test-date.c | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/cache.h b/cache.h index 49713cc5a5..8d97939c0d 100644 --- a/cache.h +++ b/cache.h @@ -1464,7 +1464,7 @@ struct date_mode { struct date_mode *date_mode_from_type(enum date_mode_type type); const char *show_date(timestamp_t time, int timezone, const struct date_mode *mode); -void show_date_relative(timestamp_t time, int tz, const struct timeval *now, +void show_date_relative(timestamp_t time, const struct timeval *now, struct strbuf *timebuf); int parse_date(const char *date, struct strbuf *out); int parse_date_basic(const char *date, timestamp_t *timestamp, int *offset); diff --git a/date.c b/date.c index 9bc15df6f9..61449f8b2e 100644 --- a/date.c +++ b/date.c @@ -107,9 +107,9 @@ static int local_tzoffset(timestamp_t time) return offset * eastwest; } -void show_date_relative(timestamp_t time, int tz, - const struct timeval *now, - struct strbuf *timebuf) +void show_date_relative(timestamp_t time, + const struct timeval *now, + struct strbuf *timebuf) { timestamp_t diff; if (now->tv_sec < time) { @@ -216,7 +216,7 @@ const char *show_date(timestamp_t time, int tz, const struct date_mode *mode) strbuf_reset(&timebuf); gettimeofday(&now, NULL); - show_date_relative(time, tz, &now, &timebuf); + show_date_relative(time, &now, &timebuf); return timebuf.buf; } diff --git a/t/helper/test-date.c b/t/helper/test-date.c index a0837371ab..aac4d542c2 100644 --- a/t/helper/test-date.c +++ b/t/helper/test-date.c @@ -16,7 +16,7 @@ static void show_relative_dates(const char **argv, struct timeval *now) for (; *argv; argv++) { time_t t = atoi(*argv); - show_date_relative(t, 0, now, &buf); + show_date_relative(t, now, &buf); printf("%s -> %s\n", *argv, buf.buf); } strbuf_release(&buf); From patchwork Thu Jan 24 13:12:32 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff King X-Patchwork-Id: 10778959 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 4773017F0 for ; Thu, 24 Jan 2019 13:12:36 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 096292F49C for ; Thu, 24 Jan 2019 13:12:36 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 07A792F4A6; Thu, 24 Jan 2019 13:12:36 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 94DAB2F494 for ; Thu, 24 Jan 2019 13:12:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728108AbfAXNMe (ORCPT ); Thu, 24 Jan 2019 08:12:34 -0500 Received: from cloud.peff.net ([104.130.231.41]:47208 "HELO cloud.peff.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with SMTP id S1727798AbfAXNMe (ORCPT ); Thu, 24 Jan 2019 08:12:34 -0500 Received: (qmail 27487 invoked by uid 109); 24 Jan 2019 13:12:34 -0000 Received: from Unknown (HELO peff.net) (10.0.1.2) by cloud.peff.net (qpsmtpd/0.94) with SMTP; Thu, 24 Jan 2019 13:12:34 +0000 Authentication-Results: cloud.peff.net; auth=none Received: (qmail 28313 invoked by uid 111); 24 Jan 2019 13:12:38 -0000 Received: from sigill.intra.peff.net (HELO sigill.intra.peff.net) (10.0.0.7) by peff.net (qpsmtpd/0.94) with (ECDHE-RSA-AES256-GCM-SHA384 encrypted) SMTP; Thu, 24 Jan 2019 08:12:38 -0500 Authentication-Results: peff.net; auth=none Received: by sigill.intra.peff.net (sSMTP sendmail emulation); Thu, 24 Jan 2019 08:12:32 -0500 Date: Thu, 24 Jan 2019 08:12:32 -0500 From: Jeff King To: git@vger.kernel.org Subject: [PATCH 6/8] config: drop unused parameter from maybe_remove_section() Message-ID: <20190124131232.GF22398@sigill.intra.peff.net> References: <20190124131104.GA24017@sigill.intra.peff.net> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20190124131104.GA24017@sigill.intra.peff.net> Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP We don't need the contents buffer to drop a section; the parse information in the config_store_data parameter is enough for our logic. Signed-off-by: Jeff King --- config.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/config.c b/config.c index ff521eb27a..24ad1a9854 100644 --- a/config.c +++ b/config.c @@ -2565,7 +2565,6 @@ static ssize_t write_pair(int fd, const char *key, const char *value, * entry (which all are to be removed). */ static void maybe_remove_section(struct config_store_data *store, - const char *contents, size_t *begin_offset, size_t *end_offset, int *seen_ptr) { @@ -2850,7 +2849,7 @@ int git_config_set_multivar_in_file_gently(const char *config_filename, replace_end = store.parsed[j].end; copy_end = store.parsed[j].begin; if (!value) - maybe_remove_section(&store, contents, + maybe_remove_section(&store, ©_end, &replace_end, &i); /* From patchwork Thu Jan 24 13:12:41 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff King X-Patchwork-Id: 10778961 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 3B7DA91E for ; Thu, 24 Jan 2019 13:12:45 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BC1722F47A for ; Thu, 24 Jan 2019 13:12:44 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BAA4A2F4AD; Thu, 24 Jan 2019 13:12:44 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4ECBB2F4BB for ; Thu, 24 Jan 2019 13:12:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728109AbfAXNMn (ORCPT ); Thu, 24 Jan 2019 08:12:43 -0500 Received: from cloud.peff.net ([104.130.231.41]:47214 "HELO cloud.peff.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with SMTP id S1727798AbfAXNMn (ORCPT ); Thu, 24 Jan 2019 08:12:43 -0500 Received: (qmail 27493 invoked by uid 109); 24 Jan 2019 13:12:42 -0000 Received: from Unknown (HELO peff.net) (10.0.1.2) by cloud.peff.net (qpsmtpd/0.94) with SMTP; Thu, 24 Jan 2019 13:12:42 +0000 Authentication-Results: cloud.peff.net; auth=none Received: (qmail 28329 invoked by uid 111); 24 Jan 2019 13:12:47 -0000 Received: from sigill.intra.peff.net (HELO sigill.intra.peff.net) (10.0.0.7) by peff.net (qpsmtpd/0.94) with (ECDHE-RSA-AES256-GCM-SHA384 encrypted) SMTP; Thu, 24 Jan 2019 08:12:47 -0500 Authentication-Results: peff.net; auth=none Received: by sigill.intra.peff.net (sSMTP sendmail emulation); Thu, 24 Jan 2019 08:12:41 -0500 Date: Thu, 24 Jan 2019 08:12:41 -0500 From: Jeff King To: git@vger.kernel.org Subject: [PATCH 7/8] convert: drop len parameter from conversion checks Message-ID: <20190124131240.GG22398@sigill.intra.peff.net> References: <20190124131104.GA24017@sigill.intra.peff.net> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20190124131104.GA24017@sigill.intra.peff.net> Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP We've already extracted the useful information into our text_stat struct, so the length is no longer needed. Signed-off-by: Jeff King --- convert.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/convert.c b/convert.c index 0d89ae7c23..dafd6db643 100644 --- a/convert.c +++ b/convert.c @@ -92,7 +92,7 @@ static void gather_stats(const char *buf, unsigned long size, struct text_stat * * The same heuristics as diff.c::mmfile_is_binary() * We treat files with bare CR as binary */ -static int convert_is_binary(unsigned long size, const struct text_stat *stats) +static int convert_is_binary(const struct text_stat *stats) { if (stats->lonecr) return 1; @@ -110,7 +110,7 @@ static unsigned int gather_convert_stats(const char *data, unsigned long size) if (!data || !size) return 0; gather_stats(data, size, &stats); - if (convert_is_binary(size, &stats)) + if (convert_is_binary(&stats)) ret |= CONVERT_STAT_BITS_BIN; if (stats.crlf) ret |= CONVERT_STAT_BITS_TXT_CRLF; @@ -245,7 +245,7 @@ static int has_crlf_in_index(const struct index_state *istate, const char *path) return has_crlf; } -static int will_convert_lf_to_crlf(size_t len, struct text_stat *stats, +static int will_convert_lf_to_crlf(struct text_stat *stats, enum crlf_action crlf_action) { if (output_eol(crlf_action) != EOL_CRLF) @@ -260,7 +260,7 @@ static int will_convert_lf_to_crlf(size_t len, struct text_stat *stats, if (stats->lonecr || stats->crlf) return 0; - if (convert_is_binary(len, stats)) + if (convert_is_binary(stats)) return 0; } return 1; @@ -527,7 +527,7 @@ static int crlf_to_git(const struct index_state *istate, convert_crlf_into_lf = !!stats.crlf; if (crlf_action == CRLF_AUTO || crlf_action == CRLF_AUTO_INPUT || crlf_action == CRLF_AUTO_CRLF) { - if (convert_is_binary(len, &stats)) + if (convert_is_binary(&stats)) return 0; /* * If the file in the index has any CR in it, do not @@ -549,7 +549,7 @@ static int crlf_to_git(const struct index_state *istate, new_stats.crlf = 0; } /* simulate "git checkout" */ - if (will_convert_lf_to_crlf(len, &new_stats, crlf_action)) { + if (will_convert_lf_to_crlf(&new_stats, crlf_action)) { new_stats.crlf += new_stats.lonelf; new_stats.lonelf = 0; } @@ -601,7 +601,7 @@ static int crlf_to_worktree(const char *path, const char *src, size_t len, return 0; gather_stats(src, len, &stats); - if (!will_convert_lf_to_crlf(len, &stats, crlf_action)) + if (!will_convert_lf_to_crlf(&stats, crlf_action)) return 0; /* are we "faking" in place editing ? */ From patchwork Thu Jan 24 13:12:51 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff King X-Patchwork-Id: 10778963 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 170E717F0 for ; Thu, 24 Jan 2019 13:12:55 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id ECAAA2F4C1 for ; Thu, 24 Jan 2019 13:12:54 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id EA4E22F4C9; Thu, 24 Jan 2019 13:12:54 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7F4172F4C3 for ; Thu, 24 Jan 2019 13:12:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728130AbfAXNMx (ORCPT ); Thu, 24 Jan 2019 08:12:53 -0500 Received: from cloud.peff.net ([104.130.231.41]:47220 "HELO cloud.peff.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with SMTP id S1727798AbfAXNMx (ORCPT ); Thu, 24 Jan 2019 08:12:53 -0500 Received: (qmail 27504 invoked by uid 109); 24 Jan 2019 13:12:52 -0000 Received: from Unknown (HELO peff.net) (10.0.1.2) by cloud.peff.net (qpsmtpd/0.94) with SMTP; Thu, 24 Jan 2019 13:12:52 +0000 Authentication-Results: cloud.peff.net; auth=none Received: (qmail 28345 invoked by uid 111); 24 Jan 2019 13:12:57 -0000 Received: from sigill.intra.peff.net (HELO sigill.intra.peff.net) (10.0.0.7) by peff.net (qpsmtpd/0.94) with (ECDHE-RSA-AES256-GCM-SHA384 encrypted) SMTP; Thu, 24 Jan 2019 08:12:57 -0500 Authentication-Results: peff.net; auth=none Received: by sigill.intra.peff.net (sSMTP sendmail emulation); Thu, 24 Jan 2019 08:12:51 -0500 Date: Thu, 24 Jan 2019 08:12:51 -0500 From: Jeff King To: git@vger.kernel.org Subject: [PATCH 8/8] convert: drop path parameter from actual conversion functions Message-ID: <20190124131250.GH22398@sigill.intra.peff.net> References: <20190124131104.GA24017@sigill.intra.peff.net> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20190124131104.GA24017@sigill.intra.peff.net> Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The caller is responsible for looking up the attributes, after which point we no longer care about the path at which the content is found. Signed-off-by: Jeff King --- convert.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/convert.c b/convert.c index dafd6db643..d8d7df3353 100644 --- a/convert.c +++ b/convert.c @@ -591,7 +591,7 @@ static int crlf_to_git(const struct index_state *istate, return 1; } -static int crlf_to_worktree(const char *path, const char *src, size_t len, +static int crlf_to_worktree(const char *src, size_t len, struct strbuf *buf, enum crlf_action crlf_action) { char *to_free = NULL; @@ -1091,7 +1091,7 @@ static int count_ident(const char *cp, unsigned long size) return cnt; } -static int ident_to_git(const char *path, const char *src, size_t len, +static int ident_to_git(const char *src, size_t len, struct strbuf *buf, int ident) { char *dst, *dollar; @@ -1135,7 +1135,7 @@ static int ident_to_git(const char *path, const char *src, size_t len, return 1; } -static int ident_to_worktree(const char *path, const char *src, size_t len, +static int ident_to_worktree(const char *src, size_t len, struct strbuf *buf, int ident) { struct object_id oid; @@ -1416,7 +1416,7 @@ int convert_to_git(const struct index_state *istate, len = dst->len; } } - return ret | ident_to_git(path, src, len, dst, ca.ident); + return ret | ident_to_git(src, len, dst, ca.ident); } void convert_to_git_filter_fd(const struct index_state *istate, @@ -1434,7 +1434,7 @@ void convert_to_git_filter_fd(const struct index_state *istate, encode_to_git(path, dst->buf, dst->len, dst, ca.working_tree_encoding, conv_flags); crlf_to_git(istate, path, dst->buf, dst->len, dst, ca.crlf_action, conv_flags); - ident_to_git(path, dst->buf, dst->len, dst, ca.ident); + ident_to_git(dst->buf, dst->len, dst, ca.ident); } static int convert_to_working_tree_internal(const struct index_state *istate, @@ -1447,7 +1447,7 @@ static int convert_to_working_tree_internal(const struct index_state *istate, convert_attrs(istate, &ca, path); - ret |= ident_to_worktree(path, src, len, dst, ca.ident); + ret |= ident_to_worktree(src, len, dst, ca.ident); if (ret) { src = dst->buf; len = dst->len; @@ -1458,7 +1458,7 @@ static int convert_to_working_tree_internal(const struct index_state *istate, * support smudge). The filters might expect CRLFs. */ if ((ca.drv && (ca.drv->smudge || ca.drv->process)) || !normalizing) { - ret |= crlf_to_worktree(path, src, len, dst, ca.crlf_action); + ret |= crlf_to_worktree(src, len, dst, ca.crlf_action); if (ret) { src = dst->buf; len = dst->len;