summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 6ea71fe)
raw | patch | inline | side by side (parent: 6ea71fe)
author | Jeff King <peff@peff.net> | |
Wed, 9 Sep 2009 11:38:58 +0000 (07:38 -0400) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Sat, 12 Sep 2009 04:33:20 +0000 (21:33 -0700) |
This message is designed to help new users understand what
has happened when refs fail to push. However, it does not
help experienced users at all, and significantly clutters
the output, frequently dwarfing the regular status table and
making it harder to see.
This patch introduces a general configuration mechanism for
optional messages, with this push message as the first
example.
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
has happened when refs fail to push. However, it does not
help experienced users at all, and significantly clutters
the output, frequently dwarfing the regular status table and
making it harder to see.
This patch introduces a general configuration mechanism for
optional messages, with this push message as the first
example.
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Documentation/config.txt | patch | blob | history | |
Makefile | patch | blob | history | |
advice.c | [new file with mode: 0644] | patch | blob |
advice.h | [new file with mode: 0644] | patch | blob |
builtin-push.c | patch | blob | history | |
cache.h | patch | blob | history | |
config.c | patch | blob | history |
index 5256c7fb811ae6f5777bf528a22b19b16b132f26..a35b9181bc811dcf63489532023d7d4ebfbd75f4 100644 (file)
--- a/Documentation/config.txt
+++ b/Documentation/config.txt
in the appropriate manual page. You will find a description of non-core
porcelain configuration variables in the respective porcelain documentation.
+advice.*::
+ When set to 'true', display the given optional help message.
+ When set to 'false', do not display. The configuration variables
+ are:
++
+--
+ pushNonFastForward::
+ Advice shown when linkgit:git-push[1] refuses
+ non-fast-forward refs. Default: true.
+--
+
core.fileMode::
If false, the executable bit differences between the index and
the working copy are ignored; useful on broken filesystems like FAT.
diff --git a/Makefile b/Makefile
index a614347568b16e7e2526580e7971f22e630ad976..9d9ff45fb24a5669a5b41e7078ecd8640043e65b 100644 (file)
--- a/Makefile
+++ b/Makefile
LIB_FILE=libgit.a
XDIFF_LIB=xdiff/lib.a
+LIB_H += advice.h
LIB_H += archive.h
LIB_H += attr.h
LIB_H += blob.h
LIB_H += wt-status.h
LIB_OBJS += abspath.o
+LIB_OBJS += advice.o
LIB_OBJS += alias.o
LIB_OBJS += alloc.o
LIB_OBJS += archive.o
diff --git a/advice.c b/advice.c
--- /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 },
+};
+
+int git_default_advice_config(const char *var, const char *value)
+{
+ const char *k = skip_prefix(var, "advice.");
+ int i;
+
+ for (i = 0; i < ARRAY_SIZE(advice_config); i++) {
+ if (strcmp(k, advice_config[i].name))
+ continue;
+ *advice_config[i].preference = git_config_bool(var, value);
+ return 0;
+ }
+
+ return 0;
+}
diff --git a/advice.h b/advice.h
--- /dev/null
+++ b/advice.h
@@ -0,0 +1,8 @@
+#ifndef ADVICE_H
+#define ADVICE_H
+
+extern int advice_push_nonfastforward;
+
+int git_default_advice_config(const char *var, const char *value);
+
+#endif /* ADVICE_H */
diff --git a/builtin-push.c b/builtin-push.c
index 787011f928556972b287ca5621a5d462cd6e2543..6eda372a55ec72e1a26119ffdff0dd69456bdcf5 100644 (file)
--- a/builtin-push.c
+++ b/builtin-push.c
continue;
error("failed to push some refs to '%s'", url[i]);
- if (nonfastforward) {
+ if (nonfastforward && advice_push_nonfastforward) {
printf("To prevent you from losing history, non-fast-forward updates were rejected\n"
"Merge the remote changes before pushing again. See the 'non-fast forward'\n"
"section of 'git push --help' for details.\n");
index 5fad24ce219be746ad582d8432464753975f34fe..e1ab09292ff3b54fcb3c548ee82e084d9eb34b61 100644 (file)
--- a/cache.h
+++ b/cache.h
#include "git-compat-util.h"
#include "strbuf.h"
#include "hash.h"
+#include "advice.h"
#include SHA1_HEADER
#ifndef git_SHA_CTX
diff --git a/config.c b/config.c
index e87edeab0c6b9579ecbd9bc5a9a11c3522d21ccf..f21530cdbd653a21d805550aedf6e69430d1e95b 100644 (file)
--- a/config.c
+++ b/config.c
if (!prefixcmp(var, "mailmap."))
return git_default_mailmap_config(var, value);
+ if (!prefixcmp(var, "advice."))
+ return git_default_advice_config(var, value);
+
if (!strcmp(var, "pager.color") || !strcmp(var, "color.pager")) {
pager_use_color = git_config_bool(var,value);
return 0;