On 9/12/21 8:39 AM, Maxim Kim wrote: > I want to set minimal vim version for a plugin depending of func > existence. > > Is there a "simple" way to find out when `strchars(` was added to vim > (there are more to check, this is an example)? > > For now I am searching github for the patches/PRs which is quite > inefficient :)
Maxim, I've used the following techniques when searching Vim's Git history for the introduction of a feature. This involves getting a copy of Vim's source from Github:: git clone https://github.com/vim/vim cd vim Frequently a Vim feature is mentioned in the commit log when it first is introduced. To search the log for ``strchars``, I'd use:: git log v7.0..HEAD --grep strchars This requests a search from version v7.0 up through the HEAD revision, using the ``--grep`` feature to search the commits. In this case, the output ends with:: commit 72597a57b526a8df333e77ef8a837b595baa18c7 Author: Bram Moolenaar <b...@vim.org> Date: Sun Jul 18 15:31:08 2010 +0200 Added strwidth() and strchars() functions. In Bram's current method of developing, each commit is associated with a Git tag; for example, the ``screenattr`` function was introduced more recently. Searching for that yield a tag directly from the ``git log --grep`` operation, e.g.:: git log --grep screenchar With output ending in:: commit 9a773488a7113cd028151e71ab6c9cd43bf56972 (tag: v7.3.1164) Author: Bram Moolenaar <b...@vim.org> Date: Tue Jun 11 18:40:13 2013 +0200 updated for version 7.3.1164 Problem: Can't test what is actually displayed on screen. Solution: Add the screenchar() and screenattr() functions. Git's output shows the tags as ``v7.3.1164``. But for the commit introducing the ``strchars`` function, there is no Git tag, so some additional work is needed to figure out the version number. One method is to checkout this commit and search for the major, minor, and patch versions:: git checkout 72597a57b526a8df333e77ef8a837b595baa18c7 grep VIM_VERSION_M src/version.* With output:: src/version.c:static char *mediumVersion = VIM_VERSION_MEDIUM; src/version.h:#define VIM_VERSION_MAJOR 7 src/version.h:#define VIM_VERSION_MAJOR_STR "7" src/version.h:#define VIM_VERSION_MINOR 3 src/version.h:#define VIM_VERSION_MINOR_STR "3" src/version.h:#define VIM_VERSION_100 (VIM_VERSION_MAJOR * 100 + VIM_VERSION_MINOR) src/version.h: * VIM_VERSION_MEDIUM is used for the startup-screen. src/version.h:#define VIM_VERSION_MEDIUM "7.3a BETA" This indicates version 7.3.x. The patch level is given by the largest number in the ``included_patches[]`` array in ``src/version.c``, findable via grep as well:: grep -A 5 'included_patches\[\]' src/version.c With output:: static int included_patches[] = { /* Add new patch number below this line */ /**/ 0 }; All together, it looks like ``strchars`` was introduced in Vim v7.3.0. Looking at the overall log via ``git log``, this change appears to have been made during the beta period for Vim 7.3, explaining why there is no individual patch number corresponding to the addition of the ``strchars`` function. The closest tag can be found via:: git tag --contains 72597a57b526a8df333e77ef8a837b595baa18c7 with output beginning with:: v7.3 v7.3.001 v7.3.002 Another way to search through Git commit history is via ``git bisect``. This performs a binary search through a range of commits, running a command at each probed version to determine if the commit contains the desired text. To perform a ``git bisect`` operation:: git bisect start git bisect old v7.0 # Or whatever starting point you want. git bisect new HEAD # Or whatever ending point you want. git bisect run sh -c '! git grep -q strchars' The first three commands above setup the bisect operation, marking the starting and ending commits for the range to search. The fourth command starts a loop that performs a binary search through the range. The loop selects a commit to probe, then runs the user-supplied command to determine if the commit is old or new. If the command exits with status==0, the commit is judged to be old, and otherwise the commit is judged to be new. We are testing the commit by running ``git grep strchars`` to search for the ``strchars`` function (using ``-q`` for quiet output). Since ``git grep`` returns status==0 when it successfully finds a match, we need to invert the meaning of the status code, which is why we use ``sh -c '! <the git grep>'`` as the command. Running the above yields output ending in:: 72597a57b526a8df333e77ef8a837b595baa18c7 is the first new commit commit 72597a57b526a8df333e77ef8a837b595baa18c7 Author: Bram Moolenaar <b...@vim.org> Date: Sun Jul 18 15:31:08 2010 +0200 Added strwidth() and strchars() functions. :040000 040000 f914e241611c09b17fdeb5a7910f8000f22c6308 b4e89aaa22df2526168397d90110ee9a5a658de0 M runtime :040000 040000 cbc446e0dbc2e2b20e2251961eb4ff1f10f2ee5b 4ce29cab4483f42b95adafb3f07b62479df7f808 M src bisect run success This technique helps when the commit message doesn't necessarily mention the text you are searching for. Michael Henry -- -- You received this message from the "vim_dev" maillist. Do not top-post! Type your reply below the text you are replying to. For more information, visit http://www.vim.org/maillist.php --- You received this message because you are subscribed to the Google Groups "vim_dev" group. To unsubscribe from this group and stop receiving emails from it, send an email to vim_dev+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/vim_dev/31c267e9-f324-6579-fd45-26f1d2b536a6%40drmikehenry.com.