summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: e41fcfe)
raw | patch | inline | side by side (parent: e41fcfe)
author | Conrad Irwin <conrad.irwin@gmail.com> | |
Sat, 7 May 2011 17:58:07 +0000 (10:58 -0700) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Tue, 10 May 2011 00:02:33 +0000 (17:02 -0700) |
The --interactive flag is already shared by git add and git commit,
share the -p and --patch flags too.
Signed-off-by: Conrad Irwin <conrad.irwin@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
share the -p and --patch flags too.
Signed-off-by: Conrad Irwin <conrad.irwin@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Documentation/git-commit.txt | patch | blob | history | |
builtin/add.c | patch | blob | history | |
builtin/commit.c | patch | blob | history | |
commit.h | patch | blob | history |
index ed50271aab4920a6135b8d8870ec22f45f2e779f..7951cb7b005bf472c449a563d073036ceb8b921a 100644 (file)
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
-----------
that have been removed from the working tree, and then perform the
actual commit;
-5. by using the --interactive switch with the 'commit' command to decide one
- by one which files should be part of the commit, before finalizing the
- operation. Currently, this is done by invoking 'git add --interactive'
- on a temporary index.
+5. by using the --interactive or --patch switches with the 'commit' command
+ to decide one by one which files or hunks should be part of the commit,
+ before finalizing the operation. See the ``Interactive Mode`` section of
+ linkgit:git-add[1] to learn how to operate these modes.
The `--dry-run` option can be used to obtain a
summary of what is included by any of the above for the next
been modified and deleted, but new files you have not
told git about are not affected.
+-p::
+--patch::
+ Use the interactive patch selection interface to chose
+ which changes to commit. See linkgit:git-add[1] for
+ details.
+
-C <commit>::
--reuse-message=<commit>::
Take an existing commit object, and reuse the log message
diff --git a/builtin/add.c b/builtin/add.c
index d39a6ab930adf2e3cd716d3e9925350befed8947..f02524bae0a610708e25a3d573ee4c00c701fe80 100644 (file)
--- a/builtin/add.c
+++ b/builtin/add.c
return status;
}
-int interactive_add(int argc, const char **argv, const char *prefix)
+int interactive_add(int argc, const char **argv, const char *prefix, int patch)
{
const char **pathspec = NULL;
}
return run_add_interactive(NULL,
- patch_interactive ? "--patch" : NULL,
+ patch ? "--patch" : NULL,
pathspec);
}
if (patch_interactive)
add_interactive = 1;
if (add_interactive)
- exit(interactive_add(argc - 1, argv + 1, prefix));
+ exit(interactive_add(argc - 1, argv + 1, prefix, patch_interactive));
if (edit_interactive)
return(edit_patch(argc, argv, prefix));
diff --git a/builtin/commit.c b/builtin/commit.c
index 7707af884494cfe68d9c781efb7ef4c532614874..008c1ec8380af17de62452dbf580c0c81912bf8e 100644 (file)
--- a/builtin/commit.c
+++ b/builtin/commit.c
static const char *author_message, *author_message_buffer;
static char *edit_message, *use_message;
static char *fixup_message, *squash_message;
-static int all, edit_flag, also, interactive, only, amend, signoff;
+static int all, edit_flag, also, interactive, patch_interactive, only, amend, signoff;
static int quiet, verbose, no_verify, allow_empty, dry_run, renew_authorship;
static int no_post_rewrite, allow_empty_message;
static char *untracked_files_arg, *force_date, *ignore_submodule_arg;
OPT_BOOLEAN('a', "all", &all, "commit all changed files"),
OPT_BOOLEAN('i', "include", &also, "add specified files to index for commit"),
OPT_BOOLEAN(0, "interactive", &interactive, "interactively add files"),
+ OPT_BOOLEAN('p', "patch", &patch_interactive, "interactively add changes"),
OPT_BOOLEAN('o', "only", &only, "commit only specified files"),
OPT_BOOLEAN('n', "no-verify", &no_verify, "bypass pre-commit hook"),
OPT_BOOLEAN(0, "dry-run", &dry_run, "show what would be committed"),
old_index_env = getenv(INDEX_ENVIRONMENT);
setenv(INDEX_ENVIRONMENT, index_lock.filename, 1);
- if (interactive_add(argc, argv, prefix) != 0)
+ if (interactive_add(argc, argv, prefix, patch_interactive) != 0)
die(_("interactive add failed"));
if (old_index_env && *old_index_env)
author_message_buffer = read_commit_message(author_message);
}
+ if (patch_interactive)
+ interactive = 1;
+
if (!!also + !!only + !!all + !!interactive > 1)
- die(_("Only one of --include/--only/--all/--interactive can be used."));
+ die(_("Only one of --include/--only/--all/--interactive/--patch can be used."));
if (argc == 0 && (also || (only && !amend)))
die(_("No paths with --include/--only does not make sense."));
if (argc == 0 && only && amend)
diff --git a/commit.h b/commit.h
index 41985130d1473573af2cfd4ca97a579e999b0c0b..b432642b997b36c742a4d4d6ff0b92497d192ee4 100644 (file)
--- a/commit.h
+++ b/commit.h
int is_descendant_of(struct commit *, struct commit_list *);
int in_merge_bases(struct commit *, struct commit **, int);
-extern int interactive_add(int argc, const char **argv, const char *prefix);
+extern int interactive_add(int argc, const char **argv, const char *prefix, int patch);
extern int run_add_interactive(const char *revision, const char *patch_mode,
const char **pathspec);