google / google/codesearch

Second and newer indexing loses paths if one directory basename is a prefix

オープン
#55 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る
主要言語
Go
スター
4k
フォーク
403
PR マージ指標
30日以内にマージされた PR はありません

説明

Easier to demonstrate.

``` make
% cat Makefile
.PHONY: all test clean

BAD1 = a
BAD2 = a-b

GOOD1 = a-x
GOOD2 = a-y

.PHONY: template good bad

template:
rm -rf test
mkdir -p test/$(VAR1) test/$(VAR2)
ls > test/$(VAR1)/a
ls > test/$(VAR2)/a
rm -f test/.csearchindex
/usr/bin/env CSEARCHINDEX=test/.csearchindex $(GOPATH)/bin/cindex test/$(VAR1) test/$(VAR2)
/usr/bin/env CSEARCHINDEX=test/.csearchindex $(GOPATH)/bin/cindex -list
# Just index them again to reproduce the bug
/usr/bin/env CSEARCHINDEX=test/.csearchindex $(GOPATH)/bin/cindex -verbose
/usr/bin/env CSEARCHINDEX=test/.csearchindex $(GOPATH)/bin/cindex -list
test `/usr/bin/env CSEARCHINDEX=test/.csearchindex $(GOPATH)/bin/cindex -list | wc -l` = 2

bad:
VAR1=$(BAD1) VAR2=$(BAD2) $(MAKE) template

good:
VAR1=$(GOOD1) VAR2=$(GOOD2) $(MAKE) template
```

No bug when test run with two directories where basenames are not a prefix or another:

``` sh
% make good
VAR1=a-x VAR2=a-y /Applications/Xcode.app/Contents/Developer/usr/bin/make template
rm -rf test
mkdir -p test/a-x test/a-y
ls > test/a-x/a
ls > test/a-y/a
rm -f test/.csearchindex
/usr/bin/env CSEARCHINDEX=test/.csearchindex /Users/xxxx/pkgs/go/bin/cindex test/a-x test/a-y
2016/02/08 17:37:14 index /Users/xxxx/work/codesearch/test/a-x
2016/02/08 17:37:14 index /Users/xxxx/work/codesearch/test/a-y
2016/02/08 17:37:14 flush index
2016/02/08 17:37:14 merge 0 files + mem
2016/02/08 17:37:14 166 data bytes, 1596 index bytes
2016/02/08 17:37:14 done
/usr/bin/env CSEARCHINDEX=test/.csearchindex /Users/xxxx/pkgs/go/bin/cindex -list
/Users/xxxx/work/codesearch/test/a-x
/Users/xxxx/work/codesearch/test/a-y
# Just index them again to reproduce the bug
/usr/bin/env CSEARCHINDEX=test/.csearchindex /Users/xxxx/pkgs/go/bin/cindex -verbose
2016/02/08 17:37:14 index /Users/xxxx/work/codesearch/test/a-x
2016/02/08 17:37:14 83 79 /Users/xxxx/work/codesearch/test/a-x/a
2016/02/08 17:37:14 index /Users/xxxx/work/codesearch/test/a-y
2016/02/08 17:37:14 83 79 /Users/xxxx/work/codesearch/test/a-y/a
2016/02/08 17:37:14 flush index
2016/02/08 17:37:14 merge 0 files + mem
2016/02/08 17:37:14 166 data bytes, 1596 index bytes
2016/02/08 17:37:14 merge test/.csearchindex test/.csearchindex~
2016/02/08 17:37:14 done
/usr/bin/env CSEARCHINDEX=test/.csearchindex /Users/xxxx/pkgs/go/bin/cindex -list
/Users/xxxx/work/codesearch/test/a-x
/Users/xxxx/work/codesearch/test/a-y
test `/usr/bin/env CSEARCHINDEX=test/.csearchindex /Users/xxxx/pkgs/go/bin/cindex -list | wc -l` = 2
```

Bug seen when test run with two directories where one basename is prefix of another:

``` sh
% make bad
VAR1=a VAR2=a-b /Applications/Xcode.app/Contents/Developer/usr/bin/make template
rm -rf test
mkdir -p test/a test/a-b
ls > test/a/a
ls > test/a-b/a
rm -f test/.csearchindex
/usr/bin/env CSEARCHINDEX=test/.csearchindex /Users/xxxx/pkgs/go/bin/cindex test/a test/a-b
2016/02/08 17:37:11 index /Users/xxxx/work/codesearch/test/a
2016/02/08 17:37:11 index /Users/xxxx/work/codesearch/test/a-b
2016/02/08 17:37:11 flush index
2016/02/08 17:37:11 merge 0 files + mem
2016/02/08 17:37:11 166 data bytes, 1592 index bytes
2016/02/08 17:37:11 done
/usr/bin/env CSEARCHINDEX=test/.csearchindex /Users/xxxx/pkgs/go/bin/cindex -list
/Users/xxxx/work/codesearch/test/a
/Users/xxxx/work/codesearch/test/a-b
# Just index them again to reproduce the bug
/usr/bin/env CSEARCHINDEX=test/.csearchindex /Users/xxxx/pkgs/go/bin/cindex -verbose
2016/02/08 17:37:11 index /Users/xxxx/work/codesearch/test/a
2016/02/08 17:37:11 83 79 /Users/xxxx/work/codesearch/test/a/a
2016/02/08 17:37:11 index /Users/xxxx/work/codesearch/test/a-b
2016/02/08 17:37:11 83 79 /Users/xxxx/work/codesearch/test/a-b/a
2016/02/08 17:37:11 flush index
2016/02/08 17:37:11 merge 0 files + mem
2016/02/08 17:37:11 166 data bytes, 1592 index bytes
2016/02/08 17:37:11 merge test/.csearchindex test/.csearchindex~
2016/02/08 17:37:11 done
/usr/bin/env CSEARCHINDEX=test/.csearchindex /Users/xxxx/pkgs/go/bin/cindex -list
/Users/xxxx/work/codesearch/test/a
test `/usr/bin/env CSEARCHINDEX=test/.csearchindex /Users/xxxx/pkgs/go/bin/cindex -list | wc -l` = 2
make[1]: *** [template] Error 1
make: *** [bad] Error 2
```

コントリビューションガイド

コントリビューションガイドを開く

調査の方向性

Use the Makefile reproduction to run the good and bad cases, especially repeated cindex indexing with directories named a and a-b. Read the cindex indexing and index-merge entry points involved in -list and -verbose, then verify that rerunning the index preserves both paths and the final list contains two directories.

索引モデルが issue の本文から書いたものです。

評価

技術スタック
go
領域
search
issue の種類
バグ
難易度
3/5
見積もり時間
1〜2日
活発さ
停滞
明瞭さ
おおむね明確
初心者へのやさしさ
45/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。