git@vger.kernel.org list mirror (unofficial, one of many)
 help / color / Atom feed
* Bug(feature?) on git-diff-files
@ 2019-04-11 12:47 NoName Req
  2019-04-11 12:56 ` Duy Nguyen
  2019-04-11 12:57 ` Jeff King
  0 siblings, 2 replies; 4+ messages in thread
From: NoName Req @ 2019-04-11 12:47 UTC (permalink / raw)
  To: git

Summary
   `git -C (folder path) diff-files --name-only` output is not correct

Steps to Reproduce
1. Apply change to a clean git repository. Go to another folder (not
within this repository) and apply the command
   `git -C repo-path diff-files --name-only`
The above command lists dirty files in that repository.
2. Now undo your changes on the repository
3. Issue the same command. It still lists the file.

More Information

`git -C repo-path diff`  command doesn't seem to have this problem.

System Information

Arch Linux 5.0.7-arch1-1-ARCH
git version 2.21.0

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

* Re: Bug(feature?) on git-diff-files
  2019-04-11 12:47 Bug(feature?) on git-diff-files NoName Req
@ 2019-04-11 12:56 ` Duy Nguyen
  2019-04-12 12:41   ` NoName Req
  2019-04-11 12:57 ` Jeff King
  1 sibling, 1 reply; 4+ messages in thread
From: Duy Nguyen @ 2019-04-11 12:56 UTC (permalink / raw)
  To: NoName Req; +Cc: Git Mailing List

On Thu, Apr 11, 2019 at 7:49 PM NoName Req <nonamereq29@gmail.com> wrote:
>
> Summary
>    `git -C (folder path) diff-files --name-only` output is not correct
>
> Steps to Reproduce
> 1. Apply change to a clean git repository. Go to another folder (not
> within this repository) and apply the command
>    `git -C repo-path diff-files --name-only`
> The above command lists dirty files in that repository.
> 2. Now undo your changes on the repository
> 3. Issue the same command. It still lists the file.
>
> More Information
>
> `git -C repo-path diff`  command doesn't seem to have this problem.

I haven't tried to reproduce. But my first impression is diff-files,
as a low-level plumbing sometimes requires you to refresh the index
first. Sometimes without that, you'll get wrong output.

"git diff" is a more high-level command that always refreshes the
index internally.

>
> System Information
>
> Arch Linux 5.0.7-arch1-1-ARCH
> git version 2.21.0



-- 
Duy

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

* Re: Bug(feature?) on git-diff-files
  2019-04-11 12:47 Bug(feature?) on git-diff-files NoName Req
  2019-04-11 12:56 ` Duy Nguyen
@ 2019-04-11 12:57 ` Jeff King
  1 sibling, 0 replies; 4+ messages in thread
From: Jeff King @ 2019-04-11 12:57 UTC (permalink / raw)
  To: NoName Req; +Cc: git

On Thu, Apr 11, 2019 at 03:47:58PM +0300, NoName Req wrote:

> Summary
>    `git -C (folder path) diff-files --name-only` output is not correct
> 
> Steps to Reproduce
> 1. Apply change to a clean git repository. Go to another folder (not
> within this repository) and apply the command
>    `git -C repo-path diff-files --name-only`
> The above command lists dirty files in that repository.
> 2. Now undo your changes on the repository
> 3. Issue the same command. It still lists the file.
> 
> More Information
> 
> `git -C repo-path diff`  command doesn't seem to have this problem.

Try running `git update-index --refresh` before running `diff-files`.

Unlike git-diff, git-diff-files is plumbing that is meant to be called
from scripts. So it is up to the script writer to decide when the index
should be refreshed from the actual filesystem (which makes sense, e.g.,
if you're going to do it once at the start of the script and then make a
bunch of separate diff-related calls).

Until that happens, diff-files will see only that the entry is
stat-dirty, and report it as a potential change.

-Peff

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

* Re: Bug(feature?) on git-diff-files
  2019-04-11 12:56 ` Duy Nguyen
@ 2019-04-12 12:41   ` NoName Req
  0 siblings, 0 replies; 4+ messages in thread
From: NoName Req @ 2019-04-12 12:41 UTC (permalink / raw)
  To: Duy Nguyen; +Cc: Git Mailing List

Okay thanks for the reply. I didn't know about git update-index will
try that now.

On Thu, Apr 11, 2019 at 3:57 PM Duy Nguyen <pclouds@gmail.com> wrote:
>
> On Thu, Apr 11, 2019 at 7:49 PM NoName Req <nonamereq29@gmail.com> wrote:
> >
> > Summary
> >    `git -C (folder path) diff-files --name-only` output is not correct
> >
> > Steps to Reproduce
> > 1. Apply change to a clean git repository. Go to another folder (not
> > within this repository) and apply the command
> >    `git -C repo-path diff-files --name-only`
> > The above command lists dirty files in that repository.
> > 2. Now undo your changes on the repository
> > 3. Issue the same command. It still lists the file.
> >
> > More Information
> >
> > `git -C repo-path diff`  command doesn't seem to have this problem.
>
> I haven't tried to reproduce. But my first impression is diff-files,
> as a low-level plumbing sometimes requires you to refresh the index
> first. Sometimes without that, you'll get wrong output.
>
> "git diff" is a more high-level command that always refreshes the
> index internally.
>
> >
> > System Information
> >
> > Arch Linux 5.0.7-arch1-1-ARCH
> > git version 2.21.0
>
>
>
> --
> Duy

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

end of thread, back to index

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-04-11 12:47 Bug(feature?) on git-diff-files NoName Req
2019-04-11 12:56 ` Duy Nguyen
2019-04-12 12:41   ` NoName Req
2019-04-11 12:57 ` Jeff King

git@vger.kernel.org list mirror (unofficial, one of many)

Archives are clonable:
	git clone --mirror https://public-inbox.org/git
	git clone --mirror http://ou63pmih66umazou.onion/git
	git clone --mirror http://czquwvybam4bgbro.onion/git
	git clone --mirror http://hjrcffqmbrq6wope.onion/git

Newsgroups are available over NNTP:
	nntp://news.public-inbox.org/inbox.comp.version-control.git
	nntp://ou63pmih66umazou.onion/inbox.comp.version-control.git
	nntp://czquwvybam4bgbro.onion/inbox.comp.version-control.git
	nntp://hjrcffqmbrq6wope.onion/inbox.comp.version-control.git
	nntp://news.gmane.org/gmane.comp.version-control.git

 note: .onion URLs require Tor: https://www.torproject.org/

AGPL code for this site: git clone https://public-inbox.org/ public-inbox