Hi,
> > Hi,
> >
> > here is a temporary implementation.
>
> Be sure to use xgit-lookup-external-git-dir. See
> `xgit-dvc-log-edit-file-name-func' for an example.
I've revised my patch based on your advice.
2008-10-22 Masatake YAMATO <[EMAIL PROTECTED]>
* xgit.el (xgit-changed-files, xgit-describe, xgit-do-annotate):
Use `xgit-git-dir-option' instead of `xgit-git-dir'
(xgit-get-root-exclude-file): Use `xgit-git-dir' instead
of `xgit-tree-root'.
* xgit-dvc.el (xgit-dvc-log-edit-file-name-func): Use
`xgit-git-dir'.
(xgit-dvc-edit-ignore-files): New function.
(xgit-dvc-ignore-files): New function.
* xgit-core.el (xgit-git-dir-option): New function
derived from `xgit-git-dir'.
(xgit-git-dir): Don't concat "--git-dir=". Do it in
`xgit-git-dir-option'.
=== modified file 'lisp/xgit-core.el'
--- lisp/xgit-core.el 2008-08-24 10:08:39 +0000
+++ lisp/xgit-core.el 2008-10-22 11:50:18 +0000
@@ -98,16 +98,19 @@
(file-readable-p (concat (xgit-tree-root) ".git/HEAD")))
(defun xgit-git-dir (&optional location)
- "Utility function to add --git-dir option to git command."
- ;; git barfs when "~/" is in the --git-dir argument, so we cannot
- ;; just concat the result of xgit-tree-root as-is
+ "Return directory name name for .git git metadata directory for LOCATION."
(let ((git-dir (xgit-lookup-external-git-dir location)))
- (concat "--git-dir="
- (file-relative-name
+ (concat (file-relative-name
(or git-dir (xgit-tree-root location))
(file-name-as-directory (or location default-directory)))
(if git-dir "" ".git"))))
+(defun xgit-git-dir-option (&optional location)
+ "Utility function to add --git-dir option to git command."
+ ;; git barfs when "~/" is in the --git-dir argument, so we cannot
+ ;; just concat the result of xgit-tree-root as-is
+ (concat "--git-dir=" (xgit-git-dir location)))
+
(defconst xgit-hash-regexp "[0-9a-f]\\{40\\}")
;;;###autoload
=== modified file 'lisp/xgit-dvc.el'
--- lisp/xgit-dvc.el 2008-09-17 17:44:07 +0000
+++ lisp/xgit-dvc.el 2008-10-22 11:26:33 +0000
@@ -45,12 +45,8 @@
(defalias 'xgit-dvc-delta 'xgit-delta)
(defun xgit-dvc-log-edit-file-name-func ()
- (let ((git-dir (xgit-lookup-external-git-dir)))
- (when git-dir
- (setq git-dir (file-name-as-directory git-dir)))
- (concat (or git-dir (xgit-tree-root))
- (if git-dir "" ".git")
- "/" xgit-log-edit-file-name)))
+ (concat (file-name-as-directory (xgit-git-dir))
+ xgit-log-edit-file-name))
(defun xgit-dvc-log-edit-done (&optional invert-normal)
"Finish a commit for git, using git commit.
@@ -133,5 +129,30 @@
;;;###autoload
(defalias 'xgit-dvc-add 'xgit-add)
+(defun xgit-dvc-edit-ignore-files ()
+ "Edit git's ignore file.
+TODO: Support per directory ignore file.
+ This only supports exclude file now."
+ (interactive)
+ (find-file-other-window (xgit-get-root-exclude-file)))
+
+(defun xgit-dvc-ignore-files (file-list)
+ "Added FILE-LIST to git's ignore file.
+TODO: Support per directory ignore file.
+ This only supports exclude file now."
+ (interactive (list (dvc-current-file-list)))
+
+ (when (y-or-n-p (format "Ignore %S for %s? "
+ file-list
+ (xgit-git-dir)))
+ (with-current-buffer
+ (find-file-noselect (xgit-get-root-exclude-file))
+ (goto-char (point-max))
+ (dolist (f-name file-list)
+ (insert (format "%s\n" f-name)))
+ (save-buffer))))
+
+
+
(provide 'xgit-dvc)
;;; xgit-dvc.el ends here
=== modified file 'lisp/xgit.el'
--- lisp/xgit.el 2008-07-29 19:53:11 +0000
+++ lisp/xgit.el 2008-10-22 11:39:10 +0000
@@ -597,7 +597,7 @@
(defun xgit-changed-files (dir rev)
"Returns list of files changed in given revision"
- (let* ((repo (xgit-git-dir dir))
+ (let* ((repo (xgit-git-dir-option dir))
(cmd "diff-tree")
(args (list repo cmd "--numstat" rev))
(result (dvc-run-dvc-sync
@@ -651,7 +651,7 @@
if revision is a tag, return tag in a string,
else returns list of '(tag offset all-described-string)."
(interactive (list default-directory (read-string "Revision: ")))
- (let* ((repo (xgit-git-dir dir))
+ (let* ((repo (xgit-git-dir-option dir))
(cmd "describe")
(args (list repo cmd rev))
(info (dvc-run-dvc-sync 'xgit args
@@ -671,7 +671,7 @@
DIR is a directory controlled by Git.
FILE is filename in the repository at DIR."
(let* ((buffer (dvc-get-buffer-create 'xgit 'annotate))
- (repo (xgit-git-dir dir))
+ (repo (xgit-git-dir-option dir))
(cmd "blame")
(fname (file-relative-name file (xgit-tree-root dir)))
(args (list repo cmd "--" fname)))
@@ -835,5 +835,11 @@
\(y/n/a/e/c/?)? "))))
answer))))
+(defun xgit-get-root-exclude-file (&optional root)
+ "returns exclude file for ROOT"
+ (concat (file-name-as-directory (xgit-git-dir root))
+ "info/"
+ "exclude"))
+
(provide 'xgit)
;;; xgit.el ends here
_______________________________________________
Dvc-dev mailing list
[email protected]
https://mail.gna.org/listinfo/dvc-dev