Skip to content

hunk diff —watch creates git locks #398

@jperasmus

Description

@jperasmus

What happened?

When running hunk diff --watch, the status polling creates git locks that trip up coding agents that try to rebase or pull from a remote.

Took a quick look and the fix is likely here:

hunk/src/core/git.ts

Lines 144 to 150 in 59cc857

/** Build the porcelain status query used to discover untracked files for working-tree review. */
function buildGitStatusArgs(input: VcsCommandInput) {
const args = ["status", "--porcelain=v1", "-z", "--untracked-files=all"];
appendGitPathspecs(args, input.pathspecs);
return args;
}

Most likely should be changed to:

/** Build the porcelain status query used to discover untracked files for working-tree review. */
function buildGitStatusArgs(input: VcsCommandInput) {
  const args = ["--no-optional-locks", "status", "--porcelain=v1", "-z", "--untracked-files=all"];


  appendGitPathspecs(args, input.pathspecs);
  return args;
}

From my understanding, this is what Zed does.

Steps to reproduce

  • run hunk diff --watch
  • run git rebase origin/main (not sure if it happens every time, but I often see it and the agent has to work around it by physically deleting git lockfiles)

Expected behavior

No locking

Version

0.14.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    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