threads / patch / 13948

patch, 2 partsbash: add more 'git add' options

Subject: [PATCH 2/2] bash: add more 'git add' options

## tl;dr

5 messages between Jun 14, 2008 and Jun 15, 2008. Diffs are folded; open one to read it.

replies: 4people: 2as markdown or json

SZEDER Gábor· Jun 14, 2008, 09:48 UTC · lore

[PATCH 1/2] git add: add long equivalents of '-u' and '-f' options

Signed-off-by: SZEDER Gábor <szeder@ira.uka.de>
---
 Documentation/git-add.txt |    7 +++++--
 builtin-add.c             |    4 ++--
 2 files changed, 7 insertions(+), 4 deletions(-)
Show changes to 2 files +7 −4

Documentation/git-add.txt, builtin-add.c

diff --git a/Documentation/git-add.txt b/Documentation/git-add.txt
index 9c6b081..b8e3fa6 100644
--- a/Documentation/git-add.txt
+++ b/Documentation/git-add.txt
@@ -8,8 +8,9 @@ git-add - Add file contents to the index
 SYNOPSIS
 --------
 [verse]
-'git-add' [-n] [-v] [-f] [--interactive | -i] [--patch | -p] [-u] [--refresh]
-	  [--ignore-errors] [--] <filepattern>...
+'git-add' [-n] [-v] [--force | -f] [--interactive | -i] [--patch | -p]
+	  [--update | -u] [--refresh] [--ignore-errors] [--]
+	  <filepattern>...
 
 DESCRIPTION
 -----------
@@ -59,6 +60,7 @@ OPTIONS
         Be verbose.
 
 -f::
+--force::
 	Allow adding otherwise ignored files.
 
 -i::
@@ -75,6 +77,7 @@ OPTIONS
 	the specified filepatterns before exiting.
 
 -u::
+--update::
 	Update only files that git already knows about, staging modified
 	content for commit and marking deleted files for removal. This
 	is similar
diff --git a/builtin-add.c b/builtin-add.c
index 1da22ee..9930cf5 100644
--- a/builtin-add.c
+++ b/builtin-add.c
@@ -200,8 +200,8 @@ static struct option builtin_add_options[] = {
 	OPT_GROUP(""),
 	OPT_BOOLEAN('i', "interactive", &add_interactive, "interactive picking"),
 	OPT_BOOLEAN('p', "patch", &patch_interactive, "interactive patching"),
-	OPT_BOOLEAN('f', NULL, &ignored_too, "allow adding otherwise ignored files"),
-	OPT_BOOLEAN('u', NULL, &take_worktree_changes, "update tracked files"),
+	OPT_BOOLEAN('f', "force", &ignored_too, "allow adding otherwise ignored files"),
+	OPT_BOOLEAN('u', "update", &take_worktree_changes, "update tracked files"),
 	OPT_BOOLEAN( 0 , "refresh", &refresh_only, "don't add, only refresh the index"),
 	OPT_BOOLEAN( 0 , "ignore-errors", &ignore_add_errors, "just skip files which cannot be added because of errors"),
 	OPT_END(),
-- 
1.5.6.rc2.55.g9b8c
SZEDER Gábor· Jun 14, 2008, 09:48 UTC · re: SZEDER Gábor · lore
Signed-off-by: SZEDER Gábor <szeder@ira.uka.de>
---
 contrib/completion/git-completion.bash |    5 ++++-
 1 files changed, 4 insertions(+), 1 deletions(-)
Show changes to contrib/completion/git-completion.bash +4 −1
diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
index 1698463..2141b6b 100755
--- a/contrib/completion/git-completion.bash
+++ b/contrib/completion/git-completion.bash
@@ -500,7 +500,10 @@ _git_add ()
 	local cur="${COMP_WORDS[COMP_CWORD]}"
 	case "$cur" in
 	--*)
-		__gitcomp "--interactive --refresh"
+		__gitcomp "
+			--interactive --refresh --patch --update --dry-run
+			--ignore-errors
+			"
 		return
 	esac
 	COMPREPLY=()
-- 
1.5.6.rc2.55.g9b8c
SZEDER Gábor· Jun 15, 2008, 08:53 UTC · lore

Re: [PATCH 1/2] git add: add long equivalents of '-u' and '-f' options

On Sun, Jun 15, 2008 at 08:43:12AM +0900, しらいしななこ wrote:
> Isn't this patch adding a new feature during the freezing period before
> the release?  What is the policy of accepting such a patch in general?

I think this patch is rather a bugfix in the user interface than a new feature.

Regards, Gábor

Junio C Hamano· Jun 15, 2008, 20:21 UTC · re: SZEDER Gábor · lore

Re: [PATCH 1/2] git add: add long equivalents of '-u' and '-f' options

SZEDER Gábor <szeder@ira.uka.de> writes:
> On Sun, Jun 15, 2008 at 08:43:12AM +0900, しらいしななこ wrote:
>> Isn't this patch adding a new feature during the freezing period before
>> the release?  What is the policy of accepting such a patch in general?

The policy during the freeze is "bugfix only unless otherwise noted", which is, admittedly, not saying much ;-)

> I think this patch is rather a bugfix in the user interface than a new
> feature.

Strictly speaking, this is a new feature but I think the documentation value to clarify -u stands for "update" is great enough to make it an exception. I've rewritten (from empty! Szeder, next time please write sensible commit log message to defend your changes, instead of having _me_ to defend your changes to others here, like this) the commit log message to clarify this point.

SZEDER Gábor· Jun 15, 2008, 21:23 UTC · re: Junio C Hamano · lore

Re: [PATCH 1/2] git add: add long equivalents of '-u' and '-f' options

On Sun, Jun 15, 2008 at 01:21:57PM -0700, Junio C Hamano wrote:
Show 7 quoted lines
> SZEDER Gábor <szeder@ira.uka.de> writes:
> > I think this patch is rather a bugfix in the user interface than a new
> > feature.
> 
> Strictly speaking, this is a new feature but I think the documentation
> value to clarify -u stands for "update" is great enough to make it an
> exception.

Well, my reasoning was that every short option must have a long equivalent, therefore the lack of long options is a bug (even if this does not lead to e.g. a runtime error).

> I've rewritten (from empty!  Szeder, next time please write
> sensible commit log message to defend your changes, instead of having _me_
> to defend your changes to others here, like this) the commit log message
> to clarify this point.

Sorry, I though the rationale behind the changes (i.e. "why?") is trivial even from that one-liner: add long options, because, well, they do not exist. In fact, I considered to write something like "these long options are '--update' and '--force'" in the commit message. But I dropped it, because that explained _what_ the patch does, and I understood that that should not go into the commit message.

Anyway, I will take care next time.

Regards, Gábor

← back to recent threads