Fix gitiles crawler:

* populate zoekt.name correctly

* don't set ?format=JSON in repo URL

Change-Id: I6b7a5f0364a309045d3e612bad429026229daa9e
diff --git a/cmd/zoekt-mirror-gitiles/gitiles.go b/cmd/zoekt-mirror-gitiles/gitiles.go
index da7a69d..9510d10 100644
--- a/cmd/zoekt-mirror-gitiles/gitiles.go
+++ b/cmd/zoekt-mirror-gitiles/gitiles.go
@@ -29,8 +29,9 @@
 }
 
 func getGitilesRepos(root *url.URL, filter func(string) bool) (map[string]*crawlTarget, error) {
-	root.RawQuery = "format=JSON"
-	resp, err := http.Get(root.String())
+	jsRoot := *root
+	jsRoot.RawQuery = "format=JSON"
+	resp, err := http.Get(jsRoot.String())
 	if err != nil {
 		return nil, err
 	}
@@ -60,8 +61,9 @@
 		web := *root
 		web.Path = path.Join(web.Path, v.Name)
 		result[k] = &crawlTarget{
-			cloneURL: v.CloneURL,
-			webURL:   web.String(),
+			cloneURL:   v.CloneURL,
+			webURL:     web.String(),
+			webURLType: "gitiles",
 		}
 	}
 	return result, nil
diff --git a/cmd/zoekt-mirror-gitiles/main.go b/cmd/zoekt-mirror-gitiles/main.go
index 1ff725f..8c0ee25 100644
--- a/cmd/zoekt-mirror-gitiles/main.go
+++ b/cmd/zoekt-mirror-gitiles/main.go
@@ -83,7 +83,7 @@
 		config := map[string]string{
 			"zoekt.web-url":      target.webURL,
 			"zoekt.web-url-type": target.webURLType,
-			"zoekt.name":         nm,
+			"zoekt.name":         filepath.Join(rootURL.Host, rootURL.Path, nm),
 		}
 
 		if err := gitindex.CloneRepo(destDir, nm, target.cloneURL, config); err != nil {