From patchwork Tue Dec 3 14:02:07 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Arver via GitGitGadget X-Patchwork-Id: 11271345 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 2382B921 for ; Tue, 3 Dec 2019 14:02:28 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id EDF002073C for ; Tue, 3 Dec 2019 14:02:27 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="XBLqO/4Y" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726608AbfLCOC0 (ORCPT ); Tue, 3 Dec 2019 09:02:26 -0500 Received: from mail-wr1-f68.google.com ([209.85.221.68]:33476 "EHLO mail-wr1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726469AbfLCOCY (ORCPT ); Tue, 3 Dec 2019 09:02:24 -0500 Received: by mail-wr1-f68.google.com with SMTP id b6so3883247wrq.0 for ; Tue, 03 Dec 2019 06:02:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=message-id:in-reply-to:references:from:date:subject:fcc :content-transfer-encoding:mime-version:to:cc; bh=HjSBzc0rGvd4vC7CgPBj9hyIis2u+fMfIGl4JldqIGg=; b=XBLqO/4YwdWR9ThEKPklxMevitqKooo/yY46FbLySXQPYo3PRU6lTCfh2s7NCnSxDA cUildRWeL8jIX1eJ8mSR+Bkd0i3XIzcHAxbDACs+S3qMhXhx/12DPf8qnTkS2mD5e3LR wzNzx8Hf7hRSpTIwhpYFPw2HxN7Nm570V+99w4LGXK3cjN2ff9jx0ahlFIEmAYhoz94j jdMWm4rEQ/bDm0IHwGxjp76n4fNxB/mHMKUbObnRY3lZPjiMwTkD6jpIA4q6qHXsOf4W JbeaJfYkr0RPVmg/RaQ1jD30n6vYb1FE0vRmFHMJTH5FFJ/9juFyQaVaeLc/Im83qe0o PPzA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:in-reply-to:references:from:date :subject:fcc:content-transfer-encoding:mime-version:to:cc; bh=HjSBzc0rGvd4vC7CgPBj9hyIis2u+fMfIGl4JldqIGg=; b=bdm9IL7DWvrpkYD7Jv6BYUg2huGRlsBsuwFqRD6OzsZFO8ZtDeHzVm1ZH5BoTr3LA5 04jfzJD/+EaQIoXvMrLv3Z+7e7KX0tVOAqIJ5Md4zYmBi/v7FYGZV5wKn5dwtaGrCv8z z6vXXJUvvpaDJ5cvzYYo/mIQZRfCRGXw2ZFmshoV+3GmwgjaG6GOlcAX5+NhfbthGoLJ S4tLdkCvX10vQOoZQEa9Skmof7RM3mCnghHj9L2WlqlFhiXtreZxdwrsA6nFOtV3eLMq dE0fHC0H/7u2A5efHVlYq3kj6nj5DKBwBfHeprwNh8lwByxhvljuf1I7U7V7hCaKnwjc FBnw== X-Gm-Message-State: APjAAAVTBPvzQ6+KueRd3ox64uEr6eFhZfF20PVQ4MB/dpIG4FNGKzbr hqn4Fd5oY2ddTIN4QUKvrs33nGO/ X-Google-Smtp-Source: APXvYqyxjUgoZdEuBUy8lg2C/jgd4g8+RY5JOcVolVqRajVgHKPmi+N3l9QMlfrpzD4rCDfl87VZbA== X-Received: by 2002:a5d:4749:: with SMTP id o9mr5222048wrs.242.1575381741975; Tue, 03 Dec 2019 06:02:21 -0800 (PST) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id r6sm3715014wrv.40.2019.12.03.06.02.21 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 03 Dec 2019 06:02:21 -0800 (PST) Message-Id: In-Reply-To: References: From: "Alexandr Miloslavskiy via GitGitGadget" Date: Tue, 03 Dec 2019 14:02:07 +0000 Subject: [PATCH v4 02/13] pathspec: add new function to parse file Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: Junio C Hamano , Alexandr Miloslavskiy , Junio C Hamano , Alexandr Miloslavskiy Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Alexandr Miloslavskiy This will be used to support the new option '--pathspec-from-file' in `git add`, `git-commit`, `git reset` etc. Note also that we specifically handle CR/LF line endings to support Windows better. To simplify code, file is first parsed into `argv_array`. This allows to avoid refactoring `parse_pathspec()`. I considered adding `nul_term_line` to `flags` instead, but decided that it doesn't fit there. The new code is mostly taken from `cmd_update_index()` and `split_mail_conv()`. Co-authored-by: Johannes Schindelin Signed-off-by: Alexandr Miloslavskiy --- pathspec.c | 38 ++++++++++++++++++++++++++++++++++++++ pathspec.h | 10 ++++++++++ 2 files changed, 48 insertions(+) diff --git a/pathspec.c b/pathspec.c index 12c2b322b3..128f27fcb7 100644 --- a/pathspec.c +++ b/pathspec.c @@ -3,6 +3,8 @@ #include "dir.h" #include "pathspec.h" #include "attr.h" +#include "argv-array.h" +#include "quote.h" /* * Finds which of the given pathspecs match items in the index. @@ -613,6 +615,42 @@ void parse_pathspec(struct pathspec *pathspec, } } +void parse_pathspec_file(struct pathspec *pathspec, unsigned magic_mask, + unsigned flags, const char *prefix, + const char *file, int nul_term_line) +{ + struct argv_array parsed_file = ARGV_ARRAY_INIT; + strbuf_getline_fn getline_fn = nul_term_line ? strbuf_getline_nul : + strbuf_getline; + struct strbuf buf = STRBUF_INIT; + struct strbuf unquoted = STRBUF_INIT; + FILE *in; + + if (!strcmp(file, "-")) + in = stdin; + else + in = xfopen(file, "r"); + + while (getline_fn(&buf, in) != EOF) { + if (!nul_term_line && buf.buf[0] == '"') { + strbuf_reset(&unquoted); + if (unquote_c_style(&unquoted, buf.buf, NULL)) + die(_("line is badly quoted: %s"), buf.buf); + strbuf_swap(&buf, &unquoted); + } + argv_array_push(&parsed_file, buf.buf); + strbuf_reset(&buf); + } + + strbuf_release(&unquoted); + strbuf_release(&buf); + if (in != stdin) + fclose(in); + + parse_pathspec(pathspec, magic_mask, flags, prefix, parsed_file.argv); + argv_array_clear(&parsed_file); +} + void copy_pathspec(struct pathspec *dst, const struct pathspec *src) { int i, j; diff --git a/pathspec.h b/pathspec.h index 1c18a2c90c..a27dc81ba2 100644 --- a/pathspec.h +++ b/pathspec.h @@ -85,6 +85,16 @@ void parse_pathspec(struct pathspec *pathspec, unsigned flags, const char *prefix, const char **args); +/* + * Same as parse_pathspec() but uses file as input. + * When 'file' is exactly "-" it uses 'stdin' instead. + */ +void parse_pathspec_file(struct pathspec *pathspec, + unsigned magic_mask, + unsigned flags, + const char *prefix, + const char *file, + int nul_term_line); void copy_pathspec(struct pathspec *dst, const struct pathspec *src); void clear_pathspec(struct pathspec *); From patchwork Tue Dec 3 14:02:08 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Arver via GitGitGadget X-Patchwork-Id: 11271347 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 D76E91805 for ; Tue, 3 Dec 2019 14:02:27 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id B50C52073C for ; Tue, 3 Dec 2019 14:02:27 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="c01cyQfI" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726661AbfLCOC0 (ORCPT ); Tue, 3 Dec 2019 09:02:26 -0500 Received: from mail-wr1-f46.google.com ([209.85.221.46]:41539 "EHLO mail-wr1-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726534AbfLCOCZ (ORCPT ); Tue, 3 Dec 2019 09:02:25 -0500 Received: by mail-wr1-f46.google.com with SMTP id b18so3785859wrj.8 for ; Tue, 03 Dec 2019 06:02:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=message-id:in-reply-to:references:from:date:subject:fcc :content-transfer-encoding:mime-version:to:cc; bh=/uK7BgEr7oMW5g58dt51M2VtdlmyVxFS9orGRLslvD0=; b=c01cyQfIfKXW7rZt3DOhl7W/ktVPJ6srSdSI78w8aGexgrtOvjDH05SZ3+njlNydL+ KsBv6xhbsAybLB2spTlmTzJvvjqidq5y0tZTxCd8wi/L4KCPIhXuemILCyB2Ozo87G/w zOtE8cLyQxB6L3sWnk3ovz7B6JHrWanU05EvaB4xBgobs+rKclcZDQhQFXyRHxXKtvKE 6b9qcXqSFl1pkPHI/0uIQVQ6qbiaMU/mSUd42rM/yF2nFGjmzlTCxvl/TZRRgh1pgf4k 0pE/Ju51yw5j8gOc3LCwuO90li99ok9NpLIfexNEKInHFbo/RzYoCAZjRVxJebQ1aHgN qEtg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:in-reply-to:references:from:date :subject:fcc:content-transfer-encoding:mime-version:to:cc; bh=/uK7BgEr7oMW5g58dt51M2VtdlmyVxFS9orGRLslvD0=; b=raI4/XSBL9vK640A2hCpyVTGhFwjCmKQ0inDZWzupC7d3Ja9SZgo3NgISJkSEldZ4+ hGeUaH4X0i1KUOKIGzoho7bQXc4g1S6/oOEG881NZQ0xfT2RDoRmoL8b3p32+OsBKgpZ NW7FJv8JVPnZ/6vXJWILBVdnWJXM8s3NsVTSYEP0ERIoNxaTsrlZnFtqz5wW3ECLQLxL LQYTtMt+0OT7//X07GQzD5RM8HgyVyAM2ABGrTSrN9/zw3pLsURxQkFfklnuEAJ4JIWA 0uBpRCQ5n4uLbOl/FnewbV2vFyChekSa2DM2evE/EdOzJHMUFS4+VOrCD24xEA02kbwY caRw== X-Gm-Message-State: APjAAAUx7N+j1wULTBcHbMTai26S90DkdvjpJIEQl5HNH+5r5DcrwYWA gpq4IKZxYujOINrdnOZ+SJOtR4Lp X-Google-Smtp-Source: APXvYqxdHE5enguw57OiRaQ+oMW/LCYEnx0loK7wpm/hV7rpTW1I4Iwm3DJ8xwbW0r1eZj78tC9FKA== X-Received: by 2002:a05:6000:367:: with SMTP id f7mr5268154wrf.174.1575381742755; Tue, 03 Dec 2019 06:02:22 -0800 (PST) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id f1sm3686178wrp.93.2019.12.03.06.02.22 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 03 Dec 2019 06:02:22 -0800 (PST) Message-Id: <1182ba39535bc7c0cc4a241bd19d4c66cf6277d7.1575381738.git.gitgitgadget@gmail.com> In-Reply-To: References: From: "Alexandr Miloslavskiy via GitGitGadget" Date: Tue, 03 Dec 2019 14:02:08 +0000 Subject: [PATCH v4 03/13] doc: reset: synchronize description Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: Junio C Hamano , Alexandr Miloslavskiy , Junio C Hamano , Alexandr Miloslavskiy Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Alexandr Miloslavskiy `git add` shows an example of good writing, follow it. Signed-off-by: Alexandr Miloslavskiy --- Documentation/git-reset.txt | 29 ++++++++++++++++++----------- builtin/reset.c | 4 ++-- 2 files changed, 20 insertions(+), 13 deletions(-) diff --git a/Documentation/git-reset.txt b/Documentation/git-reset.txt index 97e0544d9e..d517a43e73 100644 --- a/Documentation/git-reset.txt +++ b/Documentation/git-reset.txt @@ -8,8 +8,8 @@ git-reset - Reset current HEAD to the specified state SYNOPSIS -------- [verse] -'git reset' [-q] [] [--] ... -'git reset' (--patch | -p) [] [--] [...] +'git reset' [-q] [] [--] ... +'git reset' (--patch | -p) [] [--] [...] 'git reset' [--soft | --mixed [-N] | --hard | --merge | --keep] [-q] [] DESCRIPTION @@ -19,23 +19,23 @@ In the third form, set the current branch head (`HEAD`) to ``, optionally modifying index and working tree to match. The ``/`` defaults to `HEAD` in all forms. -'git reset' [-q] [] [--] ...:: - This form resets the index entries for all `` to their - state at ``. (It does not affect the working tree or - the current branch.) +'git reset' [-q] [] [--] ...:: + This form resets the index entries for all paths that match the + `` to their state at ``. (It does not affect + the working tree or the current branch.) + -This means that `git reset ` is the opposite of `git add -`. This command is equivalent to -`git restore [--source=] --staged ...`. +This means that `git reset ` is the opposite of `git add +`. This command is equivalent to +`git restore [--source=] --staged ...`. + -After running `git reset ` to update the index entry, you can +After running `git reset ` to update the index entry, you can use linkgit:git-restore[1] to check the contents out of the index to the working tree. Alternatively, using linkgit:git-restore[1] and specifying a commit with `--source`, you can copy the contents of a path out of a commit to the index and to the working tree in one go. -'git reset' (--patch | -p) [] [--] [...]:: +'git reset' (--patch | -p) [] [--] [...]:: Interactively select hunks in the difference between the index and `` (defaults to `HEAD`). The chosen hunks are applied in reverse to the index. @@ -101,6 +101,13 @@ OPTIONS `reset.quiet` config option. `--quiet` and `--no-quiet` will override the default behavior. +\--:: + Do not interpret any more arguments as options. + +...:: + Limits the paths affected by the operation. ++ +For more details, see the 'pathspec' entry in linkgit:gitglossary[7]. EXAMPLES -------- diff --git a/builtin/reset.c b/builtin/reset.c index fdd572168b..9291c0fd72 100644 --- a/builtin/reset.c +++ b/builtin/reset.c @@ -30,8 +30,8 @@ static const char * const git_reset_usage[] = { N_("git reset [--mixed | --soft | --hard | --merge | --keep] [-q] []"), - N_("git reset [-q] [] [--] ..."), - N_("git reset --patch [] [--] [...]"), + N_("git reset [-q] [] [--] ..."), + N_("git reset --patch [] [--] [...]"), NULL }; From patchwork Tue Dec 3 14:02:09 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Arver via GitGitGadget X-Patchwork-Id: 11271361 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 6EF726C1 for ; Tue, 3 Dec 2019 14:02:33 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 432972073C for ; Tue, 3 Dec 2019 14:02:33 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="m5+By/TT" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726791AbfLCOCa (ORCPT ); Tue, 3 Dec 2019 09:02:30 -0500 Received: from mail-wr1-f68.google.com ([209.85.221.68]:41707 "EHLO mail-wr1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726474AbfLCOC0 (ORCPT ); Tue, 3 Dec 2019 09:02:26 -0500 Received: by mail-wr1-f68.google.com with SMTP id b18so3785928wrj.8 for ; Tue, 03 Dec 2019 06:02:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=message-id:in-reply-to:references:from:date:subject:fcc :content-transfer-encoding:mime-version:to:cc; bh=+buHZ51n44LNLRAp/5N82/ndSWJeE5B71CXkIfxwgzQ=; b=m5+By/TTlbI2ifcG4r2PIPA5GLbVUUYOpHO/t93BKJsG+aKf7VW6S2n5HPJRuNxXSL 6hVW9IvE7Rc/Y+LrqO51wyfv53gvW1j0sx02ixwvkY640Aol/Y/xgWQO2fnxAABhFpQT ZTIk80035y9Ydq93xtr84OHRdzKpEOIBWrbELpEXWLA/a/9POLvNEeHyr4UhzC/+ve1n ViCPMdOp2Z/Do5OXP4sKdbKkU3Biz5YEB6JCapMoUc9k+rIu2PnBmnZkFSCu4Q6WsMbq 7fg6kS4AxfbJXLComm8/pvzEHGjW75xlOl4ARBwh19D7cIuFlEh208BzUZRLCmfimldB VLzg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:in-reply-to:references:from:date :subject:fcc:content-transfer-encoding:mime-version:to:cc; bh=+buHZ51n44LNLRAp/5N82/ndSWJeE5B71CXkIfxwgzQ=; b=HthgKy4SHVX+2WvGsG3LIP0luGy0YRLAgnHhVWFyvmmjirnInmKsxPzQB53kYox+kV FJ792nlIbKF/8bUOXMf8I78XqCydv4BcwL68dNeXA9zOaQtqTHMwtfAz9piqQt2z8OQV GBw+51UuxGh4Vse4CpcH2J5NOkCyHJAUXY7apqMP/lpiIU9k/rQ1D8g8uUJ2sFFh3Y7z gUgnJQMhEJGZ0Z6xHCuWWKdjvwBnq3Lqk1D0fWd0Ty6QF9klCq74o8WXtqLxr3ZIPaxx +a581LtcW+7f3raJxroa2wvOd6pqdyMcqtISsJ5j95Kd/Ob96pUyorpsIAkvsDeX8zzr EKdQ== X-Gm-Message-State: APjAAAU+mSf7M2llieaX/PmOBTFs+a3pn3d6/QVV5YGzOwmb4JgMriR+ +vl4a6NMnHJvLDlsF3tTkVcJxVQ9 X-Google-Smtp-Source: APXvYqxNfujSpARpldejATBQRPaMqYhia098AD5ya3y5aBpD0bwqzk71ytuyxKCWNKH2sW1dHy1HLg== X-Received: by 2002:adf:8150:: with SMTP id 74mr5629369wrm.114.1575381743708; Tue, 03 Dec 2019 06:02:23 -0800 (PST) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id i127sm3261454wma.35.2019.12.03.06.02.22 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 03 Dec 2019 06:02:23 -0800 (PST) Message-Id: In-Reply-To: References: From: "Alexandr Miloslavskiy via GitGitGadget" Date: Tue, 03 Dec 2019 14:02:09 +0000 Subject: [PATCH v4 04/13] reset: support the `--pathspec-from-file` option Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: Junio C Hamano , Alexandr Miloslavskiy , Junio C Hamano , Alexandr Miloslavskiy Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Alexandr Miloslavskiy Decisions taken for simplicity: 1) For now, `--pathspec-from-file` is declared incompatible with `--patch`, even when is not `stdin`. Such use case it not really expected. Also, it is harder to support in `git commit`, so I decided to make it incompatible in all places. 2) It is not allowed to pass pathspec in both args and file. Co-authored-by: Johannes Schindelin Signed-off-by: Alexandr Miloslavskiy --- Documentation/git-reset.txt | 21 ++++- builtin/reset.c | 21 ++++- t/t7107-reset-pathspec-file.sh | 155 +++++++++++++++++++++++++++++++++ 3 files changed, 192 insertions(+), 5 deletions(-) create mode 100755 t/t7107-reset-pathspec-file.sh diff --git a/Documentation/git-reset.txt b/Documentation/git-reset.txt index d517a43e73..932080c55d 100644 --- a/Documentation/git-reset.txt +++ b/Documentation/git-reset.txt @@ -9,18 +9,20 @@ SYNOPSIS -------- [verse] 'git reset' [-q] [] [--] ... +'git reset' [-q] [--pathspec-from-file= [--pathspec-file-nul]] [] 'git reset' (--patch | -p) [] [--] [...] 'git reset' [--soft | --mixed [-N] | --hard | --merge | --keep] [-q] [] DESCRIPTION ----------- -In the first and second form, copy entries from `` to the index. -In the third form, set the current branch head (`HEAD`) to ``, +In the first three forms, copy entries from `` to the index. +In the last form, set the current branch head (`HEAD`) to ``, optionally modifying index and working tree to match. The ``/`` defaults to `HEAD` in all forms. 'git reset' [-q] [] [--] ...:: - This form resets the index entries for all paths that match the +'git reset' [-q] [--pathspec-from-file= [--pathspec-file-nul]] []:: + These forms reset the index entries for all paths that match the `` to their state at ``. (It does not affect the working tree or the current branch.) + @@ -101,6 +103,19 @@ OPTIONS `reset.quiet` config option. `--quiet` and `--no-quiet` will override the default behavior. +--pathspec-from-file=:: + Pathspec is passed in `` instead of commandline args. If + `` is exactly `-` then standard input is used. Pathspec + elements are separated by LF or CR/LF. Pathspec elements can be + quoted as explained for the configuration variable `core.quotePath` + (see linkgit:git-config[1]). See also `--pathspec-file-nul` and + global `--literal-pathspecs`. + +--pathspec-file-nul:: + Only meaningful with `--pathspec-from-file`. Pathspec elements are + separated with NUL character and all other characters are taken + literally (including newlines and quotes). + \--:: Do not interpret any more arguments as options. diff --git a/builtin/reset.c b/builtin/reset.c index 9291c0fd72..246bf9d737 100644 --- a/builtin/reset.c +++ b/builtin/reset.c @@ -31,6 +31,7 @@ static const char * const git_reset_usage[] = { N_("git reset [--mixed | --soft | --hard | --merge | --keep] [-q] []"), N_("git reset [-q] [] [--] ..."), + N_("git reset [-q] [--pathspec-from-file [--pathspec-file-nul]] []"), N_("git reset --patch [] [--] [...]"), NULL }; @@ -284,8 +285,8 @@ static int git_reset_config(const char *var, const char *value, void *cb) int cmd_reset(int argc, const char **argv, const char *prefix) { int reset_type = NONE, update_ref_status = 0, quiet = 0; - int patch_mode = 0, unborn; - const char *rev; + int patch_mode = 0, pathspec_file_nul = 0, unborn; + const char *rev, *pathspec_from_file = NULL; struct object_id oid; struct pathspec pathspec; int intent_to_add = 0; @@ -306,6 +307,8 @@ int cmd_reset(int argc, const char **argv, const char *prefix) OPT_BOOL('p', "patch", &patch_mode, N_("select hunks interactively")), OPT_BOOL('N', "intent-to-add", &intent_to_add, N_("record only the fact that removed paths will be added later")), + OPT_PATHSPEC_FROM_FILE(&pathspec_from_file), + OPT_PATHSPEC_FILE_NUL(&pathspec_file_nul), OPT_END() }; @@ -316,6 +319,20 @@ int cmd_reset(int argc, const char **argv, const char *prefix) PARSE_OPT_KEEP_DASHDASH); parse_args(&pathspec, argv, prefix, patch_mode, &rev); + if (pathspec_from_file) { + if (patch_mode) + die(_("--pathspec-from-file is incompatible with --patch")); + + if (pathspec.nr) + die(_("--pathspec-from-file is incompatible with pathspec arguments")); + + parse_pathspec_file(&pathspec, 0, + PATHSPEC_PREFER_FULL, + prefix, pathspec_from_file, pathspec_file_nul); + } else if (pathspec_file_nul) { + die(_("--pathspec-file-nul requires --pathspec-from-file")); + } + unborn = !strcmp(rev, "HEAD") && get_oid("HEAD", &oid); if (unborn) { /* reset on unborn branch: treat as reset to empty tree */ diff --git a/t/t7107-reset-pathspec-file.sh b/t/t7107-reset-pathspec-file.sh new file mode 100755 index 0000000000..6b1a731fff --- /dev/null +++ b/t/t7107-reset-pathspec-file.sh @@ -0,0 +1,155 @@ +#!/bin/sh + +test_description='reset --pathspec-from-file' + +. ./test-lib.sh + +test_tick + +test_expect_success setup ' + echo A >fileA.t && + echo B >fileB.t && + echo C >fileC.t && + echo D >fileD.t && + git add . && + git commit --include . -m "Commit" && + git tag checkpoint +' + +restore_checkpoint () { + git reset --hard checkpoint +} + +verify_expect () { + git status --porcelain -- fileA.t fileB.t fileC.t fileD.t >actual && + test_cmp expect actual +} + +test_expect_success '--pathspec-from-file from stdin' ' + restore_checkpoint && + + git rm fileA.t && + echo fileA.t | git reset --pathspec-from-file=- && + + cat >expect <<-\EOF && + D fileA.t + EOF + verify_expect +' + +test_expect_success '--pathspec-from-file from file' ' + restore_checkpoint && + + git rm fileA.t && + echo fileA.t >list && + git reset --pathspec-from-file=list && + + cat >expect <<-\EOF && + D fileA.t + EOF + verify_expect +' + +test_expect_success 'NUL delimiters' ' + restore_checkpoint && + + git rm fileA.t fileB.t && + printf "fileA.t\0fileB.t\0" | git reset --pathspec-from-file=- --pathspec-file-nul && + + cat >expect <<-\EOF && + D fileA.t + D fileB.t + EOF + verify_expect +' + +test_expect_success 'LF delimiters' ' + restore_checkpoint && + + git rm fileA.t fileB.t && + printf "fileA.t\nfileB.t\n" | git reset --pathspec-from-file=- && + + cat >expect <<-\EOF && + D fileA.t + D fileB.t + EOF + verify_expect +' + +test_expect_success 'no trailing delimiter' ' + restore_checkpoint && + + git rm fileA.t fileB.t && + printf "fileA.t\nfileB.t" | git reset --pathspec-from-file=- && + + cat >expect <<-\EOF && + D fileA.t + D fileB.t + EOF + verify_expect +' + +test_expect_success 'CRLF delimiters' ' + restore_checkpoint && + + git rm fileA.t fileB.t && + printf "fileA.t\r\nfileB.t\r\n" | git reset --pathspec-from-file=- && + + cat >expect <<-\EOF && + D fileA.t + D fileB.t + EOF + verify_expect +' + +test_expect_success 'quotes' ' + restore_checkpoint && + + git rm fileA.t && + printf "\"file\\101.t\"" | git reset --pathspec-from-file=- && + + cat >expect <<-\EOF && + D fileA.t + EOF + verify_expect +' + +test_expect_success 'quotes not compatible with --pathspec-file-nul' ' + restore_checkpoint && + + git rm fileA.t && + printf "\"file\\101.t\"" >list && + # Note: "git reset" has not yet learned to fail on wrong pathspecs + git reset --pathspec-from-file=list --pathspec-file-nul && + + cat >expect <<-\EOF && + D fileA.t + EOF + test_must_fail verify_expect +' + +test_expect_success '--pathspec-from-file is not compatible with --soft or --hard' ' + restore_checkpoint && + + git rm fileA.t && + echo fileA.t >list && + test_must_fail git reset --soft --pathspec-from-file=list && + test_must_fail git reset --hard --pathspec-from-file=list +' + +test_expect_success 'only touches what was listed' ' + restore_checkpoint && + + git rm fileA.t fileB.t fileC.t fileD.t && + printf "fileB.t\nfileC.t\n" | git reset --pathspec-from-file=- && + + cat >expect <<-\EOF && + D fileA.t + D fileB.t + D fileC.t + D fileD.t + EOF + verify_expect +' + +test_done From patchwork Tue Dec 3 14:02:10 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Arver via GitGitGadget X-Patchwork-Id: 11271349 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 63C97186E for ; Tue, 3 Dec 2019 14:02:28 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 42A43206EC for ; Tue, 3 Dec 2019 14:02:28 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="oQpHYdFL" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726684AbfLCOC1 (ORCPT ); Tue, 3 Dec 2019 09:02:27 -0500 Received: from mail-wm1-f67.google.com ([209.85.128.67]:55688 "EHLO mail-wm1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726550AbfLCOC0 (ORCPT ); Tue, 3 Dec 2019 09:02:26 -0500 Received: by mail-wm1-f67.google.com with SMTP id q9so1985887wmj.5 for ; Tue, 03 Dec 2019 06:02:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=message-id:in-reply-to:references:from:date:subject:fcc :content-transfer-encoding:mime-version:to:cc; bh=jFwdsXIw10GWaJMKJTmYGPbaQki7xSpz/S6SI98raT0=; b=oQpHYdFL5NH02eugSJRB/fz5U3roaogSWrke0BmiJWH8L4RALMX4pzgD6m81RlWM94 dlcmd3UMjpqBsJ7kSY5IHQ1QRrkriXQhw0g5Uom0SPZNQ7TQXLj1nsa4R1eR5O6UPzpj xVzxaKkSoynOW4gDiFKk6kBfVdVFcn+cdffoGcOxcw6VXrXO6LuWA5m0OmTgP3GkPRUp k5+dKHqJ6nVbiG1wsyfFl9cc0J0AwJQ1hvkwGQdEGqoUjIh/LsX9BQ/eNLk2jIrjd66N J7I9ece+lodEtjteoE6IDoXI0vGg0ZxRiq4+KwGYE/2+CFVoZzycPf0wcBCCWbrYnpgh /1Gw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:in-reply-to:references:from:date :subject:fcc:content-transfer-encoding:mime-version:to:cc; bh=jFwdsXIw10GWaJMKJTmYGPbaQki7xSpz/S6SI98raT0=; b=MbFD4Yzog601oFIleHZRorm2zgXWDyW/ZkvLovShyy5hZwYanloapr/TVSy3DB2sYS bWjh2bEt+TECROYqcua/PhG/ff9gu3Runa0Sr/RUOXgl9j4edck6/zOBiQu055fe57Dl 28iT29gI1l42+0imA87oRs2sHm53M8YiFOIODXjiZ5dT632u8XIdyanYcqpbcxOwlZQV c8W2wPVyn5zbP46CRTUJOA/gK+meaypjYxAiEog0PguDncx4+taj0YI+p+LHDH/yxQBc XhaDvqoQqBfPBEpMCREPiNObtfZhMcAE/oU5g+R8rmnrr7vZsT/LMLHo5tiCkNjoxggw UoyA== X-Gm-Message-State: APjAAAW9bLX4KtstEIbkg0nM79QB43ezTcmDAMi/Co3YJm9yRPDMdSEq dpfyPTmZNHvuR/9vS6BXVJJDveaD X-Google-Smtp-Source: APXvYqxm/RoY4nwtjR2Mdr5ii+R0YXgYvugrffW/+IrjmMRxeL1JUd3XayIiFf8IPIWD2vg1sltJzA== X-Received: by 2002:a7b:c051:: with SMTP id u17mr8845360wmc.174.1575381744506; Tue, 03 Dec 2019 06:02:24 -0800 (PST) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id l3sm3748296wrt.29.2019.12.03.06.02.23 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 03 Dec 2019 06:02:24 -0800 (PST) Message-Id: <0e1ac7e8a70ae0d508b71bf91a0e0b8f666cbe34.1575381738.git.gitgitgadget@gmail.com> In-Reply-To: References: From: "Alexandr Miloslavskiy via GitGitGadget" Date: Tue, 03 Dec 2019 14:02:10 +0000 Subject: [PATCH v4 05/13] doc: commit: synchronize description Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: Junio C Hamano , Alexandr Miloslavskiy , Junio C Hamano , Alexandr Miloslavskiy Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Alexandr Miloslavskiy `git add` shows an example of good writing, follow it. This also better disambiguates ... header. Signed-off-by: Alexandr Miloslavskiy --- Documentation/git-commit.txt | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/Documentation/git-commit.txt b/Documentation/git-commit.txt index afa7b75a23..a0c44978ee 100644 --- a/Documentation/git-commit.txt +++ b/Documentation/git-commit.txt @@ -13,7 +13,7 @@ SYNOPSIS [-F | -m ] [--reset-author] [--allow-empty] [--allow-empty-message] [--no-verify] [-e] [--author=] [--date=] [--cleanup=] [--[no-]status] - [-i | -o] [-S[]] [--] [...] + [-i | -o] [-S[]] [--] [...] DESCRIPTION ----------- @@ -345,12 +345,13 @@ changes to tracked files. \--:: Do not interpret any more arguments as options. -...:: - When files are given on the command line, the command - commits the contents of the named files, without - recording the changes already staged. The contents of - these files are also staged for the next commit on top - of what have been staged before. +...:: + When pathspec is given on the command line, commit the contents of + the files that match the pathspec without recording the changes + already added to the index. The contents of these files are also + staged for the next commit on top of what have been staged before. ++ +For more details, see the 'pathspec' entry in linkgit:gitglossary[7]. :git-commit: 1 include::date-formats.txt[] From patchwork Tue Dec 3 14:02:11 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Arver via GitGitGadget X-Patchwork-Id: 11271355 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 8B704184E for ; Tue, 3 Dec 2019 14:02:29 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 5F700206EC for ; Tue, 3 Dec 2019 14:02:29 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="SFAPDzJ5" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726291AbfLCOC2 (ORCPT ); Tue, 3 Dec 2019 09:02:28 -0500 Received: from mail-wr1-f67.google.com ([209.85.221.67]:43316 "EHLO mail-wr1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726449AbfLCOC1 (ORCPT ); Tue, 3 Dec 2019 09:02:27 -0500 Received: by mail-wr1-f67.google.com with SMTP id n1so3757073wra.10 for ; Tue, 03 Dec 2019 06:02:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=message-id:in-reply-to:references:from:date:subject:fcc :content-transfer-encoding:mime-version:to:cc; bh=LkXgE6w6UaVkpKoJy9Y/Z1HKYzIncm2cE3/WP1eADks=; b=SFAPDzJ5d0jPU5k/NTeZ3a8UfAwNInlE0BDHKZ6TsSz7E1DKJWkJOVJ2UTifcZQtNv nnWoyTqcjkZ2E3w3DNvfA2xuQk49mmlMWzXGEV+MqQ/gKliCOhKBZw+ncfh8qioQ6ZRr lQVOQxsWcs1ac87NwLwLcCCi7BZs+0dMaQk9u4LznprGYA8B0GlXZWzqdCJERyqDPe5P SUb/ub/BLW7QSAcquqDOIHEc+2D+zpbjyDf+RD6mV2T45GAhkFDo88l0xTyVtaT5flcd rN0cDcjWWhtqhH/NNT8KlUckEMWZ7B11lgFpfocENyZjkfWUElOHcah4UDKEKfWiWb27 h7NA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:in-reply-to:references:from:date :subject:fcc:content-transfer-encoding:mime-version:to:cc; bh=LkXgE6w6UaVkpKoJy9Y/Z1HKYzIncm2cE3/WP1eADks=; b=XODikZqfeWu3A/5kkM81KiOuTL354jRD/6ef7dzngoEF7FO/Ox0HFG4kVBQ5jDdT0u B2j9RvekYJz4a6wJ6GhbwC730xg65F7Xz+lGfmOfasGYNsVCQevlQRMgJGhMUexEYTRQ BEWXvWlU8/JYCJn0Bv79hbl/9bzzrTFuc6KkQ++Hsk8dw55/nCPIwfHUNKW44Su1SCih ysL5fgOHWmKxHr5LWvyaSOx/H1wB8TF/wIwyJ/cSlAt92GTkNq/4d/mGVDQ7AY7SexWc 9cO4JqmUtztEmoi/Cv2MvSTjfp6Qggr96DSNBpRXTOLMxzx6URude8RmOmRmP8xd2aZH Bo/w== X-Gm-Message-State: APjAAAUMgASa4dlORDDiB4OLw8EkhVJTmArzyeImSt70iwLv8FL3ZeN3 aXiBjT2D7XR68yF3arNcru+BEwRJ X-Google-Smtp-Source: APXvYqx6falddIt44gT/GRGoEJap9Vinua3Y1OrnuHym6cWQ4egnbFhgBXzq0DHWFdKvk1+bt2ZOsA== X-Received: by 2002:adf:fe86:: with SMTP id l6mr5178355wrr.252.1575381745303; Tue, 03 Dec 2019 06:02:25 -0800 (PST) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id l13sm3081632wmh.12.2019.12.03.06.02.24 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 03 Dec 2019 06:02:24 -0800 (PST) Message-Id: In-Reply-To: References: From: "Alexandr Miloslavskiy via GitGitGadget" Date: Tue, 03 Dec 2019 14:02:11 +0000 Subject: [PATCH v4 06/13] commit: support the --pathspec-from-file option Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: Junio C Hamano , Alexandr Miloslavskiy , Junio C Hamano , Alexandr Miloslavskiy Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Alexandr Miloslavskiy Decisions taken for simplicity: 1) For now, `--pathspec-from-file` is declared incompatible with `--interactive/--patch`, even when is not `stdin`. Such use case it not really expected. Also, it would require changes to `interactive_add()`. 2) It is not allowed to pass pathspec in both args and file. Signed-off-by: Alexandr Miloslavskiy --- Documentation/git-commit.txt | 16 +++- builtin/commit.c | 25 +++++- t/t7526-commit-pathspec-file.sh | 130 ++++++++++++++++++++++++++++++++ 3 files changed, 166 insertions(+), 5 deletions(-) create mode 100755 t/t7526-commit-pathspec-file.sh diff --git a/Documentation/git-commit.txt b/Documentation/git-commit.txt index a0c44978ee..ced5a9beab 100644 --- a/Documentation/git-commit.txt +++ b/Documentation/git-commit.txt @@ -13,7 +13,8 @@ SYNOPSIS [-F | -m ] [--reset-author] [--allow-empty] [--allow-empty-message] [--no-verify] [-e] [--author=] [--date=] [--cleanup=] [--[no-]status] - [-i | -o] [-S[]] [--] [...] + [-i | -o] [--pathspec-from-file= [--pathspec-file-nul]] + [-S[]] [--] [...] DESCRIPTION ----------- @@ -278,6 +279,19 @@ FROM UPSTREAM REBASE" section in linkgit:git-rebase[1].) already been staged. If used together with `--allow-empty` paths are also not required, and an empty commit will be created. +--pathspec-from-file=:: + Pathspec is passed in `` instead of commandline args. If + `` is exactly `-` then standard input is used. Pathspec + elements are separated by LF or CR/LF. Pathspec elements can be + quoted as explained for the configuration variable `core.quotePath` + (see linkgit:git-config[1]). See also `--pathspec-file-nul` and + global `--literal-pathspecs`. + +--pathspec-file-nul:: + Only meaningful with `--pathspec-from-file`. Pathspec elements are + separated with NUL character and all other characters are taken + literally (including newlines and quotes). + -u[]:: --untracked-files[=]:: Show untracked files. diff --git a/builtin/commit.c b/builtin/commit.c index 294dc574cd..2db2ad0de4 100644 --- a/builtin/commit.c +++ b/builtin/commit.c @@ -107,9 +107,9 @@ static int all, also, interactive, patch_interactive, only, amend, signoff; static int edit_flag = -1; /* unspecified */ static int quiet, verbose, no_verify, allow_empty, dry_run, renew_authorship; static int config_commit_verbose = -1; /* unspecified */ -static int no_post_rewrite, allow_empty_message; +static int no_post_rewrite, allow_empty_message, pathspec_file_nul; static char *untracked_files_arg, *force_date, *ignore_submodule_arg, *ignored_arg; -static char *sign_commit; +static char *sign_commit, *pathspec_from_file; /* * The default commit message cleanup mode will remove the lines @@ -343,6 +343,23 @@ static const char *prepare_index(int argc, const char **argv, const char *prefix PATHSPEC_PREFER_FULL, prefix, argv); + if (pathspec_from_file) { + if (interactive) + die(_("--pathspec-from-file is incompatible with --interactive/--patch")); + + if (pathspec.nr) + die(_("--pathspec-from-file is incompatible with pathspec arguments")); + + parse_pathspec_file(&pathspec, 0, + PATHSPEC_PREFER_FULL, + prefix, pathspec_from_file, pathspec_file_nul); + } else if (pathspec_file_nul) { + die(_("--pathspec-file-nul requires --pathspec-from-file")); + } + + if (!pathspec.nr && (also || (only && !amend && !allow_empty))) + die(_("No paths with --include/--only does not make sense.")); + if (read_cache_preload(&pathspec) < 0) die(_("index file corrupt")); @@ -1198,8 +1215,6 @@ static int parse_and_validate_options(int argc, const char *argv[], if (also + only + all + interactive > 1) die(_("Only one of --include/--only/--all/--interactive/--patch can be used.")); - if (argc == 0 && (also || (only && !amend && !allow_empty))) - die(_("No paths with --include/--only does not make sense.")); cleanup_mode = get_cleanup_mode(cleanup_arg, use_editor); handle_untracked_files_arg(s); @@ -1513,6 +1528,8 @@ int cmd_commit(int argc, const char **argv, const char *prefix) OPT_BOOL(0, "amend", &amend, N_("amend previous commit")), OPT_BOOL(0, "no-post-rewrite", &no_post_rewrite, N_("bypass post-rewrite hook")), { OPTION_STRING, 'u', "untracked-files", &untracked_files_arg, N_("mode"), N_("show untracked files, optional modes: all, normal, no. (Default: all)"), PARSE_OPT_OPTARG, NULL, (intptr_t)"all" }, + OPT_PATHSPEC_FROM_FILE(&pathspec_from_file), + OPT_PATHSPEC_FILE_NUL(&pathspec_file_nul), /* end commit contents options */ OPT_HIDDEN_BOOL(0, "allow-empty", &allow_empty, diff --git a/t/t7526-commit-pathspec-file.sh b/t/t7526-commit-pathspec-file.sh new file mode 100755 index 0000000000..a06b683534 --- /dev/null +++ b/t/t7526-commit-pathspec-file.sh @@ -0,0 +1,130 @@ +#!/bin/sh + +test_description='commit --pathspec-from-file' + +. ./test-lib.sh + +test_tick + +test_expect_success setup ' + test_commit file0 && + git tag checkpoint && + + echo A >fileA.t && + echo B >fileB.t && + echo C >fileC.t && + echo D >fileD.t && + git add fileA.t fileB.t fileC.t fileD.t +' + +restore_checkpoint () { + git reset --soft checkpoint +} + +verify_expect () { + git diff-tree --no-commit-id --name-status -r HEAD >actual && + test_cmp expect actual +} + +test_expect_success '--pathspec-from-file from stdin' ' + restore_checkpoint && + + echo fileA.t | git commit --pathspec-from-file=- -m "Commit" && + + cat >expect <<-\EOF && + A fileA.t + EOF + verify_expect +' + +test_expect_success '--pathspec-from-file from file' ' + restore_checkpoint && + + echo fileA.t >list && + git commit --pathspec-from-file=list -m "Commit" && + + cat >expect <<-\EOF && + A fileA.t + EOF + verify_expect +' + +test_expect_success 'NUL delimiters' ' + restore_checkpoint && + + printf "fileA.t\0fileB.t\0" | git commit --pathspec-from-file=- --pathspec-file-nul -m "Commit" && + + cat >expect <<-\EOF && + A fileA.t + A fileB.t + EOF + verify_expect +' + +test_expect_success 'LF delimiters' ' + restore_checkpoint && + + printf "fileA.t\nfileB.t\n" | git commit --pathspec-from-file=- -m "Commit" && + + cat >expect <<-\EOF && + A fileA.t + A fileB.t + EOF + verify_expect +' + +test_expect_success 'no trailing delimiter' ' + restore_checkpoint && + + printf "fileA.t\nfileB.t" | git commit --pathspec-from-file=- -m "Commit" && + + cat >expect <<-\EOF && + A fileA.t + A fileB.t + EOF + verify_expect +' + +test_expect_success 'CRLF delimiters' ' + restore_checkpoint && + + printf "fileA.t\r\nfileB.t\r\n" | git commit --pathspec-from-file=- -m "Commit" && + + cat >expect <<-\EOF && + A fileA.t + A fileB.t + EOF + verify_expect +' + +test_expect_success 'quotes' ' + restore_checkpoint && + + printf "\"file\\101.t\"" | git commit --pathspec-from-file=- -m "Commit" && + + cat >expect <<-\EOF && + A fileA.t + EOF + verify_expect expect +' + +test_expect_success 'quotes not compatible with --pathspec-file-nul' ' + restore_checkpoint && + + printf "\"file\\101.t\"" >list && + test_must_fail git commit --pathspec-from-file=list --pathspec-file-nul -m "Commit" +' + +test_expect_success 'only touches what was listed' ' + restore_checkpoint && + + printf "fileB.t\nfileC.t\n" | git commit --pathspec-from-file=- -m "Commit" && + + cat >expect <<-\EOF && + A fileB.t + A fileC.t + EOF + verify_expect +' + +test_done From patchwork Tue Dec 3 14:02:12 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Arver via GitGitGadget X-Patchwork-Id: 11271353 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 242A518EC for ; Tue, 3 Dec 2019 14:02:31 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 03A7D2073C for ; Tue, 3 Dec 2019 14:02:31 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="MyFA04ic" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726743AbfLCOC3 (ORCPT ); Tue, 3 Dec 2019 09:02:29 -0500 Received: from mail-wr1-f68.google.com ([209.85.221.68]:41712 "EHLO mail-wr1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726534AbfLCOC2 (ORCPT ); Tue, 3 Dec 2019 09:02:28 -0500 Received: by mail-wr1-f68.google.com with SMTP id b18so3786091wrj.8 for ; Tue, 03 Dec 2019 06:02:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=message-id:in-reply-to:references:from:date:subject:fcc :content-transfer-encoding:mime-version:to:cc; bh=KIYE1Fbl7vq7RG+1KLuvsBy+QKzADB9oXkWTZbz5N3k=; b=MyFA04icvY6xj7+nhkhO7d+OXhuJMidmSveelNrvMgmOPUGIJtEKtOmqx9ZzmZaDe2 UFnf//zm6BUaq4YnBIDTrZXl1IoeXhSetSx4bdffv0LcoyPNZ+oopnrHC+fzIlKs+n39 w1uUaUsPtmha7trHFdWHuvH9VRX/wcGRkbzZXrgppzE3Wmw6zKnPvRPjbu5LMfKuBbte 4djx7Fg5oH/93TO9PVjQX4oOdIdyot0PTGmjsRCiVVkL2m8rXcwjceXOv7GsVHywJCOT dPjwRm+Hot7wr4IKy2swgzoU+bg29Xt9l6OFwIImxfo5rUbKWLGtP3YrWnH6/M+Mt1PY mxgA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:in-reply-to:references:from:date :subject:fcc:content-transfer-encoding:mime-version:to:cc; bh=KIYE1Fbl7vq7RG+1KLuvsBy+QKzADB9oXkWTZbz5N3k=; b=hYqAGAOkv9DsuSs1E8XZBrIjEaFfPvwEI44NIOyttX89wMzQuNO5ZcDI4iHeXQe7mX 60ui07gQ4Xrw9pec6aNvqTnZBsmeOjKavPfTUMhISjE2M4dwrfM8+z0fvJQplkZGEKii 7vCPQpBX86wm48gsGs01YHGbemsPsASyTdslHZSqYa8B8mlFjND0RKkluzLSfL854/9A qTam4BWUwbBsvoyCxCQYLfuGhRdppAxfCCfRSDFQp2+WFMG3TsVslKRqnzZFAdExwdIb ETCJZVgCREo+U/x6Yzik4Z4H5gUbYx0GvxIo5Rx42AF8UZKTKQpSK+otY5XDbKyDe08o Fq1A== X-Gm-Message-State: APjAAAXqBt1zScHzI6JlI+V/GdeBsEeVSRuo6xaPzlUOSNKvpLBDYGT3 VYNnBGXO2FaIUYUgGNH2o2RAvNot X-Google-Smtp-Source: APXvYqxa0inMlOSzArYDwCtOdc27Q0WFmKIkKvpnhCFnFQuScBCpeKFxzanHdWhfszrv5xTViz9P6A== X-Received: by 2002:adf:f8c4:: with SMTP id f4mr5207481wrq.243.1575381746164; Tue, 03 Dec 2019 06:02:26 -0800 (PST) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id l3sm3748378wrt.29.2019.12.03.06.02.25 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 03 Dec 2019 06:02:25 -0800 (PST) Message-Id: In-Reply-To: References: From: "Alexandr Miloslavskiy via GitGitGadget" Date: Tue, 03 Dec 2019 14:02:12 +0000 Subject: [PATCH v4 07/13] cmd_add: prepare for next patch Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: Junio C Hamano , Alexandr Miloslavskiy , Junio C Hamano , Alexandr Miloslavskiy Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Alexandr Miloslavskiy Some code blocks were moved down to be able to test for `pathspec.nr` in the next patch. Blocks are moved as is without any changes. This is done as separate patch to reduce the amount of diffs in next patch. Signed-off-by: Alexandr Miloslavskiy --- builtin/add.c | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/builtin/add.c b/builtin/add.c index dd18e5c9b6..4fabdc72e6 100644 --- a/builtin/add.c +++ b/builtin/add.c @@ -418,10 +418,6 @@ int cmd_add(int argc, const char **argv, const char *prefix) if (addremove && take_worktree_changes) die(_("-A and -u are mutually incompatible")); - if (!take_worktree_changes && addremove_explicit < 0 && argc) - /* Turn "git add pathspec..." to "git add -A pathspec..." */ - addremove = 1; - if (!show_only && ignore_missing) die(_("Option --ignore-missing can only be used together with --dry-run")); @@ -434,19 +430,6 @@ int cmd_add(int argc, const char **argv, const char *prefix) hold_locked_index(&lock_file, LOCK_DIE_ON_ERROR); - flags = ((verbose ? ADD_CACHE_VERBOSE : 0) | - (show_only ? ADD_CACHE_PRETEND : 0) | - (intent_to_add ? ADD_CACHE_INTENT : 0) | - (ignore_add_errors ? ADD_CACHE_IGNORE_ERRORS : 0) | - (!(addremove || take_worktree_changes) - ? ADD_CACHE_IGNORE_REMOVAL : 0)); - - if (require_pathspec && argc == 0) { - fprintf(stderr, _("Nothing specified, nothing added.\n")); - fprintf(stderr, _("Maybe you wanted to say 'git add .'?\n")); - return 0; - } - /* * Check the "pathspec '%s' did not match any files" block * below before enabling new magic. @@ -456,6 +439,23 @@ int cmd_add(int argc, const char **argv, const char *prefix) PATHSPEC_SYMLINK_LEADING_PATH, prefix, argv); + if (require_pathspec && argc == 0) { + fprintf(stderr, _("Nothing specified, nothing added.\n")); + fprintf(stderr, _("Maybe you wanted to say 'git add .'?\n")); + return 0; + } + + if (!take_worktree_changes && addremove_explicit < 0 && argc) + /* Turn "git add pathspec..." to "git add -A pathspec..." */ + addremove = 1; + + flags = ((verbose ? ADD_CACHE_VERBOSE : 0) | + (show_only ? ADD_CACHE_PRETEND : 0) | + (intent_to_add ? ADD_CACHE_INTENT : 0) | + (ignore_add_errors ? ADD_CACHE_IGNORE_ERRORS : 0) | + (!(addremove || take_worktree_changes) + ? ADD_CACHE_IGNORE_REMOVAL : 0)); + if (read_cache_preload(&pathspec) < 0) die(_("index file corrupt")); From patchwork Tue Dec 3 14:02:13 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Arver via GitGitGadget X-Patchwork-Id: 11271363 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 61CBB6C1 for ; Tue, 3 Dec 2019 14:02:35 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 362A9206EC for ; Tue, 3 Dec 2019 14:02:35 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="u2DPvFSz" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726008AbfLCOCe (ORCPT ); Tue, 3 Dec 2019 09:02:34 -0500 Received: from mail-wr1-f68.google.com ([209.85.221.68]:41717 "EHLO mail-wr1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726550AbfLCOC3 (ORCPT ); Tue, 3 Dec 2019 09:02:29 -0500 Received: by mail-wr1-f68.google.com with SMTP id b18so3786190wrj.8 for ; Tue, 03 Dec 2019 06:02:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=message-id:in-reply-to:references:from:date:subject:fcc :content-transfer-encoding:mime-version:to:cc; bh=65y5REQOnztt7F0mA7wPZUa0Ym+EPup2v6lwxwt+TmU=; b=u2DPvFSzplWQQ5epmwyLhF2lgSd09Z5qgrG5/Yp8mPLgFPJW/kawggitfXBYtVJaT9 SFbaedMqMsFK+KEVNkppjWJV/QU9gnKN4vo7ds/nJ6j4JTyCgWe4QQDb/OcBHWpfeDB5 Q3WlS3O/phzuVERM+bcEd9dXoJ1gDsMacvTpy/F44QQ0CPjphRONrojGgdLTspIBwDYq Cs/RgMqYKiZoM8OoNw7nhVBQzN7CBsJt/8bvsZp7xqglnlFzvo8J+y1vi9/NuAfnzCGi zaaKQW/p+Y3csw9X0OBS+BnNsfY84C5xvtK4F097HI2a3bqUykS/GLGaVtIDw/L1/RWK BUWQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:in-reply-to:references:from:date :subject:fcc:content-transfer-encoding:mime-version:to:cc; bh=65y5REQOnztt7F0mA7wPZUa0Ym+EPup2v6lwxwt+TmU=; b=MZPHZaj53BBZjZNu2sktkzr68HsLBZnOphXEhmwFQZySvtE5r7HCmmJCOB/MtM4HZ+ UAqLqClLrAEkOPCWaG6aE9iQmIWRPKEz9NMDn6risCGzTrSh3tc7jaf21opdZHya+7LJ 9qVFOOzme8+uaXpwlk3658bDtGolxtEmi75kkRHTWFb9TtF3zVqrJdZ1g8yjY/tnP7rc k78DW9sO4pPsSF8lc++o/xnaexh2X34je0Jw02hPvkE3Ji1x0UzmzT1R0YGQqdxQnR5A Nmc/aML79ambAb6HfEIxXThjObQsfEqkO0dZNSz7qYA6wIZP16CystggUC9QvIbQCavl mZnA== X-Gm-Message-State: APjAAAU/Om3tO5oX7Xjq8vZhHzU5UUmguAFVQmNVxk2HBl1DMdphyPVQ 0bPE+x8uyX03I3aZs5znLK5eYP1D X-Google-Smtp-Source: APXvYqyRhRdjxZCKEGHqja+/2Tcwxy+EE5yieN3bwo0eaJZmhlJAGi5geQ1kll1u2JUNXdsUQYO9DQ== X-Received: by 2002:a05:6000:1044:: with SMTP id c4mr5539236wrx.204.1575381746923; Tue, 03 Dec 2019 06:02:26 -0800 (PST) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id u69sm3324018wmu.39.2019.12.03.06.02.26 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 03 Dec 2019 06:02:26 -0800 (PST) Message-Id: <9a62da3470b34b490717699ce40a7c73984d1cea.1575381738.git.gitgitgadget@gmail.com> In-Reply-To: References: From: "Alexandr Miloslavskiy via GitGitGadget" Date: Tue, 03 Dec 2019 14:02:13 +0000 Subject: [PATCH v4 08/13] add: support the --pathspec-from-file option Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: Junio C Hamano , Alexandr Miloslavskiy , Junio C Hamano , Alexandr Miloslavskiy Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Alexandr Miloslavskiy Decisions taken for simplicity: 1) For now, `--pathspec-from-file` is declared incompatible with `--interactive/--patch/--edit`, even when is not `stdin`. Such use case it not really expected. Also, it would require changes to `interactive_add()` and `edit_patch()`. 2) It is not allowed to pass pathspec in both args and file. Signed-off-by: Alexandr Miloslavskiy --- Documentation/git-add.txt | 16 ++++- builtin/add.c | 30 +++++++-- t/t3704-add-pathspec-file.sh | 127 +++++++++++++++++++++++++++++++++++ 3 files changed, 168 insertions(+), 5 deletions(-) create mode 100755 t/t3704-add-pathspec-file.sh diff --git a/Documentation/git-add.txt b/Documentation/git-add.txt index 8b0e4c7fa8..be5e3ac54b 100644 --- a/Documentation/git-add.txt +++ b/Documentation/git-add.txt @@ -11,7 +11,8 @@ SYNOPSIS 'git add' [--verbose | -v] [--dry-run | -n] [--force | -f] [--interactive | -i] [--patch | -p] [--edit | -e] [--[no-]all | --[no-]ignore-removal | [--update | -u]] [--intent-to-add | -N] [--refresh] [--ignore-errors] [--ignore-missing] [--renormalize] - [--chmod=(+|-)x] [--] [...] + [--chmod=(+|-)x] [--pathspec-from-file= [--pathspec-file-nul]] + [--] [...] DESCRIPTION ----------- @@ -187,6 +188,19 @@ for "git add --no-all ...", i.e. ignored removed files. bit is only changed in the index, the files on disk are left unchanged. +--pathspec-from-file=:: + Pathspec is passed in `` instead of commandline args. If + `` is exactly `-` then standard input is used. Pathspec + elements are separated by LF or CR/LF. Pathspec elements can be + quoted as explained for the configuration variable `core.quotePath` + (see linkgit:git-config[1]). See also `--pathspec-file-nul` and + global `--literal-pathspecs`. + +--pathspec-file-nul:: + Only meaningful with `--pathspec-from-file`. Pathspec elements are + separated with NUL character and all other characters are taken + literally (including newlines and quotes). + \--:: This option can be used to separate command-line options from the list of files, (useful when filenames might be mistaken diff --git a/builtin/add.c b/builtin/add.c index 4fabdc72e6..9f6b263aba 100644 --- a/builtin/add.c +++ b/builtin/add.c @@ -28,6 +28,8 @@ static const char * const builtin_add_usage[] = { static int patch_interactive, add_interactive, edit_interactive; static int take_worktree_changes; static int add_renormalize; +static int pathspec_file_nul; +static const char *pathspec_from_file; struct update_callback_data { int flags; @@ -309,6 +311,8 @@ static struct option builtin_add_options[] = { N_("override the executable bit of the listed files")), OPT_HIDDEN_BOOL(0, "warn-embedded-repo", &warn_on_embedded_repo, N_("warn when adding an embedded repository")), + OPT_PATHSPEC_FROM_FILE(&pathspec_from_file), + OPT_PATHSPEC_FILE_NUL(&pathspec_file_nul), OPT_END(), }; @@ -402,11 +406,17 @@ int cmd_add(int argc, const char **argv, const char *prefix) builtin_add_usage, PARSE_OPT_KEEP_ARGV0); if (patch_interactive) add_interactive = 1; - if (add_interactive) + if (add_interactive) { + if (pathspec_from_file) + die(_("--pathspec-from-file is incompatible with --interactive/--patch")); exit(interactive_add(argc - 1, argv + 1, prefix, patch_interactive)); + } - if (edit_interactive) + if (edit_interactive) { + if (pathspec_from_file) + die(_("--pathspec-from-file is incompatible with --edit")); return(edit_patch(argc, argv, prefix)); + } argc--; argv++; @@ -439,13 +449,25 @@ int cmd_add(int argc, const char **argv, const char *prefix) PATHSPEC_SYMLINK_LEADING_PATH, prefix, argv); - if (require_pathspec && argc == 0) { + if (pathspec_from_file) { + if (pathspec.nr) + die(_("--pathspec-from-file is incompatible with pathspec arguments")); + + parse_pathspec_file(&pathspec, PATHSPEC_ATTR, + PATHSPEC_PREFER_FULL | + PATHSPEC_SYMLINK_LEADING_PATH, + prefix, pathspec_from_file, pathspec_file_nul); + } else if (pathspec_file_nul) { + die(_("--pathspec-file-nul requires --pathspec-from-file")); + } + + if (require_pathspec && pathspec.nr == 0) { fprintf(stderr, _("Nothing specified, nothing added.\n")); fprintf(stderr, _("Maybe you wanted to say 'git add .'?\n")); return 0; } - if (!take_worktree_changes && addremove_explicit < 0 && argc) + if (!take_worktree_changes && addremove_explicit < 0 && pathspec.nr) /* Turn "git add pathspec..." to "git add -A pathspec..." */ addremove = 1; diff --git a/t/t3704-add-pathspec-file.sh b/t/t3704-add-pathspec-file.sh new file mode 100755 index 0000000000..3cfdb669b7 --- /dev/null +++ b/t/t3704-add-pathspec-file.sh @@ -0,0 +1,127 @@ +#!/bin/sh + +test_description='add --pathspec-from-file' + +. ./test-lib.sh + +test_tick + +test_expect_success setup ' + test_commit file0 && + echo A >fileA.t && + echo B >fileB.t && + echo C >fileC.t && + echo D >fileD.t +' + +restore_checkpoint () { + git reset +} + +verify_expect () { + git status --porcelain --untracked-files=no -- fileA.t fileB.t fileC.t fileD.t >actual && + test_cmp expect actual +} + +test_expect_success '--pathspec-from-file from stdin' ' + restore_checkpoint && + + echo fileA.t | git add --pathspec-from-file=- && + + cat >expect <<-\EOF && + A fileA.t + EOF + verify_expect +' + +test_expect_success '--pathspec-from-file from file' ' + restore_checkpoint && + + echo fileA.t >list && + git add --pathspec-from-file=list && + + cat >expect <<-\EOF && + A fileA.t + EOF + verify_expect +' + +test_expect_success 'NUL delimiters' ' + restore_checkpoint && + + printf "fileA.t\0fileB.t\0" | git add --pathspec-from-file=- --pathspec-file-nul && + + cat >expect <<-\EOF && + A fileA.t + A fileB.t + EOF + verify_expect +' + +test_expect_success 'LF delimiters' ' + restore_checkpoint && + + printf "fileA.t\nfileB.t\n" | git add --pathspec-from-file=- && + + cat >expect <<-\EOF && + A fileA.t + A fileB.t + EOF + verify_expect +' + +test_expect_success 'no trailing delimiter' ' + restore_checkpoint && + + printf "fileA.t\nfileB.t" | git add --pathspec-from-file=- && + + cat >expect <<-\EOF && + A fileA.t + A fileB.t + EOF + verify_expect +' + +test_expect_success 'CRLF delimiters' ' + restore_checkpoint && + + printf "fileA.t\r\nfileB.t\r\n" | git add --pathspec-from-file=- && + + cat >expect <<-\EOF && + A fileA.t + A fileB.t + EOF + verify_expect +' + +test_expect_success 'quotes' ' + restore_checkpoint && + + printf "\"file\\101.t\"" | git add --pathspec-from-file=- && + + cat >expect <<-\EOF && + A fileA.t + EOF + verify_expect +' + +test_expect_success 'quotes not compatible with --pathspec-file-nul' ' + restore_checkpoint && + + printf "\"file\\101.t\"" >list && + test_must_fail git add --pathspec-from-file=list --pathspec-file-nul +' + +test_expect_success 'only touches what was listed' ' + restore_checkpoint && + + printf "fileB.t\nfileC.t\n" | git add --pathspec-from-file=- && + + cat >expect <<-\EOF && + A fileB.t + A fileC.t + EOF + verify_expect +' + +test_done From patchwork Tue Dec 3 14:02:14 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Arver via GitGitGadget X-Patchwork-Id: 11271359 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 589B9921 for ; Tue, 3 Dec 2019 14:02:32 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 3702820684 for ; Tue, 3 Dec 2019 14:02:32 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="hX8hwtg2" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726824AbfLCOCb (ORCPT ); Tue, 3 Dec 2019 09:02:31 -0500 Received: from mail-wr1-f66.google.com ([209.85.221.66]:39587 "EHLO mail-wr1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726186AbfLCOCa (ORCPT ); Tue, 3 Dec 2019 09:02:30 -0500 Received: by mail-wr1-f66.google.com with SMTP id y11so3804291wrt.6 for ; Tue, 03 Dec 2019 06:02:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=message-id:in-reply-to:references:from:date:subject:fcc :content-transfer-encoding:mime-version:to:cc; bh=aYqtUfxrzTqHVRn2pfoo5R2+4lk0OX725HiLpzyYtMg=; b=hX8hwtg2d7G83sb8P/UPpzKDvia7+GdaWZnnUrF/JScofvrV2mjVTKism4W3Jlo6yd NrV2QJUi8Sd3qytIyrCsJxOwID08lGM+e9cSc0TIon3C7nCKzqjx2tPT6nwHToYWPTwh BsnfcoaTFoaaLMTroo6BVDmlXhIYreKzzSfJfgmr4azQBRMtaL+Ki6MY6OU0Eva0mmYw a6GVL0zbwjyKqEndett4XYvt6vs7jDww2NSHyyL52PE4Yb/KDTtmIQKQ23iwg1/wEBMw GWooGMjzw+aZwR/rV99Cbcrby2ZyNTBaAKG7y8Fteg6IZYfs63xuwVxSxruHJCEah5Jm I1cQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:in-reply-to:references:from:date :subject:fcc:content-transfer-encoding:mime-version:to:cc; bh=aYqtUfxrzTqHVRn2pfoo5R2+4lk0OX725HiLpzyYtMg=; b=Mwife4hWfu/KLcAVil+UyvzJwt2UiqZtLFGTohpSVj0XdFO1s0Kq+hwG01KoSdVyLQ 9IO6KGSLao2KYvILsnL53x7TRVZ8fiTRRjK0xp16ukjdCD3N5DL6NOikk0EVIiG9sUBY +jECKXv0N6kDrFYjvF30kixFcsog98Sx2I/OMhjnhI69vtCnzie0adapRHreMZV8aG+0 g9v3fkFpPFbd6i7YCJv/9SIPumOo9zo8Tdq1VpdR4TCM08pvzqy6uB0RlQtrhfBKjWb8 FKvyEXllxXbPfF6JwY8P652r8cTifkKCCVcWSR/7enAvkopqlFe/NUmUeawofXScRhwf JPrg== X-Gm-Message-State: APjAAAVQ5Pbfrk1bQM8UOLaY01Lc1nNmWRfa0zdkpNho8T5PI9qnKjPi D6IoVQy5hmyooEQqnww56aKlk+VG X-Google-Smtp-Source: APXvYqxER1GRDEi/zKYnqpHAZo9D1DXdg4IZQGBOtk2kYn21Gqh2pGWUp2mt/wdS1S0s+m5gjB721A== X-Received: by 2002:a5d:6ac3:: with SMTP id u3mr5539554wrw.25.1575381747808; Tue, 03 Dec 2019 06:02:27 -0800 (PST) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id t16sm3216545wmt.38.2019.12.03.06.02.27 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 03 Dec 2019 06:02:27 -0800 (PST) Message-Id: <5e449c8d29cbade125bacac6c04778ea85e3b0bd.1575381738.git.gitgitgadget@gmail.com> In-Reply-To: References: From: "Alexandr Miloslavskiy via GitGitGadget" Date: Tue, 03 Dec 2019 14:02:14 +0000 Subject: [PATCH v4 09/13] doc: checkout: remove duplicate synopsis Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: Junio C Hamano , Alexandr Miloslavskiy , Junio C Hamano , Alexandr Miloslavskiy Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Alexandr Miloslavskiy It was added in [1]. I understand that the duplicate change was not intentional and comes from an oversight. Also, in explanation, there was only one section for two synopsis entries. Fix both problems by removing duplicate synopsis. vs is resolved in next patch. [1] Commit b59698ae ("checkout doc: clarify command line args for "checkout paths" mode" 2017-10-11) Signed-off-by: Alexandr Miloslavskiy --- Documentation/git-checkout.txt | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Documentation/git-checkout.txt b/Documentation/git-checkout.txt index cf3cac0a2b..2011fdbb1d 100644 --- a/Documentation/git-checkout.txt +++ b/Documentation/git-checkout.txt @@ -13,7 +13,6 @@ SYNOPSIS 'git checkout' [-q] [-f] [-m] [--detach] 'git checkout' [-q] [-f] [-m] [[-b|-B|--orphan] ] [] 'git checkout' [-f|--ours|--theirs|-m|--conflict=