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

[PATCH 1/3] builtin/add.c: simplify boolean variables

From
Junio C Hamano <gitster@pobox.com>
Date
Mar 9, 2013, 08:22 UTC
Message-ID
<1362817358-24356-2-git-send-email-gitster@pobox.com>
In-Reply-To
<1362817358-24356-1-git-send-email-gitster@pobox.com>

Do not to explicitly initialize static variables to 0 and instead let BSS take care of it. Also use OPT_BOOL() to let the command line arguments set these variables to 0 or 1, instead of the deprecated OPT_BOOLEAN() aka OPT_COUNTUP().

Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
 builtin/add.c | 22 +++++++++++-----------
 1 file changed, 11 insertions(+), 11 deletions(-)
diff --git a/builtin/add.c b/builtin/add.c
index 0dd014e..220321b 100644
--- a/builtin/add.c
+++ b/builtin/add.c
@@ -270,23 +270,23 @@ static struct lock_file lock_file;
 static const char ignore_error[] =
 N_("The following paths are ignored by one of your .gitignore files:\n");
 
-static int verbose = 0, show_only = 0, ignored_too = 0, refresh_only = 0;
-static int ignore_add_errors, addremove, intent_to_add, ignore_missing = 0;
+static int verbose, show_only, ignored_too, refresh_only;
+static int ignore_add_errors, addremove, intent_to_add, ignore_missing;
 
 static struct option builtin_add_options[] = {
 	OPT__DRY_RUN(&show_only, N_("dry run")),
 	OPT__VERBOSE(&verbose, N_("be verbose")),
 	OPT_GROUP(""),
-	OPT_BOOLEAN('i', "interactive", &add_interactive, N_("interactive picking")),
-	OPT_BOOLEAN('p', "patch", &patch_interactive, N_("select hunks interactively")),
-	OPT_BOOLEAN('e', "edit", &edit_interactive, N_("edit current diff and apply")),
+	OPT_BOOL('i', "interactive", &add_interactive, N_("interactive picking")),
+	OPT_BOOL('p', "patch", &patch_interactive, N_("select hunks interactively")),
+	OPT_BOOL('e', "edit", &edit_interactive, N_("edit current diff and apply")),
 	OPT__FORCE(&ignored_too, N_("allow adding otherwise ignored files")),
-	OPT_BOOLEAN('u', "update", &take_worktree_changes, N_("update tracked files")),
-	OPT_BOOLEAN('N', "intent-to-add", &intent_to_add, N_("record only the fact that the path will be added later")),
-	OPT_BOOLEAN('A', "all", &addremove, N_("add changes from all tracked and untracked files")),
-	OPT_BOOLEAN( 0 , "refresh", &refresh_only, N_("don't add, only refresh the index")),
-	OPT_BOOLEAN( 0 , "ignore-errors", &ignore_add_errors, N_("just skip files which cannot be added because of errors")),
-	OPT_BOOLEAN( 0 , "ignore-missing", &ignore_missing, N_("check if - even missing - files are ignored in dry run")),
+	OPT_BOOL('u', "update", &take_worktree_changes, N_("update tracked files")),
+	OPT_BOOL('N', "intent-to-add", &intent_to_add, N_("record only the fact that the path will be added later")),
+	OPT_BOOL('A', "all", &addremove, N_("add changes from all tracked and untracked files")),
+	OPT_BOOL( 0 , "refresh", &refresh_only, N_("don't add, only refresh the index")),
+	OPT_BOOL( 0 , "ignore-errors", &ignore_add_errors, N_("just skip files which cannot be added because of errors")),
+	OPT_BOOL( 0 , "ignore-missing", &ignore_missing, N_("check if - even missing - files are ignored in dry run")),
 	OPT_END(),
 };
 
-- 
1.8.2-rc3-203-gc9aaab5
Previous: Junio C HamanoNext: Junio C Hamano
Message 2 of 4 in “Make "git add dir/" notice removed "dir/file"”
  1. 0/3 Make "git add dir/" notice removed "dir/file"Junio C Hamano, Mar 9, 2013
  2. 1/3 builtin/add.c: simplify boolean variablesJunio C Hamano, Mar 9, 2013
  3. 2/3 git add: start preparing for "git add <pathspec>..." to default to "-A"Junio C Hamano, Mar 9, 2013
  4. 3/3 git add <pathspec>... defaults to "-A"Junio C Hamano, Mar 9, 2013

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.