aboutsummaryrefslogtreecommitdiff
path: root/cache.h
diff options
context:
space:
mode:
authorChristopher Tiwald <christiwald@gmail.com>2012-03-20 00:31:33 -0400
committerJunio C Hamano <gitster@pobox.com>2012-03-19 21:42:06 -0700
commitf25950f3475e263ed6c8f0797bb058ba6444f85e (patch)
tree93090d1d543b82c68166593a04a50f0478172b11 /cache.h
parent0e2d57fd50f61e668be3180bc8f25991ea88aa8c (diff)
downloadgit-f25950f3475e263ed6c8f0797bb058ba6444f85e.tar.gz
git-f25950f3475e263ed6c8f0797bb058ba6444f85e.tar.xz
push: Provide situational hints for non-fast-forward errors
Pushing a non-fast-forward update to a remote repository will result in an error, but the hint text doesn't provide the correct resolution in every case. Give better resolution advice in three push scenarios: 1) If you push your current branch and it triggers a non-fast-forward error, you should merge remote changes with 'git pull' before pushing again. 2) If you push to a shared repository others push to, and your local tracking branches are not kept up to date, the 'matching refs' default will generate non-fast-forward errors on outdated branches. If this is your workflow, the 'matching refs' default is not for you. Consider setting the 'push.default' configuration variable to 'current' or 'upstream' to ensure only your current branch is pushed. 3) If you explicitly specify a ref that is not your current branch or push matching branches with ':', you will generate a non-fast-forward error if any pushed branch tip is out of date. You should checkout the offending branch and merge remote changes before pushing again. Teach transport.c to recognize these scenarios and configure push.c to hint for them. If 'git push's default behavior changes or we discover more scenarios, extension is easy. Standardize on the advice API and add three new advice variables, 'pushNonFFCurrent', 'pushNonFFDefault', and 'pushNonFFMatching'. Setting any of these to 'false' will disable their affiliated advice. Setting 'pushNonFastForward' to false will disable all three, thus preserving the config option for users who already set it, but guaranteeing new users won't disable push advice accidentally. Based-on-patch-by: Junio C Hamano <gitster@pobox.com> Signed-off-by: Christopher Tiwald <christiwald@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'cache.h')
-rw-r--r--cache.h8
1 files changed, 6 insertions, 2 deletions
diff --git a/cache.h b/cache.h
index e5e1aa4e1..427b60026 100644
--- a/cache.h
+++ b/cache.h
@@ -625,7 +625,8 @@ enum push_default_type {
PUSH_DEFAULT_NOTHING = 0,
PUSH_DEFAULT_MATCHING,
PUSH_DEFAULT_UPSTREAM,
- PUSH_DEFAULT_CURRENT
+ PUSH_DEFAULT_CURRENT,
+ PUSH_DEFAULT_UNSPECIFIED
};
extern enum branch_track git_branch_track;
@@ -1008,7 +1009,6 @@ struct ref {
char *symref;
unsigned int force:1,
merge:1,
- nonfastforward:1,
deletion:1;
enum {
REF_STATUS_NONE = 0,
@@ -1019,6 +1019,10 @@ struct ref {
REF_STATUS_REMOTE_REJECT,
REF_STATUS_EXPECTING_REPORT
} status;
+ enum {
+ NON_FF_HEAD = 1,
+ NON_FF_OTHER
+ } nonfastforward;
char *remote_status;
struct ref *peer_ref; /* when renaming */
char name[FLEX_ARRAY]; /* more */