Fix target parsing bug with targets in the empty package (e.g. "blah" was incorrectly not being parsed as "//:blah").

Also add tests for parsing absolute labels in the empty package.

The empty package has been a thing in Bazel for a while now.

Note that the old error message in this case "couldn't determine target for filename 'blah'" was almost always misleading and unhelpful since we were (almost certainly incorrectly) assuming the user intended for 'blah' to be an input file in the empty package. Now the error message would be "no such target '//:blah'") which is similarly misleading and unhelpful but probably marginally less so. If we desire to improve this, a future cleanup can introduce smarter error messages.

--
MOS_MIGRATED_REVID=120566819
diff --git a/src/main/java/com/google/devtools/build/lib/cmdline/TargetPattern.java b/src/main/java/com/google/devtools/build/lib/cmdline/TargetPattern.java
index 156fdcb..ca09fdb 100644
--- a/src/main/java/com/google/devtools/build/lib/cmdline/TargetPattern.java
+++ b/src/main/java/com/google/devtools/build/lib/cmdline/TargetPattern.java
@@ -279,7 +279,7 @@
 
         // Interprets the label as a file target.  This loop stops as soon as the
         // first BUILD file is found (i.e. longest prefix match).
-        for (int i = pieces.size() - 1; i > 0; i--) {
+        for (int i = pieces.size() - 1; i >= 0; i--) {
           String packageName = SLASH_JOINER.join(pieces.subList(0, i));
           if (resolver.isPackage(PackageIdentifier.createInMainRepo(packageName))) {
             String targetName = SLASH_JOINER.join(pieces.subList(i, pieces.size()));