git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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

From
Jonathan Nieder <jrnieder@uchicago.edu>
Date
Aug 6, 2008, 22:29 UTC
Message-ID
<Pine.GSO.4.62.0808061725450.21683@harper.uchicago.edu>
In-Reply-To
<20080806214747.GY32057@genesis.frugalware.org>
Miklos Vajna wrote:
Show 6 quoted lines
> On Wed, Aug 06, 2008 at 04:22:00PM -0500, Jonathan Nieder <jrnieder@uchicago.edu> 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
Previous: Miklos VajnaNext: Jonathan Nieder
Message 3 of 10 in “Documentation: user-manual: "git commit -a" doesn't motivate .gitignore”
  1. Jonathan NiederAug 6, 2008
  2. Miklos VajnaAug 6, 2008
  3. Jonathan NiederAug 6, 2008
  4. Jonathan NiederAug 6, 2008
  5. Documentation: clarify that git-commit only works with tracked filesJonathan Nieder, Aug 7, 2008
  6. Johannes SchindelinAug 7, 2008
  7. Jonathan NiederAug 7, 2008
  8. Miklos VajnaAug 7, 2008
  9. Peter KreftingAug 7, 2008
  10. J. Bruce FieldsAug 7, 2008

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.