Re: [PATCH] Add support for -p/--patch to git-commit

Previous thread: [PATCH 1/2] t1501: avoid bashisms by =?UTF-8?q?Nguy=E1=BB=85n=20Th=C3=A1i=20Ng=E1=BB=8Dc=20Duy?= on Saturday, December 25, 2010 - 6:57 am. (9 messages)

Next thread: [PATCH] Fix false positives in t3404 due to SHELL=/bin/false by Robin H. Johnson on Sunday, December 26, 2010 - 7:50 pm. (8 messages)
From: Conrad Irwin
Date: Sunday, December 26, 2010 - 8:36 am

This works in the same was as git commit --interactive, and is
equivalent to running git add -p before git commit.

Signed-off-by: Conrad Irwin <conrad.irwin@gmail.com>
---

Hello Git,

Please let me know of any mistakes I've made, this is a first for me.

While this patch works as advertised, I wonder if it would be nicer to
change the behaviour of git commit --interactive and git commit -p to
act on a temporary copy of the index rather than mutating the existing
index. I've no idea how to go about that yet, but is it something that
should be changed?

Conrad

 Documentation/git-commit.txt |   24 ++++++++++++++++--------
 builtin/add.c                |    6 +++---
 builtin/commit.c             |   11 ++++++-----
 commit.h                     |    2 +-
 4 files changed, 26 insertions(+), 17 deletions(-)

diff --git a/Documentation/git-commit.txt b/Documentation/git-commit.txt
index b586c0f..fe3a14f 100644
--- a/Documentation/git-commit.txt
+++ b/Documentation/git-commit.txt
@@ -8,11 +8,12 @@ git-commit - Record changes to the repository
 SYNOPSIS
 --------
 [verse]
-'git commit' [-a | --interactive] [-s] [-v] [-u<mode>] [--amend] [--dry-run]
-	   [(-c | -C | --fixup | --squash) <commit>] [-F <file> | -m <msg>]
-	   [--reset-author] [--allow-empty] [--allow-empty-message] [--no-verify]
-	   [-e] [--author=<author>] [--date=<date>] [--cleanup=<mode>]
-	   [--status | --no-status] [-i | -o] [--] [<file>...]
+'git commit' [-a | --interactive | --patch] [-s] [-v] [-u<mode>] [--amend]
+	   [--dry-run] [(-c | -C | --fixup | --squash) <commit>]
+	   [-F <file> | -m <msg>] [--reset-author] [--allow-empty]
+	   [--allow-empty-message] [--no-verify] [-e] [--author=<author>]
+	   [--date=<date>] [--cleanup=<mode>] [--status | --no-status]
+	   [-i | -o] [--] [<file>...]
 
 DESCRIPTION
 -----------
@@ -39,9 +40,10 @@ The content to be added can be specified in several ways:
    that have been removed from the working tree, and then perform the
    actual commit;
 
-5. by ...
From: Matthieu Moy
Date: Sunday, December 26, 2010 - 9:30 am

At least one mistake:

To: unlisted-recipients:; (no To-header on input)


I don't think so. After a commit, I usually expect the index to be
clean, ready to start preparing the next commit (except if I
explicitely asked the opposite), which implies that the index used for


If I read correctly, this forbids "git commit --interactive --patch",
while "git add --interactive --patch" is allowed, and equivalent to
"--patch" alone.

Other than that, the patch looks good.

-- 
Matthieu Moy
http://www-verimag.imag.fr/~moy/
--

From: Conrad Irwin
Date: Sunday, December 26, 2010 - 10:56 am

This works in the same was as git commit --interactive, and is
equivalent to running git add -p before git commit.

Signed-off-by: Conrad Irwin <conrad.irwin@gmail.com>
---


Sorry, failed to use sendmail. (having read dire warnings about sending

The reason I suggested this is so that if you abort the commit (by
leaving the commit message empty), the index would be unchanged; at the
moment if you abort the commit the git-add is remembered. Certainly any
changes committed would be removed from the index. It also would allow
for git commit -p --only instead of having it always work like --include
(which might even be better default behaviour). (It's also worth noting

Well spotted :). Relatedly, git-commit currently forbids --interactive
with paths, which should also be changed (though in a different commit I
assume); I did not copy that limitation to --patch.

I've updated this patch, thank you very much for the feedback.

Conrad


 Documentation/git-commit.txt |   24 ++++++++++++++++--------
 builtin/add.c                |    6 +++---
 builtin/commit.c             |   11 ++++++-----
 commit.h                     |    2 +-
 4 files changed, 26 insertions(+), 17 deletions(-)

diff --git a/Documentation/git-commit.txt b/Documentation/git-commit.txt
index b586c0f..6e7ab5a 100644
--- a/Documentation/git-commit.txt
+++ b/Documentation/git-commit.txt
@@ -8,11 +8,12 @@ git-commit - Record changes to the repository
 SYNOPSIS
 --------
 [verse]
-'git commit' [-a | --interactive] [-s] [-v] [-u<mode>] [--amend] [--dry-run]
-	   [(-c | -C | --fixup | --squash) <commit>] [-F <file> | -m <msg>]
-	   [--reset-author] [--allow-empty] [--allow-empty-message] [--no-verify]
-	   [-e] [--author=<author>] [--date=<date>] [--cleanup=<mode>]
-	   [--status | --no-status] [-i | -o] [--] [<file>...]
+'git commit' [-a | --interactive | --patch] [-s] [-v] [-u<mode>] [--amend]
+	   [--dry-run] [(-c | -C | --fixup | --squash) <commit>]
+	   [-F <file> | -m <msg>] [--reset-author] ...
Previous thread: [PATCH 1/2] t1501: avoid bashisms by =?UTF-8?q?Nguy=E1=BB=85n=20Th=C3=A1i=20Ng=E1=BB=8Dc=20Duy?= on Saturday, December 25, 2010 - 6:57 am. (9 messages)

Next thread: