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

classic Classic list List threaded Threaded
10 messages Options
Reply | Threaded
Open this post in threaded view
|

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

Jonathan Nieder
"git commit -a" ignores untracked files and follows all tracked
files, regardless of whether they are listed in .gitignore.  So
don't use it to motivate gitignore.

Signed-off-by: Jonathan Nieder <[hidden email]>
---
        I noticed this while reading through the git-scm book, which
        looks very good.  If I am missing something, I would be very
        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"?

 Documentation/user-manual.txt |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/Documentation/user-manual.txt b/Documentation/user-manual.txt
index 43f4e39..f421689 100644
--- a/Documentation/user-manual.txt
+++ b/Documentation/user-manual.txt
@@ -1128,8 +1128,8 @@ This typically includes files generated by a build process or temporary
 backup files made by your editor. Of course, 'not' tracking files with git
 is just a matter of 'not' calling "`git-add`" on them. But it quickly becomes
 annoying to have these untracked files lying around; e.g. they make
-"`git add .`" and "`git commit -a`" practically useless, and they keep
-showing up in the output of "`git status`".
+"`git add .`" practically useless, and they keep showing up in the output of
+"`git status`".
 
 You can tell git to ignore certain files by creating a file called .gitignore
 in the top level of your working directory, with contents such as:
--
1.6.0.rc1.228.ge730

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to [hidden email]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Reply | Threaded
Open this post in threaded view
|

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

Miklos Vajna
On Wed, Aug 06, 2008 at 04:22:00PM -0500, Jonathan Nieder <[hidden email]> 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.

attachment0 (204 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

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

Jonathan Nieder
Miklos Vajna wrote:

> On Wed, Aug 06, 2008 at 04:22:00PM -0500, Jonathan Nieder <[hidden email]> 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 [hidden email]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Reply | Threaded
Open this post in threaded view
|

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

Jonathan Nieder
On Wed, 6 Aug 2008, Jonathan Nieder wrote:

> 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(-)

I was too hasty - the patch is insane in a number of ways.  But hopefully
the intent is clear :)

Jonathan
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to [hidden email]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Reply | Threaded
Open this post in threaded view
|

[PATCH] Documentation: clarify that git-commit only works with tracked files

Jonathan Nieder
In reply to this post by Jonathan Nieder
A user unfamiliar with CVS might not realize that a git-add is
needed before commiting new files.  So emphasize that "git commit
<path>..." only commits files already in the index.

Signed-off-by: Jonathan Nieder <[hidden email]>
---
        I keep on forgetting and getting annoyed when "git commit
        newfile.c" does not work.  From the same confusion I suggested
        git commit -A without really thinking about what it meant.
        This change should make the behavior easier to understand
        and remember.  Thanks for the help.

 Documentation/git-commit.txt |    7 ++++---
 1 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/Documentation/git-commit.txt b/Documentation/git-commit.txt
index 0e25bb8..9b00ccb 100644
--- a/Documentation/git-commit.txt
+++ b/Documentation/git-commit.txt
@@ -27,9 +27,10 @@ The content to be added can be specified in several ways:
 2. by using 'git-rm' to remove files from the working tree
    and the index, again before using the 'commit' command;
 
-3. by listing files as arguments to the 'commit' command, in which
-   case the commit will ignore changes staged in the index, and instead
-   record the current content of the listed files;
+3. by listing some known files as arguments to the 'commit'
+   command, in which case the commit will ignore changes staged
+   in the index and instead record the current content of the
+   listed files;
 
 4. by using the -a switch with the 'commit' command to automatically
    "add" changes from all known files (i.e. all files that are already
--
1.6.0.rc1.91.gf0c3


--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to [hidden email]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Reply | Threaded
Open this post in threaded view
|

Re: [PATCH] Documentation: clarify that git-commit only works with tracked files

Johannes Schindelin
Hi,

On Wed, 6 Aug 2008, Jonathan Nieder wrote:

> A user unfamiliar with CVS might not realize that a git-add is
> needed before commiting new files.

Funny.  I haven't used CVS for a while now, but I seem to remember that
"cvs commit newfile.c" without a prior "cvs add newfile.c" is not allowed.

Ciao,
Dscho

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to [hidden email]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Reply | Threaded
Open this post in threaded view
|

Re: [PATCH] Documentation: clarify that git-commit only works with tracked files

Jonathan Nieder
Hi,

On Thu, 7 Aug 2008, Johannes Schindelin wrote:

> On Wed, 6 Aug 2008, Jonathan Nieder wrote:
>
> > A user unfamiliar with CVS might not realize that a git-add is
> > needed before commiting new files.
>
> Funny.  I haven't used CVS for a while now, but I seem to remember that
> "cvs commit newfile.c" without a prior "cvs add newfile.c" is not allowed.

Yes, this is a closely related statement: a user familiar with CVS should
already know to add. :)

Jonathan
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to [hidden email]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Reply | Threaded
Open this post in threaded view
|

Re: [PATCH] Documentation: clarify that git-commit only works with tracked files

Miklos Vajna
In reply to this post by Johannes Schindelin
On Thu, Aug 07, 2008 at 02:39:59AM +0200, Johannes Schindelin <[hidden email]> wrote:
> Funny.  I haven't used CVS for a while now, but I seem to remember that
> "cvs commit newfile.c" without a prior "cvs add newfile.c" is not allowed.

But there is a difference. In most VCSes, you need 'add' once. In git
you need add before every commit. Of course this should be clear after
reading the "How to make a commit" part of the user manual.

attachment0 (204 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: [PATCH] Documentation: clarify that git-commit only works with tracked files

Peter Krefting
In reply to this post by Johannes Schindelin
Johannes Schindelin:

> Funny.  I haven't used CVS for a while now, but I seem to remember
> that "cvs commit newfile.c" without a prior "cvs add newfile.c" is
> not allowed.

Only to add the file to revision control initially. After that, you
just use commit to create new revisions.

--
\\// Peter - http://www.softwolves.pp.se/
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to [hidden email]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Reply | Threaded
Open this post in threaded view
|

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

J. Bruce Fields
In reply to this post by Jonathan Nieder
On Wed, Aug 06, 2008 at 04:22:00PM -0500, Jonathan Nieder wrote:
> "git commit -a" ignores untracked files and follows all tracked
> files, regardless of whether they are listed in .gitignore.  So
> don't use it to motivate gitignore.

Makes sense to me.

--b.

>
> Signed-off-by: Jonathan Nieder <[hidden email]>
> ---
> I noticed this while reading through the git-scm book, which
> looks very good.  If I am missing something, I would be very
> 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"?
>
>  Documentation/user-manual.txt |    4 ++--
>  1 files changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/Documentation/user-manual.txt b/Documentation/user-manual.txt
> index 43f4e39..f421689 100644
> --- a/Documentation/user-manual.txt
> +++ b/Documentation/user-manual.txt
> @@ -1128,8 +1128,8 @@ This typically includes files generated by a build process or temporary
>  backup files made by your editor. Of course, 'not' tracking files with git
>  is just a matter of 'not' calling "`git-add`" on them. But it quickly becomes
>  annoying to have these untracked files lying around; e.g. they make
> -"`git add .`" and "`git commit -a`" practically useless, and they keep
> -showing up in the output of "`git status`".
> +"`git add .`" practically useless, and they keep showing up in the output of
> +"`git status`".
>  
>  You can tell git to ignore certain files by creating a file called .gitignore
>  in the top level of your working directory, with contents such as:
> --
> 1.6.0.rc1.228.ge730
>
> --
> To unsubscribe from this list: send the line "unsubscribe git" in
> the body of a message to [hidden email]
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to [hidden email]
More majordomo info at  http://vger.kernel.org/majordomo-info.html