[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [vc-git] Showing ‘.git/*’ files in vc -dir
From: |
Eric James Michael Ritz |
Subject: |
Re: [vc-git] Showing ‘.git/*’ files in vc -dir |
Date: |
Sun, 04 Jul 2010 15:45:06 -0400 |
User-agent: |
Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.9) Gecko/20100423 Thunderbird/3.0.4 |
On 07/04/2010 03:30 PM, Dan Nicolaescu wrote:
> Eric James Michael Ritz <address@hidden> 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