[PATCH 0/3] Trivial cleanups

DORMANTno replies

Revision v1 of 3 in this series.

4 messages, 1 author, 2016-06-15 · open the first message on its own page

[PATCH 0/3] Trivial cleanups

From: Felipe Contreras <hidden>
Date: 2016-06-15 23:00:55

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

[PATCH 1/3] config: avoid yoda conditions

From: Felipe Contreras <hidden>
Date: 2016-06-15 23:00:55

Signed-off-by: Felipe Contreras <redacted>
---
 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

[PATCH 2/3] add: avoid yoda condition

From: Felipe Contreras <hidden>
Date: 2016-06-15 23:00:55

18 is younger than person's age.

Signed-off-by: Felipe Contreras <redacted>
---
 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

[PATCH 3/3] add: remove dead code

From: Felipe Contreras <hidden>
Date: 2016-06-15 23:00:55

addremove is already 1 by default.

Signed-off-by: Felipe Contreras <redacted>
---
 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
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help