git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: "SZEDER Gábor" <szeder.dev@gmail.com>
To: Drew DeVault <sir@cmpwn.com>
Cc: git@vger.kernel.org
Subject: Re: [PATCH] am: add --check option
Date: Mon, 3 Jun 2019 17:46:44 +0200	[thread overview]
Message-ID: <20190603154644.GQ951@szeder.dev> (raw)
In-Reply-To: <20190603142523.3826-1-sir@cmpwn.com>

On Mon, Jun 03, 2019 at 10:25:23AM -0400, Drew DeVault wrote:
> ---
>  Documentation/git-am.txt |  7 ++++++-
>  builtin/am.c             | 13 +++++++++++++
>  2 files changed, 19 insertions(+), 1 deletion(-)
> 
> diff --git a/Documentation/git-am.txt b/Documentation/git-am.txt
> index fc3b993c33..bc01e87d85 100644
> --- a/Documentation/git-am.txt
> +++ b/Documentation/git-am.txt
> @@ -9,7 +9,7 @@ git-am - Apply a series of patches from a mailbox
>  SYNOPSIS
>  --------
>  [verse]
> -'git am' [--signoff] [--keep] [--[no-]keep-cr] [--[no-]utf8]
> +'git am' [--signoff] [--keep] [--check] [--[no-]keep-cr] [--[no-]utf8]
>  	 [--[no-]3way] [--interactive] [--committer-date-is-author-date]
>  	 [--ignore-date] [--ignore-space-change | --ignore-whitespace]
>  	 [--whitespace=<option>] [-C<n>] [-p<n>] [--directory=<dir>]
> @@ -44,6 +44,11 @@ OPTIONS
>  --keep-non-patch::
>  	Pass `-b` flag to 'git mailinfo' (see linkgit:git-mailinfo[1]).
>  
> +--check::
> +	Instead of applying the patch(es), see if they are
> +	applicable to the current working tree and/or the index
> +	file and detects errors.

Note that in "real" patch series a later patch quite often depends on
the changes made in earlier patches, and this option should somehow
account for that.  I'm not sure how to do that without actually
applying the patches, though...

  # Create two patches, each modifying the same line in the same file.
  $ echo 0 >file
  $ git add file
  $ git commit -m initial
  [master 956965a] initial
   1 file changed, 1 insertion(+)
   create mode 100644 file
  $ echo 1 >file
  $ git commit -m one file
  [master fd65db1] one
   1 file changed, 1 insertion(+), 1 deletion(-)
  $ echo 2 >file
  $ git commit -m two file
  [master 1b878f1] two
   1 file changed, 1 insertion(+), 1 deletion(-)
  $ git format-patch -2
  0001-one.patch
  0002-two.patch

  # This shows that the second patch is applicable on top of the
  # first:
  $ git checkout HEAD^
  HEAD is now at fd65db1 one
  $ git apply --check 0002-two.patch ; echo $?
  0

  # But 'git am --check' reports that the two patches can't be
  # applied on the initial commit, because it attempts to apply the
  # second patch on the initial commit as well, instead on top of the
  # first:
  $ git checkout HEAD^
  Previous HEAD position was fd65db1 one
  HEAD is now at 956965a initial
  $ ~/src/git/bin-wrappers/git am --check 0001-one.patch 0002-two.patch
  Applying: one
  Applying: two
  error: patch failed: file:1
  error: file: patch does not apply
  Patch failed at 0002 two

  # Though, of course, they can be applied just fine:
  $ ~/src/git/bin-wrappers/git am 0001-one.patch 0002-two.patch
  Applying: one
  Applying: two


  reply	other threads:[~2019-06-03 15:46 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-06-03 14:25 [PATCH] am: add --check option Drew DeVault
2019-06-03 15:46 ` SZEDER Gábor [this message]
2019-06-03 21:09 ` Johannes Sixt
2019-06-04 15:37 ` René Scharfe
     [not found] <BUKFSM2OTJUH.38N6DGWH9KX7H@homura>
2019-06-04  5:58 ` Johannes Sixt
2019-06-04 13:40   ` Johannes Schindelin
2019-06-04 14:06   ` Christian Couder

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190603154644.GQ951@szeder.dev \
    --to=szeder.dev@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=sir@cmpwn.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).