git/list[1] front-page[2] threads[3] people[4] search[5] about
 

GIT_WORK_TREE=dir git ls-files --deleted

From
Jonas Bernoulli <jonas@bernoul.li>
Date
Mar 17, 2009, 01:41 UTC
Message-ID
<201bac3a0903161841y6bc59fe5iaf0c221c08db5f43@mail.gmail.com>
Hello

git ls-files --deleted seams to be broken when GIT_WORK_TREE is set as can be observed below.

Instead of just showing deleted files it also shows at least unchanged and modified files.

I have observed this behaviour with git.git and do not know if released versions are affected.

#### setup
$ mkdir -p base/worktree
$ cd base/
$ export GIT_DIR=/tmp/base/.git
$ export GIT_WORK_TREE=/tmp/base/worktree
$ git init
Initialized empty Git repository in /tmp/base/.git/
$ touch worktree/deleted worktree/modified worktree/unchanged
$ git add .
$ git commit -m init
[master (root-commit) f4e1bd3] init
 0 files changed, 0 insertions(+), 0 deletions(-)
 create mode 100644 deleted
 create mode 100644 modified
 create mode 100644 unchanged
$ rm worktree/deleted
$ echo modified > worktree/modified
#### expected result

$ git ls-files --deleted deleted

#### actual result

$ git ls-files --deleted deleted modified unchanged

#### untracked and out-of-worktree seam to be fine

$ touch worktree/untracked $ touch not-in-worktree $ git ls-files --deleted deleted modified unchanged

#### related options / commands seam to be fine

$ git ls-files --modified deleted modified $ git ls-files --others $ git ls-files --cached deleted modified unchanged $ git status # On branch master # Changed but not updated: # (use "git add/rm <file>..." to update what will be committed) # (use "git checkout -- <file>..." to discard changes in working directory) # # deleted: deleted # modified: modified # no changes added to commit (use "git add" and/or "git commit -a")

Best regards,
-- Jonas Bernoulli
Ps: Is there a way to show modified files excluding deleted files
other than this?
( git ls-files --deleted; git ls-files --modified ) | uniq --unique
Pps: The description of --others is ambitious, what is "other files"?
Next: Jeff King
Message 1 of 2 in “GIT_WORK_TREE=dir git ls-files --deleted”
  1. Jonas BernoulliMar 17, 2009
  2. Jeff KingMar 17, 2009

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.