# [PATCH 0/3] Trivial cleanups

4 messages from 2014-04-29 to 2014-04-29. Participants: Felipe Contreras.
Thread: https://gitlist.dev/t/36543

## Felipe Contreras, 2014-04-29 21:49

Subject: [PATCH 0/3] Trivial cleanups
Message-ID: <1398808178-3703-1-git-send-email-felipe.contreras@gmail.com>
URL: https://gitlist.dev/e/1398808178-3703-1-git-send-email-felipe.contreras%40gmail.com

```
Felipe Contreras (3):
  config: avoid yoda conditions
  add: avoid yoda condition
  add: remove dead code

 builtin/add.c | 6 +-----
 config.c      | 4 ++--
 2 files changed, 3 insertions(+), 7 deletions(-)

-- 
1.9.2+fc1.3.gade8541

```

## Felipe Contreras, 2014-04-29 21:49

Subject: [PATCH 1/3] config: avoid yoda conditions
Message-ID: <1398808178-3703-2-git-send-email-felipe.contreras@gmail.com>
URL: https://gitlist.dev/e/1398808178-3703-2-git-send-email-felipe.contreras%40gmail.com
In-Reply-To: <1398808178-3703-1-git-send-email-felipe.contreras@gmail.com>

```
Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
---
 config.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/config.c b/config.c
index a30cb5c..bd69ad7 100644
--- a/config.c
+++ b/config.c
@@ -616,7 +616,7 @@ static int git_config_maybe_bool_text(const char *name, const char *value)
 int git_config_maybe_bool(const char *name, const char *value)
 {
 	int v = git_config_maybe_bool_text(name, value);
-	if (0 <= v)
+	if (v >= 0)
 		return v;
 	if (git_parse_int(value, &v))
 		return !!v;
@@ -626,7 +626,7 @@ int git_config_maybe_bool(const char *name, const char *value)
 int git_config_bool_or_int(const char *name, const char *value, int *is_bool)
 {
 	int v = git_config_maybe_bool_text(name, value);
-	if (0 <= v) {
+	if (v >= 0) {
 		*is_bool = 1;
 		return v;
 	}
-- 
1.9.2+fc1.3.gade8541

```

## Felipe Contreras, 2014-04-29 21:49

Subject: [PATCH 2/3] add: avoid yoda condition
Message-ID: <1398808178-3703-3-git-send-email-felipe.contreras@gmail.com>
URL: https://gitlist.dev/e/1398808178-3703-3-git-send-email-felipe.contreras%40gmail.com
In-Reply-To: <1398808178-3703-1-git-send-email-felipe.contreras@gmail.com>

```
18 is younger than person's age.

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
---
 builtin/add.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/builtin/add.c b/builtin/add.c
index 459208a..ac10bab 100644
--- a/builtin/add.c
+++ b/builtin/add.c
@@ -321,7 +321,7 @@ int cmd_add(int argc, const char **argv, const char *prefix)
 	argc--;
 	argv++;
 
-	if (0 <= addremove_explicit)
+	if (addremove_explicit >= 0)
 		addremove = addremove_explicit;
 	else if (take_worktree_changes && ADDREMOVE_DEFAULT)
 		addremove = 0; /* "-u" was given but not "-A" */
-- 
1.9.2+fc1.3.gade8541

```

## Felipe Contreras, 2014-04-29 21:49

Subject: [PATCH 3/3] add: remove dead code
Message-ID: <1398808178-3703-4-git-send-email-felipe.contreras@gmail.com>
URL: https://gitlist.dev/e/1398808178-3703-4-git-send-email-felipe.contreras%40gmail.com
In-Reply-To: <1398808178-3703-1-git-send-email-felipe.contreras@gmail.com>

```
addremove is already 1 by default.

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
---
 builtin/add.c | 4 ----
 1 file changed, 4 deletions(-)

diff --git a/builtin/add.c b/builtin/add.c
index ac10bab..980e247 100644
--- a/builtin/add.c
+++ b/builtin/add.c
@@ -329,10 +329,6 @@ int cmd_add(int argc, const char **argv, const char *prefix)
 	if (addremove && take_worktree_changes)
 		die(_("-A and -u are mutually incompatible"));
 
-	if (!take_worktree_changes && addremove_explicit < 0 && argc)
-		/* Turn "git add pathspec..." to "git add -A pathspec..." */
-		addremove = 1;
-
 	if (!show_only && ignore_missing)
 		die(_("Option --ignore-missing can only be used together with --dry-run"));
 
-- 
1.9.2+fc1.3.gade8541

```
