@@ -803,7 +803,7 @@ static int get_oid_basic(struct repository *r, const char *str, int len,
if (len == r->hash_algo->hexsz && !get_oid_hex(str, oid)) {
if (warn_ambiguous_refs && warn_on_object_refname_ambiguity) {
- refs_found = repo_dwim_ref(r, str, len, &tmp_oid, &real_ref, 0);
+ refs_found = repo_dwim_ref(r, str, len, &tmp_oid, &real_ref, 0, 0, 0);
if (refs_found > 0) {
warning(warn_msg, len, str);
if (advice_enabled(ADVICE_OBJECT_NAME_WARNING))
@@ -854,11 +854,11 @@ static int get_oid_basic(struct repository *r, const char *str, int len,
if (!len && reflog_len)
/* allow "@{...}" to mean the current branch reflog */
- refs_found = repo_dwim_ref(r, "HEAD", 4, oid, &real_ref, 0);
+ refs_found = repo_dwim_ref(r, "HEAD", 4, oid, &real_ref, 0, 0, 0);
else if (reflog_len)
refs_found = repo_dwim_log(r, str, len, oid, &real_ref);
else
- refs_found = repo_dwim_ref(r, str, len, oid, &real_ref, 0);
+ refs_found = repo_dwim_ref(r, str, len, oid, &real_ref, 0, 0, 0);
if (!refs_found)
return -1;
@@ -637,17 +637,19 @@ static char *substitute_branch_name(struct repository *r,
}
int repo_dwim_ref(struct repository *r, const char *str, int len,
- struct object_id *oid, char **ref, int nonfatal_dangling_mark)
+ struct object_id *oid, char **ref, int nonfatal_dangling_mark,
+ int *ref_flags, int need_symref)
{
char *last_branch = substitute_branch_name(r, &str, &len,
nonfatal_dangling_mark);
- int refs_found = expand_ref(r, str, len, oid, ref);
+ int refs_found = expand_ref(r, str, len, oid, ref, ref_flags, need_symref);
free(last_branch);
return refs_found;
}
int expand_ref(struct repository *repo, const char *str, int len,
- struct object_id *oid, char **ref)
+ struct object_id *oid, char **ref, int *ref_flags,
+ int need_symref)
{
const char **p, *r;
int refs_found = 0;
@@ -666,8 +668,11 @@ int expand_ref(struct repository *repo, const char *str, int len,
fullref.buf, RESOLVE_REF_READING,
this_result, &flag);
if (r) {
- if (!refs_found++)
- *ref = xstrdup(r);
+ if (!refs_found++) {
+ *ref = xstrdup(need_symref ? fullref.buf : r);
+ if (ref_flags)
+ *ref_flags = flag;
+ }
if (!warn_ambiguous_refs)
break;
} else if ((flag & REF_ISSYMREF) && strcmp(fullref.buf, "HEAD")) {
@@ -152,15 +152,17 @@ int refname_match(const char *abbrev_name, const char *full_name);
struct strvec;
void expand_ref_prefix(struct strvec *prefixes, const char *prefix);
-int expand_ref(struct repository *r, const char *str, int len, struct object_id *oid, char **ref);
+int expand_ref(struct repository *r, const char *str, int len, struct object_id *oid, char **ref,
+ int *ref_flags, int need_symref);
int repo_dwim_ref(struct repository *r, const char *str, int len,
- struct object_id *oid, char **ref, int nonfatal_dangling_mark);
+ struct object_id *oid, char **ref, int nonfatal_dangling_mark,
+ int *ref_flags, int need_symref);
int repo_dwim_log(struct repository *r, const char *str, int len, struct object_id *oid, char **ref);
static inline int dwim_ref(const char *str, int len, struct object_id *oid,
char **ref, int nonfatal_dangling_mark)
{
return repo_dwim_ref(the_repository, str, len, oid, ref,
- nonfatal_dangling_mark);
+ nonfatal_dangling_mark, 0, 0);
}
int dwim_log(const char *str, int len, struct object_id *oid, char **ref);
@@ -975,7 +975,7 @@ static int process_deepen_not(const char *line, struct string_list *deepen_not,
if (skip_prefix(line, "deepen-not ", &arg)) {
char *ref = NULL;
struct object_id oid;
- if (expand_ref(the_repository, arg, strlen(arg), &oid, &ref) != 1)
+ if (expand_ref(the_repository, arg, strlen(arg), &oid, &ref, 0, 0) != 1)
die("git upload-pack: ambiguous deepen-not: %s", line);
string_list_append(deepen_not, ref);
free(ref);