Re: Getting version output for a file.
- From
Brian Gernhardt <benji@silverinsanity.com>
- Date
- Jul 11, 2007, 19:48 UTC
- Message-ID
- <A084830C-F1CD-4EDC-A13D-573DFC68DF77@silverinsanity.com>
- In-Reply-To
- <86abu3dv9o.fsf@lola.quinscape.zz>
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