unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* [vc-git] Showing ‘.git/*’ files in vc-dir
@ 2010-06-29 18:29 Eric James Michael Ritz
  2010-06-29 19:54 ` Dan Nicolaescu
  0 siblings, 1 reply; 31+ messages in thread
From: Eric James Michael Ritz @ 2010-06-29 18:29 UTC (permalink / raw)
  To: emacs-devel

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1


When I `vc-dir` for a directory that is under version control with
Git, I see that files under the `.git` directory are displayed, often
as being untracked.  For example, after making a commit the file
`COMMIT_EDITMSG` will appear as being untracked.  It seems like all of
these files should be ignored by vc-dir and not be shown, since I do
not think there is a legitimate reason you’d ever want to commit a
file like that, or anything else in the `.git/*` directory.

I was curious about anyone else’s thoughts on this.  If this sounds
reasonable, I would like to take a stab at writing a patch to address
this.  Also I should mention that I am using the latest Emacs 23, and
not the trunk, which I know has had recent updates to vc-mode; so my
apologizes if this is something that’s already been addressed.

- --
Eric James Michael Ritz
Cyber Sprocket Labs
(843) 225-3830
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iQEcBAEBAgAGBQJMKjt6AAoJEEHUZXw5hMWsoO4IAJfQK0tQ1y8rVfEEYEXWZhXa
QGpVHRS4+3tsmJbTV0l4joJSwcMceP0xB9hnDGMC2Axcay2OPPAKBqKcTThqElex
FjqumvskX+T+qLtt5IuosHI3kAnFxu4qjm5dtpU+YsDupStNnFnAr3g6au09USm2
eGFVSbu93KUOuI0ocX6qsHhbY3jtEVK6Mbyhez83842mo3KIlnMRXci6yYHMDQhf
mC1U6MhU4m2gjhqsGj+HSJjo7Em85xHReXIsiHh7ODl/D5gWBIQlF2To/by8jkPU
Chv/K4trj/VymTjCXStxCazagVKei8qEeHlG8JFdppXdvqOve3v5HwxzrliMWHY=
=UxUW
-----END PGP SIGNATURE-----




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

* Re: [vc-git] Showing ‘.git/*’ files in vc-dir
  2010-06-29 18:29 [vc-git] Showing ‘.git/*’ files in vc-dir Eric James Michael Ritz
@ 2010-06-29 19:54 ` Dan Nicolaescu
  2010-06-29 20:07   ` Eric James Michael Ritz
  0 siblings, 1 reply; 31+ messages in thread
From: Dan Nicolaescu @ 2010-06-29 19:54 UTC (permalink / raw)
  To: Eric; +Cc: emacs-devel

Eric James Michael Ritz <Eric@cybersprocket.com> writes:

> When I `vc-dir` for a directory that is under version control with
> Git, I see that files under the `.git` directory are displayed, often
> as being untracked.  For example, after making a commit the file
> `COMMIT_EDITMSG` will appear as being untracked.  It seems like all of
> these files should be ignored by vc-dir and not be shown, since I do
> not think there is a legitimate reason you’d ever want to commit a
> file like that, or anything else in the `.git/*` directory.
>
> I was curious about anyone else’s thoughts on this.  If this sounds

Can you please provide a recipe to reproduce this?  Please start with emacs -Q.




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

* Re: [vc-git] Showing ‘.git/*’ files in vc-dir
  2010-06-29 19:54 ` Dan Nicolaescu
@ 2010-06-29 20:07   ` Eric James Michael Ritz
  2010-06-29 20:54     ` Dan Nicolaescu
  0 siblings, 1 reply; 31+ messages in thread
From: Eric James Michael Ritz @ 2010-06-29 20:07 UTC (permalink / raw)
  To: Dan Nicolaescu; +Cc: emacs-devel

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1


On 06/29/2010 03:54 PM, Dan Nicolaescu wrote:
> Eric James Michael Ritz <Eric@cybersprocket.com> writes:
>
>> When I `vc-dir` for a directory that is under version control with
>> Git, I see that files under the `.git` directory are displayed, often
>> as being untracked.  [...]
>>
>> I was curious about anyone else’s thoughts on this.  If this sounds
>
> Can you please provide a recipe to reproduce this?  Please start with emacs -Q.

Unfortunately no.  I created a new repository and then edited some
files using emacs -Q, and from there I could not cause vc-dir to
display any of the .git/* files.  I have to admit I am not one-hundred
percent sure what causes it, and it is not consistent either.  I do
sometimes run git-commit from the command-line during work instead of
using `C-x v v`, so perhaps that is related?

I will see what I can do to narrow down the cause the next time it
happens, and then see if I can reproduce that same state starting
fresh from emacs -Q.

- --
Eric James Michael Ritz
Cyber Sprocket Labs
(843) 225-3830
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iQEcBAEBAgAGBQJMKlJ1AAoJEEHUZXw5hMWsP7cIAMmEkFjTrJc8kOPJH0+cbP8L
Xu7t3tDfdxeupjQE+wM9ub+21hjAV+W+wVmKlGQ0F+vU2qr1BAzvIhEKUsTs7+oy
VjvD7urOUcgxRQXJhYUDDZORYQ529bJ0jeHNvbEalXv9rIag3EjVKKGFN1hTGlJh
YFAlFeTBBFGBStoHBRofmgLTv6jMW/byxXH6exH1FapLl11fcL6beIbsSRf1v9ZA
oWejP1sjv8a3LILw7SYl3IfE+hT3GkAEv1JpUWNh0xot1rkwt678SRbZ1COzhazF
xHM/8Fq5+66BBspWrXR5segpn8vaFUm4sr9TzT5m8LAwBmewkZrJ8Sekh1eC2+Y=
=iap8
-----END PGP SIGNATURE-----



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

* Re: [vc-git] Showing ‘.git/*’ files in vc-dir
  2010-06-29 20:07   ` Eric James Michael Ritz
@ 2010-06-29 20:54     ` Dan Nicolaescu
  2010-06-29 21:16       ` Eric James Michael Ritz
  2010-07-01  1:27       ` Stefan Monnier
  0 siblings, 2 replies; 31+ messages in thread
From: Dan Nicolaescu @ 2010-06-29 20:54 UTC (permalink / raw)
  To: Eric James Michael Ritz; +Cc: emacs-devel

Eric James Michael Ritz <Eric@cybersprocket.com> writes:

> On 06/29/2010 03:54 PM, Dan Nicolaescu wrote:
>> Eric James Michael Ritz <Eric@cybersprocket.com> writes:
>>
>>> When I `vc-dir` for a directory that is under version control with
>>> Git, I see that files under the `.git` directory are displayed, often
>>> as being untracked.  [...]
>>>
>>> I was curious about anyone else’s thoughts on this.  If this sounds
>>
>> Can you please provide a recipe to reproduce this?  Please start with emacs -Q.
>
> Unfortunately no.  I created a new repository and then edited some
> files using emacs -Q, and from there I could not cause vc-dir to
> display any of the .git/* files.  I have to admit I am not one-hundred
> percent sure what causes it, and it is not consistent either.  I do
> sometimes run git-commit from the command-line during work instead of
> using `C-x v v`, so perhaps that is related?

Yep, I think that's it.
You probably have EDITOR set to emacsclient.  
So git-commit will use the same emacs instance that's running vc-dir.
It looks like git puts the COMMIT_MESSAGE in .git and vc-dir shows it.

What probably happens is that (vc-git-state ".git/COMMIT_MESSAGE") returns 'unregistered.

Not sure what the best solution is: make vc-git-state return
nil, or make vc-dir ignore files in .git, or something else ...



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

* Re: [vc-git] Showing ‘.git/*’ files in vc-dir
  2010-06-29 20:54     ` Dan Nicolaescu
@ 2010-06-29 21:16       ` Eric James Michael Ritz
  2010-07-01  1:27       ` Stefan Monnier
  1 sibling, 0 replies; 31+ messages in thread
From: Eric James Michael Ritz @ 2010-06-29 21:16 UTC (permalink / raw)
  To: Dan Nicolaescu; +Cc: emacs-devel

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1


On 06/29/2010 04:54 PM, Dan Nicolaescu wrote:
> Eric James Michael Ritz <Eric@cybersprocket.com> writes:
>
>> On 06/29/2010 03:54 PM, Dan Nicolaescu wrote:
>>> Eric James Michael Ritz <Eric@cybersprocket.com> writes:
>>>
>>>> When I `vc-dir` for a directory that is under version control with
>>>> Git, I see that files under the `.git` directory are displayed, often
>>>> as being untracked.  [...]
>>>>
>>>> I was curious about anyone else’s thoughts on this.  If this sounds
>>>
>>> Can you please provide a recipe to reproduce this?  Please start with emacs -Q.
>>
>> Unfortunately no.  I created a new repository and then edited some
>> files using emacs -Q, and from there I could not cause vc-dir to
>> display any of the .git/* files.  I have to admit I am not one-hundred
>> percent sure what causes it, and it is not consistent either.  I do
>> sometimes run git-commit from the command-line during work instead of
>> using `C-x v v`, so perhaps that is related?
>
> Yep, I think that's it.
> You probably have EDITOR set to emacsclient.

You are correct, I do.

> So git-commit will use the same emacs instance that's running vc-dir.
> It looks like git puts the COMMIT_MESSAGE in .git and vc-dir shows it.
>
> What probably happens is that (vc-git-state ".git/COMMIT_MESSAGE") returns 'unregistered.
>
> Not sure what the best solution is: make vc-git-state return
> nil, or make vc-dir ignore files in .git, or something else ...

I am not sure either.  My idea was to make vc-dir ignore the files
in .git.  It does not seem like there would be any negative
ramifications from that, but that’s going on my assumption that no one
would ever want to perform operations on those files from vc-dir.

- --
Eric James Michael Ritz
Cyber Sprocket Labs
(843) 225-3830
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iQEcBAEBAgAGBQJMKmK7AAoJEEHUZXw5hMWsFwkH/2gVMKUX9R4SXOhFt9/xNXiL
TczSpFDKeuaS+JV4ZrEHNHcd5mpAdQ+oXxVfbQDsg9RDod6OcHDdCSa4J9qktKId
geA3y+HTYQ9xIGSHE0u8OwdilXSsZBwmhKYf9YIh8eCpDNDdfc2jsuqoaWZfVGkR
jOgy4XPBiHJ6ISLgn+VwT8suXliBHgd2jovXOA23XNcp6OjjLsUY4Soysa4VNJv0
YGxs3BRSM6L5OBo/VT0BJfQFV4xvh9Hp3QxNF71jkibDfuCwwLt4roVIOj1ckV7K
XWkf90zwTLO5bYwpcoAu71DcytJ0KkaVCJFA38d1TLxpiK61QEP6R569qh0JCnY=
=QFGg
-----END PGP SIGNATURE-----



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

* Re: [vc-git] Showing ‘.git/*’ files in vc-dir
  2010-06-29 20:54     ` Dan Nicolaescu
  2010-06-29 21:16       ` Eric James Michael Ritz
@ 2010-07-01  1:27       ` Stefan Monnier
  2010-07-01  3:06         ` Dan Nicolaescu
  1 sibling, 1 reply; 31+ messages in thread
From: Stefan Monnier @ 2010-07-01  1:27 UTC (permalink / raw)
  To: Dan Nicolaescu; +Cc: Eric James Michael Ritz, emacs-devel

> Not sure what the best solution is: make vc-git-state return
> nil, or make vc-dir ignore files in .git, or something else ...

Maybe find-file shouldn't add unregistered files to vc-dir buffers.


        Stefan



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

* Re: [vc-git] Showing ‘.git/*’ files in vc-dir
  2010-07-01  1:27       ` Stefan Monnier
@ 2010-07-01  3:06         ` Dan Nicolaescu
  2010-07-01  5:47           ` Miles Bader
  2010-07-01  7:36           ` Jan Djärv
  0 siblings, 2 replies; 31+ messages in thread
From: Dan Nicolaescu @ 2010-07-01  3:06 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: Eric James Michael Ritz, emacs-devel

Stefan Monnier <monnier@iro.umontreal.ca> writes:

>> Not sure what the best solution is: make vc-git-state return
>> nil, or make vc-dir ignore files in .git, or something else ...
>
> Maybe find-file shouldn't add unregistered files to vc-dir buffers.

Sure it should, one wants to be able to register those files.




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

* Re: [vc-git] Showing ‘.git/*’ files in vc-dir
  2010-07-01  3:06         ` Dan Nicolaescu
@ 2010-07-01  5:47           ` Miles Bader
  2010-07-01  6:44             ` Dan Nicolaescu
  2010-07-01  7:36           ` Jan Djärv
  1 sibling, 1 reply; 31+ messages in thread
From: Miles Bader @ 2010-07-01  5:47 UTC (permalink / raw)
  To: Dan Nicolaescu; +Cc: Eric James Michael Ritz, Stefan Monnier, emacs-devel

Dan Nicolaescu <dann@gnu.org> writes:
>>> Not sure what the best solution is: make vc-git-state return
>>> nil, or make vc-dir ignore files in .git, or something else ...
>>
>> Maybe find-file shouldn't add unregistered files to vc-dir buffers.
>
> Sure it should, one wants to be able to register those files.

One can visit the file and "register" it that way, right (C-x v v)?

-Miles

-- 
Youth, n. The Period of Possibility, when Archimedes finds a fulcrum,
Cassandra has a following and seven cities compete for the honor of endowing a
living Homer.



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

* Re: [vc-git] Showing ‘.git/*’ files in vc-dir
  2010-07-01  5:47           ` Miles Bader
@ 2010-07-01  6:44             ` Dan Nicolaescu
  2010-07-01 13:40               ` Eric James Michael Ritz
                                 ` (2 more replies)
  0 siblings, 3 replies; 31+ messages in thread
From: Dan Nicolaescu @ 2010-07-01  6:44 UTC (permalink / raw)
  To: Miles Bader; +Cc: Eric James Michael Ritz, Stefan Monnier, emacs-devel

Miles Bader <miles@gnu.org> writes:

> Dan Nicolaescu <dann@gnu.org> writes:
>>>> Not sure what the best solution is: make vc-git-state return
>>>> nil, or make vc-dir ignore files in .git, or something else ...
>>>
>>> Maybe find-file shouldn't add unregistered files to vc-dir buffers.
>>
>> Sure it should, one wants to be able to register those files.
>
> One can visit the file and "register" it that way, right (C-x v v)?

This is going on the wrong track.

The problem is not unrelated to adding 'unregistered files.

The issue is that vc-git-state says 'unregistered for files that it
should not say 'unregistered.

(vc-git-state "SOME_FILE_THAT_DOES_NOT_EXIST") says 'unregistered

(vc-git-state ".git/HEAD") says 'unregistered


This patch seems to fix it:

=== modified file 'lisp/vc/vc-git.el'
--- lisp/vc/vc-git.el   2010-06-11 19:09:57 +0000
+++ lisp/vc/vc-git.el   2010-07-01 06:37:30 +0000
@@ -180,7 +180,9 @@ If nil, use the value of `vc-diff-switch
   ;; was modified upstream.  But we can't check that without a network
   ;; operation.
   (if (not (vc-git-registered file))
-      'unregistered
+      (let ((st (vc-git--run-command-string
+            file "ls-files" "-t" "-o" "--")))
+            (if (and (stringp st) (not (string= st ""))) 'unregistered nil))
     (vc-git--call nil "add" "--refresh" "--" (file-relative-name file))
     (let ((diff (vc-git--run-command-string
                  file "diff-index" "-z" "HEAD" "--")))


It would be nice if someone more familiar with the git low level
commands would take a look at this function and try to make it a bit better.
As the comment there says, it should be able to return 'ignored.
It would be nice if it could be able to return 'conflict too.



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

* Re: [vc-git] Showing ‘.git/*’ files in vc-dir
  2010-07-01  3:06         ` Dan Nicolaescu
  2010-07-01  5:47           ` Miles Bader
@ 2010-07-01  7:36           ` Jan Djärv
  2010-07-01  8:32             ` Dan Nicolaescu
  2010-07-01  8:35             ` Glenn Morris
  1 sibling, 2 replies; 31+ messages in thread
From: Jan Djärv @ 2010-07-01  7:36 UTC (permalink / raw)
  To: Dan Nicolaescu; +Cc: Eric James Michael Ritz, Stefan Monnier, emacs-devel



Dan Nicolaescu skrev 2010-07-01 05.06:
> Stefan Monnier<monnier@iro.umontreal.ca>  writes:
>
>>> Not sure what the best solution is: make vc-git-state return
>>> nil, or make vc-dir ignore files in .git, or something else ...
>>
>> Maybe find-file shouldn't add unregistered files to vc-dir buffers.
>
> Sure it should, one wants to be able to register those files.
>

How about a command and a defcustom to set the default that filters out 
unregistered files in vc-dir?

I almost always have unregistered files (.emacs.desktop for one), and thus 
can't commit from vc-dir ("files must have the same state") as bzr on savannah 
does not accept a list of files in the commit.

	Jan D.



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

* Re: [vc-git] Showing ‘.git/*’ files in vc-dir
  2010-07-01  7:36           ` Jan Djärv
@ 2010-07-01  8:32             ` Dan Nicolaescu
  2010-07-01  8:39               ` Glenn Morris
  2010-07-01  9:23               ` Jan Djärv
  2010-07-01  8:35             ` Glenn Morris
  1 sibling, 2 replies; 31+ messages in thread
From: Dan Nicolaescu @ 2010-07-01  8:32 UTC (permalink / raw)
  To: Jan Djärv; +Cc: Eric James Michael Ritz, Stefan Monnier, emacs-devel

Jan Djärv <jan.h.d@swipnet.se> writes:

> Dan Nicolaescu skrev 2010-07-01 05.06:
>> Stefan Monnier<monnier@iro.umontreal.ca>  writes:
>>
>>>> Not sure what the best solution is: make vc-git-state return
>>>> nil, or make vc-dir ignore files in .git, or something else ...
>>>
>>> Maybe find-file shouldn't add unregistered files to vc-dir buffers.
>>
>> Sure it should, one wants to be able to register those files.
>>
>
> How about a command and a defcustom to set the default that filters
> out unregistered files in vc-dir?

If someone first shows a clean design and UI for it, sure.
It could be bound to C-u x.


> I almost always have unregistered files (.emacs.desktop for one), and
> thus can't commit from vc-dir ("files must have the same state") as
> bzr on savannah does not accept a list of files in the commit.

What do you mean?
Most commits are lists of files: file(s) + ChangeLog.
You can mark files with m (or M to mark all files in the same state).
After marking at least one item,  C-x v v applies to the list of marked things.



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

* Re: [vc-git] Showing ‘.git/*’ files in vc-dir
  2010-07-01  7:36           ` Jan Djärv
  2010-07-01  8:32             ` Dan Nicolaescu
@ 2010-07-01  8:35             ` Glenn Morris
  2010-07-01  9:16               ` Miles Bader
  1 sibling, 1 reply; 31+ messages in thread
From: Glenn Morris @ 2010-07-01  8:35 UTC (permalink / raw)
  To: Jan Djärv
  Cc: Eric James Michael Ritz, Dan Nicolaescu, Stefan Monnier,
	emacs-devel

Jan Djärv wrote:

> I almost always have unregistered files (.emacs.desktop for one), and
> thus can't commit from vc-dir ("files must have the same state") as
> bzr on savannah does not accept a list of files in the commit.

Eh? I do this all the time with vc-dir. It works fine for me, using a
bound branch.

I do M-x vc-dir, mark only the files I want to commit, then press v.

Then I just wait 10-15 minutes, and presto, my changes are committed.
What could be easier?



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

* Re: [vc-git] Showing ‘.git/*’ files in vc-dir
  2010-07-01  8:32             ` Dan Nicolaescu
@ 2010-07-01  8:39               ` Glenn Morris
  2010-07-01  9:29                 ` Jan Djärv
  2010-07-01 15:34                 ` Dan Nicolaescu
  2010-07-01  9:23               ` Jan Djärv
  1 sibling, 2 replies; 31+ messages in thread
From: Glenn Morris @ 2010-07-01  8:39 UTC (permalink / raw)
  To: Dan Nicolaescu
  Cc: Eric James Michael Ritz, Jan Djärv, Stefan Monnier,
	emacs-devel

Dan Nicolaescu wrote:

>> How about a command and a defcustom to set the default that filters
>> out unregistered files in vc-dir?
>
> If someone first shows a clean design and UI for it, sure.
> It could be bound to C-u x.

http://debbugs.gnu.org/cgi/bugreport.cgi?bug=6148

It is trivial to modify vc-dir-hide-up-to-date to accept an optional
STATES argument in place of a hard-coded 'up-to-date.

Then I just use the interactive piece from the posted code, and bind
it to H, as suggested.

I use this all the time, for exactly the purpose of hiding
unregistered files.



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

* Re: [vc-git] Showing ‘.git/*’ files in vc-dir
  2010-07-01  8:35             ` Glenn Morris
@ 2010-07-01  9:16               ` Miles Bader
  2010-07-01  9:22                 ` Deniz Dogan
                                   ` (2 more replies)
  0 siblings, 3 replies; 31+ messages in thread
From: Miles Bader @ 2010-07-01  9:16 UTC (permalink / raw)
  To: Glenn Morris
  Cc: Eric James Michael Ritz, Dan Nicolaescu, Jan Djärv,
	Stefan Monnier, emacs-devel

Glenn Morris <rgm@gnu.org> writes:
> I do M-x vc-dir, mark only the files I want to commit, then press v.
>
> Then I just wait 10-15 minutes, and presto, my changes are committed.
> What could be easier?

10-15 minutes...?!

-Miles

-- 
My spirit felt washed.  With blood.  [Eli Shin, on "The Passion of the Christ"]



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

* Re: [vc-git] Showing ‘.git/*’ files in vc-dir
  2010-07-01  9:16               ` Miles Bader
@ 2010-07-01  9:22                 ` Deniz Dogan
  2010-07-01 15:23                 ` Dan Nicolaescu
  2010-07-01 21:14                 ` Glenn Morris
  2 siblings, 0 replies; 31+ messages in thread
From: Deniz Dogan @ 2010-07-01  9:22 UTC (permalink / raw)
  To: Miles Bader
  Cc: Eric James Michael Ritz, emacs-devel, Stefan Monnier,
	Dan Nicolaescu, Jan Djärv

2010/7/1 Miles Bader <miles@gnu.org>:
> Glenn Morris <rgm@gnu.org> writes:
>> I do M-x vc-dir, mark only the files I want to commit, then press v.
>>
>> Then I just wait 10-15 minutes, and presto, my changes are committed.
>> What could be easier?
>
> 10-15 minutes...?!
>

Ah, the joy of bzr...



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

* Re: [vc-git] Showing ‘.git/*’ files in vc-dir
  2010-07-01  8:32             ` Dan Nicolaescu
  2010-07-01  8:39               ` Glenn Morris
@ 2010-07-01  9:23               ` Jan Djärv
  2010-07-01 15:26                 ` Dan Nicolaescu
  1 sibling, 1 reply; 31+ messages in thread
From: Jan Djärv @ 2010-07-01  9:23 UTC (permalink / raw)
  To: Dan Nicolaescu; +Cc: Eric James Michael Ritz, Stefan Monnier, emacs-devel



Dan Nicolaescu skrev 2010-07-01 10.32:
> Jan Djärv<jan.h.d@swipnet.se>  writes:
>
>> I almost always have unregistered files (.emacs.desktop for one), and
>> thus can't commit from vc-dir ("files must have the same state") as
>> bzr on savannah does not accept a list of files in the commit.
>
> What do you mean?
> Most commits are lists of files: file(s) + ChangeLog.
> You can mark files with m (or M to mark all files in the same state).
> After marking at least one item,  C-x v v applies to the list of marked things.

Reading earlier messages, I see I confused this with not being able to commit 
with pending merges present.  So I have done commits from the command line 
when I really didn't need to, bummer...

FWIW, I think vc-dir should be similar to the command line in this respect, 
i.e. just commit if there are unregistered files present.  After all, it is 
not a limitation of the underlying version control system.

	Jan D.



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

* Re: [vc-git] Showing ‘.git/*’ files in vc-dir
  2010-07-01  8:39               ` Glenn Morris
@ 2010-07-01  9:29                 ` Jan Djärv
  2010-07-01 15:34                 ` Dan Nicolaescu
  1 sibling, 0 replies; 31+ messages in thread
From: Jan Djärv @ 2010-07-01  9:29 UTC (permalink / raw)
  To: Glenn Morris
  Cc: Eric James Michael Ritz, Dan Nicolaescu, Stefan Monnier,
	emacs-devel

What do you use instead of pushnew?

	Jan D.


Glenn Morris skrev 2010-07-01 10.39:
>
> http://debbugs.gnu.org/cgi/bugreport.cgi?bug=6148
>
> It is trivial to modify vc-dir-hide-up-to-date to accept an optional
> STATES argument in place of a hard-coded 'up-to-date.
>
> Then I just use the interactive piece from the posted code, and bind
> it to H, as suggested.
>
> I use this all the time, for exactly the purpose of hiding
> unregistered files.



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

* Re: [vc-git] Showing ‘.git/*’ files in vc-dir
  2010-07-01  6:44             ` Dan Nicolaescu
@ 2010-07-01 13:40               ` Eric James Michael Ritz
  2010-07-04 17:26               ` Eric James Michael Ritz
  2010-07-04 17:27               ` Stefan Monnier
  2 siblings, 0 replies; 31+ messages in thread
From: Eric James Michael Ritz @ 2010-07-01 13:40 UTC (permalink / raw)
  To: emacs-devel; +Cc: Stefan Monnier, Miles Bader

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1


On 07/01/2010 02:44 AM, Dan Nicolaescu wrote:
> Miles Bader <miles@gnu.org> writes:
>
>> Dan Nicolaescu <dann@gnu.org> writes:
>>>>> Not sure what the best solution is: make vc-git-state return
>>>>> nil, or make vc-dir ignore files in .git, or something else ...
>>>>
>>>> Maybe find-file shouldn't add unregistered files to vc-dir buffers.
>>>
>>> Sure it should, one wants to be able to register those files.
>>
>> One can visit the file and "register" it that way, right (C-x v v)?
>
> This is going on the wrong track.
>
> The problem is not unrelated to adding 'unregistered files.
>
> The issue is that vc-git-state says 'unregistered for files that it
> should not say 'unregistered.
>
> (vc-git-state "SOME_FILE_THAT_DOES_NOT_EXIST") says 'unregistered
>
> (vc-git-state ".git/HEAD") says 'unregistered
>
>
> This patch seems to fix it:
>
> === modified file 'lisp/vc/vc-git.el'
> --- lisp/vc/vc-git.el   2010-06-11 19:09:57 +0000
> +++ lisp/vc/vc-git.el   2010-07-01 06:37:30 +0000
> @@ -180,7 +180,9 @@ If nil, use the value of `vc-diff-switch
>    ;; was modified upstream.  But we can't check that without a network
>    ;; operation.
>    (if (not (vc-git-registered file))
> -      'unregistered
> +      (let ((st (vc-git--run-command-string
> +            file "ls-files" "-t" "-o" "--")))
> +            (if (and (stringp st) (not (string= st ""))) 'unregistered nil))
>      (vc-git--call nil "add" "--refresh" "--" (file-relative-name file))
>      (let ((diff (vc-git--run-command-string
>                   file "diff-index" "-z" "HEAD" "--")))
>
>
> It would be nice if someone more familiar with the git low level
> commands would take a look at this function and try to make it a bit better.
> As the comment there says, it should be able to return 'ignored.
> It would be nice if it could be able to return 'conflict too.

In the `-t` needed in the call to git-ls-files?  It we are just
interested in whether or not the file is there, the `-o` by itself
will work fine.

We should also be able to use `git ls-files --ignored
- --exclude-standard -- $file` to see if we need to return 'ignored for
a file.

- --
Eric James Michael Ritz
Cyber Sprocket Labs
(843) 225-3830
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iQEcBAEBAgAGBQJMLJquAAoJEEHUZXw5hMWsBzcH/R5m5qNqcWTJQubmt/x4OC3N
2EBtIkaDSPEPehDD4tLfA/Ppbd0gNyGDQqyk4TSUOGIQR67HIrQf7MVl4x9Sf5md
4YFjt9xM9xPSW48NWNn2A9xlcejCFwAL7fcq5T3sA2oLmofeYMu36mriAniGHTbq
DQ0xxsdr0FHjKltgah2bwvMUqIXUQfBnYBg9WlzYOsWnzUzTWFi4LaYgtWKzyaRz
YifXT8RS4SiRuEWXM16KF/qDuQQ/l3+uL1safnRjKr378Pp3k+t8k0CeX5+EGfvX
cmbNIuJ5Vyo0+r8UJM0SFg+qmBZf7YSzwiQuNi/D3n1G05dIvM/RvrJFm7MRFr4=
=/09u
-----END PGP SIGNATURE-----




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

* Re: [vc-git] Showing ‘.git/*’ files in vc-dir
  2010-07-01  9:16               ` Miles Bader
  2010-07-01  9:22                 ` Deniz Dogan
@ 2010-07-01 15:23                 ` Dan Nicolaescu
  2010-07-01 21:14                 ` Glenn Morris
  2 siblings, 0 replies; 31+ messages in thread
From: Dan Nicolaescu @ 2010-07-01 15:23 UTC (permalink / raw)
  To: Miles Bader
  Cc: Eric James Michael Ritz, Jan Djärv, Stefan Monnier,
	emacs-devel

Miles Bader <miles@gnu.org> writes:

> Glenn Morris <rgm@gnu.org> writes:
>> I do M-x vc-dir, mark only the files I want to commit, then press v.
>>
>> Then I just wait 10-15 minutes, and presto, my changes are committed.
>> What could be easier?
>
> 10-15 minutes...?!

Try checking in anything if you want to see it ...



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

* Re: [vc-git] Showing ‘.git/*’ files in vc-dir
  2010-07-01  9:23               ` Jan Djärv
@ 2010-07-01 15:26                 ` Dan Nicolaescu
  2010-07-01 16:25                   ` Jan Djärv
  0 siblings, 1 reply; 31+ messages in thread
From: Dan Nicolaescu @ 2010-07-01 15:26 UTC (permalink / raw)
  To: Jan Djärv; +Cc: Eric James Michael Ritz, Stefan Monnier, emacs-devel

Jan Djärv <jan.h.d@swipnet.se> writes:

> Dan Nicolaescu skrev 2010-07-01 10.32:
>> Jan Djärv<jan.h.d@swipnet.se>  writes:
>>
>>> I almost always have unregistered files (.emacs.desktop for one), and
>>> thus can't commit from vc-dir ("files must have the same state") as
>>> bzr on savannah does not accept a list of files in the commit.
>>
>> What do you mean?
>> Most commits are lists of files: file(s) + ChangeLog.
>> You can mark files with m (or M to mark all files in the same state).
>> After marking at least one item,  C-x v v applies to the list of marked things.
>
> Reading earlier messages, I see I confused this with not being able to
> commit with pending merges present.  So I have done commits from the
> command line when I really didn't need to, bummer...
>
> FWIW, I think vc-dir should be similar to the command line in this
> respect, i.e. just commit if there are unregistered files present.
> After all, it is not a limitation of the underlying version control
> system.

vc-dir does not care, it just uses C-x v v
For 'unregistered files C-x v v says that the next action is vc-register
For 'edited files C-x v v says that the next action is vc-checkin
Hence it can't do both...



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

* Re: [vc-git] Showing ‘.git/*’ files in vc-dir
  2010-07-01  8:39               ` Glenn Morris
  2010-07-01  9:29                 ` Jan Djärv
@ 2010-07-01 15:34                 ` Dan Nicolaescu
  1 sibling, 0 replies; 31+ messages in thread
From: Dan Nicolaescu @ 2010-07-01 15:34 UTC (permalink / raw)
  To: Glenn Morris
  Cc: Eric James Michael Ritz, Jan Djärv, Stefan Monnier,
	emacs-devel

Glenn Morris <rgm@gnu.org> writes:

> Dan Nicolaescu wrote:
>
>>> How about a command and a defcustom to set the default that filters
>>> out unregistered files in vc-dir?
>>
>> If someone first shows a clean design and UI for it, sure.
>> It could be bound to C-u x.
>
> http://debbugs.gnu.org/cgi/bugreport.cgi?bug=6148

I somehow missed that.

> It is trivial to modify vc-dir-hide-up-to-date to accept an optional
> STATES argument in place of a hard-coded 'up-to-date.

The change may be trivial to code, but as I said, I'd like to see a
clean design first.
What happens when you run another vc-dir, should the same type of
files be hidden again?
Should the user be able to say: I never want to see unregistered files.
(or some other type???)

> Then I just use the interactive piece from the posted code, and bind
> it to H, as suggested.

I'd like to avoid taking another key if possible.

> I use this all the time, for exactly the purpose of hiding
> unregistered files.

It would be nice to have a more generic solution, if one is needed.
Someone needs to think about it and justify one way or another.



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

* Re: [vc-git] Showing ‘.git/*’ files in vc-dir
  2010-07-01 15:26                 ` Dan Nicolaescu
@ 2010-07-01 16:25                   ` Jan Djärv
  2010-07-23 15:30                     ` Stefan Monnier
  0 siblings, 1 reply; 31+ messages in thread
From: Jan Djärv @ 2010-07-01 16:25 UTC (permalink / raw)
  To: Dan Nicolaescu; +Cc: Eric James Michael Ritz, Stefan Monnier, emacs-devel



Dan Nicolaescu skrev 2010-07-01 17.26:
> Jan Djärv<jan.h.d@swipnet.se>  writes:
>
>>
>> FWIW, I think vc-dir should be similar to the command line in this
>> respect, i.e. just commit if there are unregistered files present.
>> After all, it is not a limitation of the underlying version control
>> system.
>
> vc-dir does not care, it just uses C-x v v
> For 'unregistered files C-x v v says that the next action is vc-register
> For 'edited files C-x v v says that the next action is vc-checkin
> Hence it can't do both...

I'm not familiar with the inner workings of vc, so when I say vc-dir I really 
mean vc as a whole.  Anyway, what you say is of course correct, but if there 
are both edited and unregistered, C-x v v in this case should say vc-checkin. 
  After all, commit is far more common than register.

	Jan D.



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

* Re: [vc-git] Showing ‘.git/*’ files in vc-dir
  2010-07-01  9:16               ` Miles Bader
  2010-07-01  9:22                 ` Deniz Dogan
  2010-07-01 15:23                 ` Dan Nicolaescu
@ 2010-07-01 21:14                 ` Glenn Morris
  2010-07-01 22:24                   ` René Kyllingstad
  2 siblings, 1 reply; 31+ messages in thread
From: Glenn Morris @ 2010-07-01 21:14 UTC (permalink / raw)
  To: Miles Bader
  Cc: Eric James Michael Ritz, Dan Nicolaescu, Jan Djärv,
	Stefan Monnier, emacs-devel

Miles Bader wrote:

> Glenn Morris <rgm@gnu.org> writes:
>> I do M-x vc-dir, mark only the files I want to commit, then press v.
>>
>> Then I just wait 10-15 minutes, and presto, my changes are committed.
>> What could be easier?
>
> 10-15 minutes...?!

Just passive-aggressive bitching at Savannah on my part.

From memory, it's always > 1 minute, typically ~ 3, often up to 5, and
has indeed been up to 15 minutes. For a single line change to a README
file.



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

* Re: [vc-git] Showing ‘.git/*’ files in vc-dir
  2010-07-01 21:14                 ` Glenn Morris
@ 2010-07-01 22:24                   ` René Kyllingstad
  2010-07-02  3:14                     ` Miles Bader
  0 siblings, 1 reply; 31+ messages in thread
From: René Kyllingstad @ 2010-07-01 22:24 UTC (permalink / raw)
  To: Glenn Morris, Miles Bader, Eric James Michael Ritz,
	Dan Nicolaescu, Jan Djärv

On Thu, Jul 1, 2010 at 11:14 PM, Glenn Morris <rgm@gnu.org> wrote:
> Miles Bader wrote:
>
>> Glenn Morris <rgm@gnu.org> writes:
>>> I do M-x vc-dir, mark only the files I want to commit, then press v.
>>>
>>> Then I just wait 10-15 minutes, and presto, my changes are committed.
>>> What could be easier?
>>
>> 10-15 minutes...?!
>
> Just passive-aggressive bitching at Savannah on my part.

Would it be so bad to make launchpad the official repository?

With a more responsive system and a nice web front-end it could be like this:

    http://ericharrison.info/2010/05/28/github-is-the-best-thing-ever/


-- René



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

* Re: [vc-git] Showing ‘.git/*’ files in vc-dir
  2010-07-01 22:24                   ` René Kyllingstad
@ 2010-07-02  3:14                     ` Miles Bader
  0 siblings, 0 replies; 31+ messages in thread
From: Miles Bader @ 2010-07-02  3:14 UTC (permalink / raw)
  To: René Kyllingstad
  Cc: Eric James Michael Ritz, emacs-devel, Stefan Monnier,
	Dan Nicolaescu, Jan Djärv

On Fri, Jul 2, 2010 at 7:24 AM, René Kyllingstad
<listmailemacs@kyllingstad.com> wrote:
>> Just passive-aggressive bitching at Savannah on my part.
>
> Would it be so bad to make launchpad the official repository?

bzr and launchpad are both tightly-controlled products of ubuntu, and
I'm not sure we want Emacs to sink any farther into the "corporate
sugar-daddy with a ready handshake but murky goals" swamp.

Of course, savannah works great with git...

-Miles

-- 
Do not taunt Happy Fun Ball.



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

* Re: [vc-git] Showing ‘.git/*’ files in vc-dir
  2010-07-01  6:44             ` Dan Nicolaescu
  2010-07-01 13:40               ` Eric James Michael Ritz
@ 2010-07-04 17:26               ` Eric James Michael Ritz
  2010-07-04 19:30                 ` Dan Nicolaescu
  2010-07-04 17:27               ` Stefan Monnier
  2 siblings, 1 reply; 31+ messages in thread
From: Eric James Michael Ritz @ 2010-07-04 17:26 UTC (permalink / raw)
  To: Dan Nicolaescu; +Cc: emacs-devel, Stefan Monnier, Miles Bader


On 07/01/2010 02:44 AM, Dan Nicolaescu wrote:
> Miles Bader <miles@gnu.org> writes:
>
>> Dan Nicolaescu <dann@gnu.org> writes:
>>>>> Not sure what the best solution is: make vc-git-state return
>>>>> nil, or make vc-dir ignore files in .git, or something else ...
>>>>
>>>> Maybe find-file shouldn't add unregistered files to vc-dir buffers.
>>>
>>> Sure it should, one wants to be able to register those files.
>>
>> One can visit the file and "register" it that way, right (C-x v v)?
>
> This is going on the wrong track.
>
> The problem is not unrelated to adding 'unregistered files.
>
> The issue is that vc-git-state says 'unregistered for files that it
> should not say 'unregistered.
>
> (vc-git-state "SOME_FILE_THAT_DOES_NOT_EXIST") says 'unregistered
>
> (vc-git-state ".git/HEAD") says 'unregistered
>
>
> This patch seems to fix it:
>
> [...]
>
> It would be nice if someone more familiar with the git low level
> commands would take a look at this function and try to make it a bit better.
> As the comment there says, it should be able to return 'ignored.
> It would be nice if it could be able to return 'conflict too.

After looking into this a little more, and learning a little more
about the internals of vc-mode in general, I put together a patch that
fixes the original problem that I was having.  It also causes things like

    (vc-git-state ".git/HEAD")

to return nil instead of 'unregistered.  It also causes ignored files
to return 'ignored.  It still does nothing to return 'conflict in
the right situations.  Below is the patch.

----------------------------------------------------------------------

* vc-git.el (vc-git-state): Return nil for files in the core `.git'
directories, and also return 'ignored for files that are being
ignored.

When using vc-dir to work with a directory under source control by
Git, it is possible for vc-dir to show files under the top-level
`.git' directory as being unregistered.  As correctly guessed by Dan
Nicolescu, this is caused when a user has $EDITOR configured to be
emacsclient, and he performs certain Git operations outside of
vc-mode, e.g. running `git-commit' from the command line.

It is unlikely that any user would want to perform operations on a
file inside of the `.git' directory via vc-dir.  Therefore we can
prevent those files from appearing by teaching `vc-git-state' to
return nil for any file in those directories.
---
 lisp/ChangeLog |    6 ++++++
 lisp/vc-git.el |   36 ++++++++++++++++++++++++++----------
 2 files changed, 32 insertions(+), 10 deletions(-)

diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 953c04e..5f84e52 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,9 @@
+2010-07-04  Eric James Michael Ritz <Eric@cybersprocket.com>
+
+	* vc-git.el (vc-git-state): Return nil for files in the core
+	`.git' directories, and also return 'ignored for files that are
+	being ignored.
+
 2010-06-27  Oleksandr Gavenko  <gavenkoa@gmail.com>  (tiny change)

 	* generic-x.el (bat-generic-mode): Fix regexp for command line
diff --git a/lisp/vc-git.el b/lisp/vc-git.el
index 24062a0..ee94ee4 100644
--- a/lisp/vc-git.el
+++ b/lisp/vc-git.el
@@ -171,16 +171,32 @@ If nil, use the value of `vc-diff-switches'.  If t, use no switches."

 (defun vc-git-state (file)
   "Git-specific version of `vc-state'."
-  ;; FIXME: This can't set 'ignored yet
-  (if (not (vc-git-registered file))
-      'unregistered
-    (vc-git--call nil "add" "--refresh" "--" (file-relative-name file))
-    (let ((diff (vc-git--run-command-string
-                 file "diff-index" "-z" "HEAD" "--")))
-      (if (and diff (string-match ":[0-7]\\{6\\} [0-7]\\{6\\} [0-9a-f]\\{40\\} [0-9a-f]\\{40\\} \\([ADMUT]\\)\0[^\0]+\0"
-				  diff))
-	  (vc-git--state-code (match-string 1 diff))
-	(if (vc-git--empty-db-p) 'added 'up-to-date)))))
+  ;; A file in a '.git/' directory.
+  (cond ((string-match-p  (rx string-start
+                              (zero-or-more anything)
+                              (optional "/")
+                              ".git/"
+                              (optional (zero-or-more anything)))
+                          file)
+         nil)
+        ;; Unregistered or ignored file.
+        ((not (vc-git-registered file))
+         (if (vc-git-file-is-ignored (file-relative-name file))
+             'ignored
+           'unregistered))
+        (t
+         (vc-git--call nil "add" "--refresh" "--" (file-relative-name file))
+         (let ((diff (vc-git--run-command-string
+                      file "diff-index" "-z" "HEAD" "--")))
+           (if (and diff (string-match ":[0-7]\\{6\\} [0-7]\\{6\\} [0-9a-f]\\{40\\} [0-9a-f]\\{40\\} \\([ADMUT]\\)\0[^\0]+\0"
+                                       diff))
+               (vc-git--state-code (match-string 1 diff))
+             (if (vc-git--empty-db-p) 'added 'up-to-date))))))
+
+(defun vc-git-file-is-ignored (file)
+  "Returns non-nil if the `file' is not being ignored."
+  (vc-git--run-command-string
+   file "ls-files" "--others" "--ignored" "--exclude-standard" "--"))

 (defun vc-git-working-revision (file)
   "Git-specific version of `vc-working-revision'."
--
1.7.2.rc1





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

* Re: [vc-git] Showing ‘.git/*’ files in vc-dir
  2010-07-01  6:44             ` Dan Nicolaescu
  2010-07-01 13:40               ` Eric James Michael Ritz
  2010-07-04 17:26               ` Eric James Michael Ritz
@ 2010-07-04 17:27               ` Stefan Monnier
  2010-07-04 19:26                 ` Dan Nicolaescu
  2 siblings, 1 reply; 31+ messages in thread
From: Stefan Monnier @ 2010-07-04 17:27 UTC (permalink / raw)
  To: Dan Nicolaescu; +Cc: Eric James Michael Ritz, emacs-devel, Miles Bader

> (vc-git-state "SOME_FILE_THAT_DOES_NOT_EXIST") says 'unregistered
> (vc-git-state ".git/HEAD") says 'unregistered

I'd expect most backends to suffer from this.
The problem here is that Git seems to actively make the user access
a file under the .git directory.

Although, there might be more to it, since opening .bzr/branch/location
didn't add it to the *vc-dir* buffer when I tried it.


        Stefan



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

* Re: [vc-git] Showing ‘.git/*’ files in vc-dir
  2010-07-04 17:27               ` Stefan Monnier
@ 2010-07-04 19:26                 ` Dan Nicolaescu
  0 siblings, 0 replies; 31+ messages in thread
From: Dan Nicolaescu @ 2010-07-04 19:26 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: Eric James Michael Ritz, emacs-devel, Miles Bader

Stefan Monnier <monnier@IRO.UMontreal.CA> writes:

>> (vc-git-state "SOME_FILE_THAT_DOES_NOT_EXIST") says 'unregistered
>> (vc-git-state ".git/HEAD") says 'unregistered
>
> I'd expect most backends to suffer from this.

AFAIK only bzr and git do.
Git is too bad, it's commands can distinguish files in .git.

> The problem here is that Git seems to actively make the user access
> a file under the .git directory.
>
> Although, there might be more to it, since opening .bzr/branch/location
> didn't add it to the *vc-dir* buffer when I tried it.

It's not opening, it's saving a file that adds it to *vc-dir*.

bzr is slightly broken about this:

 $ bzr status .bzr/branch/last-revision
unknown:
  .bzr/branch/last-revision

whereas: 

 $ hg status .hg/dirstate
abort: path contains illegal component: .hg/dirstate




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

* Re: [vc-git] Showing ‘.git/*’ files in vc-dir
  2010-07-04 17:26               ` Eric James Michael Ritz
@ 2010-07-04 19:30                 ` Dan Nicolaescu
  2010-07-04 19:45                   ` Eric James Michael Ritz
  0 siblings, 1 reply; 31+ messages in thread
From: Dan Nicolaescu @ 2010-07-04 19:30 UTC (permalink / raw)
  To: Eric James Michael Ritz; +Cc: emacs-devel, Stefan Monnier, Miles Bader

Eric James Michael Ritz <Eric@cybersprocket.com> writes:

> On 07/01/2010 02:44 AM, Dan Nicolaescu wrote:
>> Miles Bader <miles@gnu.org> writes:
>>
>>> Dan Nicolaescu <dann@gnu.org> writes:
>>>>>> Not sure what the best solution is: make vc-git-state return
>>>>>> nil, or make vc-dir ignore files in .git, or something else ...
>>>>>
>>>>> Maybe find-file shouldn't add unregistered files to vc-dir buffers.
>>>>
>>>> Sure it should, one wants to be able to register those files.
>>>
>>> One can visit the file and "register" it that way, right (C-x v v)?
>>
>> This is going on the wrong track.
>>
>> The problem is not unrelated to adding 'unregistered files.
>>
>> The issue is that vc-git-state says 'unregistered for files that it
>> should not say 'unregistered.
>>
>> (vc-git-state "SOME_FILE_THAT_DOES_NOT_EXIST") says 'unregistered
>>
>> (vc-git-state ".git/HEAD") says 'unregistered
>>
>>
>> This patch seems to fix it:
>>
>> [...]
>>
>> It would be nice if someone more familiar with the git low level
>> commands would take a look at this function and try to make it a bit better.
>> As the comment there says, it should be able to return 'ignored.
>> It would be nice if it could be able to return 'conflict too.
>
> After looking into this a little more, and learning a little more
> about the internals of vc-mode in general, I put together a patch that
> fixes the original problem that I was having.  It also causes things like
>
>     (vc-git-state ".git/HEAD")
>
> to return nil instead of 'unregistered.  It also causes ignored files
> to return 'ignored.  It still does nothing to return 'conflict in
> the right situations.  Below is the patch.
>
> ----------------------------------------------------------------------
>
> * vc-git.el (vc-git-state): Return nil for files in the core `.git'
> directories, and also return 'ignored for files that are being
> ignored.
>
> When using vc-dir to work with a directory under source control by
> Git, it is possible for vc-dir to show files under the top-level
> `.git' directory as being unregistered.  As correctly guessed by Dan
> Nicolescu, this is caused when a user has $EDITOR configured to be
> emacsclient, and he performs certain Git operations outside of
> vc-mode, e.g. running `git-commit' from the command line.
>
> It is unlikely that any user would want to perform operations on a
> file inside of the `.git' directory via vc-dir.  Therefore we can
> prevent those files from appearing by teaching `vc-git-state' to
> return nil for any file in those directories.
> ---
>  lisp/ChangeLog |    6 ++++++
>  lisp/vc-git.el |   36 ++++++++++++++++++++++++++----------
>  2 files changed, 32 insertions(+), 10 deletions(-)
>
> diff --git a/lisp/ChangeLog b/lisp/ChangeLog
> index 953c04e..5f84e52 100644
> --- a/lisp/ChangeLog
> +++ b/lisp/ChangeLog
> @@ -1,3 +1,9 @@
> +2010-07-04  Eric James Michael Ritz <Eric@cybersprocket.com>
> +
> +	* vc-git.el (vc-git-state): Return nil for files in the core
> +	`.git' directories, and also return 'ignored for files that are
> +	being ignored.
> +
>  2010-06-27  Oleksandr Gavenko  <gavenkoa@gmail.com>  (tiny change)
>
>  	* generic-x.el (bat-generic-mode): Fix regexp for command line
> diff --git a/lisp/vc-git.el b/lisp/vc-git.el
> index 24062a0..ee94ee4 100644
> --- a/lisp/vc-git.el
> +++ b/lisp/vc-git.el
> @@ -171,16 +171,32 @@ If nil, use the value of `vc-diff-switches'.  If t, use no switches."
>
>  (defun vc-git-state (file)
>    "Git-specific version of `vc-state'."
> -  ;; FIXME: This can't set 'ignored yet
> -  (if (not (vc-git-registered file))
> -      'unregistered
> -    (vc-git--call nil "add" "--refresh" "--" (file-relative-name file))
> -    (let ((diff (vc-git--run-command-string
> -                 file "diff-index" "-z" "HEAD" "--")))
> -      (if (and diff (string-match ":[0-7]\\{6\\} [0-7]\\{6\\} [0-9a-f]\\{40\\} [0-9a-f]\\{40\\} \\([ADMUT]\\)\0[^\0]+\0"
> -				  diff))
> -	  (vc-git--state-code (match-string 1 diff))
> -	(if (vc-git--empty-db-p) 'added 'up-to-date)))))
> +  ;; A file in a '.git/' directory.
> +  (cond ((string-match-p  (rx string-start
> +                              (zero-or-more anything)
> +                              (optional "/")
> +                              ".git/"
> +                              (optional (zero-or-more anything)))
> +                          file)
> +         nil)

Nothing else in vc-git.el uses `rx', for consistency it would be
better to avoid it here too.

Does this work on MS windows too?
I'd like a second opinion about this: should we go for file name
matching as above, or just use "git ls-files"?


> +        ;; Unregistered or ignored file.
> +        ((not (vc-git-registered file))
> +         (if (vc-git-file-is-ignored (file-relative-name file))
> +             'ignored
> +           'unregistered))
> +        (t
> +         (vc-git--call nil "add" "--refresh" "--" (file-relative-name file))
> +         (let ((diff (vc-git--run-command-string
> +                      file "diff-index" "-z" "HEAD" "--")))
> +           (if (and diff (string-match ":[0-7]\\{6\\} [0-7]\\{6\\} [0-9a-f]\\{40\\} [0-9a-f]\\{40\\} \\([ADMUT]\\)\0[^\0]+\0"
> +                                       diff))
> +               (vc-git--state-code (match-string 1 diff))
> +             (if (vc-git--empty-db-p) 'added 'up-to-date))))))
> +
> +(defun vc-git-file-is-ignored (file)
> +  "Returns non-nil if the `file' is not being ignored."
> +  (vc-git--run-command-string
> +   file "ls-files" "--others" "--ignored" "--exclude-standard" "--"))
>
>  (defun vc-git-working-revision (file)
>    "Git-specific version of `vc-working-revision'."
> --
> 1.7.2.rc1



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

* Re: [vc-git] Showing ‘.git/*’ files in vc-dir
  2010-07-04 19:30                 ` Dan Nicolaescu
@ 2010-07-04 19:45                   ` Eric James Michael Ritz
  0 siblings, 0 replies; 31+ messages in thread
From: Eric James Michael Ritz @ 2010-07-04 19:45 UTC (permalink / raw)
  To: Dan Nicolaescu; +Cc: emacs-devel, Stefan Monnier, Miles Bader


On 07/04/2010 03:30 PM, Dan Nicolaescu wrote:
> Eric James Michael Ritz <Eric@cybersprocket.com> writes:
>
> [...]
>>
>>  	* generic-x.el (bat-generic-mode): Fix regexp for command line
>> diff --git a/lisp/vc-git.el b/lisp/vc-git.el
>> index 24062a0..ee94ee4 100644
>> --- a/lisp/vc-git.el
>> +++ b/lisp/vc-git.el
>> @@ -171,16 +171,32 @@ If nil, use the value of `vc-diff-switches'.  If t, use no switches."
>>
>>  (defun vc-git-state (file)
>>    "Git-specific version of `vc-state'."
>> -  ;; FIXME: This can't set 'ignored yet
>> -  (if (not (vc-git-registered file))
>> -      'unregistered
>> -    (vc-git--call nil "add" "--refresh" "--" (file-relative-name file))
>> -    (let ((diff (vc-git--run-command-string
>> -                 file "diff-index" "-z" "HEAD" "--")))
>> -      (if (and diff (string-match ":[0-7]\\{6\\} [0-7]\\{6\\} [0-9a-f]\\{40\\} [0-9a-f]\\{40\\} \\([ADMUT]\\)\0[^\0]+\0"
>> -				  diff))
>> -	  (vc-git--state-code (match-string 1 diff))
>> -	(if (vc-git--empty-db-p) 'added 'up-to-date)))))
>> +  ;; A file in a '.git/' directory.
>> +  (cond ((string-match-p  (rx string-start
>> +                              (zero-or-more anything)
>> +                              (optional "/")
>> +                              ".git/"
>> +                              (optional (zero-or-more anything)))
>> +                          file)
>> +         nil)
>
> Nothing else in vc-git.el uses `rx', for consistency it would be
> better to avoid it here too.

Noted.

> Does this work on MS windows too?
> I'd like a second opinion about this: should we go for file name
> matching as above, or just use "git ls-files"?

I have not tried it on Windows, but I will look into it.

Using `git ls-files` could also be possible.  Running something like

    $ git ls-files .git/COMMIT_EDITMSG -t --others

gives us

    ? .git/COMMIT_EDITMSG

`vc-git--state-code` doesn’t know about ‘?’, which just means ‘other’
in Git.  Maybe we should return nil for files with that state code?
That’s one possibility.  But I agree, second opinion from a Git user
would be useful.

>> +        ;; Unregistered or ignored file.
>> +        ((not (vc-git-registered file))
>> +         (if (vc-git-file-is-ignored (file-relative-name file))
>> +             'ignored
>> +           'unregistered))
>> +        (t
>> +         (vc-git--call nil "add" "--refresh" "--" (file-relative-name file))
>> +         (let ((diff (vc-git--run-command-string
>> +                      file "diff-index" "-z" "HEAD" "--")))
>> +           (if (and diff (string-match ":[0-7]\\{6\\} [0-7]\\{6\\} [0-9a-f]\\{40\\} [0-9a-f]\\{40\\} \\([ADMUT]\\)\0[^\0]+\0"
>> +                                       diff))
>> +               (vc-git--state-code (match-string 1 diff))
>> +             (if (vc-git--empty-db-p) 'added 'up-to-date))))))
>> +
>> +(defun vc-git-file-is-ignored (file)
>> +  "Returns non-nil if the `file' is not being ignored."
>> +  (vc-git--run-command-string
>> +   file "ls-files" "--others" "--ignored" "--exclude-standard" "--"))
>>
>>  (defun vc-git-working-revision (file)
>>    "Git-specific version of `vc-working-revision'."
>> --
>> 1.7.2.rc1
>

--
Eric James Michael Ritz
Cyber Sprocket Labs
(843) 225-3830



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

* Re: [vc-git] Showing ‘.git/*’ files in vc-dir
  2010-07-01 16:25                   ` Jan Djärv
@ 2010-07-23 15:30                     ` Stefan Monnier
  0 siblings, 0 replies; 31+ messages in thread
From: Stefan Monnier @ 2010-07-23 15:30 UTC (permalink / raw)
  To: Jan Djärv; +Cc: Eric James Michael Ritz, Dan Nicolaescu, emacs-devel

> I'm not familiar with the inner workings of vc, so when I say vc-dir
> I really mean vc as a whole.  Anyway, what you say is of course correct, but
> if there are both edited and unregistered, C-x v v in this case should say
> vc-checkin. After all, commit is far more common than register.

I guess I mostly agree except that I'd throw out the "vc-next-action"
altogether and replace it with vc-commit (at least in *VC-Dir*).


        Stefan



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

end of thread, other threads:[~2010-07-23 15:30 UTC | newest]

Thread overview: 31+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-06-29 18:29 [vc-git] Showing ‘.git/*’ files in vc-dir Eric James Michael Ritz
2010-06-29 19:54 ` Dan Nicolaescu
2010-06-29 20:07   ` Eric James Michael Ritz
2010-06-29 20:54     ` Dan Nicolaescu
2010-06-29 21:16       ` Eric James Michael Ritz
2010-07-01  1:27       ` Stefan Monnier
2010-07-01  3:06         ` Dan Nicolaescu
2010-07-01  5:47           ` Miles Bader
2010-07-01  6:44             ` Dan Nicolaescu
2010-07-01 13:40               ` Eric James Michael Ritz
2010-07-04 17:26               ` Eric James Michael Ritz
2010-07-04 19:30                 ` Dan Nicolaescu
2010-07-04 19:45                   ` Eric James Michael Ritz
2010-07-04 17:27               ` Stefan Monnier
2010-07-04 19:26                 ` Dan Nicolaescu
2010-07-01  7:36           ` Jan Djärv
2010-07-01  8:32             ` Dan Nicolaescu
2010-07-01  8:39               ` Glenn Morris
2010-07-01  9:29                 ` Jan Djärv
2010-07-01 15:34                 ` Dan Nicolaescu
2010-07-01  9:23               ` Jan Djärv
2010-07-01 15:26                 ` Dan Nicolaescu
2010-07-01 16:25                   ` Jan Djärv
2010-07-23 15:30                     ` Stefan Monnier
2010-07-01  8:35             ` Glenn Morris
2010-07-01  9:16               ` Miles Bader
2010-07-01  9:22                 ` Deniz Dogan
2010-07-01 15:23                 ` Dan Nicolaescu
2010-07-01 21:14                 ` Glenn Morris
2010-07-01 22:24                   ` René Kyllingstad
2010-07-02  3:14                     ` Miles Bader

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).