@matheusbsbs / matheus-bagliano / commits / 011fbc7f07
Fork 0

Remove misguided branch disambiguation.

This removes the misguided attempt to refuse processing a branch name xyzzy and insist it to be given as either heads/xyzzy or tags/xyzzy when a tag xyzzy exists. There was no reason to do so --- the search order was predictable and well defined, so if the user says xyzzy we should have taken the tag xyzzy in such a case without complaining. This incidentally fixes another subtle bug related to this. If such a duplicate branch/tag name happened to be a unique valid prefix of an existing commit object name (say, "beef"), we did not take the tag "beef" but after complaining used the commit object whose name started with beef. Another problem this fixes while introducing some confusion is that there is no longer a reason to forbid a branch name HEAD anymore. In other words, now "git pull . ref1:HEAD" would work as expected, once we revert "We do not like HEAD branch" patch. It creates "HEAD" branch under ${GIT_DIR-.git}/refs/heads (or fast-forwards if already exists) using the tip of ref1 branch from the current repository, and merges it into the current branch. Signed-off-by: Junio C Hamano <junkio@cox.net>

Junio C Hamano committed Dec 16, 2005 at 23:19 UTC 011fbc7f07fdf82cf922d1eb269bb4dac3e0cc40
1 file changed +3 -30
sha1_name.c
+3 -30
@@ -238,7 +238,6 @@ static int get_sha1_basic(const char *str, int len, unsigned char *sha1)
238 NULL
239 };
240 const char **p;
241 - int found = 0;
241
242 if (len == 40 && !get_sha1_hex(str, sha1))
243 return 0;
@@ -249,36 +248,10 @@ static int get_sha1_basic(const char *str, int len, unsigned char *sha1)
248
249 for (p = prefix; *p; p++) {
250 char *pathname = git_path("%s/%.*s", *p, len, str);
252 -
253 - if (!read_ref(pathname, sha1)) {
254 - /* Must be unique; i.e. when heads/foo and
255 - * tags/foo are both present, reject "foo".
256 - */
257 - if (1 < found++)
258 - return -1;
259 - }
260 -
261 - /* We want to allow .git/description file and
262 - * "description" branch to exist at the same time.
263 - * "git-rev-parse description" should silently skip
264 - * .git/description file as a candidate for
265 - * get_sha1(). However, having garbage file anywhere
266 - * under refs/ is not OK, and we would not have caught
267 - * ambiguous heads and tags with the above test.
268 - */
269 - else if (**p && !access(pathname, F_OK)) {
270 - /* Garbage exists under .git/refs */
271 - return error("garbage ref found '%s'", pathname);
272 - }
273 - }
274 - switch (found) {
275 - case 0:
276 - return -1;
277 - case 1:
278 - return 0;
279 - default:
280 - return error("ambiguous refname '%.*s'", len, str);
251 + if (!read_ref(pathname, sha1))
252 + return 0;
253 }
254 + return -1;
255 }
256
257 static int get_sha1_1(const char *name, int len, unsigned char *sha1);