From 2857093ba15982d21ff0d5a9fd65294ac895cb67 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nguy=E1=BB=85n=20Th=C3=A1i=20Ng=E1=BB=8Dc=20Duy?= Date: Mon, 16 Jan 2012 16:46:16 +0700 Subject: clone: print advice on checking out detached HEAD MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Nguyễn Thái Ngọc Duy Signed-off-by: Junio C Hamano --- advice.h | 1 + 1 file changed, 1 insertion(+) (limited to 'advice.h') diff --git a/advice.h b/advice.h index e5d0af782b..7bda45b83e 100644 --- a/advice.h +++ b/advice.h @@ -14,5 +14,6 @@ int git_default_advice_config(const char *var, const char *value); void advise(const char *advice, ...); int error_resolve_conflict(const char *me); extern void NORETURN die_resolve_conflict(const char *me); +void detach_advice(const char *new_name); #endif /* ADVICE_H */ -- cgit v1.2.1 From f25950f3475e263ed6c8f0797bb058ba6444f85e Mon Sep 17 00:00:00 2001 From: Christopher Tiwald Date: Tue, 20 Mar 2012 00:31:33 -0400 Subject: 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 Signed-off-by: Christopher Tiwald Signed-off-by: Junio C Hamano --- advice.h | 3 +++ 1 file changed, 3 insertions(+) (limited to 'advice.h') diff --git a/advice.h b/advice.h index 7bda45b83e..f3cdbbf29e 100644 --- a/advice.h +++ b/advice.h @@ -4,6 +4,9 @@ #include "git-compat-util.h" extern int advice_push_nonfastforward; +extern int advice_push_non_ff_current; +extern int advice_push_non_ff_default; +extern int advice_push_non_ff_matching; extern int advice_status_hints; extern int advice_commit_before_merge; extern int advice_resolve_conflict; -- cgit v1.2.1 From 1184564eac8ef6c82da068a31f60aee0d6870265 Mon Sep 17 00:00:00 2001 From: Chris Rorvick Date: Sun, 2 Dec 2012 21:27:50 -0600 Subject: push: rename config variable for more general use The 'pushNonFastForward' advice config can be used to squelch several instances of push-related advice. Rename it to 'pushUpdateRejected' to cover other reject scenarios that are unrelated to fast-forwarding. Retain the old name for compatibility. Signed-off-by: Chris Rorvick Signed-off-by: Junio C Hamano --- advice.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'advice.h') diff --git a/advice.h b/advice.h index f3cdbbf29e..c28ef8ac23 100644 --- a/advice.h +++ b/advice.h @@ -3,7 +3,7 @@ #include "git-compat-util.h" -extern int advice_push_nonfastforward; +extern int advice_push_update_rejected; extern int advice_push_non_ff_current; extern int advice_push_non_ff_default; extern int advice_push_non_ff_matching; -- cgit v1.2.1 From b450568209c8ae270d26ee7fda2e4687ad8a5327 Mon Sep 17 00:00:00 2001 From: Chris Rorvick Date: Sun, 2 Dec 2012 21:27:51 -0600 Subject: push: allow already-exists advice to be disabled Add 'advice.pushAlreadyExists' option to disable the advice shown when an update is rejected for a reference that is not allowed to update at all (verses those that are allowed to fast-forward.) Signed-off-by: Chris Rorvick Signed-off-by: Junio C Hamano --- advice.h | 1 + 1 file changed, 1 insertion(+) (limited to 'advice.h') diff --git a/advice.h b/advice.h index c28ef8ac23..8bf63563a5 100644 --- a/advice.h +++ b/advice.h @@ -7,6 +7,7 @@ extern int advice_push_update_rejected; extern int advice_push_non_ff_current; extern int advice_push_non_ff_default; extern int advice_push_non_ff_matching; +extern int advice_push_already_exists; extern int advice_status_hints; extern int advice_commit_before_merge; extern int advice_resolve_conflict; -- cgit v1.2.1 From 75e5c0dc5529aed42122b3a774e6b17383e51b66 Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Wed, 23 Jan 2013 13:55:30 -0800 Subject: push: introduce REJECT_FETCH_FIRST and REJECT_NEEDS_FORCE When we push to update an existing ref, if: * the object at the tip of the remote is not a commit; or * the object we are pushing is not a commit, it won't be correct to suggest to fetch, integrate and push again, as the old and new objects will not "merge". We should explain that the push must be forced when there is a non-committish object is involved in such a case. If we do not have the current object at the tip of the remote, we do not even know that object, when fetched, is something that can be merged. In such a case, suggesting to pull first just like non-fast-forward case may not be technically correct, but in practice, most such failures are seen when you try to push your work to a branch without knowing that somebody else already pushed to update the same branch since you forked, so "pull first" would work as a suggestion most of the time. And if the object at the tip is not a commit, "pull first" will fail, without making any permanent damage. As a side effect, it also makes the error message the user will get during the next "push" attempt easier to understand, now the user is aware that a non-commit object is involved. In these cases, the current code already rejects such a push on the client end, but we used the same error and advice messages as the ones used when rejecting a non-fast-forward push, i.e. pull from there and integrate before pushing again. Introduce new rejection reasons and reword the messages appropriately. [jc: with help by Peff on message details] Signed-off-by: Junio C Hamano --- advice.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'advice.h') diff --git a/advice.h b/advice.h index 8bf63563a5..fad36df467 100644 --- a/advice.h +++ b/advice.h @@ -8,6 +8,8 @@ extern int advice_push_non_ff_current; extern int advice_push_non_ff_default; extern int advice_push_non_ff_matching; extern int advice_push_already_exists; +extern int advice_push_fetch_first; +extern int advice_push_needs_force; extern int advice_status_hints; extern int advice_commit_before_merge; extern int advice_resolve_conflict; -- cgit v1.2.1 From 6a38ef2ced55f0a8a7967581934e40f79e1d8733 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nguy=E1=BB=85n=20Th=C3=A1i=20Ng=E1=BB=8Dc=20Duy?= Date: Wed, 13 Mar 2013 19:59:16 +0700 Subject: status: advise to consider use of -u when read_directory takes too long MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Introduce advice.statusUoption to suggest considering use of -u to strike different trade-off when it took more than 2 seconds to enumerate untracked/ignored files. Signed-off-by: Nguyễn Thái Ngọc Duy Signed-off-by: Junio C Hamano --- advice.h | 1 + 1 file changed, 1 insertion(+) (limited to 'advice.h') diff --git a/advice.h b/advice.h index f3cdbbf29e..e3e665dc18 100644 --- a/advice.h +++ b/advice.h @@ -8,6 +8,7 @@ extern int advice_push_non_ff_current; extern int advice_push_non_ff_default; extern int advice_push_non_ff_matching; extern int advice_status_hints; +extern int advice_status_u_option; extern int advice_commit_before_merge; extern int advice_resolve_conflict; extern int advice_implicit_identity; -- cgit v1.2.1 From caa2036b3b4105bfe34f01115e4fb34b78a4db86 Mon Sep 17 00:00:00 2001 From: Jeff King Date: Tue, 2 Apr 2013 15:05:12 -0400 Subject: branch: give advice when tracking start-point is missing If the user requests to --set-upstream-to a branch that does not exist, then either: 1. It was a typo. 2. They thought the branch should exist. In case (1), there is not much we can do beyond showing the name we tried to use. For case (2), though, we can help to guide them through common workflows. Signed-off-by: Jeff King Signed-off-by: Junio C Hamano --- advice.h | 1 + 1 file changed, 1 insertion(+) (limited to 'advice.h') diff --git a/advice.h b/advice.h index af0c983c68..94caa32f92 100644 --- a/advice.h +++ b/advice.h @@ -16,6 +16,7 @@ extern int advice_commit_before_merge; extern int advice_resolve_conflict; extern int advice_implicit_identity; extern int advice_detached_head; +extern int advice_set_upstream_failure; int git_default_advice_config(const char *var, const char *value); void advise(const char *advice, ...); -- cgit v1.2.1 From 798c35fcd8a71a094ca68ac05d81e08c5ac8166d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nguy=E1=BB=85n=20Th=C3=A1i=20Ng=E1=BB=8Dc=20Duy?= Date: Wed, 29 May 2013 19:12:42 +0700 Subject: get_sha1: warn about full or short object names that look like refs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When we get 40 hex digits, we immediately assume it's an SHA-1. This is the right thing to do because we have no way else to specify an object. If there is a ref with the same object name, it will be ignored. Warn the user about this case because the ref with full object name is likely a mistake, for example git checkout -b $empty_var $(git rev-parse something) advice.object_name_warning is not documented because frankly people should not be aware about it until they encounter this situation. While at there, warn about ambiguation with abbreviated SHA-1 too. Signed-off-by: Nguyễn Thái Ngọc Duy Signed-off-by: Junio C Hamano --- advice.h | 1 + 1 file changed, 1 insertion(+) (limited to 'advice.h') diff --git a/advice.h b/advice.h index fad36df467..24d5420b7a 100644 --- a/advice.h +++ b/advice.h @@ -15,6 +15,7 @@ extern int advice_commit_before_merge; extern int advice_resolve_conflict; extern int advice_implicit_identity; extern int advice_detached_head; +extern int advice_object_name_warning; int git_default_advice_config(const char *var, const char *value); void advise(const char *advice, ...); -- cgit v1.2.1 From 7e30944622573ebdf87beed057b098af7360234c Mon Sep 17 00:00:00 2001 From: Mathieu Lienard--Mayor Date: Wed, 12 Jun 2013 10:06:44 +0200 Subject: rm: introduce advice.rmHints to shorten messages Introduce advice.rmHints to choose whether to display advice or not when git rm fails. Defaults to true, in order to preserve current behavior. As an example, the message: error: 'foo.txt' has changes staged in the index (use --cached to keep the file, or -f to force removal) would look like, with advice.rmHints=false: error: 'foo.txt' has changes staged in the index Signed-off-by: Mathieu Lienard--Mayor Signed-off-by: Jorge Juan Garcia Garcia Signed-off-by: Matthieu Moy Signed-off-by: Junio C Hamano --- advice.h | 1 + 1 file changed, 1 insertion(+) (limited to 'advice.h') diff --git a/advice.h b/advice.h index 94caa32f92..36104c4776 100644 --- a/advice.h +++ b/advice.h @@ -17,6 +17,7 @@ extern int advice_resolve_conflict; extern int advice_implicit_identity; extern int advice_detached_head; extern int advice_set_upstream_failure; +extern int advice_rm_hints; int git_default_advice_config(const char *var, const char *value); void advise(const char *advice, ...); -- cgit v1.2.1 From 4621085b7eb2f4cffe16d508988ff9b4a874b4ef Mon Sep 17 00:00:00 2001 From: Jeff King Date: Tue, 9 Jul 2013 20:18:40 -0400 Subject: add missing "format" function attributes For most of our functions that take printf-like formats, we use gcc's __attribute__((format)) to get compiler warnings when the functions are misused. Let's give a few more functions the same protection. In most cases, the annotations do not uncover any actual bugs; the only code change needed is that we passed a size_t to transfer_debug, which expected an int. Since we expect the passed-in value to be a relatively small buffer size (and cast a similar value to int directly below), we can just cast away the problem. Signed-off-by: Jeff King Signed-off-by: Junio C Hamano --- advice.h | 1 + 1 file changed, 1 insertion(+) (limited to 'advice.h') diff --git a/advice.h b/advice.h index 94caa32f92..d4c1764f2a 100644 --- a/advice.h +++ b/advice.h @@ -19,6 +19,7 @@ extern int advice_detached_head; extern int advice_set_upstream_failure; int git_default_advice_config(const char *var, const char *value); +__attribute__((format (printf, 1, 2))) void advise(const char *advice, ...); int error_resolve_conflict(const char *me); extern void NORETURN die_resolve_conflict(const char *me); -- cgit v1.2.1