Thread (2 messages) flat view 2 messages, 2 authors, 2016-06-15

Re: [PATCH 1/2] push: make non-fast-forward help message configurable

From: Junio C Hamano <hidden>
Date: 2016-06-15 22:47:23

Jeff King [off-list ref] writes:
quoted hunk
diff --git a/advice.c b/advice.c
new file mode 100644
index 0000000..b5216a2
--- /dev/null
+++ b/advice.c
@@ -0,0 +1,25 @@
+#include "cache.h"
+
+int advice_push_nonfastforward = 1;
+
+static struct {
+	const char *name;
+	int *preference;
+} advice_config[] = {
+	{ "pushnonfastforward", &advice_push_nonfastforward },
+};
Can we have the value inside this struct, instead of having a pointer
to another variable, and get rid of that variable altogether?
quoted hunk
diff --git a/builtin-push.c b/builtin-push.c
index 787011f..6eda372 100644
--- a/builtin-push.c
+++ b/builtin-push.c
@@ -157,7 +157,7 @@ static int do_push(const char *repo, int flags)
 			continue;
 
 		error("failed to push some refs to '%s'", url[i]);
-		if (nonfastforward) {
+		if (nonfastforward && advice_push_nonfastforward) {
If we did so, this part needs to become

	if (nonfastforward && check_advice("pushnonfastforward")) {

which would be less efficient, but by definition advices are on the slow
path, right?

And check_advice() implementation can find programming errors by barfing
when the given string token does not exist in the table.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help