threads / patch / 36543

patch, 3 partsTrivial cleanups

Subject: [PATCH 0/3] Trivial cleanups

## tl;dr

4 messages between Apr 29, 2014 and Apr 29, 2014. Diffs are folded; open one to read it.

replies: 3people: 1as markdown or json

Felipe Contreras· Apr 29, 2014, 21:49 UTC · lore
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· Apr 29, 2014, 21:49 UTC · re: Felipe Contreras · lore

[PATCH 1/3] config: avoid yoda conditions

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
---
 config.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
Show changes to config.c +2 −2
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· Apr 29, 2014, 21:49 UTC · re: Felipe Contreras · lore

[PATCH 2/3] add: avoid yoda condition

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(-)
Show changes to builtin/add.c +1 −1
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· Apr 29, 2014, 21:49 UTC · re: Felipe Contreras · lore

[PATCH 3/3] add: remove dead code

addremove is already 1 by default.
Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
---
 builtin/add.c | 4 ----
 1 file changed, 4 deletions(-)
Show changes to builtin/add.c +0 −4
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

← back to recent threads