zoekt - can we use zoekt-repo-index to index multiple branches?

159 views
Skip to first unread message

Makson Lee

unread,
Nov 29, 2016, 2:04:04 AM11/29/16
to Repo and Gerrit Discussion
we tried to do that with following command but then got error, so do zoekt-repo-index support index multiple branches?

$ ~/work/bin/zoekt-repo-index -parallelism 8 -index /media/d/zoekt -name review -base_url http://review:8080/plugins/gitiles/ -manifest_repo_url http://review:8080/plugins/gitiles/platform/manifest.git -repo_cache /media/d/mirror -manifest_rev_prefix= --rev_prefix= branch1:default.xml branch2:default.xml
2016/11/29 14:57:57 sub project path %!q(MISSING) has zero ID.
panic: sub project path %!q(MISSING) has zero ID.

goroutine 1 [running]:
panic(0x76acc0, 0xc4399758d0)
        /usr/local/go/src/runtime/panic.go:500 +0x1a1
log.Panicf(0x7ddc0b, 0x20, 0x0, 0x0, 0x0)
        /usr/local/go/src/log/log.go:327 +0xe3
main.main()
        /home/administrator/work/src/github.com/google/zoekt/cmd/zoekt-repo-index/main.go:221 +0x14f9

Makson Lee

unread,
Dec 1, 2016, 4:38:24 AM12/1/16
to Repo and Gerrit Discussion
can anyone confirm that if multiple branches indexing is supported?

Stefan Beller

unread,
Dec 1, 2016, 5:25:10 PM12/1/16
to Makson Lee, Han-Wen Nienhuys, Repo and Gerrit Discussion
+cc HanWen, the author of zoekt.
> --
> --
> To unsubscribe, email repo-discuss...@googlegroups.com
> More info at http://groups.google.com/group/repo-discuss?hl=en
>
> ---
> You received this message because you are subscribed to the Google Groups
> "Repo and Gerrit Discussion" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to repo-discuss...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

Makson Lee

unread,
Dec 1, 2016, 10:26:11 PM12/1/16
to Repo and Gerrit Discussion, cdle...@gmail.com, han...@google.com
to be more precise, is two repo branches having different sub repositories supported?

Makson Lee

unread,
Dec 2, 2016, 12:59:00 AM12/2/16
to Repo and Gerrit Discussion, cdle...@gmail.com, han...@google.com
it works if we remove the following checks.

diff --git a/cmd/zoekt-repo-index/main.go b/cmd/zoekt-repo-index/main.go
index 48ce904..93323b0 100644
--- a/cmd/zoekt-repo-index/main.go
+++ b/cmd/zoekt-repo-index/main.go
@@ -217,20 +217,18 @@ func main() {
                        hasher.Write([]byte(p))
                        hasher.Write([]byte(id.String()))

-                       if id.String() == zero.String() {
-                               log.Panicf("sub project path %q has zero ID.")
+                       if id.String() != zero.String() {
+                               repo.Branches = append(repo.Branches, zoekt.RepositoryBranch{
+                                       Name:    br.branch,
+                                       Version: id.String(),
+                               })
+
+                               opts.RepositoryDescription.Branches = append(opts.RepositoryDescription.Branches, zoekt.RepositoryBranch{
+                                       Name:    br.branch,
+                                       Version: fmt.Sprintf("%x", hasher.Sum(nil)),
+                               })
                        }
-                       repo.Branches = append(repo.Branches, zoekt.RepositoryBranch{
-                               Name:    br.branch,
-                               Version: id.String(),
-                       })
                }
-
-               opts.RepositoryDescription.Branches = append(opts.RepositoryDescription.Branches, zoekt.RepositoryBranch{
-                       Name:    br.branch,
-                       Version: fmt.Sprintf("%x", hasher.Sum(nil)),
-               })
-
        }

        // key => branch
diff --git a/indexbuilder.go b/indexbuilder.go
index 62ee850..8e81cad 100644
--- a/indexbuilder.go
+++ b/indexbuilder.go
@@ -123,16 +123,6 @@ func (b *IndexBuilder) AddSubRepository(path string, desc *Repository) error {
        if len(b.files) > 0 {
                return fmt.Errorf("AddSubRepository called after adding files.")
        }
-       branchEqual := len(b.repo.Branches) == len(desc.Branches)
-       if branchEqual {
-               for i, b := range b.repo.Branches {
-                       branchEqual = branchEqual && (b.Name == desc.Branches[i].Name)
-               }
-       }
-
-       if !branchEqual {
-               return fmt.Errorf("got subrepository branches %v, want main repository branches %v", desc.Branches, b.repo.Branches)
-       }
        if err := desc.verify(); err != nil {
                return err

Han-Wen Nienhuys

unread,
Dec 5, 2016, 3:04:39 AM12/5/16
to Makson Lee, Repo and Gerrit Discussion
It should work, but the multi-branch support has not been tested in any depth.

Let me fix the error message for starters.
> --
> --
> To unsubscribe, email repo-discuss...@googlegroups.com
> More info at http://groups.google.com/group/repo-discuss?hl=en
>
> ---
> You received this message because you are subscribed to the Google Groups
> "Repo and Gerrit Discussion" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to repo-discuss...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.



--
Han-Wen Nienhuys
Google Munich
han...@google.com

Han-Wen Nienhuys

unread,
Dec 5, 2016, 5:58:46 AM12/5/16
to Makson Lee, Repo and Gerrit Discussion
see https://gerrit-review.googlesource.com/c/92630/

(let me see if I can index a couple of android branches separately)

Makson Lee

unread,
Dec 5, 2016, 10:24:56 PM12/5/16
to Repo and Gerrit Discussion, cdle...@gmail.com
thanks, after applied the patch, multiple branches indexing can be done without any problem, but we got another issue, the link of file in search result point to a wrong git repository.

the situation is that the git repository R1 on branch B1 and R2 on branch B2 have same path specified in manifest.

Han-Wen Nienhuys

unread,
Dec 6, 2016, 7:45:17 AM12/6/16
to Makson Lee, Repo and Gerrit Discussion
you mean :


B1 has R1 on path "subrepo/" and B2 has R2 on the same path "subrepo/" ?

Makson Lee

unread,
Dec 6, 2016, 8:59:40 AM12/6/16
to Repo and Gerrit Discussion, cdle...@gmail.com
for some reason, yes.

Han-Wen Nienhuys

unread,
Dec 6, 2016, 11:09:12 AM12/6/16
to Makson Lee, Repo and Gerrit Discussion
Blergh. That will require some rearchitecting.

Makson Lee

unread,
Dec 6, 2016, 10:24:52 PM12/6/16
to Repo and Gerrit Discussion, cdle...@gmail.com
got it and looking forward to it.
Reply all
Reply to author
Forward
0 new messages