Skip to content

LSIF: git args seem incorrect

Created by: chrismwendt

  • Clear out existing commits to be able to trigger a gitserver call later psql --dbname sourcegraph_lsif -c "delete from commits;"
  • Apply the following diff to log gitserver errors:
diff --git a/lsif/src/commits.ts b/lsif/src/commits.ts
index 3ae1faecd2..2cd3a822b9 100644
--- a/lsif/src/commits.ts
+++ b/lsif/src/commits.ts
@@ -163,7 +163,11 @@ async function gitserverExecLines(gitserverUrl: string, repository: string, args
  * @param args The command to run in the repository's git directory.
  */
 async function gitserverExec(gitserverUrl: string, repository: string, args: string[]): Promise<string> {
-    return (await got(new URL(`http://${gitserverUrl}/exec`).href, {
+    const r = await got(new URL(`http://${gitserverUrl}/exec`).href, {
         body: JSON.stringify({ repo: repository, args }),
-    })).body
+    })
+    console.log({ repo: repository, args })
+    console.log(r.trailers)
+    console.log(r.body)
+    return r.body
 }
20:12:10            lsif-server | {
20:12:10            lsif-server |   repo: 'github.com/sourcegraph/sourcegraph',
20:12:10            lsif-server |   args: [
20:12:10            lsif-server |     'git',
20:12:10            lsif-server |     'log',
20:12:10            lsif-server |     '--pretty=%H %P',
20:12:10            lsif-server |     '4a7d469702c5f71bff6baa150b982e77517a5aa0',
20:12:10            lsif-server |     '-5000'
20:12:10            lsif-server |   ]
20:12:10            lsif-server | }
20:12:10            lsif-server | {
20:12:10            lsif-server |   'x-exec-error': 'exit status 1',
20:12:10            lsif-server |   'x-exec-exit-status': '1',
20:12:10            lsif-server |   'x-exec-stderr': "git: 'git' is not a git command. See 'git --help'.  The most similar command is \tinit"
20:12:10            lsif-server | }

I believe this is caused by the presence of the git command in the args:

https://github.com/sourcegraph/sourcegraph/blob/603ce95e1374b63d98868cdebd02f37d4f19a922/lsif/src/commits.ts#L114