path: root/advice.c
diff options
authorNguyễn Thái Ngọc Duy <>2013-05-29 12:12:42 (GMT)
committerJunio C Hamano <>2013-05-29 18:31:36 (GMT)
commit798c35fcd8a71a094ca68ac05d81e08c5ac8166d (patch)
tree6832c0926c40542a955a83b77d70ef3ccc36cfeb /advice.c
parent239222f587ed06f96d90dd71c66d80a2b1e3dc9f (diff)
get_sha1: warn about full or short object names that look like refs
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 <>
Diffstat (limited to 'advice.c')
1 files changed, 2 insertions, 0 deletions
diff --git a/advice.c b/advice.c
index 780f58d..22abde9 100644
--- a/advice.c
+++ b/advice.c
@@ -12,6 +12,7 @@ int advice_commit_before_merge = 1;
int advice_resolve_conflict = 1;
int advice_implicit_identity = 1;
int advice_detached_head = 1;
+int advice_object_name_warning = 1;
static struct {
const char *name;
@@ -29,6 +30,7 @@ static struct {
{ "resolveconflict", &advice_resolve_conflict },
{ "implicitidentity", &advice_implicit_identity },
{ "detachedhead", &advice_detached_head },
+ { "object_name_warning", &advice_object_name_warning },
/* make this an alias for backward compatibility */
{ "pushnonfastforward", &advice_push_update_rejected }