Skip to content

vdoctor: error in V git status with packaged build #24419

Description

@lcheylus

Describe the bug

With a packaged build of V (build from v4.0.10 sources, outside of Git worktree), there is an error for V git status in vdoctor output:

$ ./v -v version
V 0.4.10 9b1937a87166e3327497f332bf9584ff90592617.

$ ./v doctor
|V full version      |V 0.4.10 9b1937a87166e3327497f332bf9584ff90592617.
|:-------------------|:-------------------
|OS                  |linux, Debian GNU/Linux trixie/sid
(...)
|Git version         |git version 2.47.2
|V git status        |Error: fatal: not a git repository (or any parent up to mount point /)
Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
|.git/config present |false
(...)

Reproduction Steps

Build V 0.4.10 from sources

# Download packaged sources for V 0.4.10 and vc commit 66ea39be2275ac723225b9ca99d51ec1212c640d
$ wget https://github.com/vlang/v/archive/refs/tags/0.4.10.tar.gz -O v-0.4.10.tar.gz
$ wget https://github.com/vlang/vc/archive/66ea39be2275ac723225b9ca99d51ec1212c640d.tar.gz -O vc-66ea39be2275ac723225b9ca99d51ec1212c640d.tar.gz

# Extract sources for V 0.4.10
$ tar xzvf v-0.4.10.tar.gz
$ tar xzvf vc-66ea39be2275ac723225b9ca99d51ec1212c640d.tar.gz

$ cd v-0.4.10
$ mv ../vc-66ea39be2275ac723225b9ca99d51ec1212c640d ./vc

# Build with local sources
$ make local=1 prod=1
Using local vc
Using local tcc
The executable './thirdparty/tcc/tcc.exe' does not work.
cc  -std=gnu99 -w -o v1 ./vc/v.c -lm -lpthread  || cmd/tools/cc_compilation_failed_non_windows.sh
./v1 -no-parallel -o v2 -prod cmd/v
./v2 -nocache -o ./v -prod cmd/v
rm -rf v1 v2

# Output for V version
$ ./v version
V 0.4.10
$ ./v -v version
V 0.4.10 9b1937a87166e3327497f332bf9584ff90592617.

Expected Behavior

In vdoctor output, V git status = N/A

Current Behavior

See description above for "V Git status" error in vdoctor output.

Possible Solution

In cmd/tools/vdoctor.v, function git_info, check if we are in a Git worktree and returns N/A if not.

To check if we are in a Git worktree, we could use git rev-parse --is-inside-work-tree and check if output == true.

Additional Information/Context

No response

V version

V 0.4.10

Environment details (OS name and version, etc.)

OS = Linux Debian/testing on amd64

$ lsb_release -d -s
Debian GNU/Linux trixie/sid

Note

You can use the 👍 reaction to increase the issue's priority for developers.

Please note that only the 👍 reaction to the issue itself counts as a vote.
Other reactions and those to comments will not be taken into account.

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugThis tag is applied to issues which reports bugs.

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions