On 25/12/06 03:53PM, Michael Albinus wrote:
> Peter Marinov <[email protected]> writes:
> Hi Peter,
>

Thanks for your comment, iteresting suggestions, and attached source
code


>
> > It works in this format, for example:
> >
> > /git:5e7a71d:/home/peterm/work/emacs
> >
> > This will open a dired viewer of the repo, entering folders or viewing
> > files keeps the initial hash.
>
> Why to restrict yourself to the dired viewer? If you implement this with
> file name handlers, you shall have all possible functions in mind.

Yes, my impelementation (together with some bugs as it seems) can
handle both directories and files. If you were to navige in a dired
you can then press RET (or 'v') to load files


>
> > To try it quickly:
> >
> > $ git clone https://git.sr.ht/~pem/git-tramp
> > $ cd git-tramp
> > $ emacs -nw -l git-tramp.el
>
> I've tried it shortly, but it didn't work for me. Perhaps it is in an
> early stage.

I'm sorry, there are bugs, however, the display of directory and
loading of files should work.

Would you please try it in this format:

$ emacs -nw -l ~/work/git-tramp/git-tramp.el /git:HEAD:/home/peterm/tmp/emacs

(No '~', complete path, as '~' is not yet resolved)


>
> > My ultimate plan is for this to be integrated with
> > 'vc-print-root-log'. Where now we can do '=' to see a diff, or RET to
> > see the commit comment, I would like to add 't' to invoke git-tramp
> > over that hash in the log.
>
> Well, I'm not sure whether it is what users need this way. I would
> rather expect a syntax which gives first the file name, and after that
> the git hash. This is more convenient when you want to compare different
> versions of the same file.

There is a problem with the order where the hash is after the
path. Let me explain:

In the current format we have (with some a location deeper in the repo):

/git:5e7a71d:/home/peterm/tmp/emacs/doc/lispintro

Apart from the protocol and the hash we have path. That path itself
has 2 components:

'/home/peterm/tmp/' -- this is a path to a repo that has nothing to do
with the protocol and the hash

'emacs/doc/lispintro' -- this is a path inside the repo

Notice that the path inside the repo needs the hash, that is because
the path inside the repo exists, or not, depending on the history of
the repo, we can't do 'TAB' to autocomplete paths inside a repo
without the corresponding hash.

The hash has to precede the file path!


> The full range of operations is listed in the Emacs Lisp manual, see
> (info "(elisp) Magic File Names")

This is what I was looking for! I didn't know this documentation page
existed.


> > Any additional comments or suggestions are welcome.
>
> I don't believe you must base your implamentation on Tramp. All what you
> need is proper handling of a file name handler.
>
> Some years ago, I wrote something similar called 'vc-handler'. The idea
> was to support a file name syntax like
> "/path/to/file@@/branch/revision-or-label". You see that the resivision
> (hash in the git case) and the branch come after the file name.
> The package 'vc-git-handler' was the backend for git; I didn't implement
> it for other VCS backends.

Thank you for sending me your implemention on this topic, I'm going to
study it and borrow ideas.


> Well, it worked to some extend. But I gave up, because the performance
> was miserable, and I'm not such a git aficionado that I could tune it.

I think the performance problems might be in only 1 place:
autocompletion of hashes/branches/tags. To autocomplete you will always
need the complete list, imagine the length of one such list on an old
project such as Emacs, or Linux kernel.

For the moment I chose not to autocomplete.


>
> I'll append both files for your amusement. You can try it like this:
>
> --8<---------------cut here---------------start------------->8---
> # emacs -Q -L ~/lisp -l vc-handler ;; My private Lisp files reside in ~/lisp
> C-x C-f ~/src/git-tramp/ ;; This is your checked out repo
> C-x C-f git-t TAB ;; Expands to ~/src/git-tramp/git-tramp.el
> @@/ TAB ;; Expands to { HEAD | master/ }
> mas TAB ;; Expands to { 07db2bd | 1196543 | 2b9edd5 | ... }
> 07db2bd RET ;; Here we are.
> --8<---------------cut here---------------end--------------->8---
>
> 8 years old; I'm pretty sure there are missing parts.

In your example, once you are past the path ~/src/git-tramp, you can't
continue with the completion if you don't already have the hash (or
equivalent) in the path.

>From my point of view, the TRAMP's path format solves for this
requirement.


> Best regards, Michael.

Regards,
Peter M.

Reply via email to