Thread (3 messages) 3 messages, 2 authors, 2016-06-15

Re: Getting version output for a file.

flat view

From: Brian Gernhardt <hidden>
Date: 2016-06-15 22:43:20

I don't know lisp very well, and elisp not at all, but I can help you with what command lines would give you the results you might want.

On Jul 11, 2007, at 7:39 AM, David Kastrup wrote:
(vc-git-previous-version FILE REV)
Return the version number immediately preceding REV for FILE,
or nil if there is no previous version.
If you want the last revision where the file was altered, you could easily use

git rev-list -2 $current_rev -- $file | tail -1

The result would be a SHA-1 of the next commit where the file was altered.
(vc-git-next-version FILE REV)
Return the version number immediately following REV for FILE,
or nil if there is no previous version.
This is a little more problematic as git doesn't have forward links in it's history.  If you have a ref to start with (HEAD is a good one to use, if you don't have anything else) you could use a similar command to the above

git rev-list $ref -- $file | grep -C1 -m1 $current_rev | head -1

If you don't have a ref to start from, you could use --all, but that may not be what the user expects.

If you want a human readable name for either you could use name-rev.  (Add "| git name-rev --stdin" to the end of the above.)  It places a human readable name after the SHA-1 in parentheses.  (example: "54dadbdb29668fbd51effefd0a0c65d915f5422b (master~3)")

~~ Brian
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help