Skip to content

Commit c3d4063

Browse files
committed
vpm: detect unpushed commits on detached HEAD too
`git rev-list --branches --not --remotes` only walks local branch refs, so it misses local commits made on a detached HEAD — which is exactly the state vpm leaves a versioned install in (`git clone -b <tag>`). Add `HEAD` to the rev-list so a clean working tree with a local commit on a detached HEAD is also detected.
1 parent 8e9f622 commit c3d4063

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

cmd/tools/vpm/install.v

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,10 @@ fn has_local_git_changes(path string) bool {
182182
if status.output.trim_space() != '' {
183183
return true
184184
}
185-
unpushed := os.execute_opt('git -C ${quoted} rev-list --branches --not --remotes') or {
185+
// Include `HEAD` so commits made on a detached HEAD (e.g. after
186+
// `git clone -b <tag>`, the layout vpm uses for versioned installs) are
187+
// also detected. `--branches` alone only walks local branch refs.
188+
unpushed := os.execute_opt('git -C ${quoted} rev-list HEAD --branches --not --remotes') or {
186189
return false
187190
}
188191
return unpushed.output.trim_space() != ''

0 commit comments

Comments
 (0)