Skip to content

query: Display definitions for duplicate files - #409

Open
fstachura wants to merge 1 commit into
bootlin:masterfrom
fstachura:fix-402
Open

query: Display definitions for duplicate files#409
fstachura wants to merge 1 commit into
bootlin:masterfrom
fstachura:fix-402

Conversation

@fstachura

Copy link
Copy Markdown
Collaborator

This commit modifies get_idents_defs so that definitions are duplicated for duplicate files - files with same id as other files (and therefore same contents), but different paths.

Fixes: #402

This commit modifies get_idents_defs so that definitions are duplicated
for duplicate files - files with same id as other files (and therefore
same contents), but different paths.

Fixes: bootlin#402
@tleb

tleb commented Aug 21, 2026

Copy link
Copy Markdown
Member

This is an LLM output. It looks valid to me and the commands have been tested, no hallucination there.


Identifier pages still drop the references and doc comments of duplicate
files — this PR fixes that for definitions only.

Elixir stores file contents deduplicated: byte-identical files share one
blob id, and files_this_version yields their (id, path) pairs
consecutively. The defs/refs/docs iterators are keyed by blob id, so once
they have answered for the first path, the following paths with the same id
read nothing. get_idents_defs() carries the previous definitions slice
over to duplicate paths (this PR's fix for definitions), but rBuf and
docBuf have no such carry-over: a duplicate file contributes definitions,
but zero references and doc comments.

EAGAIN shows references in six arch/*/bits/errno.h headers holding only
three distinct contents — one path per content is displayed:

⟩ # commit 4f14855
⟩ git checkout -q -f franek/fix-402

⟩ # change musl repo because it's inaccessible and fetch a single tag
⟩ git diff -U0 utils/index
diff --git a/utils/index b/utils/index
index 3298a87..6f7f15f 100755
--- a/utils/index
+++ b/utils/index
@@ -47 +47 @@ project_fetch() {
-    $git fetch --all --tags -j4
+    $git fetch --no-tags remote0 +refs/tags/v1.2.6:refs/tags/v1.2.6
@@ -128 +128 @@ add_default_remotes $1 $# $2 mesa https://gitlab.freedesktop.org/mesa/mesa.git
-add_default_remotes $1 $# $2 musl https://git.musl-libc.org/git/musl
+add_default_remotes $1 $# $2 musl https://github.com/kraj/musl.git

⟩ docker build -q -t elixir-repro -f docker/Dockerfile .
⟩ sudo rm -rf data/

⟩ docker run --rm -v ./data:/srv/elixir-data --entrypoint index \
  elixir-repro /srv/elixir-data musl
... indexes v1.2.6 ...

⟩ docker run -d --name lxr-t -p 8080:80 -v ./data:/srv/elixir-data elixir-repro
⟩ curl -s http://localhost:8080/musl/v1.2.6/A/ident/EAGAIN | \
    sed -n '/Referenced in/,/<\/ul>/p' | grep -oE 'arch/[a-z0-9]+/bits/errno.h' | sort -u
arch/generic/bits/errno.h
arch/mips/bits/errno.h
arch/powerpc/bits/errno.h

⟩ # => only 3 of 6, mips64/mipsn32/powerpc64 are missing

⟩ docker rm -f lxr-t

The bug is read-path: get_idents_defs() dedups per file_idx but only
carries prev_dbuf_slice over for duplicate files. This patch fixes it:

⟩ git apply ../pr409-1.patch
⟩ docker build -q -t elixir-repro -f docker/Dockerfile .
⟩ docker run -d --name lxr-t -p 8080:80 -v ./data:/srv/elixir-data elixir-repro
⟩ curl -s http://localhost:8080/musl/v1.2.6/A/ident/EAGAIN | \
    sed -n '/Referenced in/,/<\/ul>/p' | grep -oE 'arch/[a-z0-9]+/bits/errno.h' | sort -u
arch/generic/bits/errno.h
arch/mips/bits/errno.h
arch/mips64/bits/errno.h
arch/mipsn32/bits/errno.h
arch/powerpc/bits/errno.h
arch/powerpc64/bits/errno.h

⟩ # => all 6, same index, only the web app rebuilt

⟩ docker rm -f lxr-t
⟩ git checkout -q -f master

pr409-1.patch

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Definitions inside duplicate files are not displayed

2 participants