diff --git a/.editorconfig b/.editorconfig index abd7452a..0ff3c66d 100644 --- a/.editorconfig +++ b/.editorconfig @@ -3,7 +3,19 @@ root = true [*] end_of_line = lf insert_final_newline = true +charset = utf-8 +trim_trailing_whitespace = true + +[{Makefile*,*.mk,*.mk.in}] +indent_style = tab +indent_size = 4 + +[*.m4] +indent_style = space +indent_size = 8 + +[*.md] +trim_trailing_whitespace = false [{vcsh.in,completions/vcsh.*}] indent_style = tab -trim_trailing_whitespace = true diff --git a/LICENSE b/LICENSE.md similarity index 71% rename from LICENSE rename to LICENSE.md index d159169d..0daa0415 100644 --- a/LICENSE +++ b/LICENSE.md @@ -1,14 +1,16 @@ - GNU GENERAL PUBLIC LICENSE - Version 2, June 1991 +GNU General Public License +========================== - Copyright (C) 1989, 1991 Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. +_Version 2, June 1991_ +_Copyright © 1989, 1991 Free Software Foundation, Inc.,_ +_51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA_ - Preamble +Everyone is permitted to copy and distribute verbatim copies +of this license document, but changing it is not allowed. - The licenses for most software are designed to take away your +### Preamble + +The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This @@ -18,56 +20,55 @@ using it. (Some other Free Software Foundation software is covered by the GNU Lesser General Public License instead.) You can apply it to your programs, too. - When we speak of free software, we are referring to freedom, not +When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. - To protect your rights, we need to make restrictions that forbid +To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. - For example, if you distribute copies of such a program, whether +For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. - We protect your rights with two steps: (1) copyright the software, and -(2) offer you this license which gives you legal permission to copy, +We protect your rights with two steps: **(1)** copyright the software, and +**(2)** offer you this license which gives you legal permission to copy, distribute and/or modify the software. - Also, for each author's protection and ours, we want to make certain +Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. - Finally, any free program is threatened constantly by software +Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all. - The precise terms and conditions for copying, distribution and +The precise terms and conditions for copying, distribution and modification follow. - GNU GENERAL PUBLIC LICENSE - TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION +### TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION - 0. This License applies to any program or other work which contains +**0.** This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed -under the terms of this General Public License. The "Program", below, -refers to any such program or work, and a "work based on the Program" +under the terms of this General Public License. The “Program”, below, +refers to any such program or work, and a “work based on the Program” means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in -the term "modification".) Each licensee is addressed as "you". +the term “modification”.) Each licensee is addressed as “you”. Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of @@ -76,7 +77,7 @@ is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does. - 1. You may copy and distribute verbatim copies of the Program's +**1.** You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the @@ -87,29 +88,27 @@ along with the Program. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. - 2. You may modify your copy or copies of the Program or any portion +**2.** You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: - a) You must cause the modified files to carry prominent notices - stating that you changed the files and the date of any change. - - b) You must cause any work that you distribute or publish, that in - whole or in part contains or is derived from the Program or any - part thereof, to be licensed as a whole at no charge to all third - parties under the terms of this License. - - c) If the modified program normally reads commands interactively - when run, you must cause it, when started running for such - interactive use in the most ordinary way, to print or display an - announcement including an appropriate copyright notice and a - notice that there is no warranty (or else, saying that you provide - a warranty) and that users may redistribute the program under - these conditions, and telling the user how to view a copy of this - License. (Exception: if the Program itself is interactive but - does not normally print such an announcement, your work based on - the Program is not required to print an announcement.) +* **a)** You must cause the modified files to carry prominent notices +stating that you changed the files and the date of any change. +* **b)** You must cause any work that you distribute or publish, that in +whole or in part contains or is derived from the Program or any +part thereof, to be licensed as a whole at no charge to all third +parties under the terms of this License. +* **c)** If the modified program normally reads commands interactively +when run, you must cause it, when started running for such +interactive use in the most ordinary way, to print or display an +announcement including an appropriate copyright notice and a +notice that there is no warranty (or else, saying that you provide +a warranty) and that users may redistribute the program under +these conditions, and telling the user how to view a copy of this +License. (Exception: if the Program itself is interactive but +does not normally print such an announcement, your work based on +the Program is not required to print an announcement.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, @@ -131,26 +130,24 @@ with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. - 3. You may copy and distribute the Program (or a work based on it, +**3.** You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following: - a) Accompany it with the complete corresponding machine-readable - source code, which must be distributed under the terms of Sections - 1 and 2 above on a medium customarily used for software interchange; or, - - b) Accompany it with a written offer, valid for at least three - years, to give any third party, for a charge no more than your - cost of physically performing source distribution, a complete - machine-readable copy of the corresponding source code, to be - distributed under the terms of Sections 1 and 2 above on a medium - customarily used for software interchange; or, - - c) Accompany it with the information you received as to the offer - to distribute corresponding source code. (This alternative is - allowed only for noncommercial distribution and only if you - received the program in object code or executable form with such - an offer, in accord with Subsection b above.) +* **a)** Accompany it with the complete corresponding machine-readable +source code, which must be distributed under the terms of Sections +1 and 2 above on a medium customarily used for software interchange; or, +* **b)** Accompany it with a written offer, valid for at least three +years, to give any third party, for a charge no more than your +cost of physically performing source distribution, a complete +machine-readable copy of the corresponding source code, to be +distributed under the terms of Sections 1 and 2 above on a medium +customarily used for software interchange; or, +* **c)** Accompany it with the information you received as to the offer +to distribute corresponding source code. (This alternative is +allowed only for noncommercial distribution and only if you +received the program in object code or executable form with such +an offer, in accord with Subsection b above.) The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source @@ -169,7 +166,7 @@ access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code. - 4. You may not copy, modify, sublicense, or distribute the Program +**4.** You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. @@ -177,7 +174,7 @@ However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. - 5. You are not required to accept this License, since you have not +**5.** You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by @@ -186,7 +183,7 @@ Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it. - 6. Each time you redistribute the Program (or any work based on the +**6.** Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further @@ -194,7 +191,7 @@ restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License. - 7. If, as a consequence of a court judgment or allegation of patent +**7.** If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not @@ -226,7 +223,7 @@ impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. - 8. If the distribution and/or use of the Program is restricted in +**8.** If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding @@ -234,20 +231,20 @@ those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. - 9. The Free Software Foundation may publish revised and/or new versions +**9.** The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program -specifies a version number of this License which applies to it and "any -later version", you have the option of following the terms and conditions +specifies a version number of this License which applies to it and “any +later version”, you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation. - 10. If you wish to incorporate parts of the Program into other free +**10.** If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes @@ -255,19 +252,19 @@ make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. - NO WARRANTY +### NO WARRANTY - 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY +**11.** BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES -PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED +PROVIDE THE PROGRAM “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. - 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +**12.** IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING @@ -277,32 +274,32 @@ YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. - END OF TERMS AND CONDITIONS +END OF TERMS AND CONDITIONS - How to Apply These Terms to Your New Programs +### How to Apply These Terms to Your New Programs - If you develop a new program, and you want it to be of the greatest +If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. - To do so, attach the following notices to the program. It is safest +To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least -the "copyright" line and a pointer to where the full notice is found. +the “copyright” line and a pointer to where the full notice is found. Copyright (C) - + This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. - + This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - + You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. @@ -317,20 +314,20 @@ when it starts in an interactive mode: This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. -The hypothetical commands `show w' and `show c' should show the appropriate +The hypothetical commands `show w` and `show c` should show the appropriate parts of the General Public License. Of course, the commands you use may -be called something other than `show w' and `show c'; they could even be +be called something other than `show w` and `show c`; they could even be mouse-clicks or menu items--whatever suits your program. You should also get your employer (if you work as a programmer) or your -school, if any, to sign a "copyright disclaimer" for the program, if +school, if any, to sign a “copyright disclaimer” for the program, if necessary. Here is a sample; alter the names: - Yoyodyne, Inc., hereby disclaims all copyright interest in the program - `Gnomovision' (which makes passes at compilers) written by James Hacker. - - , 1 April 1989 - Ty Coon, President of Vice + Yoyodyne, Inc., hereby disclaims all copyright interest in the program + `Gnomovision' (which makes passes at compilers) written by James Hacker. + + , 1 April 1989 + Ty Coon, President of Vice This General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may diff --git a/Makefile.am b/Makefile.am index bef699c0..87e69aaa 100644 --- a/Makefile.am +++ b/Makefile.am @@ -8,66 +8,47 @@ ACLOCAL_AMFLAGS = -I build-aux docdir = $(datarootdir)/doc/$(TRANSFORMED_PACKAGE_NAME) licensedir = $(datarootdir)/licenses/$(TRANSFORMED_PACKAGE_NAME) +bin_SCRIPTS = vcsh dist_doc_DATA = changelog doc/INSTALL.md doc/README.md doc/error_codes.md samplehooksdir = $(docdir)/sample_hooks dist_samplehooks_DATA = doc/sample_hooks/post-init-add-origin doc/sample_hooks/post-init-setup-mr doc/sample_hooks/post-merge-unclobber doc/sample_hooks/pre-merge-unclobber -dist_license_DATA = LICENSE CONTRIBUTORS +dist_license_DATA = LICENSE.md CONTRIBUTORS if ENABLE_MAN_PAGE dist_man_MANS = doc/vcsh.1 endif -bin_SCRIPTS = vcsh -EXTRA_DIST = completions/vcsh.bash completions/vcsh.zsh build-aux/git-version-gen build-aux/ax_prog_perl_modules.m4 +EXTRA_DIST = completions/vcsh.bash completions/vcsh.zsh build-aux/ax_prog_perl_modules.m4 EXTRA_DIST += t/000-tear-env.t t/001-setup-env.t t/100-init.t t/300-add.t t/950-delete.t t/999-tear-env.t -BUILT_SOURCES = .version -CLEANFILES = $(BUILT_SOURCES) .version-prev $(dist_man_MANS) $(bin_SCRIPTS) - -if ENABLE_BASH_COMPLETION -bashcompletiondir = $(BASH_COMPLETION_DIR) -nodist_bashcompletion_DATA = completions/$(TRANSFORMED_PACKAGE_NAME) -CLEANFILES += $(nodist_bashcompletion_DATA) -endif +BUILT_SOURCES = +CLEANFILES = $(dist_man_MANS) $(bin_SCRIPTS) -if ENABLE_ZSH_COMPLETION -zshcompletiondir = $(ZSH_COMPLETION_DIR) -nodist_zshcompletion_DATA = completions/_$(TRANSFORMED_PACKAGE_NAME) -CLEANFILES += $(nodist_zshcompletion_DATA) -endif +include $(top_srcdir)/build-aux/git_version.mk +include $(top_srcdir)/build-aux/shell_completion_dirs.mk if !IS_SDIST doc/vcsh.1: doc/vcsh.1.ronn $(RONN) < $< > $@ endif -completions/$(TRANSFORMED_PACKAGE_NAME): completions/vcsh.bash +$(COMPLETIONS_OUT_DIR)/$(TRANSFORMED_PACKAGE_NAME): completions/vcsh.bash mkdir -p $(dir $@) install $< $@ -completions/_$(TRANSFORMED_PACKAGE_NAME): completions/vcsh.zsh +$(COMPLETIONS_OUT_DIR)/_$(TRANSFORMED_PACKAGE_NAME): completions/vcsh.zsh mkdir -p $(dir $@) install $< $@ -.version: $(shell $(AWK) '{print ".git/" $$2}' .git/HEAD 2>/dev/null ||:) - [ -e "$@" ] && mv "$@" "$@-prev" || $(if $<,touch,cp "$(srcdir)/.tarball-version") "$@-prev" - $(if $<,./build-aux/git-version-gen "$(srcdir)/.tarball-version",printf "$(VERSION)") > "$@" - $(CMP) -s "$@" "$@-prev" || autoreconf configure.ac --force - -_CHECKDEPS = check-version - if ENABLE_TESTS -_CHECKDEPS += prove +_CHECKDEPS = prove endif check-local: $(_CHECKDEPS) -installcheck-local: - ./$(TRANSFORMED_PACKAGE_NAME) version +check-version: check-dep-versions -.PHONY: check-version -check-version: vcsh | .version - $(GREP) -Fx '$(VERSION)' $| - ./$< version | $(GREP) -Ff $| +.PHONY: check-dep-versions +check-dep-version: $(PACKAGE_NAME) | .version ./$< version | $(GREP) -Ff <($(GIT) version) .PHONY: prove @@ -85,7 +66,7 @@ lint-editor-config: ec .PHONY: lint-shellheck -lint-shellcheck: vcsh +lint-shellcheck: $(PACKAGE_NAME) shellcheck $< CONTRIBUTORS: @@ -97,6 +78,3 @@ CONTRIBUTORS: changelog-HEAD: changelog sed -nEe '2d;s/^\t//p;/^$$/q;' $< > $@ - -dist-hook: - printf "$(VERSION)" > "$(distdir)/.tarball-version" diff --git a/build-aux/ax_git_version.m4 b/build-aux/ax_git_version.m4 new file mode 100644 index 00000000..b5980783 --- /dev/null +++ b/build-aux/ax_git_version.m4 @@ -0,0 +1,9 @@ +AC_DEFUN([AX_GIT_VERSION], [ + + AC_PROG_AWK + AC_PROG_GREP + AX_PROGVAR([cmp]) + + AX_TRANSFORM_PACKAGE_NAME + +]) diff --git a/build-aux/ax_prog_perl_modules.m4 b/build-aux/ax_prog_perl_modules.m4 index 70b3230e..b13fcf6c 100644 --- a/build-aux/ax_prog_perl_modules.m4 +++ b/build-aux/ax_prog_perl_modules.m4 @@ -38,40 +38,39 @@ AU_ALIAS([AC_PROG_PERL_MODULES], [AX_PROG_PERL_MODULES]) AC_DEFUN([AX_PROG_PERL_MODULES],[dnl m4_define([ax_perl_modules]) -m4_foreach([ax_perl_module], m4_split(m4_normalize([$1])), - [ - m4_append([ax_perl_modules], - [']m4_bpatsubst(ax_perl_module,=,[ ])[' ]) - ]) +m4_foreach([ax_perl_module], m4_split(m4_normalize([$1])), [ + m4_append([ax_perl_modules], + [']m4_bpatsubst(ax_perl_module,=,[ ])[' ]) +]) # Make sure we have perl if test -z "$PERL"; then -AC_CHECK_PROG(PERL,perl,perl) + AC_CHECK_PROG(PERL,perl,perl) fi if test "x$PERL" != x; then - ax_perl_modules_failed=0 - for ax_perl_module in ax_perl_modules; do - AC_MSG_CHECKING(for perl module $ax_perl_module) + ax_perl_modules_failed=0 + for ax_perl_module in ax_perl_modules; do + AC_MSG_CHECKING(for perl module $ax_perl_module) - # Would be nice to log result here, but can't rely on autoconf internals - $PERL -e "use $ax_perl_module; exit" > /dev/null 2>&1 - if test $? -ne 0; then - AC_MSG_RESULT(no); - ax_perl_modules_failed=1 - else - AC_MSG_RESULT(ok); - fi - done + # Would be nice to log result here, but can't rely on autoconf internals + $PERL -e "use $ax_perl_module; exit" > /dev/null 2>&1 + if test $? -ne 0; then + AC_MSG_RESULT(no); + ax_perl_modules_failed=1 + else + AC_MSG_RESULT(ok); + fi + done - # Run optional shell commands - if test "$ax_perl_modules_failed" = 0; then - : - $2 - else - : - $3 - fi + # Run optional shell commands + if test "$ax_perl_modules_failed" = 0; then + : + $2 + else + : + $3 + fi else - AC_MSG_WARN(could not find perl) + AC_MSG_WARN(could not find perl) fi])dnl diff --git a/build-aux/ax_progvar.m4 b/build-aux/ax_progvar.m4 index 131c8061..e584ed4a 100644 --- a/build-aux/ax_progvar.m4 +++ b/build-aux/ax_progvar.m4 @@ -1,5 +1,5 @@ AC_DEFUN([AX_PROGVAR], [ - test -n "$m4_toupper($1)" || { AC_PATH_PROG(m4_toupper($1), m4_default($2,$1)) } - test -n "$m4_toupper($1)" || AC_MSG_ERROR([m4_default($2,$1) is required]) - ]) + test -n "$m4_toupper($1)" || { AC_PATH_PROG(m4_toupper($1), m4_default($2,$1)) } + test -n "$m4_toupper($1)" || AC_MSG_ERROR([m4_default($2,$1) is required]) +]) diff --git a/build-aux/ax_shell_completion_dirs.m4 b/build-aux/ax_shell_completion_dirs.m4 new file mode 100644 index 00000000..2f455be0 --- /dev/null +++ b/build-aux/ax_shell_completion_dirs.m4 @@ -0,0 +1,33 @@ +AC_DEFUN_ONCE([AX_SHELL_COMPLETION_DIRS], [ + + AX_TRANSFORM_PACKAGE_NAME + + AC_ARG_WITH([bash-completion-dir], + AS_HELP_STRING([--with-bash-completion-dir[=PATH]], + [Install the bash auto-completion script in this directory. @<:@default=yes@:>@]), + [], + [with_bash_completion_dir=yes]) + AM_CONDITIONAL([ENABLE_BASH_COMPLETION], + [test "x$with_bash_completion_dir" != "xno"]) + + AM_COND_IF([ENABLE_BASH_COMPLETION], + [PKG_CHECK_MODULES([BASH_COMPLETION], [bash-completion >= 2.0], + [BASH_COMPLETION_DIR="$(pkg-config --define-variable=datadir=$datadir --variable=completionsdir bash-completion)"], + [BASH_COMPLETION_DIR="$datadir/bash-completion/completions"])], + [BASH_COMPLETION_DIR="$with_bash_completion_dir"]) + AC_SUBST([BASH_COMPLETION_DIR]) + + AC_ARG_WITH([zsh-completion-dir], + AS_HELP_STRING([--with-zsh-completion-dir[=PATH]], + [Install the zsh auto-completion script in this directory. @<:@default=yes@:>@]), + [], + [with_zsh_completion_dir=yes]) + AM_CONDITIONAL([ENABLE_ZSH_COMPLETION], + [test "x$with_zsh_completion_dir" != "xno"]) + + AM_COND_IF([ENABLE_ZSH_COMPLETION], + [ZSH_COMPLETION_DIR="$datadir/zsh/site-functions"], + [ZSH_COMPLETION_DIR="$with_zsh_completion_dir"]) + AC_SUBST([ZSH_COMPLETION_DIR]) + +]) diff --git a/build-aux/ax_subst_transformed_package_name.m4 b/build-aux/ax_subst_transformed_package_name.m4 deleted file mode 100644 index a6ae7747..00000000 --- a/build-aux/ax_subst_transformed_package_name.m4 +++ /dev/null @@ -1,5 +0,0 @@ -AC_DEFUN([AX_SUBST_TRANSFORMED_PACKAGE_NAME], [ - AC_PROG_SED - TRANSFORMED_PACKAGE_NAME="$(printf "$PACKAGE_NAME" | $SED -e "$(printf "$program_transform_name" | $SED -e 's/\$\$/\$/')")" - AC_SUBST([TRANSFORMED_PACKAGE_NAME]) -]) diff --git a/build-aux/ax_transform_package_name.m4 b/build-aux/ax_transform_package_name.m4 new file mode 100644 index 00000000..ff53dd93 --- /dev/null +++ b/build-aux/ax_transform_package_name.m4 @@ -0,0 +1,18 @@ +# The autotools supplied AC_ARG_PROGRAM enables renaming operations, but it +# supplies them as a sed operation that can be applied to multiple binaries. +# This isn't convenient to use if we're just renaming the top level package, so +# we go ahead and *do* the transformation and save for use as a substitution. + +AC_DEFUN_ONCE([AX_TRANSFORM_PACKAGE_NAME], [ + + AC_PROG_SED + + TRANSFORMED_PACKAGE_NAME="$(printf "$PACKAGE_NAME" | $SED -e "$(printf "$program_transform_name" | $SED -e 's/\$\$/\$/')")" + AC_SUBST([TRANSFORMED_PACKAGE_NAME]) + + PACKAGE_VAR="$(printf "$PACKAGE_NAME" | $SED -e "s/-/_/g")" + AC_SUBST([PACKAGE_VAR]) + + AC_ARG_PROGRAM + +]) diff --git a/build-aux/git-version-gen b/build-aux/git-version-gen index e2e9a795..b971f41c 100755 --- a/build-aux/git-version-gen +++ b/build-aux/git-version-gen @@ -152,7 +152,7 @@ then # directory, and "git describe" output looks sensible, use that to # derive a version string. elif test "`git log -1 --pretty=format:x . 2>/dev/null`" = x \ - && v=`git describe --tags --abbrev=7 --match="$prefix*" HEAD 2>/dev/null \ + && v=`git describe --tags --abbrev=7 --match="$prefix*\.*\.*" HEAD 2>/dev/null \ || git describe --tags --abbrev=7 HEAD 2>/dev/null \ || git log -1 --pretty=format:'v0-HEAD-%h' 2>/dev/null` \ && v=`printf '%s\n' "$v" | sed "$tag_sed_script"` \ @@ -182,7 +182,7 @@ then ;; esac - v=`echo "$v" | sed 's/-\([0-9]\)/.r\1/'`; + v=`echo "$v" | sed 's/-\([0-9]\)/.r\1/'`; v_from_git=1 else v=UNKNOWN diff --git a/build-aux/git_version.mk b/build-aux/git_version.mk new file mode 100644 index 00000000..58e16119 --- /dev/null +++ b/build-aux/git_version.mk @@ -0,0 +1,37 @@ +.SECONDEXPANSION: + +# EXTRA_@PACKAGE_VAR@_SOURCES += .version +EXTRA_DIST += build-aux/git-version-gen +BUILT_SOURCES += .version +CLEANFILES += .version .version-prev + +_BRANCH_REF != $(AWK) '{print ".git/" $$2}' .git/HEAD 2>/dev/null ||: +.version: $(_BRANCH_REF) + @if [ -e "$(srcdir)/.tarball-version" ]; then \ + printf "$(VERSION)" > $@; \ + else \ + touch "$@-prev"; \ + if [ -e "$@" ]; then \ + cp "$@" "$@-prev"; \ + fi; \ + ./build-aux/git-version-gen "$(srcdir)/.tarball-version" > $@; \ + $(CMP) -s "$@" "$@-prev" || autoreconf configure.ac --force; \ + fi + +check-version: check-git-version + +.PHONY: check-git-version +check-git-version: $(PACKAGE_NAME)$(EXEEXT) | .version + $(GREP) -Fx '$(VERSION)' $| + ./$< --version | $(GREP) -Ff $| + +installcheck-local-version: + ./$(TRANSFORMED_PACKAGE_NAME)$(EXEEXT) --version + +dist-hook: dist-tarball-version + +.PHONY: dist-tarball-version +dist-tarball-version: + printf "$(VERSION)" > "$(distdir)/.tarball-version" + +# vim: ft=automake diff --git a/build-aux/shell_completion_dirs.mk b/build-aux/shell_completion_dirs.mk new file mode 100644 index 00000000..1f52ea7c --- /dev/null +++ b/build-aux/shell_completion_dirs.mk @@ -0,0 +1,21 @@ +COMPLETIONS_OUT_DIR = completions + +if ENABLE_BASH_COMPLETION +bashcompletiondir = $(BASH_COMPLETION_DIR) +nodist_bashcompletion_DATA = $(COMPLETIONS_OUT_DIR)/$(TRANSFORMED_PACKAGE_NAME) +CLEANFILES += $(nodist_bashcompletion_DATA) +endif + +# if ENABLE_FISH_COMPLETION +# fishcompletiondir = $(FISH_COMPLETION_DIR) +# nodist_fishcompletion_DATA = $(COMPLETIONS_OUT_DIR)/$(TRANSFORMED_PACKAGE_NAME).fish +# CLEANFILES += $(nodist_fishcompletion_DATA) +# endif + +if ENABLE_ZSH_COMPLETION +zshcompletiondir = $(ZSH_COMPLETION_DIR) +nodist_zshcompletion_DATA = $(COMPLETIONS_OUT_DIR)/_$(TRANSFORMED_PACKAGE_NAME) +CLEANFILES += $(nodist_zshcompletion_DATA) +endif + +# vim: ft=automake diff --git a/configure.ac b/configure.ac index e3b91964..5c31ad71 100644 --- a/configure.ac +++ b/configure.ac @@ -1,9 +1,13 @@ AC_PREREQ([2.69]) AC_INIT([vcsh], [m4_esyscmd(build-aux/git-version-gen .tarball-version)]) AC_CONFIG_AUX_DIR([build-aux]) +AC_CONFIG_MACRO_DIR([build-aux]) AM_INIT_AUTOMAKE([foreign tar-pax dist-xz dist-zip no-dist-gzip color-tests]) AM_SILENT_RULES([yes]) -AC_CONFIG_MACRO_DIR([build-aux]) + +AX_GIT_VERSION +AX_TRANSFORM_PACKAGE_NAME +AX_SHELL_COMPLETION_DIRS AM_CONDITIONAL([IS_SDIST], [test ! -e .gitignore]) @@ -25,12 +29,10 @@ AC_ARG_WITH([standalone], ], []) -AC_PROG_AWK AC_PROG_GREP AC_PROG_SED AX_PROGVAR([comm]) -AX_PROGVAR([cmp]) AX_PROGVAR([git]) AX_PROGVAR([wc]) @@ -74,38 +76,8 @@ AM_COND_IF([ENABLE_TESTS], [ AC_MSG_ERROR(Perl module required for testing not found)) ]) -AC_ARG_WITH([bash-completion-dir], - AS_HELP_STRING([--with-bash-completion-dir[=PATH]], - [Install bash auto-completion definitions to a directory. @<:@default=yes@:>@]), - [], - [with_bash_completion_dir=yes]) -AM_CONDITIONAL([ENABLE_BASH_COMPLETION], - [test x"$with_bash_completion_dir" != x"no"]) -AM_COND_IF([ENABLE_BASH_COMPLETION], - [PKG_CHECK_MODULES([BASH_COMPLETION], [bash-completion >= 2.0], - [BASH_COMPLETION_DIR="$(pkg-config --define-variable=datadir=$datadir --variable=completionsdir bash-completion)"], - [BASH_COMPLETION_DIR="$datadir/bash-completion/completions"])], - [BASH_COMPLETION_DIR="$with_bash_completion_dir"]) -AC_SUBST([BASH_COMPLETION_DIR]) - -AC_ARG_WITH([zsh-completion-dir], - AS_HELP_STRING([--with-zsh-completion-dir[=PATH]], - [Install zsh auto-completion definitions to a directory. @<:@default=yes@:>@]), - [], - [with_zsh_completion_dir=yes]) -AM_CONDITIONAL([ENABLE_ZSH_COMPLETION], - [test x"$with_zsh_completion_dir" != x"no"]) -AM_COND_IF([ENABLE_ZSH_COMPLETION], - [ZSH_COMPLETION_DIR="$datadir/zsh/site-functions"], - [ZSH_COMPLETION_DIR="$with_zsh_completion_dir"]) -AC_SUBST([ZSH_COMPLETION_DIR]) - -AX_SUBST_TRANSFORMED_PACKAGE_NAME - AC_CONFIG_FILES([Makefile]) AC_CONFIG_FILES([vcsh], [chmod +x vcsh]) AC_CONFIG_FILES([doc/vcsh.1.ronn]) -AC_ARG_PROGRAM - AC_OUTPUT diff --git a/doc/sample_hooks/pre-merge-unclobber b/doc/sample_hooks/pre-merge-unclobber index 52610962..5d566e54 100755 --- a/doc/sample_hooks/pre-merge-unclobber +++ b/doc/sample_hooks/pre-merge-unclobber @@ -7,5 +7,5 @@ # the now-renamed files. for object in $(git ls-tree -r origin/master | awk '{print $4}'); do - [ -e "$object" ] && mv "$object" "$object.vcsh-unclobber" + [ -e "$object" ] && mv "$object" "$object.vcsh-unclobber" done diff --git a/vcsh.in b/vcsh.in index 8a2c0203..aa44c978 100755 --- a/vcsh.in +++ b/vcsh.in @@ -1,21 +1,16 @@ #!@SHELL@ - -# This program is licensed under the GNU GPL version 2 or later. -# (c) Richard "RichiH" Hartmann , 2011-2015 -# For details, see LICENSE. To submit patches, you have to agree to -# license your code under the GNU GPL version 2 or later. - -# While the following is not legally binding, the author would like to -# explain the choice of GPLv2+ over GPLv3+. -# The author prefers GPLv3+ over GPLv2+ but feels it's better to maintain -# full compatibility's with Git. In case Git ever changes its licensing terms, -# which is admittedly extremely unlikely to the point of being impossible, -# this software will most likely follow suit. +# Copyright (C) 2011-2015 Richard "RichiH" Hartmann , see CONTRIBUTORS for details. +# SPDX-License-Identifier: GPL-2.0-or-later +# +# While the following is not legally binding, the author would like to explain +# the choice of GPLv2+ over GPLv3+. The author prefers GPLv3+ over GPLv2+ but +# feels it's better to maintain full compatibility's with Git. In case Git ever +# changes its licensing terms, which is admittedly extremely unlikely to the +# point of being impossible, this software will most likely follow suit. # This should always be the first line of code to facilitate debugging [ -n "$VCSH_DEBUG" ] && set -vx - # If '.r-g' is appended to the version, you are seeing an unreleased # version built from the main branch HEAD. If "-standalone" is appended you are # using a version built explicitly for portability as a standalone script