summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: ac74905)
raw | patch | inline | side by side (parent: ac74905)
author | Junio C Hamano <junkio@cox.net> | |
Tue, 21 Mar 2006 02:45:47 +0000 (18:45 -0800) | ||
committer | Junio C Hamano <junkio@cox.net> | |
Tue, 21 Mar 2006 07:34:17 +0000 (23:34 -0800) |
Signed-off-by: Junio C Hamano <junkio@cox.net>
cache.h | patch | blob | history | |
config.c | patch | blob | history | |
environment.c | patch | blob | history | |
sha1_name.c | patch | blob | history |
index 1f962809b0be75b83abc285d492b62c7e6426623..255e6b5cc7aa799eee892dcd3632cd0656e6dd1e 100644 (file)
--- a/cache.h
+++ b/cache.h
extern int trust_executable_bit;
extern int assume_unchanged;
extern int only_use_symrefs;
+extern int warn_ambiguous_refs;
extern int diff_rename_limit_default;
extern int shared_repository;
extern const char *apply_default_whitespace;
diff --git a/config.c b/config.c
index 7dbdce1966b3c5e462e377b34ce8a11dd9668c0a..95ec34923d3fcf4d2a8fa16cbab9a5cbfe8e4f6f 100644 (file)
--- a/config.c
+++ b/config.c
return 0;
}
+ if (!strcmp(var, "core.warnambiguousrefs")) {
+ warn_ambiguous_refs = git_config_bool(var, value);
+ return 0;
+ }
+
if (!strcmp(var, "user.name")) {
strncpy(git_default_name, value, sizeof(git_default_name));
return 0;
diff --git a/environment.c b/environment.c
index 16c08f06971c25a48fce0784845fa7176ec3f568..5d29b92bd5fe65ecad1efbec66c810cdcd523113 100644 (file)
--- a/environment.c
+++ b/environment.c
int trust_executable_bit = 1;
int assume_unchanged = 0;
int only_use_symrefs = 0;
+int warn_ambiguous_refs = 0;
int repository_format_version = 0;
char git_commit_encoding[MAX_ENCODING_LENGTH] = "utf-8";
int shared_repository = 0;
diff --git a/sha1_name.c b/sha1_name.c
index d67de18ba5f5aa1f5b3dd1c5c81e75618d12e330..74c479c5e654354d2516477f8fe3e8366bdc2dd7 100644 (file)
--- a/sha1_name.c
+++ b/sha1_name.c
"refs",
"refs/tags",
"refs/heads",
+ "refs/remotes",
NULL
};
const char **p;
+ const char *warning = "warning: refname '%.*s' is ambiguous.\n";
+ char *pathname;
+ int already_found = 0;
if (len == 40 && !get_sha1_hex(str, sha1))
return 0;
return -1;
for (p = prefix; *p; p++) {
- char *pathname = git_path("%s/%.*s", *p, len, str);
- if (!read_ref(pathname, sha1))
- return 0;
+ unsigned char sha1_from_ref[20];
+ unsigned char *this_result =
+ already_found ? sha1_from_ref : sha1;
+ pathname = git_path("%s/%.*s", *p, len, str);
+ if (!read_ref(pathname, this_result)) {
+ if (warn_ambiguous_refs) {
+ if (already_found &&
+ !memcmp(sha1, sha1_from_ref, 20))
+ fprintf(stderr, warning, len, str);
+ already_found++;
+ }
+ else
+ return 0;
+ }
}
+ if (already_found)
+ return 0;
return -1;
}