all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Eric James Michael Ritz <Eric@cybersprocket.com>
To: Dan Nicolaescu <dann@gnu.org>
Cc: emacs-devel@gnu.org, Stefan Monnier <monnier@iro.umontreal.ca>,
	Miles Bader <miles@gnu.org>
Subject: Re: [vc-git] Showing ‘.git/*’ files in vc-dir
Date: Sun, 04 Jul 2010 15:45:06 -0400	[thread overview]
Message-ID: <4C30E4C2.9020500@cybersprocket.com> (raw)
In-Reply-To: <yxq1vbjm4cu.fsf@fencepost.gnu.org>


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



  reply	other threads:[~2010-07-04 19:45 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4C30E4C2.9020500@cybersprocket.com \
    --to=eric@cybersprocket.com \
    --cc=dann@gnu.org \
    --cc=emacs-devel@gnu.org \
    --cc=miles@gnu.org \
    --cc=monnier@iro.umontreal.ca \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

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

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.