All of lore.kernel.org
 help / color / mirror / Atom feed
* GIT_WORK_TREE=dir git ls-files --deleted
@ 2009-03-17  1:41 Jonas Bernoulli
  2009-03-17  9:03 ` Jeff King
  0 siblings, 1 reply; 2+ messages in thread
From: Jonas Bernoulli @ 2009-03-17  1:41 UTC (permalink / raw)
  To: git

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"?

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: GIT_WORK_TREE=dir git ls-files --deleted
  2009-03-17  1:41 GIT_WORK_TREE=dir git ls-files --deleted Jonas Bernoulli
@ 2009-03-17  9:03 ` Jeff King
  0 siblings, 0 replies; 2+ messages in thread
From: Jeff King @ 2009-03-17  9:03 UTC (permalink / raw)
  To: Jonas Bernoulli; +Cc: Junio C Hamano, git

On Tue, Mar 17, 2009 at 02:41:50AM +0100, Jonas Bernoulli wrote:

> 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.

I don't think it has ever worked correctly. A fix is below, but I'm
really unsure if it is right. It seems like we should be able to just
refresh the index and see its status, rather than calling the lstat
ourselves. But perhaps this is an optimization to avoid refresh (see
builtin-ls-files.c, lines 186-202). Junio?

-- >8 --
Subject: [PATCH] ls-files: require worktree when --deleted is given

The code will end up calling lstat() to check whether the
file still exists; obviously this doesn't work if we're not
in the worktree.

Signed-off-by: Jeff King <peff@peff.net>
---
The version in next has the same bug, but the code is totally different
due to parseopt-ification (but the fix is still a one-liner to set
require_work_tree when show_deleted is set).

 builtin-ls-files.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/builtin-ls-files.c b/builtin-ls-files.c
index 9dec282..ca6f33d 100644
--- a/builtin-ls-files.c
+++ b/builtin-ls-files.c
@@ -419,6 +419,7 @@ int cmd_ls_files(int argc, const char **argv, const char *prefix)
 		}
 		if (!strcmp(arg, "-d") || !strcmp(arg, "--deleted")) {
 			show_deleted = 1;
+			require_work_tree = 1;
 			continue;
 		}
 		if (!strcmp(arg, "-m") || !strcmp(arg, "--modified")) {
-- 
1.6.2.1.137.gb6aa78

^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2009-03-17  9:04 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-03-17  1:41 GIT_WORK_TREE=dir git ls-files --deleted Jonas Bernoulli
2009-03-17  9:03 ` Jeff King

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.