Re: Documentation: user-manual: "git commit -a" doesn't motivate .gitignore

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Miklos Vajna wrote:

> On Wed, Aug 06, 2008 at 04:22:00PM -0500, Jonathan Nieder <jrnieder@xxxxxxxxxxxx> wrote:
> > 	happy to know.  Maybe the sort of person that wants to track the
> > 	exact contents of the working tree would prefer
> > 	"git commit -a -i ." over "git commit -a"?
> 
> If you want so, then probably git add -A && git commit is easier.

Hmm.  I don't want it myself, but it seemed like the spirit behind
the lines I mentioned in the user manual.  Maybe something like this
(untested) would serve such people even better.

If anyone actually wants this, I'd be glad to make tests and document
it.  Thanks for the pointer.

-- snipsnip --
Subject: git commit --addremove: add and update all files

This makes git commit -A a shortcut for git add -A && git commit.  It
saves keystrokes, but more importantly it seems to be conceptually the
right thing thing for users who have perfect .gitignore files and want
to ignore the index.
---
 builtin-commit.c |   18 +++++++++++++++---
 1 files changed, 15 insertions(+), 3 deletions(-)

diff --git a/builtin-commit.c b/builtin-commit.c
index b783e6e..e3f645e 100644
--- a/builtin-commit.c
+++ b/builtin-commit.c
@@ -50,7 +50,8 @@ static char *logfile, *force_author;
 static const char *template_file;
 static char *edit_message, *use_message;
 static char *author_name, *author_email, *author_date;
-static int all, edit_flag, also, interactive, only, amend, signoff;
+static int all, addremove, edit_flag, also, interactive, only;
+static int amend, signoff;
 static int quiet, verbose, no_verify, allow_empty;
 static char *untracked_files_arg;
 /*
@@ -99,6 +100,7 @@ static struct option builtin_commit_options[] = {
 
 	OPT_GROUP("Commit contents options"),
 	OPT_BOOLEAN('a', "all", &all, "commit all changed files"),
+	OPT_BOOLEAN('A', "addremove", &addremove, "commit all changed files, including untracked"),
 	OPT_BOOLEAN('i', "include", &also, "add specified files to index for commit"),
 	OPT_BOOLEAN(0, "interactive", &interactive, "interactively add files"),
 	OPT_BOOLEAN('o', "only", &only, "commit only specified files"),
@@ -788,8 +790,8 @@ static int parse_and_validate_options(int argc, const char *argv[],
 			free(enc);
 	}
 
-	if (!!also + !!only + !!all + !!interactive > 1)
-		die("Only one of --include/--only/--all/--interactive can be used.");
+	if (!!also + !!only + !!all + !!addremove + !!interactive > 1)
+		die("Only one of --include/--only/--all/--addremove/--interactive can be used.");
 	if (argc == 0 && (also || (only && !amend)))
 		die("No paths with --include/--only does not make sense.");
 	if (argc == 0 && only && amend)
@@ -823,6 +825,16 @@ static int parse_and_validate_options(int argc, const char *argv[],
 	else if (interactive && argc > 0)
 		die("Paths with --interactive does not make sense.");
 
+	if (addremove) {
+		all = 1;
+		also = 1;
+	}
+	if (addremove && !argc) {
+		static const char *here[2] = {".", NULL };
+		argc = 1;
+		*argv = here;
+	}
+
 	return argc;
 }
 
-- 
1.6.0.rc1.228.ge730

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux