From patchwork Mon Nov 4 20:03:46 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denton Liu X-Patchwork-Id: 11226363 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 8042B1747 for ; Mon, 4 Nov 2019 20:03:52 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 5E74320869 for ; Mon, 4 Nov 2019 20:03:52 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="qG7IDU00" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728766AbfKDUDv (ORCPT ); Mon, 4 Nov 2019 15:03:51 -0500 Received: from mail-pg1-f176.google.com ([209.85.215.176]:37155 "EHLO mail-pg1-f176.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728332AbfKDUDu (ORCPT ); Mon, 4 Nov 2019 15:03:50 -0500 Received: by mail-pg1-f176.google.com with SMTP id z24so7581191pgu.4 for ; Mon, 04 Nov 2019 12:03:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=GoMo9fR9bHK2xS8ar6rwuXwfMe7x/xt+BpMvl3iJGNM=; b=qG7IDU004BV8/QT/utrgjy6e0/grk3YlvqgSKcvHprfrNb1woeT4hg9SbIduDf0Ff9 RFfrprWQXaberGTlxw3HfOWRCPSJs+Ly8s3u3wHbvWbqs4k2aA+Re8CRGgeyzZwniPft 1MRhs04QP3ZpYTdqC+68znMfg6kp7w/rpyA8ad/GqMRqBVL3yiPFYYPwkZWqID7A/ofL k03KpiMQXGr80YGbsb1kcu14IGYKqhARZIx+Lg7jPd7oIxZV9pFjMjjwjsYVwb+uD9Cl h4t37sGXGMwm2cuQ9nwVlCQCj3K6c50FsCwXtSD3EGCj3CC8dN2xGLNopPWneQJyasSw Vxng== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=GoMo9fR9bHK2xS8ar6rwuXwfMe7x/xt+BpMvl3iJGNM=; b=aHiqvNFLiAwBC6+JXin5D4pTq6/9KUE1o0nwEs4RJaDoJcgvGL90T87fbq2VzHpGpp Aa9EEkvT1ff5sxU4SSek3QsbvEhHb4+7RBB6YK3sCu2RjgPJajde9KZ2arxazqvkNEFe 0AQ+XevQ1vZpSfiQ/oxTZZMkHim5Fs3ZtnfbYf+RSsAEWAySbxkhahTXjVRgT2axh/Ol U8csgPnRt/rhvKPnDC7xJkkuLepceXM9FxRsk2g+0vsmquHgbKyWu3RjOTrNalHeZHAQ bBdZlFR4XOKcgqMj9U23ulxkkg/6VcFVv+cN3RALE3lQp8lzQCoI85xxjSP5q+HOGNZJ iHqQ== X-Gm-Message-State: APjAAAUFJsMD6dEvCmNyHHoGXbMJk4hEYPWInYaf8IWWkPGth0iCDV/9 ZMShrBLTsU3Mc23Byt1nifnYcYKL X-Google-Smtp-Source: APXvYqxZwzrF6Qjg6J1LxrLOM/+LMtxugPHbROWoF0t0UW1iVttS2xcbm5xqZ1WZIfPF5HiinJ/gnQ== X-Received: by 2002:a63:4553:: with SMTP id u19mr31540027pgk.436.1572897829712; Mon, 04 Nov 2019 12:03:49 -0800 (PST) Received: from generichostname ([204.14.236.210]) by smtp.gmail.com with ESMTPSA id a145sm9615440pfa.7.2019.11.04.12.03.48 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Nov 2019 12:03:48 -0800 (PST) Date: Mon, 4 Nov 2019 15:03:46 -0500 From: Denton Liu To: Git Mailing List Subject: [PATCH 1/8] pretty-formats.txt: use generic terms for hash Message-ID: <09ab0c587b93ddce25888f5676e9d6ca0ac16fe4.1572897736.git.liu.denton@gmail.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.12.2 (2019-09-21) Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Since Git is planning on upgrading from SHA-1 to be more hash-agnostic, replace specific references to SHA-1 with more generic terminology. Signed-off-by: Denton Liu --- Documentation/pretty-formats.txt | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/Documentation/pretty-formats.txt b/Documentation/pretty-formats.txt index b87e2e83e6..71eef684d0 100644 --- a/Documentation/pretty-formats.txt +++ b/Documentation/pretty-formats.txt @@ -4,7 +4,7 @@ PRETTY FORMATS If the commit is a merge, and if the pretty-format is not 'oneline', 'email' or 'raw', an additional line is inserted before the 'Author:' line. This line begins with -"Merge: " and the sha1s of ancestral commits are printed, +"Merge: " and the hashes of ancestral commits are printed, separated by spaces. Note that the listed commits may not necessarily be the list of the *direct* parent commits if you have limited your view of history: for example, if you are @@ -20,20 +20,20 @@ built-in formats: * 'oneline' - + <hash> <title line> + This is designed to be as compact as possible. * 'short' - commit <sha1> + commit <hash> Author: <author> <title line> * 'medium' - commit <sha1> + commit <hash> Author: <author> Date: <author date> @@ -43,7 +43,7 @@ This is designed to be as compact as possible. * 'full' - commit <sha1> + commit <hash> Author: <author> Commit: <committer> @@ -53,7 +53,7 @@ This is designed to be as compact as possible. * 'fuller' - commit <sha1> + commit <hash> Author: <author> AuthorDate: <author date> Commit: <committer> @@ -65,7 +65,7 @@ This is designed to be as compact as possible. * 'email' - From <sha1> <date> + From <hash> <date> From: <author> Date: <author date> Subject: [PATCH] <title line> @@ -75,7 +75,7 @@ This is designed to be as compact as possible. * 'raw' + The 'raw' format shows the entire commit exactly as -stored in the commit object. Notably, the SHA-1s are +stored in the commit object. Notably, the hashes are displayed in full, regardless of whether --abbrev or --no-abbrev are used, and 'parents' information show the true parent commits, without taking grafts or history From patchwork Mon Nov 4 20:03:50 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denton Liu <liu.denton@gmail.com> X-Patchwork-Id: 11226365 Return-Path: <SRS0=eADV=Y4=vger.kernel.org=git-owner@kernel.org> Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C5E101747 for <patchwork-git@patchwork.kernel.org>; Mon, 4 Nov 2019 20:03:54 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id A325B2084D for <patchwork-git@patchwork.kernel.org>; Mon, 4 Nov 2019 20:03:54 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="d1dIorDm" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728876AbfKDUDx (ORCPT <rfc822;patchwork-git@patchwork.kernel.org>); Mon, 4 Nov 2019 15:03:53 -0500 Received: from mail-pl1-f196.google.com ([209.85.214.196]:46740 "EHLO mail-pl1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728332AbfKDUDx (ORCPT <rfc822;git@vger.kernel.org>); Mon, 4 Nov 2019 15:03:53 -0500 Received: by mail-pl1-f196.google.com with SMTP id l4so2870625plt.13 for <git@vger.kernel.org>; Mon, 04 Nov 2019 12:03:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=bchuMdPI/Illdsr3uWvZlOJbFZ3BWOd/5u7DUzZg1F8=; b=d1dIorDmLEU+AuAHIiriZ/1AhzpXNZARSLMJAqFp8ndaMM+ZAPqj3GDTnoC146mjmi +z+2sy9Tny0HyG1S34bw5kf1v3YWROcyWeOi6yyXD5k7MzMM2bSU6ixFVwVZ9vPxh0uV iCxcab3v8fOGi7zizE+cFnpsDc7REgDM9T/WnJuPR1UrG8tyCOLIWHN829msC6uOIYLq sr17cXooyxBROMpAK45KARghGtR82yaXqu8qu6vPkM8dv2AtX/DLU40P4/BLvWTWI3d9 42vMGBIis/Jg8nBWw5tieRpJAXPex5yWdqBZ4D+OImfBWrfuF10Bx3Oc9kpyNof2SfSS F0Ng== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=bchuMdPI/Illdsr3uWvZlOJbFZ3BWOd/5u7DUzZg1F8=; b=f+Ng4Yi5bxBFDApOHG8QI/EFISkqJUlZMMsOhogJRK0OPlIl97+oQKHF6uIGDpX0Mb qxskko+yhlvwQu+FR+H7QV7+rL9tIYuC8q3qJ1iNiu7RyxWhLSBpBQnx5lzdGzpezPDY u9+maO92XpDsS0hKNH+0lnaY11EF05vR2AU/AhM72pRQc1cfis6eFoV28E4sEglmCQ2c KBmWgNjUju3maJeSlTyWMsPV2OhvX5lJZUgCMhupwbMjX3JCA8xW4LTO5CFGeoxlXXTS 21GHBNyP7WB5H7XKU+WHq2hWJkEfyialTnpUz7atyLWrJQU5nvgCEmFeUeW1DC+VswDu eVoA== X-Gm-Message-State: APjAAAXaOKFCmvhkqxUVvaEjb2pSdHV6uQx7015bEsXTd89cCh1bviDV 1S0Cs3VI8AyT2oc99+HAPfgnzmQd X-Google-Smtp-Source: APXvYqwq5vjIaI3A19K8U0hAOhz1AlTS507UhB2JTA6ezfq6bBuaF3VUKZFQCunb4d3oYNVoPnN1HQ== X-Received: by 2002:a17:902:ac98:: with SMTP id h24mr4152775plr.227.1572897832529; Mon, 04 Nov 2019 12:03:52 -0800 (PST) Received: from generichostname ([204.14.236.210]) by smtp.gmail.com with ESMTPSA id u7sm5101924pjx.19.2019.11.04.12.03.51 for <git@vger.kernel.org> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Nov 2019 12:03:52 -0800 (PST) Date: Mon, 4 Nov 2019 15:03:50 -0500 From: Denton Liu <liu.denton@gmail.com> To: Git Mailing List <git@vger.kernel.org> Subject: [PATCH 2/8] revision: make get_revision_mark() return const pointer Message-ID: <743a91029960eb134420bd315eb0d5076a40427f.1572897736.git.liu.denton@gmail.com> References: <cover.1572897736.git.liu.denton@gmail.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <cover.1572897736.git.liu.denton@gmail.com> User-Agent: Mutt/1.12.2 (2019-09-21) Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: <git.vger.kernel.org> X-Mailing-List: git@vger.kernel.org get_revision_mark() used to return a `char *`, even though all of the strings it was returning were string literals. Make get_revision_mark() return a `const char *` so that callers won't be tempted to modify the returned string. Signed-off-by: Denton Liu <liu.denton@gmail.com> --- revision.c | 4 ++-- revision.h | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/revision.c b/revision.c index 0e39b2b8a5..2151b119b7 100644 --- a/revision.c +++ b/revision.c @@ -3944,7 +3944,7 @@ struct commit *get_revision(struct rev_info *revs) return c; } -char *get_revision_mark(const struct rev_info *revs, const struct commit *commit) +const char *get_revision_mark(const struct rev_info *revs, const struct commit *commit) { if (commit->object.flags & BOUNDARY) return "-"; @@ -3966,7 +3966,7 @@ char *get_revision_mark(const struct rev_info *revs, const struct commit *commit void put_revision_mark(const struct rev_info *revs, const struct commit *commit) { - char *mark = get_revision_mark(revs, commit); + const char *mark = get_revision_mark(revs, commit); if (!strlen(mark)) return; fputs(mark, stdout); diff --git a/revision.h b/revision.h index 4134dc6029..addd69410b 100644 --- a/revision.h +++ b/revision.h @@ -322,8 +322,8 @@ int handle_revision_arg(const char *arg, struct rev_info *revs, void reset_revision_walk(void); int prepare_revision_walk(struct rev_info *revs); struct commit *get_revision(struct rev_info *revs); -char *get_revision_mark(const struct rev_info *revs, - const struct commit *commit); +const char *get_revision_mark(const struct rev_info *revs, + const struct commit *commit); void put_revision_mark(const struct rev_info *revs, const struct commit *commit); From patchwork Mon Nov 4 20:03:52 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denton Liu <liu.denton@gmail.com> X-Patchwork-Id: 11226367 Return-Path: <SRS0=eADV=Y4=vger.kernel.org=git-owner@kernel.org> Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 008C613A4 for <patchwork-git@patchwork.kernel.org>; Mon, 4 Nov 2019 20:03:58 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id D22312084D for <patchwork-git@patchwork.kernel.org>; Mon, 4 Nov 2019 20:03:57 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="L2Ssoidl" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728940AbfKDUD5 (ORCPT <rfc822;patchwork-git@patchwork.kernel.org>); Mon, 4 Nov 2019 15:03:57 -0500 Received: from mail-pl1-f195.google.com ([209.85.214.195]:35883 "EHLO mail-pl1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728332AbfKDUD4 (ORCPT <rfc822;git@vger.kernel.org>); Mon, 4 Nov 2019 15:03:56 -0500 Received: by mail-pl1-f195.google.com with SMTP id g9so8120654plp.3 for <git@vger.kernel.org>; Mon, 04 Nov 2019 12:03:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=bH4fJjFPG3gave2oZpr+9i1o4EYmpJA4A1zunk6z7ps=; b=L2Ssoidl43RDPEUF6xVavpL98gdrxFBzyNttLcfft0FLqb7rX5VcT8goxX5AVtCuqV K9NTX2UVdpp2LMaI1zbnL/uNDyW66ESinZ/gJaXcuKEpS2D9zfgqn/TG9v6J7TJdNABA 32kBiJD94RFkjmhMkRvxb+ZotEOXtXXYSRZ7CTAl2cfJsbXhYTt+vB057CkHyHMKfn5t EzciuIfBn32n/fGhel0pi3oP7lSbrZzZleEPyMzcAE9xZIuUybmdMU8n5B4WY1HVOd0F xytCJ9qNWdjDcIOFQU+8iWzR3J6/ro9Gh4w9pJ4fN1izgxHVqQyz09Vpsqw56U+qSJ0Y tsmw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=bH4fJjFPG3gave2oZpr+9i1o4EYmpJA4A1zunk6z7ps=; b=DG8d/RENWFzTzLcdRlmjlPbEGUumd31rUkvCvi0PIzGpLDPUVQhGJTz9yPLaH4RH2T hBTnyc6atNmw5RjyJtdJg+aVxnDwWcwQwKV4FDrskRMRtvLtel5vaOL6LqIgMB9BdQGF q1qT94AusSGQaQN7YubuaWTCm8XLXgW8QjzhfhUS5pUILIwPtsqeb2SJWjKTLtAF1grF Lkq/7km+Xk9JK/TIkEHWaC1qU2a/aiPp7GRMGm7Cxab4fGlr6Vm3Rr8Dta+DYrbVCNun xEb91izmuvFz1Z6QavBo8FAbSdkXfiY2rs3k/iEuFZQr6icKfqyqLRT7LDoNwNezDcx3 LhVw== X-Gm-Message-State: APjAAAW+AeFYWIzxqokW8fitBOmR0bUhXlMvGHm4wKlkRa6OVoNbtmZP Ujq4Zxr7SqVTd9/ig28VW5lKKGfS X-Google-Smtp-Source: APXvYqwRhRtkZoG9aFbkpqEuxUVDB89ZwiOvhSE5eidLmy7B3CbmtNi2gM+mS+4CNS1ROSsQAfF8aA== X-Received: by 2002:a17:902:5a04:: with SMTP id q4mr29273165pli.34.1572897835415; Mon, 04 Nov 2019 12:03:55 -0800 (PST) Received: from generichostname ([204.14.236.210]) by smtp.gmail.com with ESMTPSA id b9sm17858853pfp.77.2019.11.04.12.03.54 for <git@vger.kernel.org> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Nov 2019 12:03:54 -0800 (PST) Date: Mon, 4 Nov 2019 15:03:52 -0500 From: Denton Liu <liu.denton@gmail.com> To: Git Mailing List <git@vger.kernel.org> Subject: [PATCH 3/8] revision: change abbrev_commit_given to abbrev_commit_explicit Message-ID: <f6f6b3d6710c7375db3e92f97245f8cf20231d1d.1572897736.git.liu.denton@gmail.com> References: <cover.1572897736.git.liu.denton@gmail.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <cover.1572897736.git.liu.denton@gmail.com> User-Agent: Mutt/1.12.2 (2019-09-21) Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: <git.vger.kernel.org> X-Mailing-List: git@vger.kernel.org In a future patch, we want to know if `--[no-]abbrev-commit` arguments have been explicitly provided. Since `rev_info.abbrev_commit_given` is only used in one place, co-opt it to become `rev_info.abbrev_commit_explicit`. This information will be used in a future patch. With this change, the semantics of the original usage (in the `--pretty=raw` codepath) aren't altered. Signed-off-by: Denton Liu <liu.denton@gmail.com> --- builtin/log.c | 2 +- revision.c | 3 ++- revision.h | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/builtin/log.c b/builtin/log.c index 89873d2dc2..e4df16be79 100644 --- a/builtin/log.c +++ b/builtin/log.c @@ -230,7 +230,7 @@ static void cmd_log_init_finish(int argc, const char **argv, const char *prefix, */ if (!decoration_given) decoration_style = 0; - if (!rev->abbrev_commit_given) + if (!rev->abbrev_commit_explicit) rev->abbrev_commit = 0; } diff --git a/revision.c b/revision.c index 2151b119b7..02b49ab754 100644 --- a/revision.c +++ b/revision.c @@ -2271,9 +2271,10 @@ static int handle_revision_opt(struct rev_info *revs, int argc, const char **arg revs->abbrev = hexsz; } else if (!strcmp(arg, "--abbrev-commit")) { revs->abbrev_commit = 1; - revs->abbrev_commit_given = 1; + revs->abbrev_commit_explicit = 1; } else if (!strcmp(arg, "--no-abbrev-commit")) { revs->abbrev_commit = 0; + revs->abbrev_commit_explicit = 1; } else if (!strcmp(arg, "--full-diff")) { revs->diff = 1; revs->full_diff = 1; diff --git a/revision.h b/revision.h index addd69410b..7670f29973 100644 --- a/revision.h +++ b/revision.h @@ -185,7 +185,7 @@ struct rev_info { show_signature:1, pretty_given:1, abbrev_commit:1, - abbrev_commit_given:1, + abbrev_commit_explicit:1, zero_commit:1, use_terminator:1, missing_newline:1, From patchwork Mon Nov 4 20:03:55 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denton Liu <liu.denton@gmail.com> X-Patchwork-Id: 11226369 Return-Path: <SRS0=eADV=Y4=vger.kernel.org=git-owner@kernel.org> Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 475A013A4 for <patchwork-git@patchwork.kernel.org>; Mon, 4 Nov 2019 20:04:00 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 257382084D for <patchwork-git@patchwork.kernel.org>; Mon, 4 Nov 2019 20:04:00 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="q8KbXz/k" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729074AbfKDUD7 (ORCPT <rfc822;patchwork-git@patchwork.kernel.org>); Mon, 4 Nov 2019 15:03:59 -0500 Received: from mail-pg1-f195.google.com ([209.85.215.195]:42759 "EHLO mail-pg1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728332AbfKDUD7 (ORCPT <rfc822;git@vger.kernel.org>); Mon, 4 Nov 2019 15:03:59 -0500 Received: by mail-pg1-f195.google.com with SMTP id s23so8750703pgo.9 for <git@vger.kernel.org>; Mon, 04 Nov 2019 12:03:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=ajk4p9YJkLKcm/THm7WAAf8oXLtntlz+KmZyJalxkrA=; b=q8KbXz/k4CFXpvrA9BLq4cTB4n0yMr20F95kpolBeNF8/RD4Pdg+Lzo5+058gHDfmZ Yv+8W1klOh51Zg1WM1HnFy93r46IXW0v4lWyQfH4O3WS+8m3DzGkfUraSZb4P/lG8zt2 DU1H+30iYRo4hqiumkZ0qV1biDS0UEcWiv9JmKuAYpOBOOJq6HU1ryrHfiS/e6olFcKU 58wIofJd4UcW7VS9VAnbKTiX6Wb5CNIvsIsdgB/6TjBCZyvgKjOHtKsEM7Yv31RR8Qlj s+DcAWsadcyqs4F5yeoeNn1qobAm5VBnttwhnV9nspxvTL0VW9p5mWwwnxRLIc62wZAJ kYdw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=ajk4p9YJkLKcm/THm7WAAf8oXLtntlz+KmZyJalxkrA=; b=IW3NtX3zI0+uPcHkEPDrPYhnbyMo3umArnuerBAfWkmSqxF8M4x8MI2H1xui4cxSM7 Wa2vNWUhkxY/ZoUKqnpCK702vSSFnmsUtweiKXpmqx9tj8R0QfripF/dYNEbtv97Fe56 yC8ANgF6o/iCKhlblAzxPXL7/8r2ZSWxwMYK4fYsmUbWw9ZZwMBMisAb481rjQIaJPT8 YXcU0pVc2KslCGLobpN3ZlsnX5oKXqi4dSdqDhNR6fMJ9zPo0vQtSEqXsU754cNma2NI XRdqBD97WQrCiSKcMmRP6VDGRQYjB3pV2HiCHktKsP5HMMfO2B3gRQP4RQ1+nfi9HGiu lVWw== X-Gm-Message-State: APjAAAV3kdMhfRdKVZAGN1NYS3RLxOWlzjn/4RL/DJjb+dLe0VIzfRCq 5Vgyb1EeD0y7ELxkgogTkLHxTnjb X-Google-Smtp-Source: APXvYqyAdTKD9s9tA9Gp4ZDpbOGFX2DxLTGmaaSWZsICpQfse3bbGlSe6vc/xtKF+PUT/vTieD2fGQ== X-Received: by 2002:a62:5c07:: with SMTP id q7mr32447108pfb.159.1572897838148; Mon, 04 Nov 2019 12:03:58 -0800 (PST) Received: from generichostname ([204.14.236.210]) by smtp.gmail.com with ESMTPSA id s66sm5642758pfb.38.2019.11.04.12.03.57 for <git@vger.kernel.org> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Nov 2019 12:03:57 -0800 (PST) Date: Mon, 4 Nov 2019 15:03:55 -0500 From: Denton Liu <liu.denton@gmail.com> To: Git Mailing List <git@vger.kernel.org> Subject: [PATCH 4/8] pretty.c: inline initalize format_context Message-ID: <1551e903225bb4f7652341382d0c1cf71b9bd7d4.1572897736.git.liu.denton@gmail.com> References: <cover.1572897736.git.liu.denton@gmail.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <cover.1572897736.git.liu.denton@gmail.com> User-Agent: Mutt/1.12.2 (2019-09-21) Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: <git.vger.kernel.org> X-Mailing-List: git@vger.kernel.org Instead of memsetting and then initializing the fields in the struct, move the initialization of `format_context` to its assignment. In preparation for a future commit where we mechanically move lines from repo_format_commit_message() into a helper function, `format_context.wrap_start` is not generically used so move its assignment closer to its use. Signed-off-by: Denton Liu <liu.denton@gmail.com> --- pretty.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/pretty.c b/pretty.c index b32f036953..6f2b0ad917 100644 --- a/pretty.c +++ b/pretty.c @@ -1610,14 +1610,13 @@ void repo_format_commit_message(struct repository *r, const char *format, struct strbuf *sb, const struct pretty_print_context *pretty_ctx) { - struct format_commit_context context; + struct format_commit_context context = { + .commit = commit, + .pretty_ctx = pretty_ctx + }; const char *output_enc = pretty_ctx->output_encoding; const char *utf8 = "UTF-8"; - memset(&context, 0, sizeof(context)); - context.commit = commit; - context.pretty_ctx = pretty_ctx; - context.wrap_start = sb->len; /* * convert a commit message to UTF-8 first * as far as 'format_commit_item' assumes it in UTF-8 @@ -1626,6 +1625,7 @@ void repo_format_commit_message(struct repository *r, &context.commit_encoding, utf8); + context.wrap_start = sb->len; strbuf_expand(sb, format, format_commit_item, &context); rewrap_message_tail(sb, &context, 0, 0, 0); From patchwork Mon Nov 4 20:03:58 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denton Liu <liu.denton@gmail.com> X-Patchwork-Id: 11226371 Return-Path: <SRS0=eADV=Y4=vger.kernel.org=git-owner@kernel.org> Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 7CDDA15AB for <patchwork-git@patchwork.kernel.org>; Mon, 4 Nov 2019 20:04:04 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 5AA8E20869 for <patchwork-git@patchwork.kernel.org>; Mon, 4 Nov 2019 20:04:04 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="DBLM2GHp" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729137AbfKDUED (ORCPT <rfc822;patchwork-git@patchwork.kernel.org>); Mon, 4 Nov 2019 15:04:03 -0500 Received: from mail-pg1-f195.google.com ([209.85.215.195]:47052 "EHLO mail-pg1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729091AbfKDUED (ORCPT <rfc822;git@vger.kernel.org>); Mon, 4 Nov 2019 15:04:03 -0500 Received: by mail-pg1-f195.google.com with SMTP id f19so12112422pgn.13 for <git@vger.kernel.org>; Mon, 04 Nov 2019 12:04:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=ogf9U6bXxjS7eoP2MYn2/FzoYyB0bsV/jjc0VrS5wfc=; b=DBLM2GHpAizPMnpu6InylDa5oJqJJR1p3FGSiIGXBq16suhl7dusogiBssgEjhdSw4 pz7cL27qncKpHTDPblCzJHHk1RVG2Ctb3AVb2II4QxU4xrKCWBIMd9yun8f4CeQjj2xv EIFFD+OEQ6ALCDkKp3hYEPD0wLWTPAmV/8v5fiybDtVHaEdXRmwJCLIAP30ULlN0hkF8 /Ja84NOiQbCITZYxSjge2CUXoi3yGT0KaP1X56AvyYTrRoEiIZs6G6DM5g+W+lIncEIL BR5HmySGII84QUsRQwmqJBlJ3uYpZc0KBbscVseXFxUjUeK4VWJ5liNG1gk/rwqiBjUw 0MIQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=ogf9U6bXxjS7eoP2MYn2/FzoYyB0bsV/jjc0VrS5wfc=; b=IjyzGHgJqrFLFk0OdRu8JDyAazTDqqG6yPrmGzTYmmXhxGYXyh6KaOCnGKmEUO3yOB nt4I9utgAcMJrxmjYFyvmpjYUlwJq+/YWx+A2lB3UAJYwoyUoL7GuPNwDu54LhIt34Lg mYcDQvSGypiptPf4c91SzrfZMxOVsU35FIB8SgfzVjDuPo5mOmcWL5J1RlRQ9sLIdzr3 XRaYVxGzSbzp0wOfhUGkIMdG+hj46MvE2wMPxkTm9ZBI6Z5JK5VkdZ6ZqZcW4Rkpeo4A oTDc7wGfWUS1f5iDSN8FnkWBy1w+u/BQSHuZpYNaqg+8mPWewYzlacpwq1Umt6D4OcJ+ ZAww== X-Gm-Message-State: APjAAAWcvm+xxOstFyym0TrwZH7OLuiriPQlhTasaS9NGbpaQlBgS1Aj MH+/cCsH8BYVVScnaY4snxSFRlmC X-Google-Smtp-Source: APXvYqzoHIR2KE2p1FQo/5JJBkaemFRM0Jj/JrgiJimQh4/aRiKka7IvkhdsWVe83IdP5MwDMMhp9g== X-Received: by 2002:a63:ae02:: with SMTP id q2mr32688338pgf.210.1572897841003; Mon, 04 Nov 2019 12:04:01 -0800 (PST) Received: from generichostname ([204.14.236.210]) by smtp.gmail.com with ESMTPSA id s24sm5828884pfh.108.2019.11.04.12.04.00 for <git@vger.kernel.org> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Nov 2019 12:04:00 -0800 (PST) Date: Mon, 4 Nov 2019 15:03:58 -0500 From: Denton Liu <liu.denton@gmail.com> To: Git Mailing List <git@vger.kernel.org> Subject: [PATCH 5/8] pretty.c: extract functionality to repo_format_commit_generic() Message-ID: <e54b8ef8779b2cafd2aba45074f1b6680f4d7221.1572897736.git.liu.denton@gmail.com> References: <cover.1572897736.git.liu.denton@gmail.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <cover.1572897736.git.liu.denton@gmail.com> User-Agent: Mutt/1.12.2 (2019-09-21) Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: <git.vger.kernel.org> X-Mailing-List: git@vger.kernel.org In a future commit, we will be reusing common functionality from repo_format_commit_message(). Extract this common functionality into repo_format_commit_generic() so that it can be reused in the future. Signed-off-by: Denton Liu <liu.denton@gmail.com> --- pretty.c | 35 ++++++++++++++++++++++++++++------- 1 file changed, 28 insertions(+), 7 deletions(-) diff --git a/pretty.c b/pretty.c index 6f2b0ad917..a6e5fc115a 100644 --- a/pretty.c +++ b/pretty.c @@ -1605,10 +1605,14 @@ void userformat_find_requirements(const char *fmt, struct userformat_want *w) strbuf_release(&dummy); } -void repo_format_commit_message(struct repository *r, - const struct commit *commit, - const char *format, struct strbuf *sb, - const struct pretty_print_context *pretty_ctx) +static void repo_format_commit_generic(struct repository *r, + const struct commit *commit, + struct strbuf *sb, + const struct pretty_print_context *pretty_ctx, + void (*fn)(struct strbuf *, + struct format_commit_context *, + void *), + void *data) { struct format_commit_context context = { .commit = commit, @@ -1625,9 +1629,7 @@ void repo_format_commit_message(struct repository *r, &context.commit_encoding, utf8); - context.wrap_start = sb->len; - strbuf_expand(sb, format, format_commit_item, &context); - rewrap_message_tail(sb, &context, 0, 0, 0); + fn(sb, &context, data); /* then convert a commit message to an actual output encoding */ if (output_enc) { @@ -1651,6 +1653,25 @@ void repo_format_commit_message(struct repository *r, repo_unuse_commit_buffer(r, commit, context.message); } +static void do_repo_format_commit_message(struct strbuf *sb, + struct format_commit_context *context, + void *data) +{ + const char *format = data; + context->wrap_start = sb->len; + strbuf_expand(sb, format, format_commit_item, context); + rewrap_message_tail(sb, context, 0, 0, 0); +} + +void repo_format_commit_message(struct repository *r, + const struct commit *commit, + const char *format, struct strbuf *sb, + const struct pretty_print_context *pretty_ctx) +{ + repo_format_commit_generic(r, commit, sb, pretty_ctx, + do_repo_format_commit_message, (void *)format); +} + static void pp_header(struct pretty_print_context *pp, const char *encoding, const struct commit *commit, From patchwork Mon Nov 4 20:04:01 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denton Liu <liu.denton@gmail.com> X-Patchwork-Id: 11226373 Return-Path: <SRS0=eADV=Y4=vger.kernel.org=git-owner@kernel.org> Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 8E8C31747 for <patchwork-git@patchwork.kernel.org>; Mon, 4 Nov 2019 20:04:06 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 6D0B420869 for <patchwork-git@patchwork.kernel.org>; Mon, 4 Nov 2019 20:04:06 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="MISWMH/0" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729216AbfKDUEF (ORCPT <rfc822;patchwork-git@patchwork.kernel.org>); Mon, 4 Nov 2019 15:04:05 -0500 Received: from mail-pl1-f196.google.com ([209.85.214.196]:42699 "EHLO mail-pl1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729091AbfKDUEF (ORCPT <rfc822;git@vger.kernel.org>); Mon, 4 Nov 2019 15:04:05 -0500 Received: by mail-pl1-f196.google.com with SMTP id j12so6164592plt.9 for <git@vger.kernel.org>; Mon, 04 Nov 2019 12:04:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=8IwljkIz6CVwZIm90p0bHcVH+CFlFeV4rtuB9hz+2FI=; b=MISWMH/0+AAiiZ71JA1D474+kkbBTJsbkb64OZYg8MpA8pbuR/o8BGdo8PV9/IPJe9 +eeNQBJN8SXWOpzvAaaBBrDPEHliyx0JDOrofaPnLAEP8vvPdn1Lm30VntqYCBGY32kH 2UNfLcPbyHtNb/srii7UyTjgIQ6ONxBKIscWB4gTMwsvIgJUXd78gMZU9vqB/36/HDhD aup4U9tT1s5yMDs3V8T6/KI/mOsyz+KCrOI5oPnQOoYEVtq0dF9Z1D92jBCapOkuZafT F792rjaAfcwuacty/GZBPXViTSbb6LuorEXdm1+65pibN6ce/YTHYWdgX60ICRQoiEj0 2ulA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=8IwljkIz6CVwZIm90p0bHcVH+CFlFeV4rtuB9hz+2FI=; b=LvR8T/CrnYXsjJufCcxN2Lr8c0OxWU6lRL96hnpPcnF0fB19fVALK5EQjRk6LN0lWA H2jJZ+FLxEQL5pKeuXtvwQYTrDjkSjovwbO8ESiTI4rjlwP3Kl3yFPiyyKoYrmOasy7K bT/Z0j4DNBvxEw4dlSHYTr5QazgY1qDwQ1IjfWQYIN7CZMEpj6pT6EFBl4bAZg4ZhR0c IrqXnZ9HJfPdArh05HPr/fMTJgi2BYP7LApB8wGzCss6QKIhYOOyiYOzA9Q7LUwu+7JM nzAHbqpJQ1eXFRgfEra6gY6YnXEA/pVeAufxAClaK4e264gsbGfLQxeAM0VTo0axT0ra GerQ== X-Gm-Message-State: APjAAAUXYz6aLDqAhhuZq+NRQG/xtmxBF93VP0N6Juc8yIucfTReBqmY SdM3b4GW1LJK4NX/SyfA5IOPLzPG X-Google-Smtp-Source: APXvYqwpgX4QX8hGFRPGS6gO6iwm7hBbSz/4t8c6VslpikXgG7rBDOzvR3NSq6t0e8JhiP40HsZ0XA== X-Received: by 2002:a17:902:aa04:: with SMTP id be4mr29576939plb.279.1572897843777; Mon, 04 Nov 2019 12:04:03 -0800 (PST) Received: from generichostname ([204.14.236.210]) by smtp.gmail.com with ESMTPSA id j22sm15132982pff.42.2019.11.04.12.04.02 for <git@vger.kernel.org> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Nov 2019 12:04:03 -0800 (PST) Date: Mon, 4 Nov 2019 15:04:01 -0500 From: Denton Liu <liu.denton@gmail.com> To: Git Mailing List <git@vger.kernel.org> Subject: [PATCH 6/8] reflog-walk.c: don't print last newline with oneline Message-ID: <449c58009ae46d43ec2bd0499674c9858b706d04.1572897736.git.liu.denton@gmail.com> References: <cover.1572897736.git.liu.denton@gmail.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <cover.1572897736.git.liu.denton@gmail.com> User-Agent: Mutt/1.12.2 (2019-09-21) Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: <git.vger.kernel.org> X-Mailing-List: git@vger.kernel.org In a future commit, we want to possibly be able to continue the reflog message on the same line without breaking the line. As a result, when `oneline == 1`, strip any trailing new lines. Add these missing newlines back in show_log(). Signed-off-by: Denton Liu <liu.denton@gmail.com> --- log-tree.c | 4 +++- reflog-walk.c | 6 +++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/log-tree.c b/log-tree.c index 923a299e70..4a7d668af6 100644 --- a/log-tree.c +++ b/log-tree.c @@ -661,8 +661,10 @@ void show_log(struct rev_info *opt) opt->commit_format == CMIT_FMT_ONELINE, &opt->date_mode, opt->date_mode_explicit); - if (opt->commit_format == CMIT_FMT_ONELINE) + if (opt->commit_format == CMIT_FMT_ONELINE) { + putc('\n', opt->diffopt.file); return; + } } } diff --git a/reflog-walk.c b/reflog-walk.c index 3a25b27d8f..e2b4c0b290 100644 --- a/reflog-walk.c +++ b/reflog-walk.c @@ -285,7 +285,11 @@ void show_reflog_message(struct reflog_walk_info *reflog_info, int oneline, info = &commit_reflog->reflogs->items[commit_reflog->recno+1]; get_reflog_selector(&selector, reflog_info, dmode, force_date, 0); if (oneline) { - printf("%s: %s", selector.buf, info->message); + struct strbuf message = STRBUF_INIT; + strbuf_addstr(&message, info->message); + strbuf_trim_trailing_newline(&message); + printf("%s: %s", selector.buf, message.buf); + strbuf_release(&message); } else { printf("Reflog: %s (%s)\nReflog message: %s", From patchwork Mon Nov 4 20:04:04 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denton Liu <liu.denton@gmail.com> X-Patchwork-Id: 11226375 Return-Path: <SRS0=eADV=Y4=vger.kernel.org=git-owner@kernel.org> Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 7D7C515AB for <patchwork-git@patchwork.kernel.org>; Mon, 4 Nov 2019 20:04:09 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 470C320869 for <patchwork-git@patchwork.kernel.org>; Mon, 4 Nov 2019 20:04:09 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="gYkgj6ci" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729312AbfKDUEI (ORCPT <rfc822;patchwork-git@patchwork.kernel.org>); Mon, 4 Nov 2019 15:04:08 -0500 Received: from mail-pl1-f172.google.com ([209.85.214.172]:43070 "EHLO mail-pl1-f172.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729091AbfKDUEI (ORCPT <rfc822;git@vger.kernel.org>); Mon, 4 Nov 2019 15:04:08 -0500 Received: by mail-pl1-f172.google.com with SMTP id a18so6971273plm.10 for <git@vger.kernel.org>; Mon, 04 Nov 2019 12:04:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=m64dMGD0H2LQcBzS72fInNckVioZa4/x7km99z8xRAs=; b=gYkgj6ci9j44q0h0MsqvfjPbOj1K36pTHIrv92x+1UJIoAWWe/PQ8GG+P3RBBooEzS rDJ63qKH9FZkmHvdpI67LqIgqUo9piO4CG39TP/0Ea9ix5tA/4wZk5dcOTSZ2zt6NUA9 b8HBO0/qdXJEETEB0IH9muMcH/Ex9VvV0SOeK3bdNeHF/hhUw5dkhO1tm+ZWXWBlVT+O 8w3lxN+8xuZQnic+D9RDyEx/gc0w6hT5iDytykcl4yECdbd9J9osZp69kRWUXmUQi+7k 1cvMnO1efc/QOEIy64BhGwOyy1ZzXtTreyq8N/tt6qxD0XxCru6AdUuz2nvv3eLucGSS SB8Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=m64dMGD0H2LQcBzS72fInNckVioZa4/x7km99z8xRAs=; b=gPVIpUcDLd1f7im6Kl0JZCyVdC6gIEKlMqrjCdohZ9mBG4BRPaRqUULAa794QIE4GF m52ItkKhpMPO7s2hdg77SFiGo18qni8SwL7ejuAUQ5LmcNVddNNfTvq6Ncz6bFYr/6XK 8OscJ9Bo/3Uw8AJW46+DEr2+kXrnk3WZi/Bimy4Y0ug1mN4TlIvLQXS3+sGXgNLwoKNo ycLN3Y/mZZtcdsxkd3g7izcFEyKpncl3rCemNNc4sOQvP2gKOEckHEKwVkHAzDGGTII5 D+Q5lxPml3r+CdbFNmh27Rx8Tl2WarQQLRjg+IgJySBUszg6l2/16XgPnDIDfa6fr1Sx 8zcw== X-Gm-Message-State: APjAAAWPp6QhrBQXVJty3gbM5SDRC20OPB7iUSH0o7lIjpmR/NZC2yYo 91I8f4nYGaZPfOzws2dSzMMiEvXS X-Google-Smtp-Source: APXvYqzgdKg3R9pcXcS0OQiCkFPgZjadqcrYH93i11sgczIG6V/hIPXnca436yW/Ru/PgM5Y4XDuQQ== X-Received: by 2002:a17:902:8f93:: with SMTP id z19mr1783351plo.217.1572897846925; Mon, 04 Nov 2019 12:04:06 -0800 (PST) Received: from generichostname ([204.14.236.210]) by smtp.gmail.com with ESMTPSA id 205sm14360294pge.56.2019.11.04.12.04.05 for <git@vger.kernel.org> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Nov 2019 12:04:06 -0800 (PST) Date: Mon, 4 Nov 2019 15:04:04 -0500 From: Denton Liu <liu.denton@gmail.com> To: Git Mailing List <git@vger.kernel.org> Subject: [PATCH 7/8] pretty: implement 'summary' format Message-ID: <64b6f7c9d7434ba39929220c1aebcd9a1fd0ad6e.1572897736.git.liu.denton@gmail.com> References: <cover.1572897736.git.liu.denton@gmail.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <cover.1572897736.git.liu.denton@gmail.com> User-Agent: Mutt/1.12.2 (2019-09-21) Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: <git.vger.kernel.org> X-Mailing-List: git@vger.kernel.org The standard format for referencing other commits within some projects (such as git.git) is the summary format. This is described in Documentation/SubmittingPatches as If you want to reference a previous commit in the history of a stable branch, use the format "abbreviated sha1 (subject, date)", with the subject enclosed in a pair of double-quotes, like this: .... Commit f86a374 ("pack-bitmap.c: fix a memleak", 2015-03-30) noticed that ... .... Since this format is so commonly used, standardize it as a pretty format. This format is implemented as a separate flow that skips most of pretty_print_commit() and instead calls format_commit_summary(). The reason why this is done is because the other pretty formats expect output to be generated in a specific order. Specifically, the header, including the date, is always printed before the commit message, including the subject. Reversing the order would be possible but would involve butchering pretty_print_commit() so it is implemented as a separate flow. Signed-off-by: Denton Liu <liu.denton@gmail.com> --- Documentation/pretty-formats.txt | 9 ++++++ Documentation/pretty-options.txt | 2 +- Documentation/rev-list-options.txt | 2 +- builtin/log.c | 30 ++++++++++++++--- log-tree.c | 11 +++++-- pretty.c | 31 +++++++++++++++++- pretty.h | 1 + t/t4205-log-pretty-formats.sh | 52 ++++++++++++++++++++++++++++++ 8 files changed, 127 insertions(+), 11 deletions(-) diff --git a/Documentation/pretty-formats.txt b/Documentation/pretty-formats.txt index 71eef684d0..5641903b93 100644 --- a/Documentation/pretty-formats.txt +++ b/Documentation/pretty-formats.txt @@ -63,6 +63,15 @@ This is designed to be as compact as possible. <full commit message> +* 'summary' + + <abbrev hash> ("<title line>", <short author date>) ++ +This format is useful for referring to other commits when writing a new +commit message. Although by default, '<abbrev sha1>' is used, this can +be overridden with '--no-abbrev'. In addition, '<short author date>' can +be overridden by with '--date='. + * 'email' From <hash> <date> diff --git a/Documentation/pretty-options.txt b/Documentation/pretty-options.txt index e44fc8f738..0a5b206193 100644 --- a/Documentation/pretty-options.txt +++ b/Documentation/pretty-options.txt @@ -3,7 +3,7 @@ Pretty-print the contents of the commit logs in a given format, where '<format>' can be one of 'oneline', 'short', 'medium', - 'full', 'fuller', 'email', 'raw', 'format:<string>' + 'full', 'fuller', 'summary', 'email', 'raw', 'format:<string>' and 'tformat:<string>'. When '<format>' is none of the above, and has '%placeholder' in it, it acts as if '--pretty=tformat:<format>' were given. diff --git a/Documentation/rev-list-options.txt b/Documentation/rev-list-options.txt index 90ff9e2bea..76df494ed6 100644 --- a/Documentation/rev-list-options.txt +++ b/Documentation/rev-list-options.txt @@ -289,7 +289,7 @@ depending on a few rules: 4. Otherwise, show the index format. -- + -Under `--pretty=oneline`, the commit message is +Under `--pretty=oneline` and `--pretty=summary`, the commit message is prefixed with this information on the same line. This option cannot be combined with `--reverse`. See also linkgit:git-reflog[1]. diff --git a/builtin/log.c b/builtin/log.c index e4df16be79..ad96a746a3 100644 --- a/builtin/log.c +++ b/builtin/log.c @@ -223,15 +223,35 @@ static void cmd_log_init_finish(int argc, const char **argv, const char *prefix, read_mailmap(rev->mailmap, NULL); } - if (rev->pretty_given && rev->commit_format == CMIT_FMT_RAW) { + if (rev->pretty_given) { + switch (rev->commit_format) { + /* * "log --pretty=raw" is special; ignore UI oriented * configuration variables such as decoration. */ - if (!decoration_given) - decoration_style = 0; - if (!rev->abbrev_commit_explicit) - rev->abbrev_commit = 0; + case CMIT_FMT_RAW: + if (!decoration_given) + decoration_style = 0; + if (!rev->abbrev_commit_explicit) + rev->abbrev_commit = 0; + break; + + /* + * "log --pretty=summary" is special; ignore UI oriented + * configuration variables such as decoration but keep + * abbreviations. + */ + case CMIT_FMT_SUMMARY: + if (!decoration_given) + decoration_style = 0; + if (!rev->abbrev_commit_explicit) + rev->abbrev_commit = 1; + break; + + default: + break; + } } if (decoration_style) { diff --git a/log-tree.c b/log-tree.c index 4a7d668af6..433adaf0f1 100644 --- a/log-tree.c +++ b/log-tree.c @@ -627,7 +627,8 @@ void show_log(struct rev_info *opt) ctx.print_email_subject = 1; } else if (opt->commit_format != CMIT_FMT_USERFORMAT) { fputs(diff_get_color_opt(&opt->diffopt, DIFF_COMMIT), opt->diffopt.file); - if (opt->commit_format != CMIT_FMT_ONELINE) + if (opt->commit_format != CMIT_FMT_ONELINE && + opt->commit_format != CMIT_FMT_SUMMARY) fputs("commit ", opt->diffopt.file); if (!opt->graph) @@ -644,7 +645,8 @@ void show_log(struct rev_info *opt) find_unique_abbrev(&parent->object.oid, abbrev_commit)); fputs(diff_get_color_opt(&opt->diffopt, DIFF_RESET), opt->diffopt.file); show_decorations(opt, commit); - if (opt->commit_format == CMIT_FMT_ONELINE) { + if (opt->commit_format == CMIT_FMT_ONELINE || + opt->commit_format == CMIT_FMT_SUMMARY) { putc(' ', opt->diffopt.file); } else { putc('\n', opt->diffopt.file); @@ -658,12 +660,15 @@ void show_log(struct rev_info *opt) * graph info here. */ show_reflog_message(opt->reflog_info, - opt->commit_format == CMIT_FMT_ONELINE, + (opt->commit_format == CMIT_FMT_ONELINE || + opt->commit_format == CMIT_FMT_SUMMARY), &opt->date_mode, opt->date_mode_explicit); if (opt->commit_format == CMIT_FMT_ONELINE) { putc('\n', opt->diffopt.file); return; + } else if (opt->commit_format == CMIT_FMT_SUMMARY) { + putc(' ', opt->diffopt.file); } } } diff --git a/pretty.c b/pretty.c index a6e5fc115a..8efb2486a5 100644 --- a/pretty.c +++ b/pretty.c @@ -97,7 +97,8 @@ static void setup_commit_formats(void) { "mboxrd", CMIT_FMT_MBOXRD, 0, 0 }, { "fuller", CMIT_FMT_FULLER, 0, 8 }, { "full", CMIT_FMT_FULL, 0, 8 }, - { "oneline", CMIT_FMT_ONELINE, 1, 0 } + { "oneline", CMIT_FMT_ONELINE, 1, 0 }, + { "summary", CMIT_FMT_SUMMARY, 1, 0 }, /* * Please update $__git_log_pretty_formats in * git-completion.bash when you add new formats. @@ -1672,6 +1673,26 @@ void repo_format_commit_message(struct repository *r, do_repo_format_commit_message, (void *)format); } +static void do_repo_format_commit_summary(struct strbuf *sb, + struct format_commit_context *context, + void *additional_context) +{ + struct ident_split ident; + + parse_commit_header(context); + parse_commit_message(context); + + strbuf_addstr(sb, "(\""); + format_subject(sb, context->message + context->subject_off, " "); + if (!split_ident_line(&ident, + context->message + context->author.off, + context->author.len)) { + strbuf_addstr(sb, "\", "); + strbuf_addstr(sb, show_ident_date(&ident, &context->pretty_ctx->date_mode)); + } + strbuf_addstr(sb, ")"); +} + static void pp_header(struct pretty_print_context *pp, const char *encoding, const struct commit *commit, @@ -1923,6 +1944,14 @@ void pretty_print_commit(struct pretty_print_context *pp, format_commit_message(commit, user_format, sb, pp); return; } + if (pp->fmt == CMIT_FMT_SUMMARY) { + if (!pp->date_mode_explicit) + pp->date_mode = *DATE_MODE(SHORT); + + repo_format_commit_generic(the_repository, commit, sb, pp, + do_repo_format_commit_summary, NULL); + return; + } encoding = get_log_output_encoding(); msg = reencoded = logmsg_reencode(commit, NULL, encoding); diff --git a/pretty.h b/pretty.h index 4ad1fc31ff..6d5b18a4f1 100644 --- a/pretty.h +++ b/pretty.h @@ -16,6 +16,7 @@ enum cmit_fmt { CMIT_FMT_FULL, CMIT_FMT_FULLER, CMIT_FMT_ONELINE, + CMIT_FMT_SUMMARY, CMIT_FMT_EMAIL, CMIT_FMT_MBOXRD, CMIT_FMT_USERFORMAT, diff --git a/t/t4205-log-pretty-formats.sh b/t/t4205-log-pretty-formats.sh index f42a69faa2..09b1a33cf1 100755 --- a/t/t4205-log-pretty-formats.sh +++ b/t/t4205-log-pretty-formats.sh @@ -788,4 +788,56 @@ test_expect_success '%S in git log --format works with other placeholders (part test_cmp expect actual ' +test_expect_success 'log --pretty=summary' ' + git log --date=short --pretty="tformat:%h (\"%s\", %ad)" >expect && + git log --pretty=summary >actual && + test_cmp expect actual +' + +test_expect_success 'log --pretty=summary with log.date is overridden by short date' ' + git log --date=short --pretty="tformat:%h (\"%s\", %ad)" >expect && + test_config log.date rfc && + git log --pretty=summary >actual && + test_cmp expect actual +' + +test_expect_success 'log --pretty=summary with explicit date overrides short date' ' + git log --date=rfc --pretty="tformat:%h (\"%s\", %ad)" >expect && + git log --date=rfc --pretty=summary >actual && + test_cmp expect actual +' + +test_expect_success 'log --pretty=summary with log.abbrevCommit is overidden' ' + git log --date=short --pretty="tformat:%h (\"%s\", %ad)" >expect && + test_config log.abbrevCommit false && + git log --pretty=summary >actual && + test_cmp expect actual +' + +test_expect_success 'log --pretty=summary with explicit --no-abbrev overrides abbreviated' ' + git log --date=short --pretty="tformat:%H (\"%s\", %ad)" >expect && + git log --no-abbrev --pretty=summary >actual && + test_cmp expect actual +' + +test_expect_success 'log --pretty=summary with log.decorate is overridden' ' + git log --date=short --pretty="tformat:%h (\"%s\", %ad)" >expect && + test_config log.decorate short && + git log --pretty=summary >actual && + test_cmp expect actual +' + +test_expect_success 'log --pretty=summary with explicit decorate overrides no decoration' ' + git log --date=short --pretty="tformat:%h%d (\"%s\", %ad)" >expect && + git log --decorate=short --pretty=summary >actual && + test_cmp expect actual +' + +test_expect_success 'log --pretty=summary with --walk-reflogs' ' + test_config log.date short && + git log --walk-reflogs --pretty="tformat:%h %gd: %gs (\"%s\", %ad)" >expect && + git log --walk-reflogs --pretty=summary >actual && + test_cmp expect actual +' + test_done From patchwork Mon Nov 4 20:04:07 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denton Liu <liu.denton@gmail.com> X-Patchwork-Id: 11226377 Return-Path: <SRS0=eADV=Y4=vger.kernel.org=git-owner@kernel.org> Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 0D62B15AB for <patchwork-git@patchwork.kernel.org>; Mon, 4 Nov 2019 20:04:12 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id DFAAA2084D for <patchwork-git@patchwork.kernel.org>; Mon, 4 Nov 2019 20:04:11 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="TR2n+zmG" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729340AbfKDUEL (ORCPT <rfc822;patchwork-git@patchwork.kernel.org>); Mon, 4 Nov 2019 15:04:11 -0500 Received: from mail-pf1-f194.google.com ([209.85.210.194]:44741 "EHLO mail-pf1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729091AbfKDUEK (ORCPT <rfc822;git@vger.kernel.org>); Mon, 4 Nov 2019 15:04:10 -0500 Received: by mail-pf1-f194.google.com with SMTP id q26so13114481pfn.11 for <git@vger.kernel.org>; Mon, 04 Nov 2019 12:04:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=my6aVG3DlfjCVcAHaEWnywsR3E6kPtPcwKmxnpYJJp0=; b=TR2n+zmGm7dgJlyu4+JR5+exy7IYEBzd77QU1C7i62ShXNVrL6d2ZpKu9XnHCfT5B3 m4jGTl0Kp5R7KphBfAE4wVrOdAINtRpG28vGl839I6f5Ere/vBEhX3vmgs0WSduOInZ9 gssAgclvlx6BnvAxDyzcZXeWHcSJerNRf3ymxPk/A8xhAS5FQZNtPQW+HTVmBuXhrhN4 La1OZB+fF8sa/gWbg2eZeir5LIi2hI+MHF5RifeA+ZcUu7pvKj0z4XpkaBWAJ1k7ciZq w2IGh/3VczoLQCvud8CspgeefBWgS8izCGElE13bFYSECKkHFy3MpWfeW1JDjBhQF/fd /pjA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=my6aVG3DlfjCVcAHaEWnywsR3E6kPtPcwKmxnpYJJp0=; b=HroSWMvRp8NqnYmBhOQKXCqypfecfwy2bot+jrzj310tRrI3hMNuW2FtFQJmB0JqaG 7NGoYWlYVqrOD1ypWGD3Ues4zwzbjtLveoofYIs8zkxc/Bquyp6xDrJJX7dGUna49LiB 2/zthMMqZN90P0EXsjAr4vKQqH8Enm9dgaAV/Vlt/JDa4iRCpTRzYOerL4DGpm1JtxBq au067xaCIGJgXHhjqw2At343nlCyahTWowGF2pkOhyHlXjs0Fyv/p+pkBJZQ82wWlSKj gIrLFR4OtGxloCC4ffyPFiN66q2lJqV5Z5gqL5/IMWxdp0pmoxv4qZbej3Rzf0pe1de9 3f8g== X-Gm-Message-State: APjAAAUSQO3JcKoeDx5uXRRlu5ZDPXNntntH/2WZ9gryjKy+RTsAKhkh 5JYvfjdzobrIck1grSz8dG3hIlp3 X-Google-Smtp-Source: APXvYqySFhgupeYWEQQb9XkMs6VQrdHx+4bilY90rceyji1Lc1fdXFbXZEB7mAIkDI+D5b0LW8mxbQ== X-Received: by 2002:a62:1d8e:: with SMTP id d136mr33788572pfd.49.1572897849778; Mon, 04 Nov 2019 12:04:09 -0800 (PST) Received: from generichostname ([204.14.236.210]) by smtp.gmail.com with ESMTPSA id r13sm21521156pfg.3.2019.11.04.12.04.08 for <git@vger.kernel.org> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Nov 2019 12:04:09 -0800 (PST) Date: Mon, 4 Nov 2019 15:04:07 -0500 From: Denton Liu <liu.denton@gmail.com> To: Git Mailing List <git@vger.kernel.org> Subject: [PATCH 8/8] SubmittingPatches: use `--pretty=summary` Message-ID: <0b861a47890a3d1e193d520f4678d017aac87207.1572897736.git.liu.denton@gmail.com> References: <cover.1572897736.git.liu.denton@gmail.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <cover.1572897736.git.liu.denton@gmail.com> User-Agent: Mutt/1.12.2 (2019-09-21) Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: <git.vger.kernel.org> X-Mailing-List: git@vger.kernel.org Since Git was taught the `--pretty=summary` option, it is no longer necessary to manually specify the format string to get the commit summary. Teach users to use the new option while keeping the old invocation around in case they have an older version of Git. Signed-off-by: Denton Liu <liu.denton@gmail.com> --- Documentation/SubmittingPatches | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Documentation/SubmittingPatches b/Documentation/SubmittingPatches index 1a60cc1329..6969ecca45 100644 --- a/Documentation/SubmittingPatches +++ b/Documentation/SubmittingPatches @@ -153,6 +153,12 @@ with the subject enclosed in a pair of double-quotes, like this: The "Copy commit summary" command of gitk can be used to obtain this format, or this invocation of `git show`: +.... + git show -s --pretty=summary <commit> +.... + +or, on an older version of Git without support for --pretty=summary: + .... git show -s --date=short --pretty='format:%h ("%s", %ad)' <commit> ....