Thread (22 messages) 22 messages, 1 author, 2021-05-31

[PATCH v2 10/13] push: remove redundant check

DORMANTno replies

From: Felipe Contreras <hidden>
Date: 2021-05-31 19:52:21
Subsystem: the rest · Maintainer: Linus Torvalds

If fetch_remote is NULL (i.e. the branch remote is invalid), then it
can't possibly be same as remote, which can't be NULL.

The check is redundant, and so is the extra variable.

Also, fix the Yoda condition: we want to check if remote is the same as
the branch remote, not the other way around.

Signed-off-by: Felipe Contreras <redacted>
---
 builtin/push.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/builtin/push.c b/builtin/push.c
index b5e951bf59..aa22d6a8e5 100644
--- a/builtin/push.c
+++ b/builtin/push.c
@@ -204,8 +204,7 @@ static const char *get_upstream_ref(struct branch *branch, const char *remote_na
 
 static int is_same_remote(struct remote *remote)
 {
-	struct remote *fetch_remote = remote_get(NULL);
-	return (!fetch_remote || fetch_remote == remote);
+	return remote == remote_get(NULL);
 }
 
 static void setup_default_push_refspecs(struct remote *remote)
-- 
2.32.0.rc0
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help