From 2ce3ab5e522ea59e687b3668f22447d0fe46e2ca Mon Sep 17 00:00:00 2001 From: Richard Hartmann Date: Wed, 13 Feb 2013 22:56:39 +0100 Subject: [PATCH 001/121] Unigore vcsh.1 --- .gitignore | 1 - 1 file changed, 1 deletion(-) diff --git a/.gitignore b/.gitignore index 7567c757..06623cf1 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,3 @@ -vcsh.1 *.patch *.swp *.bak From 8b578a590656adf6c62d9f5cf42f8cbec7f971d5 Mon Sep 17 00:00:00 2001 From: Richard Hartmann Date: Wed, 13 Feb 2013 22:57:05 +0100 Subject: [PATCH 002/121] Add static manpage to ease homebrew packaging --- vcsh.1 | 283 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 283 insertions(+) create mode 100644 vcsh.1 diff --git a/vcsh.1 b/vcsh.1 new file mode 100644 index 00000000..d1c2d306 --- /dev/null +++ b/vcsh.1 @@ -0,0 +1,283 @@ +.\" generated with Ronn/v0.7.3 +.\" http://github.com/rtomayko/ronn/tree/0.7.3 +. +.TH "VCSH" "1" "February 2013" "" "" +. +.SH "NAME" +\fBvcsh\fR \- manage config files in $HOME via fake bare git repositories +. +.SH "SYNOPSIS" +\fBvcsh\fR [\fIoptions\fR] \fIcommand\fR +. +.P +\fBvcsh\fR clone \fIurl\fR [\fIrepo\fR] +. +.P +\fBvcsh\fR delete \fIrepo\fR +. +.P +\fBvcsh\fR enter \fIrepo\fR +. +.P +\fBvcsh\fR help +. +.P +\fBvcsh\fR init \fIrepo\fR +. +.P +\fBvcsh\fR list +. +.P +\fBvcsh\fR list\-tracked +. +.P +\fBvcsh\fR list\-tracked\-by \fIrepo\fR +. +.P +\fBvcsh\fR rename \fIrepo\fR \fInewname\fR +. +.P +\fBvcsh\fR run \fIrepo\fR \fIshell command\fR +. +.P +\fBvcsh\fR setup \fIrepo\fR +. +.P +\fBvcsh\fR which \fIsubstring\fR +. +.P +\fBvcsh\fR write\-gitignore \fIrepo\fR +. +.P +\fBvcsh\fR \fIrepo\fR \fIgit command\fR +. +.P +\fBvcsh\fR \fIrepo\fR +. +.SH "DESCRIPTION" +\fBvcsh\fR allows you to have several \fBgit\fR(1) repositories, all maintaining their working trees in $HOME without clobbering each other\. That, in turn, means you can have one repository per config set (zsh, vim, ssh, etc), picking and choosing which configs you want to use on which machine\. +. +.P +\fBvcsh\fR is using a technique called fake bare git repositories, keeping \fI$GIT_DIR\fR in a different directory from \fI$GIT_WORK_TREE\fR which is pointed to \fI$HOME\fR\. +. +.P +The use of symlinks is not needed in this setup, making for a cleaner setup\. +. +.P +\fBvcsh\fR was designed with \fBmr\fR(1) in mind so you might want to install it alongside vcsh\. That being said, you can easily use \fBvcsh\fR without \fBmr\fR if you prefer\. +. +.P +A sample configuration for \fBvcsh\fR and \fBmr\fR can be found at \fIhttps://github\.com/RichiH/vcsh_mr_template\fR and used with \fBvcsh clone https://github\.com/RichiH/vcsh_mr_template mr\fR\. +. +.P +Please note that you can always use a path instead of a name for \fIrepo\fR\. This is needed to support mr and other scripts properly and of no concern to an interactive user\. +. +.SH "OPTIONS" +. +.TP +\-c +Source \fIfile\fR prior to other configuration files +. +.TP +\-d +Enable debug mode +. +.TP +\-v +Enable verbose mode +. +.SH "COMMANDS" +. +.TP +clone +Clone an existing repository\. +. +.TP +delete +Delete an existing repository\. +. +.TP +enter +Enter repository; spawn new \fI$SHELL\fR\. +. +.TP +help +Display help\. +. +.TP +init +Initialize an empty repository\. +. +.TP +list +List all local vcsh repositories\. +. +.TP +list\-tracked +List all files tracked by vcsh\. +. +.TP +list\-tracked\-by +List files tracked by a repository\. +. +.TP +rename +Rename a repository\. +. +.TP +run +Run command with \fI$GIT_DIR\fR and \fI$GIT_WORK_TREE\fR set\. Allows you to run any and all commands without any restrictions\. Use with care\. +. +.IP +Please note that there is a somewhat magic feature for run\. Instead of \fIrepo\fR it accepts \fIpath\fR, as well\. Anything that has a slash in it will be assumed to be a path\. \fBvcsh run\fR will then operate on this directory instead of the one normally generated from the repository\'s name\. This is needed to support mr and other scripts properly and of no concern to an interactive user\. +. +.TP +setup +Set up repository with recommended settings\. +. +.TP +which \fIsubstring\fR +Find \fIsubstring\fR in name of any tracked file\. +. +.TP +write\-gitignore +Write \.gitignore\.d/\fIrepo\fR via git ls\-files\. +. +.TP +\fIrepo\fR \fIgitcommand\fR +Shortcut to run \fBvcsh\fR on a repo\. Will prepend \fBgit\fR to \fIcommand\fR\. +. +.TP +\fIrepo\fR +Shortcut to run \fBvcsh enter \fR\. +. +.SH "ENVIRONMENT" +As noted earlier, \fBvcsh\fR will set \fI$GIT_DIR\fR and \fI$GIT_WORK_TREE\fR to the appropriate values for fake bare git repositories\. +. +.SH "CONFIG" +There are several ways to turn the various knobs on \fBvcsh\fR\. In order of ascending precedence, they are: +. +.IP "\(bu" 4 +\fBVARIABLE=foo vcsh\fR +. +.IP "\(bu" 4 + +. +.IP "\(bu" 4 +<$XDG_CONFIG_HOME/vcsh/config> +. +.IP "\(bu" 4 +\fBvcsh \-c \fR +. +.IP "" 0 +. +.P +Please note that those files are sourced\. Any and all commands will be executed in the context of your shell\. +. +.P +Interesting knobs you can turn: +. +.TP +\fI$VCSH_GITIGNORE\fR +Can be either \fIexact\fR or \fIrecursive\fR\. +. +.IP +\fIexact\fR will seed the repo\-specific <\.gitignore> with all file and directory names which \fBgit ls\-files\fR returns\. +. +.IP +\fIrecursive\fR will descend through all directories recursively additionally to the above\. +. +.IP +Defaults to \fIexact\fR\. +. +.P +Less interesting knobs you could turn: +. +.TP +\fI$VCSH_DEBUG\fR +Enter debug mode\. +. +.TP +\fI$XDG_CONFIG_HOME\fR +As specified in the \'XDG Base Directory Specification\', see \fIhttp://standards\.freedesktop\.org/basedir\-spec/basedir\-spec\-latest\.html\fR +. +.IP +Defaults to <$HOME/\.config>\. +. +.TP +\fI$VCSH_REPO_D\fR +The directory where repositories are read from and stored\. +. +.IP +Defaults to <$XDG_CONFIG_HOME/vcsh/repo\.d>\. +. +.TP +\fI$VCSH_HOOK_D\fR +The directory where hooks are read from\. +. +.IP +Defaults to <$XDG_CONFIG_HOME/vcsh/hooks\-enabled>\. +. +.TP +\fI$VCSH_BASE\fR +The directory where repositories are checked out to\. +. +.IP +Defaults to \fI$HOME\fR\. +. +.SH "HOOK SYSTEM" +\fBvcsh\fR provides a hook system\. Hook scripts must be executable and should be placed in <$XDG_CONFIG_HOME/vcsh/hooks\-available>\. From there, they can be soft\-linked into <$XDG_CONFIG_HOME/vcsh/hooks\-enabled>; \fBvcsh\fR will only execute hooks that are in this directory\. +. +.P +Hooks follow a simple format\. \fIpre\-run\fR will be run before anything is run\. If you want to have more than one script for a certain hook, just append any kind of string to order them\. A system of \fIpre\-run\fR, , etc is suggested; other options would be \fIpre\-run\-10\fR or \. A dot after the hook name is optional\. +. +.P +If you want to create hooks for a specific \fIvcsh\fR repository, simply prepend the repository\'s name, followed by a dot, i\.e\. \. Otherwise, the same rules as above apply\. The dot between the repository\'s name and the hook is mandatory, though\. +. +.P +Available hooks are \fIpre\-enter\fR, \fIpost\-enter\fR, \fIpre\-run\fR, \fIpost\-run\fR, \fIpre\-setup\fR, and \fIpost\-setup\fR\. If you need more, vcsh is trivial to patch, but please let upstream know so we can ship them by default\. +. +.SH "DETAILED HOWTO AND FURTHER READING" +Manpages are often short and sometimes useless to glean best practices from\. While the author tried to avoid this in this case, manpages can not cover detailed howtos\. +. +.P +This software also comes with a file called \. It contains various approaches to setting up and using vcsh\. You can view the file it as plain text or render it into various other formats via Markdown\. +. +.P +On Debian\-based systems, this file can be found in \. +. +.SH "SECURITY CONSIDERATIONS" +\fBvcsh\fR allows you to execute arbitrary commands via \fBvcsh run\fR\. For example, adding a \fBsudo\fR(8) rule for \fBvcsh\fR would be pretty stupid\. +. +.P +Additionally, vcsh will source, i\.e\. execute, all files listed in \fICONFIG\fR\. You can put any and all commands into these config files and they will be executed\. +. +.SH "BUGS" +None are known at this time, but reports and/or patches are more than welcome\. +. +.SH "INTEROPERABILITY" +If you rely on \fBgit submodule\fR, use \fBgit\fR 1\.7\.12 or later\. Earlier versions do not clean internal variables properly before descending into a submodule\. +. +.SH "HISTORY" +Like most people, the author initially made do with a single repository for all config files, all of which were soft\-linked into \fI$HOME\fR\. +. +.P +Martin F\. Krafft aka madduck came up with the concept of fake bare git repositories\. +. +.P +vcsh was initally written by madduck\. This version is a re\-implementation from scratch with a lot more features\. madduck graciously agreed to let the author take over the name\. +. +.SH "AUTHOR" +This manpage and \fBvcsh\fR itself were written by Richard "RichiH" Hartmann\. +. +.SH "COPYRIGHT" +Copyright 2011\-2012 Richard Hartmann \fIrichih\.mailinglist@gmail\.com\fR +. +.P +Licensed under the GNU GPL version 2 or higher\. +. +.P +https://github\.com/RichiH/vcsh +. +.SH "SEE ALSO" +\fBgit\fR(1), \fBmr\fR(1) From d83ea2c8a6f71728c96828b6d4c042a2398214c0 Mon Sep 17 00:00:00 2001 From: Richard Hartmann Date: Sun, 21 Apr 2013 02:35:16 +0200 Subject: [PATCH 003/121] Update static manpage --- vcsh.1 | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/vcsh.1 b/vcsh.1 index d1c2d306..21f011c4 100644 --- a/vcsh.1 +++ b/vcsh.1 @@ -1,7 +1,7 @@ .\" generated with Ronn/v0.7.3 .\" http://github.com/rtomayko/ronn/tree/0.7.3 . -.TH "VCSH" "1" "February 2013" "" "" +.TH "VCSH" "1" "April 2013" "" "" . .SH "NAME" \fBvcsh\fR \- manage config files in $HOME via fake bare git repositories @@ -43,6 +43,9 @@ \fBvcsh\fR setup \fIrepo\fR . .P +\fBvcsh\fR version +. +.P \fBvcsh\fR which \fIsubstring\fR . .P @@ -136,6 +139,10 @@ setup Set up repository with recommended settings\. . .TP +version +Print version information\. +. +.TP which \fIsubstring\fR Find \fIsubstring\fR in name of any tracked file\. . @@ -256,7 +263,7 @@ Additionally, vcsh will source, i\.e\. execute, all files listed in \fICONFIG\fR None are known at this time, but reports and/or patches are more than welcome\. . .SH "INTEROPERABILITY" -If you rely on \fBgit submodule\fR, use \fBgit\fR 1\.7\.12 or later\. Earlier versions do not clean internal variables properly before descending into a submodule\. +If you rely on \fBgit submodule\fR use \fBgit\fR 1\.7\.12 or later\. Earlier versions do not clean internal variables properly before descending into submodules, resulting in unhappy end users\. . .SH "HISTORY" Like most people, the author initially made do with a single repository for all config files, all of which were soft\-linked into \fI$HOME\fR\. From 13f9aa52ae4f879854c857e8fd0f3b31adee869f Mon Sep 17 00:00:00 2001 From: Richard Hartmann Date: Mon, 27 May 2013 23:46:28 +0200 Subject: [PATCH 004/121] Update static manpage --- vcsh.1 | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/vcsh.1 b/vcsh.1 index 21f011c4..1d91f591 100644 --- a/vcsh.1 +++ b/vcsh.1 @@ -1,10 +1,10 @@ .\" generated with Ronn/v0.7.3 .\" http://github.com/rtomayko/ronn/tree/0.7.3 . -.TH "VCSH" "1" "April 2013" "" "" +.TH "VCSH" "1" "May 2013" "" "" . .SH "NAME" -\fBvcsh\fR \- manage config files in $HOME via fake bare git repositories +\fBvcsh\fR \- manage config files in $HOME via fake bare Git repositories . .SH "SYNOPSIS" \fBvcsh\fR [\fIoptions\fR] \fIcommand\fR @@ -40,7 +40,7 @@ \fBvcsh\fR run \fIrepo\fR \fIshell command\fR . .P -\fBvcsh\fR setup \fIrepo\fR +\fBvcsh\fR upgrade \fIrepo\fR . .P \fBvcsh\fR version @@ -61,7 +61,7 @@ \fBvcsh\fR allows you to have several \fBgit\fR(1) repositories, all maintaining their working trees in $HOME without clobbering each other\. That, in turn, means you can have one repository per config set (zsh, vim, ssh, etc), picking and choosing which configs you want to use on which machine\. . .P -\fBvcsh\fR is using a technique called fake bare git repositories, keeping \fI$GIT_DIR\fR in a different directory from \fI$GIT_WORK_TREE\fR which is pointed to \fI$HOME\fR\. +\fBvcsh\fR is using a technique called fake bare Git repositories, keeping \fI$GIT_DIR\fR in a different directory from \fI$GIT_WORK_TREE\fR which is pointed to \fI$HOME\fR\. . .P The use of symlinks is not needed in this setup, making for a cleaner setup\. @@ -135,8 +135,8 @@ Run command with \fI$GIT_DIR\fR and \fI$GIT_WORK_TREE\fR set\. Allows you to run Please note that there is a somewhat magic feature for run\. Instead of \fIrepo\fR it accepts \fIpath\fR, as well\. Anything that has a slash in it will be assumed to be a path\. \fBvcsh run\fR will then operate on this directory instead of the one normally generated from the repository\'s name\. This is needed to support mr and other scripts properly and of no concern to an interactive user\. . .TP -setup -Set up repository with recommended settings\. +upgrade +Upgrade repository to currently recommended settings\. . .TP version @@ -148,7 +148,7 @@ Find \fIsubstring\fR in name of any tracked file\. . .TP write\-gitignore -Write \.gitignore\.d/\fIrepo\fR via git ls\-files\. +Write \.gitignore\.d/\fIrepo\fR via \fBgit ls\-files\fR\. . .TP \fIrepo\fR \fIgitcommand\fR @@ -159,7 +159,7 @@ Shortcut to run \fBvcsh\fR on a repo\. Will prepend \fBgit\fR to \fIcommand\fR\. Shortcut to run \fBvcsh enter \fR\. . .SH "ENVIRONMENT" -As noted earlier, \fBvcsh\fR will set \fI$GIT_DIR\fR and \fI$GIT_WORK_TREE\fR to the appropriate values for fake bare git repositories\. +As noted earlier, \fBvcsh\fR will set \fI$GIT_DIR\fR and \fI$GIT_WORK_TREE\fR to the appropriate values for fake bare Git repositories\. . .SH "CONFIG" There are several ways to turn the various knobs on \fBvcsh\fR\. In order of ascending precedence, they are: @@ -242,7 +242,7 @@ Hooks follow a simple format\. \fIpre\-run\fR will be run before anything is run If you want to create hooks for a specific \fIvcsh\fR repository, simply prepend the repository\'s name, followed by a dot, i\.e\. \. Otherwise, the same rules as above apply\. The dot between the repository\'s name and the hook is mandatory, though\. . .P -Available hooks are \fIpre\-enter\fR, \fIpost\-enter\fR, \fIpre\-run\fR, \fIpost\-run\fR, \fIpre\-setup\fR, and \fIpost\-setup\fR\. If you need more, vcsh is trivial to patch, but please let upstream know so we can ship them by default\. +Available hooks are \fIpre\-enter\fR, \fIpost\-enter\fR, \fIpre\-run\fR, \fIpost\-run\fR, \fIpre\-upgrade\fR, and \fIpost\-upgrade\fR\. If you need more, vcsh is trivial to patch, but please let upstream know so we can ship them by default\. . .SH "DETAILED HOWTO AND FURTHER READING" Manpages are often short and sometimes useless to glean best practices from\. While the author tried to avoid this in this case, manpages can not cover detailed howtos\. @@ -269,7 +269,7 @@ If you rely on \fBgit submodule\fR use \fBgit\fR 1\.7\.12 or later\. Earlier ver Like most people, the author initially made do with a single repository for all config files, all of which were soft\-linked into \fI$HOME\fR\. . .P -Martin F\. Krafft aka madduck came up with the concept of fake bare git repositories\. +Martin F\. Krafft aka madduck came up with the concept of fake bare Git repositories\. . .P vcsh was initally written by madduck\. This version is a re\-implementation from scratch with a lot more features\. madduck graciously agreed to let the author take over the name\. From 6345c7ee65b51cea2aca031b9aa3e75e0b450095 Mon Sep 17 00:00:00 2001 From: Richard Hartmann Date: Wed, 24 Jul 2013 00:59:33 +0200 Subject: [PATCH 005/121] Update static manpage --- vcsh.1 | 30 +++++++++++++++++++++++++----- 1 file changed, 25 insertions(+), 5 deletions(-) diff --git a/vcsh.1 b/vcsh.1 index 1d91f591..808b9488 100644 --- a/vcsh.1 +++ b/vcsh.1 @@ -1,10 +1,10 @@ .\" generated with Ronn/v0.7.3 .\" http://github.com/rtomayko/ronn/tree/0.7.3 . -.TH "VCSH" "1" "May 2013" "" "" +.TH "VCSH" "1" "July 2013" "" "" . .SH "NAME" -\fBvcsh\fR \- manage config files in $HOME via fake bare Git repositories +\fBvcsh\fR \- Version Control System for $HOME \- multiple Git repositories in $HOME . .SH "SYNOPSIS" \fBvcsh\fR [\fIoptions\fR] \fIcommand\fR @@ -34,6 +34,12 @@ \fBvcsh\fR list\-tracked\-by \fIrepo\fR . .P +\fBvcsh\fR pull +. +.P +\fBvcsh\fR push +. +.P \fBvcsh\fR rename \fIrepo\fR \fInewname\fR . .P @@ -95,6 +101,9 @@ Enable verbose mode clone Clone an existing repository\. . +.IP +If you need to clone a bundle of repositories, look into the \fBpost\-clone\-retired\fR hook\. +. .TP delete Delete an existing repository\. @@ -124,6 +133,14 @@ list\-tracked\-by List files tracked by a repository\. . .TP +pull +Pull from all vcsh remotes\. +. +.TP +push +Push to all vcsh remotes\. +. +.TP rename Rename a repository\. . @@ -186,15 +203,18 @@ Interesting knobs you can turn: . .TP \fI$VCSH_GITIGNORE\fR -Can be either \fIexact\fR or \fIrecursive\fR\. +Can be \fIexact\fR, \fIrecursive\fR, or \fInone\fR\. . .IP -\fIexact\fR will seed the repo\-specific <\.gitignore> with all file and directory names which \fBgit ls\-files\fR returns\. +\fIexact\fR will seed the repo\-specific ignore file with all file and directory names which \fBgit ls\-files\fR returns\. . .IP \fIrecursive\fR will descend through all directories recursively additionally to the above\. . .IP +\fInone\fR will not write any ignore file\. +. +.IP Defaults to \fIexact\fR\. . .P @@ -278,7 +298,7 @@ vcsh was initally written by madduck\. This version is a re\-implementation from This manpage and \fBvcsh\fR itself were written by Richard "RichiH" Hartmann\. . .SH "COPYRIGHT" -Copyright 2011\-2012 Richard Hartmann \fIrichih\.mailinglist@gmail\.com\fR +Copyright 2011\-2013 Richard Hartmann \fIrichih\.mailinglist@gmail\.com\fR . .P Licensed under the GNU GPL version 2 or higher\. From d37b586b619502ee046382a9e1d3e8ff10eabdf1 Mon Sep 17 00:00:00 2001 From: Richard Hartmann Date: Wed, 24 Jul 2013 22:39:13 +0200 Subject: [PATCH 006/121] Update static manpage --- vcsh.1 | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/vcsh.1 b/vcsh.1 index 808b9488..5ed7ab9d 100644 --- a/vcsh.1 +++ b/vcsh.1 @@ -46,6 +46,9 @@ \fBvcsh\fR run \fIrepo\fR \fIshell command\fR . .P +\fBvcsh\fR status +. +.P \fBvcsh\fR upgrade \fIrepo\fR . .P @@ -152,6 +155,10 @@ Run command with \fI$GIT_DIR\fR and \fI$GIT_WORK_TREE\fR set\. Allows you to run Please note that there is a somewhat magic feature for run\. Instead of \fIrepo\fR it accepts \fIpath\fR, as well\. Anything that has a slash in it will be assumed to be a path\. \fBvcsh run\fR will then operate on this directory instead of the one normally generated from the repository\'s name\. This is needed to support mr and other scripts properly and of no concern to an interactive user\. . .TP +status +Show statuses of all vcsh repositories\. +. +.TP upgrade Upgrade repository to currently recommended settings\. . @@ -203,16 +210,16 @@ Interesting knobs you can turn: . .TP \fI$VCSH_GITIGNORE\fR -Can be \fIexact\fR, \fIrecursive\fR, or \fInone\fR\. +Can be \fIexact\fR, \fInone\fR, or \fIrecursive\fR\. . .IP \fIexact\fR will seed the repo\-specific ignore file with all file and directory names which \fBgit ls\-files\fR returns\. . .IP -\fIrecursive\fR will descend through all directories recursively additionally to the above\. +\fInone\fR will not write any ignore file\. . .IP -\fInone\fR will not write any ignore file\. +\fIrecursive\fR will descend through all directories recursively additionally to the above\. . .IP Defaults to \fIexact\fR\. From 0a920fe28be455363213f9c752735f61c6898c98 Mon Sep 17 00:00:00 2001 From: Richard Hartmann Date: Thu, 29 Aug 2013 22:52:23 +0200 Subject: [PATCH 007/121] Update static manpage --- vcsh.1 | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/vcsh.1 b/vcsh.1 index 5ed7ab9d..cbfe9c9a 100644 --- a/vcsh.1 +++ b/vcsh.1 @@ -1,7 +1,7 @@ .\" generated with Ronn/v0.7.3 .\" http://github.com/rtomayko/ronn/tree/0.7.3 . -.TH "VCSH" "1" "July 2013" "" "" +.TH "VCSH" "1" "August 2013" "" "" . .SH "NAME" \fBvcsh\fR \- Version Control System for $HOME \- multiple Git repositories in $HOME @@ -46,7 +46,7 @@ \fBvcsh\fR run \fIrepo\fR \fIshell command\fR . .P -\fBvcsh\fR status +\fBvcsh\fR status [\fIrepo\fR] . .P \fBvcsh\fR upgrade \fIrepo\fR @@ -108,6 +108,10 @@ Clone an existing repository\. If you need to clone a bundle of repositories, look into the \fBpost\-clone\-retired\fR hook\. . .TP +commit +Commit in all repositories +. +.TP delete Delete an existing repository\. . @@ -156,7 +160,7 @@ Please note that there is a somewhat magic feature for run\. Instead of \fIrepo\ . .TP status -Show statuses of all vcsh repositories\. +Show statuses of all/one vcsh repositories\. . .TP upgrade @@ -269,7 +273,7 @@ Hooks follow a simple format\. \fIpre\-run\fR will be run before anything is run If you want to create hooks for a specific \fIvcsh\fR repository, simply prepend the repository\'s name, followed by a dot, i\.e\. \. Otherwise, the same rules as above apply\. The dot between the repository\'s name and the hook is mandatory, though\. . .P -Available hooks are \fIpre\-enter\fR, \fIpost\-enter\fR, \fIpre\-run\fR, \fIpost\-run\fR, \fIpre\-upgrade\fR, and \fIpost\-upgrade\fR\. If you need more, vcsh is trivial to patch, but please let upstream know so we can ship them by default\. +Available hooks are \fIpre\-clone\fR, \fIpost\-clone\fR, \fIpost\-clone\-retired\fR, \fIpre\-command\fR, \fIpost\-command\fR, \fIpre\-enter\fR, \fIpost\-enter\fR, \fIpre\-init\fR, \fIpost\-init\fR, \fIpre\-pull\fR, \fIpost\-pull\fR, \fIpre\-push\fR, \fIpost\-push\fR, \fIpre\-run\fR, \fIpost\-run\fR, \fIpre\-upgrade\fR, and \fIpost\-upgrade\fR\. If you need more, vcsh is trivial to patch, but please let upstream know so we can ship them by default\. . .SH "DETAILED HOWTO AND FURTHER READING" Manpages are often short and sometimes useless to glean best practices from\. While the author tried to avoid this in this case, manpages can not cover detailed howtos\. @@ -305,7 +309,7 @@ vcsh was initally written by madduck\. This version is a re\-implementation from This manpage and \fBvcsh\fR itself were written by Richard "RichiH" Hartmann\. . .SH "COPYRIGHT" -Copyright 2011\-2013 Richard Hartmann \fIrichih\.mailinglist@gmail\.com\fR +Copyright 2011\-2013 Richard Hartmann \fIrichih@debian\.org\fR . .P Licensed under the GNU GPL version 2 or higher\. From 0b2183507e42e2d63d3aad27f5e26a415ebac50e Mon Sep 17 00:00:00 2001 From: Richard Hartmann Date: Sat, 14 Dec 2013 00:50:25 +0100 Subject: [PATCH 008/121] Update static manpage --- vcsh.1 | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/vcsh.1 b/vcsh.1 index cbfe9c9a..9f8558e6 100644 --- a/vcsh.1 +++ b/vcsh.1 @@ -1,7 +1,7 @@ .\" generated with Ronn/v0.7.3 .\" http://github.com/rtomayko/ronn/tree/0.7.3 . -.TH "VCSH" "1" "August 2013" "" "" +.TH "VCSH" "1" "December 2013" "" "" . .SH "NAME" \fBvcsh\fR \- Version Control System for $HOME \- multiple Git repositories in $HOME @@ -228,6 +228,19 @@ Can be \fIexact\fR, \fInone\fR, or \fIrecursive\fR\. .IP Defaults to \fIexact\fR\. . +.TP +\fI$VCSH_VCSH_WORKTREE\fR +Can be \fIabsolute\fR, or \fIrelative\fR\. +. +.IP +\fIabsolute\fR will set an absolute path; defaulting to \fI$HOME\fR\. +. +.IP +\fIrelative\fR will set a path relative to \fI$GIT_DIR\fR\. +. +.IP +Defaults to \fIabsolute\fR\. +. .P Less interesting knobs you could turn: . From 2d303c87154de85eb5af491b4ef878e1065745b2 Mon Sep 17 00:00:00 2001 From: Richard Hartmann Date: Thu, 8 May 2014 13:51:15 +0200 Subject: [PATCH 009/121] Makefile: Don't build manpage by default If you want to build them in this branch, use make manpages --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 4ae8d889..b40c618f 100644 --- a/Makefile +++ b/Makefile @@ -6,7 +6,7 @@ RONN ?= ronn self=vcsh manpages=$(self).1 -all=test manpages +all=test all: $(all) From 19ac17eadde47dbdd915072b4ce615112606f164 Mon Sep 17 00:00:00 2001 From: Richard Hartmann Date: Thu, 8 May 2014 13:52:04 +0200 Subject: [PATCH 010/121] vcsh.1: Update --- vcsh.1 | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/vcsh.1 b/vcsh.1 index 9f8558e6..9f8e6e22 100644 --- a/vcsh.1 +++ b/vcsh.1 @@ -1,7 +1,7 @@ .\" generated with Ronn/v0.7.3 .\" http://github.com/rtomayko/ronn/tree/0.7.3 . -.TH "VCSH" "1" "December 2013" "" "" +.TH "VCSH" "1" "May 2014" "" "" . .SH "NAME" \fBvcsh\fR \- Version Control System for $HOME \- multiple Git repositories in $HOME @@ -213,6 +213,19 @@ Please note that those files are sourced\. Any and all commands will be executed Interesting knobs you can turn: . .TP +\fI$VCSH_GITATTRIBUTES\fR +Can be \fInone\fR, or any other value\. +. +.IP +\fInone\fR will not maintain Git attributes in a special location\. +. +.IP +If set to any other value, repo\-specific gitattributes files will be maintained\. +. +.IP +Defaults to \fInone\fR\. +. +.TP \fI$VCSH_GITIGNORE\fR Can be \fIexact\fR, \fInone\fR, or \fIrecursive\fR\. . From ef15aeeb0553efb698e3d4261e79eff77a136ee7 Mon Sep 17 00:00:00 2001 From: Richard Hartmann Date: Sun, 26 Oct 2014 00:43:43 +0200 Subject: [PATCH 011/121] Update manpage --- vcsh.1 | 39 +++++++++++++++++++++++++++++++++++---- 1 file changed, 35 insertions(+), 4 deletions(-) diff --git a/vcsh.1 b/vcsh.1 index 9f8e6e22..9f248422 100644 --- a/vcsh.1 +++ b/vcsh.1 @@ -1,7 +1,7 @@ .\" generated with Ronn/v0.7.3 .\" http://github.com/rtomayko/ronn/tree/0.7.3 . -.TH "VCSH" "1" "May 2014" "" "" +.TH "VCSH" "1" "October 2014" "" "" . .SH "NAME" \fBvcsh\fR \- Version Control System for $HOME \- multiple Git repositories in $HOME @@ -10,7 +10,7 @@ \fBvcsh\fR [\fIoptions\fR] \fIcommand\fR . .P -\fBvcsh\fR clone \fIurl\fR [\fIrepo\fR] +\fBvcsh\fR clone [\-b \fIbranch\fR] \fIurl\fR [\fIrepo\fR] . .P \fBvcsh\fR delete \fIrepo\fR @@ -28,10 +28,10 @@ \fBvcsh\fR list . .P -\fBvcsh\fR list\-tracked +\fBvcsh\fR list\-tracked [\fIrpoe\fR] . .P -\fBvcsh\fR list\-tracked\-by \fIrepo\fR +\fBvcsh\fR list\-untracked [\fI\-r\fR] [\fIrepo\fR] . .P \fBvcsh\fR pull @@ -107,6 +107,9 @@ Clone an existing repository\. .IP If you need to clone a bundle of repositories, look into the \fBpost\-clone\-retired\fR hook\. . +.IP +You can also use a single git repository with several branches\. Use the \fB\-b\fR option to specify a branch at clone time, the default is \fBmaster\fR\. +. .TP commit Commit in all repositories @@ -135,10 +138,26 @@ List all local vcsh repositories\. list\-tracked List all files tracked by vcsh\. . +.IP +If you want to list files tracked by a specific repository, simply append the repository\'s name last\. +. .TP list\-tracked\-by List files tracked by a repository\. . +.IP +This is a legacy command; you should use \fBlist\-tracked \fR instead\. +. +.TP +list\-untracked +List all files NOT tracked by vcsh\. +. +.IP +By default, the file list is shallow and stops at directory levels where possible\. If you prefer to get a list of all files, append \fB\-r\fR for recursive mode\. +. +.IP +If you want to list files not tracked by a specific repository, simply append the repository\'s name last\. +. .TP pull Pull from all vcsh remotes\. @@ -301,6 +320,18 @@ If you want to create hooks for a specific \fIvcsh\fR repository, simply prepend .P Available hooks are \fIpre\-clone\fR, \fIpost\-clone\fR, \fIpost\-clone\-retired\fR, \fIpre\-command\fR, \fIpost\-command\fR, \fIpre\-enter\fR, \fIpost\-enter\fR, \fIpre\-init\fR, \fIpost\-init\fR, \fIpre\-pull\fR, \fIpost\-pull\fR, \fIpre\-push\fR, \fIpost\-push\fR, \fIpre\-run\fR, \fIpost\-run\fR, \fIpre\-upgrade\fR, and \fIpost\-upgrade\fR\. If you need more, vcsh is trivial to patch, but please let upstream know so we can ship them by default\. . +.SH "OVERLAY SYSTEM" +\fBvcsh\fR also provides an overlay system\. Similar to hooks, the recommended locations are <$XDG_CONFIG_HOME/vcsh/overlays\-available> and <$XDG_CONFIG_HOME/vcsh/overlays\-enabled>\. +. +.P +Overlays follow the same rules as hooks and you are free to overwrite any and all functions\. Same as hooks, you can use global or repository\-specific overlays by using either <$VCSH_OVERLAY_D/$VCSH_COMMAND> or <$VCSH_OVERLAY_D/$VCSH_REPO_NAME\.$VCSH_COMMAND>\. +. +.P +Please note that nothing stops you from, e\.g\. overwriting \fBstatus()\fR in <$VCSH_OVERLAY_D/commit>\. As the overlays will be sourced and you are replacing arbitrary functions, any and all features may stop working, or you may even lose data\. +. +.P +You have been warned\. +. .SH "DETAILED HOWTO AND FURTHER READING" Manpages are often short and sometimes useless to glean best practices from\. While the author tried to avoid this in this case, manpages can not cover detailed howtos\. . From db6906126cf1e099916e0e0a88ee40215bf98bfd Mon Sep 17 00:00:00 2001 From: Richard Hartmann Date: Sat, 2 May 2015 16:25:29 +0200 Subject: [PATCH 012/121] Release 1.20150502 --- changelog | 9 +++++++++ vcsh | 2 +- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/changelog b/changelog index 9cc6c16f..6f23d0f5 100644 --- a/changelog +++ b/changelog @@ -1,3 +1,12 @@ +2015-05-02 Richard Hartmann + + * Release 1.20150502 + * Add tests + * Integrate tests with Travis CI + * Make `vcsh --list_untracked` GNU-independent + * Improve vcsh's code quality + * Improve Makefile, documentation, etc + 2014-10-26 Richard Hartmann * Release 1.20141026 diff --git a/vcsh b/vcsh index 51f2d212..ab79db25 100755 --- a/vcsh +++ b/vcsh @@ -19,7 +19,7 @@ # If '.git-HEAD' is appended to the version, you are seeing an unreleased # version of vcsh; the master branch is supposed to be clean at all times # so you can most likely just use it nonetheless -VERSION='1.20141026' +VERSION='1.20150502' SELF=$(basename $0) fatal() { From 24949d03789aab3a6a4a5ba8c2964bf4415f9832 Mon Sep 17 00:00:00 2001 From: Richard Hartmann Date: Sat, 2 May 2015 16:45:02 +0200 Subject: [PATCH 013/121] Makefile: Don't remove vcsh.1 any more --- Makefile | 6 ------ 1 file changed, 6 deletions(-) diff --git a/Makefile b/Makefile index b15779de..984c623d 100644 --- a/Makefile +++ b/Makefile @@ -21,13 +21,7 @@ install: all install -d $(DESTDIR)$(ZSHDIR) install -m 0644 _$(self) $(DESTDIR)$(ZSHDIR) -manpages: $(manpages) - -$(self).1: doc/$(self).1.ronn - $(RONN) < doc/$(self).1.ronn > $(self).1 || rm $(self).1 - clean: - rm -rf $(self).1 uninstall: rm -rf $(DESTDIR)$(PREFIX)/bin/$(self) From bf2c8435e28d53ec22c99a6589320e809e8798ac Mon Sep 17 00:00:00 2001 From: Richard Hartmann Date: Mon, 25 May 2015 01:11:34 +0200 Subject: [PATCH 014/121] vcsh: Make clone() check GIT_REMOTE early GitHub: Hopefully closes richih/vcsh#161 --- vcsh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/vcsh b/vcsh index 8bfafab1..116d95fc 100755 --- a/vcsh +++ b/vcsh @@ -149,6 +149,8 @@ info() { clone() { hook pre-clone + # Check if remote is reachable. Abort early if there's a typo, TLS certificate problem, etc + git ls-remote "$GIT_REMOTE" 2> /dev/null || fatal "Can not reach '$GIT_REMOTE'" init git remote add origin "$GIT_REMOTE" git checkout -b "$VCSH_BRANCH" || return $? From 87a5c9e16ea5f0a9d1d32f11747732e900da615d Mon Sep 17 00:00:00 2001 From: Richard Hartmann Date: Tue, 9 Jun 2015 08:06:22 +0200 Subject: [PATCH 015/121] Makefile: Remove reference to ronn Thanks to Vasyl Zuzyak for noticing. --- Makefile | 1 - 1 file changed, 1 deletion(-) diff --git a/Makefile b/Makefile index 984c623d..dfde7a00 100644 --- a/Makefile +++ b/Makefile @@ -2,7 +2,6 @@ PREFIX?=/usr DOCDIR_PREFIX=$(PREFIX)/share/doc DOCDIR=$(DOCDIR_PREFIX)/$(self) ZSHDIR=$(PREFIX)/share/zsh/vendor-completions -RONN ?= ronn self=vcsh manpages=$(self).1 From 53fff6aec963bc3bdd8bfb156d2028f96b08bfda Mon Sep 17 00:00:00 2001 From: Richard Hartmann Date: Tue, 29 Dec 2015 20:23:52 +0100 Subject: [PATCH 016/121] vcsh.1: Import static manpage --- vcsh.1 | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/vcsh.1 b/vcsh.1 index 9f248422..c3cb62c5 100644 --- a/vcsh.1 +++ b/vcsh.1 @@ -1,7 +1,7 @@ .\" generated with Ronn/v0.7.3 .\" http://github.com/rtomayko/ronn/tree/0.7.3 . -.TH "VCSH" "1" "October 2014" "" "" +.TH "VCSH" "1" "December 2015" "" "" . .SH "NAME" \fBvcsh\fR \- Version Control System for $HOME \- multiple Git repositories in $HOME @@ -19,6 +19,9 @@ \fBvcsh\fR enter \fIrepo\fR . .P +\fBvcsh\fR foreach [\-g] \fIgit command\fR +. +.P \fBvcsh\fR help . .P @@ -28,10 +31,10 @@ \fBvcsh\fR list . .P -\fBvcsh\fR list\-tracked [\fIrpoe\fR] +\fBvcsh\fR list\-tracked [\fIrepo\fR] . .P -\fBvcsh\fR list\-untracked [\fI\-r\fR] [\fIrepo\fR] +\fBvcsh\fR list\-untracked [\fI\-a\fR] [\fI\-r\fR] [\fIrepo\fR] . .P \fBvcsh\fR pull @@ -123,6 +126,13 @@ enter Enter repository; spawn new \fI$SHELL\fR\. . .TP +foreach +Execute git command for every vcsh repository\. +. +.IP +\fB\-g\fR: Execute in general context\. +. +.TP help Display help\. . @@ -153,10 +163,13 @@ list\-untracked List all files NOT tracked by vcsh\. . .IP -By default, the file list is shallow and stops at directory levels where possible\. If you prefer to get a list of all files, append \fB\-r\fR for recursive mode\. +\fB\-a\fR: Show all files\. By default, the \fBgit ls\-files \-\-exclude\-standard\fR is called\. +. +.IP +\fB\-r\fR: Recursive mode\. By default, the file list is shallow and stops at directory levels where possible\. . .IP -If you want to list files not tracked by a specific repository, simply append the repository\'s name last\. +\fB$repo\fR: List files not tracked by this specific repository\. . .TP pull @@ -366,7 +379,7 @@ vcsh was initally written by madduck\. This version is a re\-implementation from This manpage and \fBvcsh\fR itself were written by Richard "RichiH" Hartmann\. . .SH "COPYRIGHT" -Copyright 2011\-2013 Richard Hartmann \fIrichih@debian\.org\fR +Copyright 2011\-2015 Richard Hartmann \fIrichih@debian\.org\fR . .P Licensed under the GNU GPL version 2 or higher\. From b8bd702362a260c22df3980767460190f8a0b1c1 Mon Sep 17 00:00:00 2001 From: Richard Hartmann Date: Tue, 29 Dec 2015 19:07:02 +0100 Subject: [PATCH 017/121] Release 1.20151229 --- changelog | 14 ++++++++++++++ vcsh | 2 +- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/changelog b/changelog index 6f23d0f5..44a44ad3 100644 --- a/changelog +++ b/changelog @@ -1,3 +1,17 @@ +2015-12-29 Richard Hartmann + + * Fix tests to always use C locale, this makes vcsh reproducible + * Implement `vcsh foreach` + * Implement `vcsh list-untracked -a` + * Handle Git older than 2.x gracefully + * Fix broken list-tracked-by + * Fix regression in `vcsh which` + * Skip ignored files in the output of list-untracked + * Improve cloning + * Clean up docs + * Implement `vcsh status --terse` + * Improve tests + 2015-05-02 Richard Hartmann * Release 1.20150502 diff --git a/vcsh b/vcsh index b934afba..3f00b1f3 100755 --- a/vcsh +++ b/vcsh @@ -19,7 +19,7 @@ # If '.git-HEAD' is appended to the version, you are seeing an unreleased # version of vcsh; the master branch is supposed to be clean at all times # so you can most likely just use it nonetheless -VERSION='1.20150502' +VERSION='1.20151229' SELF=$(basename $0) fatal() { From b1c523b171975e5e0b7d800ba2f59fc66ef74fd4 Mon Sep 17 00:00:00 2001 From: Harendra Kumar Date: Mon, 11 Jul 2016 14:37:30 +0530 Subject: [PATCH 018/121] Fail the command if a hook script fails Currently vcsh commands succeed even if a hook script fails. This is not the right behavior in my opinion. The user should know when a hook fails rather than silently continuing even though it may not make sense. --- vcsh | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/vcsh b/vcsh index de1b419f..985feb1e 100755 --- a/vcsh +++ b/vcsh @@ -248,11 +248,17 @@ git_dir_exists() { [ -d "$GIT_DIR" ] || fatal "no repository found for '$VCSH_REPO_NAME'" 12 } +# $1: message +die () { + >&2 echo -e $1 + exit 1 +} + hook() { for hook in "$VCSH_HOOK_D/$1"* "$VCSH_HOOK_D/$VCSH_REPO_NAME.$1"*; do [ -x "$hook" ] || continue verbose "executing '$hook'" - "$hook" + "$hook" || die "Hook [$hook] failed" done } From 43ffbea3695755a3fbfb4e07d0c608624612ba9c Mon Sep 17 00:00:00 2001 From: leycec Date: Mon, 8 Jun 2015 01:37:06 -0400 Subject: [PATCH 019/121] Makefile portability and safety improvements. Per GNU makefile conventions, directories hardcoded into the makefile have been replaced by conventional variables (e.g., $(BINDIR)). Zsh completions are now installed to a platform-agnostic rather than Debian-specific directory. Installation no longer requires unit tests (and hence Perl) or manpages (and hence ronn and ruby) and fails if the $(BINDIR) directory does not exist (rather than attempting to unsafely create that directory). Manpages are conditionally installed only if previously generated, which fails if the $(MANDIR) directory does not exist (again, rather than attempting to unsafely create that directory). Zsh completions are conditionally installed only if zsh is found. For both safety and efficiency, abstract targets are now listed as .PHONY. All targets and variables now have human-readable comments. --- BSDmakefile | 17 +++++++++++++ GNUmakefile | 71 +++++++++++++++++++++++++++++++++++++++++++++++++++++ Makefile | 69 +++++++++++++++++++++++++++++++++++---------------- 3 files changed, 136 insertions(+), 21 deletions(-) create mode 100644 BSDmakefile create mode 100644 GNUmakefile diff --git a/BSDmakefile b/BSDmakefile new file mode 100644 index 00000000..9be15637 --- /dev/null +++ b/BSDmakefile @@ -0,0 +1,17 @@ +# BSD make-specific makefile, read only by BSD make and hence containing +# BSD make-specific extensions (e.g., "ifeq (...)", "$(shell ...)"). + +#FIXME: Conditionalize according to the "GNUmakefile" approach. + +# Default target, running all preparatory installation targets without actually +# installing. This *MUST* be the first non-"."-prefixed target in this makefile. +all: manpages test + +# Install vcsh and supplementary artifacts. +install: all install-common +# Install man pages and zsh completions. + install -m 0644 $(manpages) $(DESTDIR)$(MANDIR)/man1/ + install -m 0644 $(zshcompletions) $(DESTDIR)$(ZSH_COMPLETIONS_DIR)/ + +# Define all platform-agnostic variables and rules. +.include "Makefile" diff --git a/GNUmakefile b/GNUmakefile new file mode 100644 index 00000000..8fc6e2db --- /dev/null +++ b/GNUmakefile @@ -0,0 +1,71 @@ +# GNU make-specific makefile, read only by GNU make and hence containing +# GNU make-specific extensions (e.g., "ifeq (...)", "$(shell ...)"). + +# Define all platform-agnostic variables and rules. +include Makefile + +# Absolute path of zsh's completions directory. Since Debian-based Linux distros +# prefer a different directory to that of most platforms, test for the existence +# of such directory before falling back to a platform-agnostic directory. +ifneq ($(wildcard $(DESTDIR)$(ZSHDIR_PREFIX)/vendor-completions),) +ZSH_COMPLETIONS_DIR:=$(ZSHDIR_PREFIX)/vendor-completions +else ifneq ($(wildcard $(DESTDIR)$(ZSHDIR_PREFIX)/site-functions),) +ZSH_COMPLETIONS_DIR:=$(ZSHDIR_PREFIX)/site-functions +endif + +# List of targets to be run both when no target is specified and when the +# "install" rule is run. +all_targets:= + +# Non-empty only if the "manpages" target is listed in $(all). +is_manpaging= + +# Non-empty only if the "test" target is listed in $(all). +is_testing= + +# If Ronn is in the current $PATH, generate Ronn-based man pages by default. +ifneq ($(shell command -v "$(RONN)" 2>/dev/null),) +all_targets+= manpages +is_manpaging:=true +endif + +# If Git, Perl, and the Perl-based unit test runner "prove" are all in the +# current $PATH and the requisite Perl modules are in the @INC module path, run +# Perl-based unit tests by default. +ifneq ($(shell command -v git 2>/dev/null),) +ifneq ($(shell command -v perl 2>/dev/null),) +ifneq ($(shell command -v prove 2>/dev/null),) + ifeq ($(shell perl -e 'use Test::Most; use Shell::Command;' 2>&1),) +all_targets+= test +is_testing:=true +endif +endif +endif +endif + +# Default target, running all preparatory installation targets without actually +# installing. This *MUST* be the first non-"."-prefixed target in this makefile. +all: $(all_targets) +# Notify the user of skipped targets. +ifeq ($(is_manpaging),) + @echo 'Skipping man page generation: "$(RONN)" not found.' 1>&2 +endif +ifeq ($(is_testing),) + @echo 'Skipping unit tests: "git", "prove", and/or Perl modules "Test::Most" and "Shell::Command" not found.' 1>&2 +endif + +# Coerce the default target to be the prior target (rather than the first rule +# defined by the makefile included above). +.DEFAULT_GOAL:=all + +# Install vcsh and supplementary artifacts. +install: all install-common +# If the man page has been generated, install it during installation. +ifneq ($(wildcard $(manpages)),) + install -m 0644 $(manpages) $(DESTDIR)$(MANDIR)/man1/ +endif + +# If zsh's completions directory exists, install ours there during installation. +ifneq ($(ZSH_COMPLETIONS_DIR),) + install -m 0644 $(zshcompletions) $(DESTDIR)$(ZSH_COMPLETIONS_DIR)/ +endif diff --git a/Makefile b/Makefile index b9154e7f..75533d11 100644 --- a/Makefile +++ b/Makefile @@ -1,48 +1,75 @@ +# make-agnostic makefile, read by all make flavours including GNU make and hence +# consisting of only POSIX make-compliant syntax. +# +# This makefile defines all variables and rules except those required by and +# including the "all" and "install" rules, whose complexity necessitates +# conditional logic inexpressible in POSIX make-compliant syntax. + +self=vcsh + PREFIX?=/usr +BINDIR=$(PREFIX)/bin DOCDIR_PREFIX=$(PREFIX)/share/doc DOCDIR=$(DOCDIR_PREFIX)/$(self) -ZSHDIR=$(PREFIX)/share/zsh/vendor-completions +MANDIR=$(PREFIX)/share/man RONN ?= ronn -self=vcsh +# Basename of the man page to be generated. manpages=$(self).1 -all=test manpages -all: $(all) +# Basename of our zsh completions script. +zshcompletions=_$(self) + +# Absolute path of zsh's top-level data directory. +ZSHDIR_PREFIX=$(PREFIX)/share/zsh -install: all - install -d $(DESTDIR)$(PREFIX)/bin - install -m 0755 $(self) $(DESTDIR)$(PREFIX)/bin - install -d $(DESTDIR)$(PREFIX)/share/man/man1 - install -m 0644 $(manpages) $(DESTDIR)$(PREFIX)/share/man/man1 +# Absolute path of zsh's completions directory. +ZSH_COMPLETIONS_DIR=$(ZSHDIR_PREFIX)/site-functions + +# List of abstract target names not corresponding to actual paths, preventing +# conflicts with any such paths and improving efficiency in general. +.PHONY: all clean install install-common manpages moo purge test uninstall + +# Install all paths *NOT* requiring conditional and hence non-POSIX logic. +install-common: +# Install the "vcsh" command. + install -m 0755 $(self) $(DESTDIR)$(BINDIR)/ + +# Install documentation. install -d $(DESTDIR)$(DOCDIR) - install -m 0644 README.md $(DESTDIR)$(DOCDIR) - install -m 0644 doc/hooks $(DESTDIR)$(DOCDIR) - install -d $(DESTDIR)$(ZSHDIR) - install -m 0644 _$(self) $(DESTDIR)$(ZSHDIR) + install -m 0644 README.md $(DESTDIR)$(DOCDIR)/ + install -m 0644 doc/hooks $(DESTDIR)$(DOCDIR)/ +# Generate the manpage. manpages: $(manpages) $(self).1: doc/$(self).1.ronn $(RONN) < doc/$(self).1.ronn > $(self).1 || rm $(self).1 +# Remove the generated manpage. clean: rm -rf $(self).1 +# Remove all previously installed paths. uninstall: - rm -rf $(DESTDIR)$(PREFIX)/bin/$(self) - rm -rf $(DESTDIR)$(PREFIX)/share/man/man1/$(self).1 + rm -rf $(DESTDIR)$(BINDIR)/$(self) + rm -rf $(DESTDIR)$(MANDIR)/man1/$(self).1 rm -rf $(DESTDIR)$(DOCDIR) - rm -rf $(DESTDIR)$(ZSHDIR)/_$(self) + rm -rf $(DESTDIR)$(ZSH_COMPLETIONS_DIR)/$(zshcompletions) + +# FIXME: The "--ignore-fail-on-non-empty" option is GNU-specific. -# Potentially harmful, used a non-standard option on purpose. -# If PREFIX=/usr/local and that's empty... +# Remove all previously installed paths and all empty parent directories of +# these paths. Since this is potentially harmful, this target has intentionally +# been given a non-standard name. For example, if $(PREFIX) is "/usr/local" and +# now empty due to uninstalling vcsh, this target would remove "/usr/local"! purge: uninstall - rmdir -p --ignore-fail-on-non-empty $(DESTDIR)$(PREFIX)/bin/ - rmdir -p --ignore-fail-on-non-empty $(DESTDIR)$(PREFIX)/share/man/man1/ + rmdir -p --ignore-fail-on-non-empty $(DESTDIR)$(BINDIR) + rmdir -p --ignore-fail-on-non-empty $(DESTDIR)$(MANDIR)/man1 rmdir -p --ignore-fail-on-non-empty $(DESTDIR)$(DOCDIR) - rmdir -p --ignore-fail-on-non-empty $(DESTDIR)$(ZSHDIR) + rmdir -p --ignore-fail-on-non-empty $(DESTDIR)$(ZSH_COMPLETIONS_DIR) +# Run all unit tests if both git and Perl's prove are found. test: @if which git > /dev/null; then : ; else echo "'git' not found, exiting..." ; exit 1; fi @if which prove > /dev/null; then prove; else echo "'prove' not found; not running tests"; fi From c88cf6f46abc7df0791c008a242b021e9bfec416 Mon Sep 17 00:00:00 2001 From: Kevin Lyda Date: Tue, 29 Aug 2017 10:35:15 +0100 Subject: [PATCH 020/121] Make hooks work as documented. Make per-repo {pre,post}-commit hooks run for the appropriate repo. Make global {pre,post}-commit hooks run {before,after} looping through repos. --- vcsh | 41 +++++++++++++++++++++++++++++++---------- 1 file changed, 31 insertions(+), 10 deletions(-) diff --git a/vcsh b/vcsh index d1d26edd..17885fbf 100755 --- a/vcsh +++ b/vcsh @@ -189,17 +189,19 @@ clone() { } commit() { - hook pre-commit + global_hook pre-commit shift # remove the "commit" command. for VCSH_REPO_NAME in $(list); do echo "$VCSH_REPO_NAME: " GIT_DIR=$VCSH_REPO_D/$VCSH_REPO_NAME.git; export GIT_DIR use + repo_hook pre-commit git commit --untracked-files=no --quiet "$@" + repo_hook post-commit VCSH_COMMAND_RETURN_CODE=$? echo done - hook post-commit + global_hook post-commit } delete() { @@ -229,7 +231,7 @@ enter() { } foreach() { - hook pre-foreach + global_hook pre-foreach # We default to prefixing `git` to all commands passed to foreach, but # allow running in general context with -g @@ -244,23 +246,38 @@ foreach() { echo "$VCSH_REPO_NAME:" GIT_DIR=$VCSH_REPO_D/$VCSH_REPO_NAME.git; export GIT_DIR use + repo_hook pre-foreach $command_prefix "$@" + repo_hook post-foreach done - hook post-foreach + global_hook post-foreach } git_dir_exists() { [ -d "$GIT_DIR" ] || fatal "no repository found for '$VCSH_REPO_NAME'" 12 } -hook() { - for hook in "$VCSH_HOOK_D/$1"* "$VCSH_HOOK_D/$VCSH_REPO_NAME.$1"*; do +global_hook() { + for hook in "$VCSH_HOOK_D/$1"*; do + [ -x "$hook" ] || continue + verbose "executing '$hook'" + "$hook" + done +} + +repo_hook() { + for hook in "$VCSH_HOOK_D/$VCSH_REPO_NAME.$1"*; do [ -x "$hook" ] || continue verbose "executing '$hook'" "$hook" done } +hook() { + global_hook "$1" + repo_hook "$1" +} + init() { hook pre-init [ ! -e "$GIT_DIR" ] || fatal "'$GIT_DIR' exists" 10 @@ -354,29 +371,33 @@ list_untracked_helper() { } pull() { - hook pre-pull + global_hook pre-pull for VCSH_REPO_NAME in $(list); do printf '%s: ' "$VCSH_REPO_NAME" GIT_DIR=$VCSH_REPO_D/$VCSH_REPO_NAME.git; export GIT_DIR use + repo_hook pre-pull git pull + repo_hook post-pull VCSH_COMMAND_RETURN_CODE=$? echo done - hook post-pull + global_hook post-pull } push() { - hook pre-push + global_hook pre-push for VCSH_REPO_NAME in $(list); do printf '%s: ' "$VCSH_REPO_NAME" GIT_DIR=$VCSH_REPO_D/$VCSH_REPO_NAME.git; export GIT_DIR use + repo_hook pre-push git push + repo_hook post-push VCSH_COMMAND_RETURN_CODE=$? echo done - hook post-push + global_hook post-push } retire() { From 27e3144e572a5468665be0013fe04421d041595d Mon Sep 17 00:00:00 2001 From: Edward Betts Date: Fri, 15 Sep 2017 09:50:25 +0100 Subject: [PATCH 021/121] correct spelling mistakes --- changelog | 2 +- doc/README.md | 2 +- doc/vcsh.1.ronn | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/changelog b/changelog index 9cc6c16f..5e657e04 100644 --- a/changelog +++ b/changelog @@ -201,7 +201,7 @@ 2011-11-19 Richard Hartmann * Bugfixes - * Improve XDG compability + * Improve XDG compatibility 2011-11-18 Richard Hartmann diff --git a/doc/README.md b/doc/README.md index b14d782e..8b9b2446 100644 --- a/doc/README.md +++ b/doc/README.md @@ -293,7 +293,7 @@ Note the portage package for myrepos still has the old project name: vcsh is available via this [AUR](https://aur.archlinux.org/packages/vcsh/) package. Likewise myrepos is available [here](https://aur.archlinux.org/packages/myrepos/). -You may install both useing your favorite AUR helper. e.g. with yaourt: +You may install both using your favorite AUR helper. e.g. with yaourt: yaourt -Sya myrepos vcsh diff --git a/doc/vcsh.1.ronn b/doc/vcsh.1.ronn index a25bf65b..16c4f367 100644 --- a/doc/vcsh.1.ronn +++ b/doc/vcsh.1.ronn @@ -338,7 +338,7 @@ config files, all of which were soft-linked into <$HOME>. Martin F. Krafft aka madduck came up with the concept of fake bare Git repositories. -vcsh was initally written by madduck. This version is a re-implementation from +vcsh was initially written by madduck. This version is a re-implementation from scratch with a lot more features. madduck graciously agreed to let the author take over the name. From e72b0961e6b0271dd28a182f586a6e1499e9f037 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aryel=20Mota=20G=C3=B3is?= Date: Sat, 14 Apr 2018 17:36:41 -0300 Subject: [PATCH 022/121] Update status_helper Use git config to avoid paths cluttered with '..', as in: RichiH/myrepos@eabad02ab25169b9658d87fbdebd32a3ac86b317 That functionality was removed in order to use vcsh status: RichiH/myrepos@c6a37fa0d2309fe6a16948ec33b7ad78899dec53 Since vcsh is supposed to have its worktree in $HOME, having paths relative to the current working directory is meaningless and just distracts me --- vcsh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vcsh b/vcsh index d1d26edd..3eb8e7e2 100755 --- a/vcsh +++ b/vcsh @@ -422,7 +422,7 @@ status() { status_helper() { GIT_DIR=$VCSH_REPO_D/$1.git; export GIT_DIR - VCSH_GIT_OPTIONS=$2 + VCSH_GIT_OPTIONS="-c status.relativePaths=false $2" use remote_tracking_branch=$(git rev-parse --abbrev-ref --symbolic-full-name @{u} 2> /dev/null) && { commits_behind=$(git log ..${remote_tracking_branch} --oneline | wc -l) From ed5ffedd0ff490d6b96cfcb3f98cb273417f76c2 Mon Sep 17 00:00:00 2001 From: Julien Lecomte Date: Mon, 18 Jun 2018 10:33:28 +0200 Subject: [PATCH 023/121] Enable vcsh ls-file to take an option '-p' to prefix all lines with repo name --- vcsh | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/vcsh b/vcsh index d1d26edd..38d505ba 100755 --- a/vcsh +++ b/vcsh @@ -110,7 +110,8 @@ help() { delete Delete an existing repository enter Enter repository; spawn new instance of \$SHELL with \$GIT_DIR set. - foreach [<-g>] + foreach \\ + [<-g>] [<-p>] \\ Execute a command for every repository help Display this help text init Initialize a new repository @@ -234,17 +235,20 @@ foreach() { # We default to prefixing `git` to all commands passed to foreach, but # allow running in general context with -g command_prefix=git - while getopts "g" flag; do + command_suffix='cat' + while getopts "gp" flag; do if [ x"$1" = x'-g' ]; then unset command_prefix fi + if [ x"$1" = x'-p' ]; then + command_suffix='sed "s/^/$VCSH_REPO_NAME: /"' + fi shift 1 done for VCSH_REPO_NAME in $(list); do - echo "$VCSH_REPO_NAME:" GIT_DIR=$VCSH_REPO_D/$VCSH_REPO_NAME.git; export GIT_DIR use - $command_prefix "$@" + $command_prefix "$@" | eval $command_suffix done hook post-foreach } From 269b297e72a387f71bcb3779e728ba859099b3a5 Mon Sep 17 00:00:00 2001 From: arndtc Date: Tue, 26 Mar 2019 17:51:50 -0600 Subject: [PATCH 024/121] Fixed debug function in Cygwin on Windows 10 The debug function was causing a bad exit code when calling vcsh from mr on Windows 10. --- vcsh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vcsh b/vcsh index d1d26edd..870186a5 100755 --- a/vcsh +++ b/vcsh @@ -139,7 +139,7 @@ help() { } debug() { - [ -n "$VCSH_DEBUG" ] && echo "$SELF: debug: $@" + if [ -n "$VCSH_DEBUG" ]; then echo "$SELF: debug: $@"; fi } verbose() { From 06ec458ca587225479229634a2942dbaa02bf9a9 Mon Sep 17 00:00:00 2001 From: soulofmischief <30357883+soulofmischief@users.noreply.github.com> Date: Mon, 20 May 2019 16:07:25 -0500 Subject: [PATCH 025/121] Fix typo in Config section $VCSH_VCSH_WORKTREE -> $VCSH_WORKTREE --- doc/vcsh.1.ronn | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/vcsh.1.ronn b/doc/vcsh.1.ronn index 16c4f367..6e19ef8b 100644 --- a/doc/vcsh.1.ronn +++ b/doc/vcsh.1.ronn @@ -220,7 +220,7 @@ Interesting knobs you can turn: Defaults to . -* <$VCSH_VCSH_WORKTREE>: +* <$VCSH_WORKTREE>: Can be , or . will set an absolute path; defaulting to <$HOME>. From dbc9c077403b805406b9be289621dbe41ae2e94b Mon Sep 17 00:00:00 2001 From: Richard Hartmann Date: Mon, 29 Mar 2021 16:56:19 +0200 Subject: [PATCH 026/121] Release v1.20190619 Signed-off-by: Richard Hartmann --- changelog | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/changelog b/changelog index 5e657e04..a8aae0cd 100644 --- a/changelog +++ b/changelog @@ -1,3 +1,10 @@ +2021-03-29 Richard Hartmann + + * Release 1.20190619 + * Various bugfixes + * This is a safe harbour release. + * @alerque is now a co-maintainer + 2014-10-26 Richard Hartmann * Release 1.20141026 From e8b2148def384a82fcea1cc985f89db07550d4d5 Mon Sep 17 00:00:00 2001 From: Caleb Maclennan Date: Mon, 29 Mar 2021 22:17:40 +0300 Subject: [PATCH 027/121] Drop Travis CI config Travis reduced support for open-source projects :( --- .travis.yml | 16 ---------------- 1 file changed, 16 deletions(-) delete mode 100644 .travis.yml diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index be5a1d79..00000000 --- a/.travis.yml +++ /dev/null @@ -1,16 +0,0 @@ -language: perl -before_install: - - cpanm Shell::Command - - cpanm Test::Most - - apt-get moo -install: - - sudo apt-get update - - sudo apt-get install cowsay git ruby-ronn -script: - - make test -after_script: - - make moo -notifications: - email: - on_success: change - on_failure: always From 330d15ae9f9687a56e6c4664458d66d3d54713e3 Mon Sep 17 00:00:00 2001 From: Caleb Maclennan Date: Mon, 29 Mar 2021 22:43:32 +0300 Subject: [PATCH 028/121] Add GitHub Actions workflow to run test suite --- .github/workflows/test.yml | 20 ++++++++++++++++++++ README.md | 3 +-- 2 files changed, 21 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/test.yml diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 00000000..e3a674d1 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,20 @@ +name: Test +on: [push, pull_request] +jobs: + test: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v2 + - name: Install build dependencies + run: | + sudo apt-get install ruby-ronn + - name: Install perl test dependencies + uses: perl-actions/install-with-cpanm@v1.1 + with: + install: | + Shell::Command + Test::Most + - name: Run tests + run: | + make test diff --git a/README.md b/README.md index f885b4a3..0022d344 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,6 @@ vcsh - Version Control System for $HOME - multiple Git repositories in $HOME -[![Build Status](https://travis-ci.org/RichiH/vcsh.svg?branch=master)](https://travis-ci.org/RichiH/vcsh) - +[![Test Status](https://github.com/RichiH/vcsh/actions/workflows/test.yml/badge.svg)](https://github.com/RichiH/vcsh/actions/workflows/test.yml) # Index From b491cb8084a229a7196077d8d045fb7ca2d1f881 Mon Sep 17 00:00:00 2001 From: Caleb Maclennan Date: Mon, 29 Mar 2021 22:45:05 +0300 Subject: [PATCH 029/121] =?UTF-8?q?Cows=20=E2=80=98moo=E2=80=99,=20but=20l?= =?UTF-8?q?eave=20them=20to=20chew=20the=20cud=20in=20peace?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Makefile | 3 --- doc/INSTALL.md | 4 ---- 2 files changed, 7 deletions(-) diff --git a/Makefile b/Makefile index b9154e7f..40924588 100644 --- a/Makefile +++ b/Makefile @@ -46,6 +46,3 @@ purge: uninstall test: @if which git > /dev/null; then : ; else echo "'git' not found, exiting..." ; exit 1; fi @if which prove > /dev/null; then prove; else echo "'prove' not found; not running tests"; fi - -moo: - @which cowsay >/dev/null 2>&1 && cowsay "I hope you're happy now..." diff --git a/doc/INSTALL.md b/doc/INSTALL.md index 65fc5f3b..727e14e8 100644 --- a/doc/INSTALL.md +++ b/doc/INSTALL.md @@ -44,8 +44,4 @@ To clean up the generated manpage, run make clean -and if you are bored, I suggest - - make moo - [1]: http://rtomayko.github.io/ronn/ From 4726057bdf2aa69012baf227a67df0ab97730f3a Mon Sep 17 00:00:00 2001 From: Kevin Lyda Date: Mon, 29 Mar 2021 23:26:15 +0100 Subject: [PATCH 030/121] Alias commit to ci (#238) Mercurial, subversion and a common git alias for commit is "ci". The PR adds that alias. Note that all of those also alias checkout as "co" so this current case statement is a bit confusing. That said it doesn't make a huge amount of sense to do vcsh checkout so it's fine if this stays if people have it in muscle memory. --- vcsh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vcsh b/vcsh index d1d26edd..47d8972c 100755 --- a/vcsh +++ b/vcsh @@ -534,7 +534,7 @@ VCSH_COMMAND=$1; export VCSH_COMMAND case $VCSH_COMMAND in clon|clo|cl) VCSH_COMMAND=clone;; - commi|comm|com|co) VCSH_COMMAND=commit;; + commi|comm|com|co|ci) VCSH_COMMAND=commit;; delet|dele|del|de) VCSH_COMMAND=delete;; ente|ent|en) VCSH_COMMAND=enter;; hel|he) VCSH_COMMAND=help;; From b6398def47085dbb86bfbbf0aace4205c89980f3 Mon Sep 17 00:00:00 2001 From: Kevin Lyda Date: Tue, 29 Aug 2017 09:35:31 +0100 Subject: [PATCH 031/121] Add editor modeline This will make sure people have a better chance of following the code style of this file. --- vcsh | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/vcsh b/vcsh index d1d26edd..ab98612d 100755 --- a/vcsh +++ b/vcsh @@ -672,3 +672,14 @@ $VCSH_COMMAND "$@" hook post-command verbose "$VCSH_COMMAND end, exiting" exit $VCSH_COMMAND_RETURN_CODE + +# +# Editor modelines - https://www.wireshark.org/tools/modelines.html +# +# Local variables: +# indent-tabs-mode: t +# End: +# +# vi: set noexpandtab: +# :noTabs=false: +# From 7c40d6f7707d194b6ae83664c5aba4dec440c3f5 Mon Sep 17 00:00:00 2001 From: Edward Betts Date: Fri, 15 Sep 2017 09:50:25 +0100 Subject: [PATCH 032/121] Correct spelling mistakes and typos in docs --- changelog | 2 +- doc/README.md | 2 +- doc/vcsh.1.ronn | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/changelog b/changelog index 9cc6c16f..5e657e04 100644 --- a/changelog +++ b/changelog @@ -201,7 +201,7 @@ 2011-11-19 Richard Hartmann * Bugfixes - * Improve XDG compability + * Improve XDG compatibility 2011-11-18 Richard Hartmann diff --git a/doc/README.md b/doc/README.md index b14d782e..8b9b2446 100644 --- a/doc/README.md +++ b/doc/README.md @@ -293,7 +293,7 @@ Note the portage package for myrepos still has the old project name: vcsh is available via this [AUR](https://aur.archlinux.org/packages/vcsh/) package. Likewise myrepos is available [here](https://aur.archlinux.org/packages/myrepos/). -You may install both useing your favorite AUR helper. e.g. with yaourt: +You may install both using your favorite AUR helper. e.g. with yaourt: yaourt -Sya myrepos vcsh diff --git a/doc/vcsh.1.ronn b/doc/vcsh.1.ronn index a25bf65b..6e19ef8b 100644 --- a/doc/vcsh.1.ronn +++ b/doc/vcsh.1.ronn @@ -220,7 +220,7 @@ Interesting knobs you can turn: Defaults to . -* <$VCSH_VCSH_WORKTREE>: +* <$VCSH_WORKTREE>: Can be , or . will set an absolute path; defaulting to <$HOME>. @@ -338,7 +338,7 @@ config files, all of which were soft-linked into <$HOME>. Martin F. Krafft aka madduck came up with the concept of fake bare Git repositories. -vcsh was initally written by madduck. This version is a re-implementation from +vcsh was initially written by madduck. This version is a re-implementation from scratch with a lot more features. madduck graciously agreed to let the author take over the name. From 95c12ab219cdcf2f2d05bc80ad880be81a351edf Mon Sep 17 00:00:00 2001 From: Caleb Maclennan Date: Tue, 30 Mar 2021 10:29:58 +0300 Subject: [PATCH 033/121] Replace file level modeline with project level EditorConfig --- .editorconfig | 9 +++++++++ vcsh | 11 ----------- 2 files changed, 9 insertions(+), 11 deletions(-) create mode 100644 .editorconfig diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 00000000..32d78adb --- /dev/null +++ b/.editorconfig @@ -0,0 +1,9 @@ +root = true + +[*] +end_of_line = lf +insert_final_newline = true + +[vcsh] +indent_style = tab +trim_trailing_whitespace = true diff --git a/vcsh b/vcsh index ab98612d..d1d26edd 100755 --- a/vcsh +++ b/vcsh @@ -672,14 +672,3 @@ $VCSH_COMMAND "$@" hook post-command verbose "$VCSH_COMMAND end, exiting" exit $VCSH_COMMAND_RETURN_CODE - -# -# Editor modelines - https://www.wireshark.org/tools/modelines.html -# -# Local variables: -# indent-tabs-mode: t -# End: -# -# vi: set noexpandtab: -# :noTabs=false: -# From 536f9196d825f1aca1406316e4bbedaa3215b3ba Mon Sep 17 00:00:00 2001 From: Caleb Maclennan Date: Tue, 30 Mar 2021 11:22:08 +0300 Subject: [PATCH 034/121] Add EditorConfig lint workflow to GH Actions --- .github/workflows/lint.yml | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 .github/workflows/lint.yml diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml new file mode 100644 index 00000000..917862ab --- /dev/null +++ b/.github/workflows/lint.yml @@ -0,0 +1,10 @@ +name: Lint +on: [push, pull_request] +jobs: + editor-config: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v2 + - name: Lint code style + uses: editorconfig-checker/action-editorconfig-checker@v1.0.0 From e636440c25071e2792a1b64c5d74e10057466d6a Mon Sep 17 00:00:00 2001 From: Caleb Maclennan Date: Tue, 30 Mar 2021 11:28:50 +0300 Subject: [PATCH 035/121] Normalize indent style to please linter Long term I think these offending lines I had to ignore can be refactored other ways, but for now at least we can see when other PRs introduce mixed indentation formats. --- vcsh | 36 +++++++++++++++++++----------------- 1 file changed, 19 insertions(+), 17 deletions(-) diff --git a/vcsh b/vcsh index 47d8972c..7e3a7ec4 100755 --- a/vcsh +++ b/vcsh @@ -94,6 +94,7 @@ if [ ! "x$VCSH_WORKTREE" = 'xabsolute' ] && [ ! "x$VCSH_WORKTREE" = 'xrelative' fi +# editorconfig-checker-disable help() { echo "usage: $SELF @@ -137,6 +138,7 @@ help() { Shortcut to run git commands directly Shortcut to enter repository" >&2 } +# editorconfig-checker-enable debug() { [ -n "$VCSH_DEBUG" ] && echo "$SELF: debug: $@" @@ -163,7 +165,7 @@ clone() { git config branch."$VCSH_BRANCH".merge refs/heads/"$VCSH_BRANCH" if [ $(git ls-remote origin "$VCSH_BRANCH" 2> /dev/null | wc -l ) -lt 1 ]; then info "remote is empty, not merging anything. - You should add files to your new repository." + You should add files to your new repository." # editorconfig-checker-disable-line exit fi GIT_VERSION_MAJOR=$(git --version | sed -E -n 's/.* ([0-9]+)\..*/\1/p' ) @@ -180,7 +182,7 @@ clone() { done [ x"$VCSH_CONFLICT" = x'1' ]) && fatal "will stop after fetching and not try to merge! - Once this situation has been resolved, run 'vcsh $VCSH_REPO_NAME pull' to finish cloning." 17 + Once this situation has been resolved, run 'vcsh $VCSH_REPO_NAME pull' to finish cloning." 17 # editorconfig-checker-disable-line git -c merge.ff=true merge origin/"$VCSH_BRANCH" hook post-merge hook post-clone @@ -190,7 +192,7 @@ clone() { commit() { hook pre-commit - shift # remove the "commit" command. + shift # remove the "commit" command. for VCSH_REPO_NAME in $(list); do echo "$VCSH_REPO_NAME: " GIT_DIR=$VCSH_REPO_D/$VCSH_REPO_NAME.git; export GIT_DIR @@ -548,7 +550,7 @@ case $VCSH_COMMAND in versio|versi|vers|ver|ve) VCSH_COMMAND=version;; which|whi|wh) VCSH_COMMAND=which;; write|writ|wri|wr) VCSH_COMMAND=write-gitignore;; -esac +esac if [ x"$VCSH_COMMAND" = x'clone' ]; then VCSH_BRANCH= @@ -583,30 +585,30 @@ elif [ x"$VCSH_COMMAND" = x'which' ]; then [ -n "$3" ] && fatal "$VCSH_COMMAND: too many parameters" 1 VCSH_COMMAND_PARAMETER=$2; export VCSH_COMMAND_PARAMETER elif [ x"$VCSH_COMMAND" = x'delete' ] || - [ x"$VCSH_COMMAND" = x'enter' ] || - [ x"$VCSH_COMMAND" = x'init' ] || - [ x"$VCSH_COMMAND" = x'list-tracked-by' ] || - [ x"$VCSH_COMMAND" = x'rename' ] || - [ x"$VCSH_COMMAND" = x'run' ] || - [ x"$VCSH_COMMAND" = x'upgrade' ] || - [ x"$VCSH_COMMAND" = x'write-gitignore' ]; then + [ x"$VCSH_COMMAND" = x'enter' ] || + [ x"$VCSH_COMMAND" = x'init' ] || + [ x"$VCSH_COMMAND" = x'list-tracked-by' ] || + [ x"$VCSH_COMMAND" = x'rename' ] || + [ x"$VCSH_COMMAND" = x'run' ] || + [ x"$VCSH_COMMAND" = x'upgrade' ] || + [ x"$VCSH_COMMAND" = x'write-gitignore' ]; then [ -z "$2" ] && fatal "$VCSH_COMMAND: please specify repository to work on" 1 [ x"$VCSH_COMMAND" = x'rename' ] && [ -z "$3" ] && fatal "$VCSH_COMMAND: please specify a target name" 1 [ x"$VCSH_COMMAND" = x'run' ] && [ -z "$3" ] && fatal "$VCSH_COMMAND: please specify a command" 1 VCSH_REPO_NAME=$2; export VCSH_REPO_NAME GIT_DIR=$VCSH_REPO_D/$VCSH_REPO_NAME.git; export GIT_DIR [ x"$VCSH_COMMAND" = x'rename' ] && { VCSH_REPO_NAME_NEW=$3; export VCSH_REPO_NAME_NEW; - GIT_DIR_NEW=$VCSH_REPO_D/$VCSH_REPO_NAME_NEW.git; export GIT_DIR_NEW; } + GIT_DIR_NEW=$VCSH_REPO_D/$VCSH_REPO_NAME_NEW.git; export GIT_DIR_NEW; } [ x"$VCSH_COMMAND" = x'run' ] && shift 2 elif [ x"$VCSH_COMMAND" = x'foreach' ]; then [ -z "$2" ] && fatal "$VCSH_COMMAND: please specify a command" 1 shift 1 elif [ x"$VCSH_COMMAND" = x'commit' ] || - [ x"$VCSH_COMMAND" = x'list' ] || - [ x"$VCSH_COMMAND" = x'list-tracked' ] || - [ x"$VCSH_COMMAND" = x'list-untracked' ] || - [ x"$VCSH_COMMAND" = x'pull' ] || - [ x"$VCSH_COMMAND" = x'push' ]; then + [ x"$VCSH_COMMAND" = x'list' ] || + [ x"$VCSH_COMMAND" = x'list-tracked' ] || + [ x"$VCSH_COMMAND" = x'list-untracked' ] || + [ x"$VCSH_COMMAND" = x'pull' ] || + [ x"$VCSH_COMMAND" = x'push' ]; then : elif [ x"$VCSH_COMMAND" = x'status' ]; then if [ x"$2" = x'--terse' ]; then From fef6158d5def00b93e1ab8510c16d3c4a0ba310a Mon Sep 17 00:00:00 2001 From: Daniel Shahaf Date: Tue, 30 Mar 2021 17:17:33 +0000 Subject: [PATCH 036/121] Port ZSH completion fixes (#271) The change to __vcsh_repositories will require users to update zstyle settings, if anyone has created such zstyle settings. Ported (by Daniel Shahaf) from the following zsh upstream commit: commit 13fc579343b24d298fb8905933b6000d7fcda114 Author: Oliver Kiddle Date: Tue Oct 14 23:03:40 2014 +0200 33467: correct return status on functions and numerous other minor fixes With this change, our completion is a superset of zsh's _vcsh, so the latter may be removed. See issue #270. Co-authored-by: Oliver Kiddle --- _vcsh | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/_vcsh b/_vcsh index 9aca0f97..72924ce2 100644 --- a/_vcsh +++ b/_vcsh @@ -1,10 +1,9 @@ #compdef vcsh function __vcsh_repositories () { - local expl local -a repos - repos=( ${(f)"$(command vcsh list)"} ) - _describe -t repos 'repositories' repos + repos=( ${(f)"$(_call_program repositories vcsh list)"} ) + _describe -t repositories 'repository' repos } function __vcsh_not_implemented_yet () { @@ -56,9 +55,11 @@ function _vcsh-push () { } function _vcsh-rename () { - (( CURRENT == 2 )) && __vcsh_repositories - (( CURRENT == 3 )) && _message "new repository name" - (( CURRENT > 3 )) && _nothing + case $CURRENT in + 2) __vcsh_repositories ;; + 3) _message "new repository name" ;; + *) _nothing ;; + esac } function _vcsh-run () { @@ -93,7 +94,7 @@ function _vcsh-write-gitignore () { } function _vcsh () { - local curcontext="${curcontext}" + local curcontext="${curcontext}" ret=1 local state vcshcommand local -a args subcommands @@ -129,25 +130,26 @@ function _vcsh () { '*:: :->subcommand_or_options_or_repo' ) - _arguments -C ${args} && return + _arguments -C ${args} && ret=0 if [[ ${state} == "subcommand_or_options_or_repo" ]]; then if (( CURRENT == 1 )); then - _describe -t subcommands 'vcsh sub-commands' subcommands - __vcsh_repositories + _describe -t subcommands 'vcsh sub-commands' subcommands && ret=0 + __vcsh_repositories && ret=0 else vcshcommand="${words[1]}" if ! (( ${+functions[_vcsh-$vcshcommand]} )); then # There is no handler function, so this is probably the name # of a repository. Act accordingly. # FIXME: this may want to use '_dispatch vcsh git' - GIT_DIR=$VCSH_REPO_D/$words[1].git _dispatch git git + GIT_DIR=$VCSH_REPO_D/$words[1].git _dispatch git git && ret=0 else curcontext="${curcontext%:*:*}:vcsh-${vcshcommand}:" _call_function ret _vcsh-${vcshcommand} && (( ret )) fi fi fi + return ret } _vcsh "$@" From 832cfb0dba0d8c32ab3b8aff0faa4fd5a16c158a Mon Sep 17 00:00:00 2001 From: "martin f. krafft" Date: Wed, 31 Mar 2021 06:57:36 +1300 Subject: [PATCH 037/121] Make arg to write-gitignore optional (#245) Co-authored-by: Caleb Maclennan --- doc/vcsh.1.ronn | 5 +++-- vcsh | 11 +++++++---- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/doc/vcsh.1.ronn b/doc/vcsh.1.ronn index 6e19ef8b..c1021ae6 100644 --- a/doc/vcsh.1.ronn +++ b/doc/vcsh.1.ronn @@ -39,7 +39,7 @@ vcsh(1) - Version Control System for $HOME - multiple Git repositories in $HOME `vcsh` which -`vcsh` write-gitignore +`vcsh` write-gitignore [] `vcsh` @@ -170,7 +170,8 @@ an interactive user. Find in name of any tracked file. * write-gitignore: - Write .gitignore.d/ via `git ls-files`. + Write .gitignore.d/ via `git ls-files`. If is not specified but + we're withing a vcsh repository, use that. * : Shortcut to run `git` commands on a repo. Will prepend `git` to . diff --git a/vcsh b/vcsh index 7e3a7ec4..2ee44490 100755 --- a/vcsh +++ b/vcsh @@ -133,7 +133,7 @@ help() { version Print version information which Find substring in name of any tracked file write-gitignore \\ - Write .gitignore.d/ via git ls-files + [] Write .gitignore.d/ via git ls-files Shortcut to run git commands directly Shortcut to enter repository" >&2 @@ -592,11 +592,14 @@ elif [ x"$VCSH_COMMAND" = x'delete' ] || [ x"$VCSH_COMMAND" = x'run' ] || [ x"$VCSH_COMMAND" = x'upgrade' ] || [ x"$VCSH_COMMAND" = x'write-gitignore' ]; then - [ -z "$2" ] && fatal "$VCSH_COMMAND: please specify repository to work on" 1 + if [ -z "$2" ]; then + [ -z "$VCSH_REPO_NAME" ] && fatal "$VCSH_COMMAND: please specify repository to work on" 1 + else + VCSH_REPO_NAME=$2; export VCSH_REPO_NAME + fi + GIT_DIR=$VCSH_REPO_D/$VCSH_REPO_NAME.git; export GIT_DIR [ x"$VCSH_COMMAND" = x'rename' ] && [ -z "$3" ] && fatal "$VCSH_COMMAND: please specify a target name" 1 [ x"$VCSH_COMMAND" = x'run' ] && [ -z "$3" ] && fatal "$VCSH_COMMAND: please specify a command" 1 - VCSH_REPO_NAME=$2; export VCSH_REPO_NAME - GIT_DIR=$VCSH_REPO_D/$VCSH_REPO_NAME.git; export GIT_DIR [ x"$VCSH_COMMAND" = x'rename' ] && { VCSH_REPO_NAME_NEW=$3; export VCSH_REPO_NAME_NEW; GIT_DIR_NEW=$VCSH_REPO_D/$VCSH_REPO_NAME_NEW.git; export GIT_DIR_NEW; } [ x"$VCSH_COMMAND" = x'run' ] && shift 2 From 22099c456ea606929aed592e44f70c3ab01416c3 Mon Sep 17 00:00:00 2001 From: Harendra Kumar Date: Mon, 11 Jul 2016 14:15:57 +0530 Subject: [PATCH 038/121] Use git read-tree (dry run) to detect conflicts (#210) ls-tree does not account for sparse checkout settings and therefore reports spurious conflicts if an existing file in the worktree conflicts with a file in the repository which is not even being checked out. On the other hand, read-tree takes care of sparse checkout settings. --- vcsh | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/vcsh b/vcsh index 2ee44490..973f74f9 100755 --- a/vcsh +++ b/vcsh @@ -175,13 +175,8 @@ clone() { git fetch origin fi hook pre-merge - git ls-tree -r --name-only origin/"$VCSH_BRANCH" | (while read object; do - [ -e "$object" ] && - error "'$object' exists." && - VCSH_CONFLICT=1 - done - [ x"$VCSH_CONFLICT" = x'1' ]) && - fatal "will stop after fetching and not try to merge! + git read-tree -n -mu origin/"$VCSH_BRANCH" \ + || fatal "will stop after fetching and not try to merge! Once this situation has been resolved, run 'vcsh $VCSH_REPO_NAME pull' to finish cloning." 17 # editorconfig-checker-disable-line git -c merge.ff=true merge origin/"$VCSH_BRANCH" hook post-merge From abe4ae64da7c7fb96d72b3cc468afc1a1d83c1fb Mon Sep 17 00:00:00 2001 From: Noah Birnel Date: Sun, 15 Nov 2015 18:43:02 -0800 Subject: [PATCH 039/121] =?UTF-8?q?Remove=20=E2=80=98test=E2=80=99=20targe?= =?UTF-8?q?t=20from=20=E2=80=98install=E2=80=99=20dependencies?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index b9154e7f..df633ffb 100644 --- a/Makefile +++ b/Makefile @@ -10,7 +10,7 @@ all=test manpages all: $(all) -install: all +install: manpages install -d $(DESTDIR)$(PREFIX)/bin install -m 0755 $(self) $(DESTDIR)$(PREFIX)/bin install -d $(DESTDIR)$(PREFIX)/share/man/man1 From 4cb22db1730eed49db101c297426570939bfdebd Mon Sep 17 00:00:00 2001 From: Caleb Maclennan Date: Tue, 30 Mar 2021 22:41:27 +0300 Subject: [PATCH 040/121] Decouple build targets from test target --- Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index df633ffb..dc2b199d 100644 --- a/Makefile +++ b/Makefile @@ -6,11 +6,11 @@ RONN ?= ronn self=vcsh manpages=$(self).1 -all=test manpages +all=manpages all: $(all) -install: manpages +install: all install -d $(DESTDIR)$(PREFIX)/bin install -m 0755 $(self) $(DESTDIR)$(PREFIX)/bin install -d $(DESTDIR)$(PREFIX)/share/man/man1 From c0d7264ea5c594b26395b98d8b3d750daf6df0e7 Mon Sep 17 00:00:00 2001 From: Noah Birnel Date: Sun, 15 Nov 2015 18:43:02 -0800 Subject: [PATCH 041/121] Clarify README/INSTALL --- README.md | 16 +++++++++------- doc/INSTALL.md | 13 ++++++++++++- 2 files changed, 21 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index f885b4a3..88acfaf7 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,8 @@ vcsh - Version Control System for $HOME - multiple Git repositories in $HOME 1. [30 Second How-to](#30-second-how-to) 2. [Introduction](#introduction) -3. [Contact](#contact) +3. [Installation](#installation) +4. [Contact](#contact) # 30 Second How-to @@ -47,12 +48,6 @@ For example, you may not need to have your `mplayer` configuration on a server or available to root and you may want to maintain different configuration for `ssh` on your personal and your work machines. -A lot of modern UNIX-based systems offer packages for `vcsh`. In case yours -does not, read [INSTALL.md](doc/INSTALL.md) for install instructions or -[PACKAGING.md](doc/PACKAGING.md) to create a package yourself. If you do end -up packaging `vcsh` please let us know so we can give you your own packaging -branch in the upstream repository. - ## Talks Some people found it useful to look at slides and videos explaining how `vcsh` @@ -60,6 +55,13 @@ works instead of working through the docs. All slides, videos, and further information can be found [on the author's talk page][talks]. +# Installation + +A lot of modern UNIX-based systems offer packages for `vcsh`. In case yours +does not, read [INSTALL.md](doc/INSTALL.md) for install instructions or +[PACKAGING.md](doc/PACKAGING.md) to create a package yourself. If you do end +up packaging `vcsh` please let us know so we can give you your own packaging +branch in the upstream repository. # Contact diff --git a/doc/INSTALL.md b/doc/INSTALL.md index 65fc5f3b..e6c6c028 100644 --- a/doc/INSTALL.md +++ b/doc/INSTALL.md @@ -44,7 +44,18 @@ To clean up the generated manpage, run make clean -and if you are bored, I suggest +To run the test suite, run + + make test + +To run the test suite, you will need `perl`, +and the modules `Test::Most` and `Shell::Command`. + +To install the perl modules, run + + cpan install 'Test::Most' 'Shell::Command'. + +If you are bored, I suggest make moo From 72aab0b39d7265acb8b2990e9f7a236fd71399f7 Mon Sep 17 00:00:00 2001 From: Caleb Maclennan Date: Wed, 31 Mar 2021 17:11:16 +0300 Subject: [PATCH 042/121] =?UTF-8?q?Catch=20=E2=80=98help=E2=80=99=20as=20v?= =?UTF-8?q?alid=20command?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- vcsh | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/vcsh b/vcsh index 448ea8d7..ba289e24 100755 --- a/vcsh +++ b/vcsh @@ -571,6 +571,8 @@ if [ x"$VCSH_COMMAND" = x'clone' ]; then export VCSH_REPO_NAME [ -n "$VCSH_BRANCH" ] || VCSH_BRANCH=master GIT_DIR=$VCSH_REPO_D/$VCSH_REPO_NAME.git; export GIT_DIR +elif [ "$VCSH_COMMAND" = 'help' ]; then + help && exit elif [ "$VCSH_COMMAND" = 'version' ]; then echo "$SELF $VERSION" git version @@ -627,8 +629,8 @@ elif [ -n "$VCSH_COMMAND" ]; then GIT_DIR=$VCSH_REPO_D/$VCSH_REPO_NAME.git; export GIT_DIR [ -d "$GIT_DIR" ] || { help; exit 1; } else - # $1 is empty, or 'help' - help && exit + # $1 is empty + help && exit 1 fi # Did we receive a directory instead of a name? From 063a2eaf26cfb2599f2bd7732ae15950081e9b35 Mon Sep 17 00:00:00 2001 From: James Davidson Date: Fri, 17 Apr 2020 12:10:38 -0700 Subject: [PATCH 043/121] Make repos an associative array There are uses of the repos array such as "${repos[$subcmd]}" and "${repos[$cmd]}" which requires that the repos array be associative to retrieve the correct value. With an indexed array, the integer conversion of the subscript will be 0 which is not what is required. If the subscript contains a period ('.'), bash returns an error trying to convert the subscript to an integer. For example, trying to bash complete for 'add': vcsh bashrc.d adbash: bashrc.d: syntax error: invalid arithmetic operator (error token is ".d") --- _vcsh_bash | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/_vcsh_bash b/_vcsh_bash index 3cfe88a6..93bf9107 100644 --- a/_vcsh_bash +++ b/_vcsh_bash @@ -55,8 +55,12 @@ _vcsh () { local cur prev words cword OPTS _init_completion -n = || return - local repos cmds - repos=( $(command vcsh list) ) + local r reponames + local -A repos + mapfile -t reponames < <(command vcsh list) + for r in "${reponames[@]}"; do repos["$r"]="$r"; done + unset r reponames + local cmds cmds="clone delete enter foreach help init list list-tracked list-untracked pull push rename run status upgrade version which write-gitignore" From 5e2fb0ef7912fbf7cec620ef06e083b933725548 Mon Sep 17 00:00:00 2001 From: James Davidson Date: Fri, 17 Apr 2020 12:41:16 -0700 Subject: [PATCH 044/121] Add emacs bash mode variables --- _vcsh_bash | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/_vcsh_bash b/_vcsh_bash index 93bf9107..c278d742 100644 --- a/_vcsh_bash +++ b/_vcsh_bash @@ -139,4 +139,8 @@ _vcsh () { complete -F _vcsh vcsh +# Local Variables: +# mode:shell-script +# sh-shell:bash +# End: # vim: ft=sh: From 2d4bc6b4755c6e4d345d845517c33c82de872f1e Mon Sep 17 00:00:00 2001 From: James Davidson Date: Fri, 17 Apr 2020 12:44:51 -0700 Subject: [PATCH 045/121] Remove unused cword variable --- _vcsh_bash | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/_vcsh_bash b/_vcsh_bash index c278d742..87b5b714 100644 --- a/_vcsh_bash +++ b/_vcsh_bash @@ -52,7 +52,7 @@ _vcsh_git_command () { } _vcsh () { - local cur prev words cword OPTS + local cur prev words OPTS _init_completion -n = || return local r reponames From 69497b18f17a7062ecc64459257fff151107d079 Mon Sep 17 00:00:00 2001 From: James Davidson Date: Fri, 17 Apr 2020 12:51:50 -0700 Subject: [PATCH 046/121] Remove $ from variables in arithmetic context These uses are flagged from shellcheck as: $/${} is unnecessary on arithmetic variables. [SC2004] See https://github.com/koalaman/shellcheck/wiki/SC2004 for more details. --- _vcsh_bash | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/_vcsh_bash b/_vcsh_bash index 87b5b714..d4a2b077 100644 --- a/_vcsh_bash +++ b/_vcsh_bash @@ -4,7 +4,7 @@ # based on bash_completion:_command_offset() _vcsh_git_command () { local word_offset=$1 - for (( i=0; i < $word_offset; i++ )); do + for (( i=0; i < word_offset; i++ )); do for (( j=0; j <= ${#COMP_LINE}; j++ )); do [[ "$COMP_LINE" == "${COMP_WORDS[i]}"* ]] && break COMP_LINE=${COMP_LINE:1} @@ -17,14 +17,14 @@ _vcsh_git_command () { ((COMP_POINT+=4)) # shift COMP_WORDS elements and adjust COMP_CWORD - for (( i=1; i <= COMP_CWORD - $word_offset + 1; i++ )); do + for (( i=1; i <= COMP_CWORD - word_offset + 1; i++ )); do COMP_WORDS[i]=${COMP_WORDS[i+$word_offset-1]} done for (( i; i <= COMP_CWORD; i++ )); do unset 'COMP_WORDS[i]' done COMP_WORDS[0]=git - ((COMP_CWORD -= $word_offset - 1)) + ((COMP_CWORD -= word_offset - 1)) local cspec=$( complete -p git 2>/dev/null ) if [[ -n $cspec ]]; then @@ -101,7 +101,7 @@ _vcsh () { run) if [[ -n $subcmd && -n "${repos[$subcmd]}" ]]; then - _command_offset $(( $subcword+1 )) + _command_offset $(( subcword+1 )) return fi ;;& From 0e9daf792587fd2ec572539b1ae43844444fb0bb Mon Sep 17 00:00:00 2001 From: James Davidson Date: Fri, 17 Apr 2020 13:02:57 -0700 Subject: [PATCH 047/121] Quote variables to prevent globbing/splitting These uses are flagged from shellcheck as: Double quote to prevent globbing and word splitting. [SC2086] See https://github.com/koalaman/shellcheck/wiki/SC2086 for more details. --- _vcsh_bash | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/_vcsh_bash b/_vcsh_bash index d4a2b077..e22c78ee 100644 --- a/_vcsh_bash +++ b/_vcsh_bash @@ -73,7 +73,7 @@ _vcsh () { if [[ -z $cmd ]]; then case $prev in -c) - COMPREPLY=( $(compgen -f -- $cur) ) + COMPREPLY=( $(compgen -f -- "$cur") ) return ;; esac @@ -81,11 +81,11 @@ _vcsh () { case $cur in -*) OPTS='-c -d -h -v' - COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) ) + COMPREPLY=( $(compgen -W "${OPTS[*]}" -- "$cur") ) return ;; esac - COMPREPLY=( $(compgen -W "${repos[*]} ${cmds[*]}" -- $cur) ) + COMPREPLY=( $(compgen -W "${repos[*]} ${cmds[*]}" -- "$cur") ) return 0 fi @@ -96,7 +96,7 @@ _vcsh () { list-untracked) [[ $cur == -* ]] && \ - COMPREPLY=( $(compgen -W '-a -r' -- $cur) ) && return + COMPREPLY=( $(compgen -W '-a -r' -- "$cur") ) && return ;;& run) @@ -109,7 +109,7 @@ _vcsh () { delete|enter|list-tracked|list-untracked|rename|run|status|upgrade|write-gitignore) # return repos if [[ -z $subcmd ]]; then - COMPREPLY=( $(compgen -W "${repos[*]}" -- $cur) ) + COMPREPLY=( $(compgen -W "${repos[*]}" -- "$cur") ) return fi return @@ -117,13 +117,13 @@ _vcsh () { clone) [[ $cur == -* ]] && \ - COMPREPLY=( $(compgen -W '-b' -- $cur) ) + COMPREPLY=( $(compgen -W '-b' -- "$cur") ) return ;; foreach) [[ $cur == -* ]] \ - && COMPREPLY=( $(compgen -W "-g" -- $cur) ) && return + && COMPREPLY=( $(compgen -W "-g" -- "$cur") ) && return _vcsh_git_command $subcword return ;; From 97f52485c5b2df2799e2478410e56e0c8c05359f Mon Sep 17 00:00:00 2001 From: James Davidson Date: Fri, 17 Apr 2020 13:11:40 -0700 Subject: [PATCH 048/121] Use mapfile to avoid globbing/splitting These uses are flagged from shellcheck as: Prefer mapfile or read -a to split command output (or quote to avoid splitting). [SC2207] See https://github.com/koalaman/shellcheck/wiki/SC2207 for more details. --- _vcsh_bash | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/_vcsh_bash b/_vcsh_bash index e22c78ee..9f315169 100644 --- a/_vcsh_bash +++ b/_vcsh_bash @@ -73,7 +73,7 @@ _vcsh () { if [[ -z $cmd ]]; then case $prev in -c) - COMPREPLY=( $(compgen -f -- "$cur") ) + mapfile -t COMPREPLY < <(compgen -f -- "$cur") return ;; esac @@ -81,11 +81,11 @@ _vcsh () { case $cur in -*) OPTS='-c -d -h -v' - COMPREPLY=( $(compgen -W "${OPTS[*]}" -- "$cur") ) + mapfile -t COMPREPLY < <(compgen -W "${OPTS[*]}" -- "$cur") return ;; esac - COMPREPLY=( $(compgen -W "${repos[*]} ${cmds[*]}" -- "$cur") ) + mapfile -t COMPREPLY < <(compgen -W "${repos[*]} ${cmds[*]}" -- "$cur") return 0 fi @@ -96,7 +96,7 @@ _vcsh () { list-untracked) [[ $cur == -* ]] && \ - COMPREPLY=( $(compgen -W '-a -r' -- "$cur") ) && return + mapfile -t COMPREPLY < <(compgen -W '-a -r' -- "$cur") && return ;;& run) @@ -109,7 +109,7 @@ _vcsh () { delete|enter|list-tracked|list-untracked|rename|run|status|upgrade|write-gitignore) # return repos if [[ -z $subcmd ]]; then - COMPREPLY=( $(compgen -W "${repos[*]}" -- "$cur") ) + mapfile -t COMPREPLY < <(compgen -W "${repos[*]}" -- "$cur") return fi return @@ -117,13 +117,13 @@ _vcsh () { clone) [[ $cur == -* ]] && \ - COMPREPLY=( $(compgen -W '-b' -- "$cur") ) + mapfile -t COMPREPLY < <(compgen -W '-b' -- "$cur") return ;; foreach) [[ $cur == -* ]] \ - && COMPREPLY=( $(compgen -W "-g" -- "$cur") ) && return + && mapfile -t COMPREPLY < <(compgen -W "-g" -- "$cur") && return _vcsh_git_command $subcword return ;; From 7f4155eb4f7112f5e60a947386de51c093f2d31f Mon Sep 17 00:00:00 2001 From: James Davidson Date: Fri, 17 Apr 2020 13:25:02 -0700 Subject: [PATCH 049/121] Fix use of non-array variables OPTS and cmds are not arrays so do not reference them if they were. --- _vcsh_bash | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/_vcsh_bash b/_vcsh_bash index 9f315169..2baec84c 100644 --- a/_vcsh_bash +++ b/_vcsh_bash @@ -81,11 +81,11 @@ _vcsh () { case $cur in -*) OPTS='-c -d -h -v' - mapfile -t COMPREPLY < <(compgen -W "${OPTS[*]}" -- "$cur") + mapfile -t COMPREPLY < <(compgen -W "$OPTS" -- "$cur") return ;; esac - mapfile -t COMPREPLY < <(compgen -W "${repos[*]} ${cmds[*]}" -- "$cur") + mapfile -t COMPREPLY < <(compgen -W "${repos[*]} ${cmds}" -- "$cur") return 0 fi From c8d366b59eff67be357afd25a2297d43d895fa53 Mon Sep 17 00:00:00 2001 From: Caleb Maclennan Date: Thu, 1 Apr 2021 11:54:49 +0300 Subject: [PATCH 050/121] Anchor file paths to $HOME in status output --- t/300-add.t | 4 ++-- vcsh | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/t/300-add.t b/t/300-add.t index 4acd0a2c..7a74159e 100644 --- a/t/300-add.t +++ b/t/300-add.t @@ -25,14 +25,14 @@ system (".././vcsh test1 add 'a'"); my $output = `.././vcsh status`; ok $output eq "test1: -A a +A ~/a ", 'Adding a file works'; $output = `.././vcsh status --terse`; ok $output eq "test1: -A a +A ~/a ", 'Terse output works'; done_testing; diff --git a/vcsh b/vcsh index 3eb8e7e2..ef2b3a43 100755 --- a/vcsh +++ b/vcsh @@ -430,7 +430,7 @@ status_helper() { [ ${commits_behind} -ne 0 ] && echo "Behind $remote_tracking_branch by $commits_behind commits" [ ${commits_ahead} -ne 0 ] && echo "Ahead of $remote_tracking_branch by $commits_ahead commits" } - git ${VCSH_GIT_OPTIONS} status --short --untracked-files='no' + git ${VCSH_GIT_OPTIONS} status --short --untracked-files='no' | sed -E 's@([^ ] +)@\1~/@' VCSH_COMMAND_RETURN_CODE=$? } From d157e585cf8ba6b6a17d60cf56297b3f928af055 Mon Sep 17 00:00:00 2001 From: Caleb Maclennan Date: Thu, 1 Apr 2021 12:44:03 +0300 Subject: [PATCH 051/121] Populate test runner's Git config to suppress warnings in output --- t/001-setup-env.t | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/t/001-setup-env.t b/t/001-setup-env.t index fb59f058..43a2be8b 100644 --- a/t/001-setup-env.t +++ b/t/001-setup-env.t @@ -3,6 +3,7 @@ use strict; use warnings; +use Cwd 'abs_path'; use Test::Most; system ("mkdir -p t/etc"); @@ -16,4 +17,9 @@ chdir 't/etc/' or die $!; system ("ln -s '../../vcsh'"); ok !$?; +$ENV{'HOME'} = abs_path ('.vcsh_home'); + +system ("git config --global init.defaultBranch test"); +ok !$?; + done_testing; From 4f070d38b96cf3378cdb78984073ceed22f58563 Mon Sep 17 00:00:00 2001 From: Caleb Maclennan Date: Fri, 2 Apr 2021 10:32:48 +0300 Subject: [PATCH 052/121] Override XDG_CONFIG_HOME in test fixtures Co-authored-by: Richard Hartmann --- t/001-setup-env.t | 1 + t/100-init.t | 1 + t/300-add.t | 1 + t/950-delete.t | 1 + 4 files changed, 4 insertions(+) diff --git a/t/001-setup-env.t b/t/001-setup-env.t index 43a2be8b..b50313b9 100644 --- a/t/001-setup-env.t +++ b/t/001-setup-env.t @@ -18,6 +18,7 @@ system ("ln -s '../../vcsh'"); ok !$?; $ENV{'HOME'} = abs_path ('.vcsh_home'); +$ENV{'XDG_CONFIG_HOME'} = $ENV{'HOME'}.'/.config'; system ("git config --global init.defaultBranch test"); ok !$?; diff --git a/t/100-init.t b/t/100-init.t index 15ce922f..c8984281 100644 --- a/t/100-init.t +++ b/t/100-init.t @@ -11,6 +11,7 @@ use Test::Most; chdir 't/etc/' or die $!; $ENV{'HOME'} = abs_path ('.vcsh_home'); +$ENV{'XDG_CONFIG_HOME'} = $ENV{'HOME'}.'/.config'; my $output = `./vcsh status`; diff --git a/t/300-add.t b/t/300-add.t index 7a74159e..c7e9d2f4 100644 --- a/t/300-add.t +++ b/t/300-add.t @@ -11,6 +11,7 @@ use Test::Most; chdir 't/etc/' or die $!; $ENV{'HOME'} = abs_path ('.vcsh_home'); +$ENV{'XDG_CONFIG_HOME'} = $ENV{'HOME'}.'/.config'; chdir '.vcsh_home' or die $!; diff --git a/t/950-delete.t b/t/950-delete.t index cd078714..012586b7 100644 --- a/t/950-delete.t +++ b/t/950-delete.t @@ -9,6 +9,7 @@ use Test::Most; chdir 't/etc/' or die $!; $ENV{'HOME'} = abs_path ('.vcsh_home'); +$ENV{'XDG_CONFIG_HOME'} = $ENV{'HOME'}.'/.config'; system ("echo 'Yes, do as I say' | ./vcsh delete test1"); From 2cc13616356b218cc564fa3ae3559caf8dd03f26 Mon Sep 17 00:00:00 2001 From: Richard Hartmann Date: Fri, 2 Apr 2021 14:58:16 +0200 Subject: [PATCH 053/121] Update README.md --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 09f97fb2..e1df357f 100644 --- a/README.md +++ b/README.md @@ -49,7 +49,7 @@ or available to root and you may want to maintain different configuration for ## Talks -Some people found it useful to look at slides and videos explaining how `vcsh` +Some people found it useful to look at [slides](https://github.com/RichiH/talks/blob/main/2013/10-linuxcon-eu/linuxcon_eu-2013-10-gitify_your_life.pdf) and videos explaining how `vcsh` works instead of working through the docs. All slides, videos, and further information can be found [on the author's talk page][talks]. @@ -75,6 +75,6 @@ community around the general idea of version controlling your (digital) life. [myrepos]: http://myrepos.branchable.com/ -[talks]: http://richardhartmann.de/talks/ +[talks]: https://github.com/RichiH/talks [vcsh]: https://github.com/RichiH/vcsh [vcs-home-list]: http://lists.madduck.net/listinfo/vcs-home From 6226ab8f158b834b70370e2ac2f0f0f6450af469 Mon Sep 17 00:00:00 2001 From: James Davidson Date: Fri, 17 Apr 2020 15:54:19 -0700 Subject: [PATCH 054/121] Pass GIT_DIR to _vcsh_git_command completion helper Setting GIT_DIR appropriately improves the completion behaviour for git subcommands. This change is equivalent to commit b99d26914007cd902b92c5fe0524a233d778a724 for zsh completion. --- _vcsh_bash | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/_vcsh_bash b/_vcsh_bash index 2baec84c..084b3eec 100644 --- a/_vcsh_bash +++ b/_vcsh_bash @@ -132,7 +132,8 @@ _vcsh () { # git command on repository if [[ -n "${repos[$cmd]}" ]]; then - _vcsh_git_command $subcword + : "${VCSH_REPO_D:=${XDG_CONFIG_HOME:-$HOME/.config}/vcsh/repo.d}" + GIT_DIR="${VCSH_REPO_D}/${cmd}.git" _vcsh_git_command "$subcword" fi return 0 } From 78a05e1ad340d03cdc55bd5f57089b84779ee513 Mon Sep 17 00:00:00 2001 From: Caleb Maclennan Date: Sat, 3 Apr 2021 12:13:47 +0300 Subject: [PATCH 055/121] Fix broken getopts() usage, allows multiple flags MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The current usage of getopts is a kind of dirty hack: using it to iterate over passable arguments but using a hand rolled flag matching syntax. It appears this was done as a workaround to catch a long form ‘--debug’ argument, but I believe it introduces more problems than it solves. The long form argument does sort of work, but only after getpots throws an error about invalid argument syntax and only on a fluke of ‘-d’ being a substring of ‘--debug’ and getpots having assigned ‘ebug’ as $OPTARG. In one sense this is a regression because it removes the long form option parsing, but it was not documented in help anyway and I believe it is unlikely anybody is using this particular flag in a script that will break. On the other hand with proper iteration of the getopts assigned flags variable, we can now properly handle multiple flags. Previously things like `-d -v` or `-v -c foo` would attempt to do crazy broken things such as: GIT_DIR=/home/caleb/.config/vcsh/repo.d/-v.git Now multiple flag handling just works as expected. --- vcsh | 42 +++++++++++++++++++++++------------------- 1 file changed, 23 insertions(+), 19 deletions(-) diff --git a/vcsh b/vcsh index ab8e7f64..5a3b9439 100755 --- a/vcsh +++ b/vcsh @@ -34,21 +34,25 @@ fatal() { # We need to run getops as soon as possible so we catch -d and other # options that will modify our behaviour. # Commands are handled at the end of this script. -while getopts "c:dv" flag; do - if [ x"$1" = x'-d' ] || [ x"$1" = x'--debug' ]; then - set -vx - VCSH_DEBUG=1 - echo "debug mode on" - echo "$SELF $VERSION" - elif [ x"$1" = x'-v' ]; then - VCSH_VERBOSE=1 - echo "verbose mode on" - echo "$SELF $VERSION" - elif [ x"$1" = x'-c' ]; then - VCSH_OPTION_CONFIG=$OPTARG - fi - shift 1 +while getopts c:dv flag; do + case "$flag" in + d) + set -vx + VCSH_DEBUG=1 + echo 'debug mode on' + echo "$SELF $VERSION" + ;; + v) + VCSH_VERBOSE=1 + echo 'verbose mode on' + echo "$SELF $VERSION" + ;; + c) + VCSH_OPTION_CONFIG="$OPTARG" + ;; + esac done +shift $((OPTIND-1)) source_all() { # Source file even if it's in $PWD and does not have any slashes in it @@ -233,12 +237,12 @@ foreach() { # We default to prefixing `git` to all commands passed to foreach, but # allow running in general context with -g command_prefix=git - while getopts "g" flag; do - if [ x"$1" = x'-g' ]; then - unset command_prefix - fi - shift 1 + while getopts g flag; do + case "$flag" in + g) unset command_prefix ;; + esac done + shift $((OPTIND-1)) for VCSH_REPO_NAME in $(list); do echo "$VCSH_REPO_NAME:" GIT_DIR=$VCSH_REPO_D/$VCSH_REPO_NAME.git; export GIT_DIR From 87c12fe114e11dc6aef1cc8470424b1eacb9b1dc Mon Sep 17 00:00:00 2001 From: Caleb Maclennan Date: Sat, 3 Apr 2021 11:55:22 +0300 Subject: [PATCH 056/121] Fix opt processing, avoid eval and useless cat --- vcsh | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/vcsh b/vcsh index 38d505ba..64c941cd 100755 --- a/vcsh +++ b/vcsh @@ -235,20 +235,21 @@ foreach() { # We default to prefixing `git` to all commands passed to foreach, but # allow running in general context with -g command_prefix=git - command_suffix='cat' - while getopts "gp" flag; do - if [ x"$1" = x'-g' ]; then - unset command_prefix - fi - if [ x"$1" = x'-p' ]; then - command_suffix='sed "s/^/$VCSH_REPO_NAME: /"' - fi - shift 1 + while getopts gp flag; do + case "$flag" in + g) unset command_prefix ;; + p) VCSH_PRINT_REPO_PREFIX=1 ;; + esac done + shift $((OPTIND-1)) for VCSH_REPO_NAME in $(list); do GIT_DIR=$VCSH_REPO_D/$VCSH_REPO_NAME.git; export GIT_DIR use - $command_prefix "$@" | eval $command_suffix + if [ -n "${VCSH_PRINT_REPO_PREFIX+x}" ]; then + $command_prefix "$@" | sed "s/^/$VCSH_REPO_NAME: /" + else + $command_prefix "$@" + fi done hook post-foreach } From 680cd47fcdf0c29a4066df3aab6911ea8554d00d Mon Sep 17 00:00:00 2001 From: Caleb Maclennan Date: Sat, 3 Apr 2021 16:58:55 +0300 Subject: [PATCH 057/121] Restore header, removal was regression in PR --- vcsh | 1 + 1 file changed, 1 insertion(+) diff --git a/vcsh b/vcsh index 35c4bfd4..0ede4a6a 100755 --- a/vcsh +++ b/vcsh @@ -251,6 +251,7 @@ foreach() { if [ -n "${VCSH_PRINT_REPO_PREFIX+x}" ]; then $command_prefix "$@" | sed "s/^/$VCSH_REPO_NAME: /" else + echo "$VCSH_REPO_NAME:" $command_prefix "$@" fi done From 444da8735776e652778d79dc092bc282b258c016 Mon Sep 17 00:00:00 2001 From: tikki Date: Sun, 28 Oct 2018 16:45:27 +0100 Subject: [PATCH 058/121] Don't try to push/pull from repos without remote --- vcsh | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/vcsh b/vcsh index ab8e7f64..fb2e3079 100755 --- a/vcsh +++ b/vcsh @@ -276,6 +276,13 @@ list() { done } +list_has_remote() { + for VCSH_REPO_NAME in $(list); do + GIT_DIR=$VCSH_REPO_D/$VCSH_REPO_NAME.git; export GIT_DIR + git config remote.origin.url >/dev/null && echo "$VCSH_REPO_NAME" + done +} + get_files() { GIT_DIR=$VCSH_REPO_D/$VCSH_REPO_NAME.git; export GIT_DIR git ls-files --full-name @@ -354,7 +361,7 @@ list_untracked_helper() { pull() { hook pre-pull - for VCSH_REPO_NAME in $(list); do + for VCSH_REPO_NAME in $(list_has_remote); do printf '%s: ' "$VCSH_REPO_NAME" GIT_DIR=$VCSH_REPO_D/$VCSH_REPO_NAME.git; export GIT_DIR use @@ -367,7 +374,7 @@ pull() { push() { hook pre-push - for VCSH_REPO_NAME in $(list); do + for VCSH_REPO_NAME in $(list_has_remote); do printf '%s: ' "$VCSH_REPO_NAME" GIT_DIR=$VCSH_REPO_D/$VCSH_REPO_NAME.git; export GIT_DIR use From cbfd1ff9349b684a8e8ae33de0165818cc3ebe4d Mon Sep 17 00:00:00 2001 From: tikki Date: Sat, 3 Apr 2021 12:17:21 +0200 Subject: [PATCH 059/121] Support any remote name Co-authored-by: Caleb Maclennan --- vcsh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vcsh b/vcsh index fb2e3079..c1ec8a6b 100755 --- a/vcsh +++ b/vcsh @@ -279,7 +279,7 @@ list() { list_has_remote() { for VCSH_REPO_NAME in $(list); do GIT_DIR=$VCSH_REPO_D/$VCSH_REPO_NAME.git; export GIT_DIR - git config remote.origin.url >/dev/null && echo "$VCSH_REPO_NAME" + git config branch.$VCSH_BRANCH.remote > /dev/null && echo "$VCSH_REPO_NAME" done } From 2e54e04344b260a78f8efc772cf83c4fcb33bd7a Mon Sep 17 00:00:00 2001 From: Caleb Maclennan Date: Sat, 3 Apr 2021 20:24:28 +0300 Subject: [PATCH 060/121] Rename hook function per general schema --- vcsh | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/vcsh b/vcsh index 58f5240f..eb11d5ce 100755 --- a/vcsh +++ b/vcsh @@ -192,19 +192,19 @@ clone() { } commit() { - global_hook pre-commit + hook_global pre-commit shift # remove the "commit" command. for VCSH_REPO_NAME in $(list); do echo "$VCSH_REPO_NAME: " GIT_DIR=$VCSH_REPO_D/$VCSH_REPO_NAME.git; export GIT_DIR use - repo_hook pre-commit + hook_repo pre-commit git commit --untracked-files=no --quiet "$@" - repo_hook post-commit + hook_repo post-commit VCSH_COMMAND_RETURN_CODE=$? echo done - global_hook post-commit + hook_global post-commit } delete() { @@ -234,7 +234,7 @@ enter() { } foreach() { - global_hook pre-foreach + hook_global pre-foreach # We default to prefixing `git` to all commands passed to foreach, but # allow running in general context with -g @@ -249,18 +249,18 @@ foreach() { echo "$VCSH_REPO_NAME:" GIT_DIR=$VCSH_REPO_D/$VCSH_REPO_NAME.git; export GIT_DIR use - repo_hook pre-foreach + hook_repo pre-foreach $command_prefix "$@" - repo_hook post-foreach + hook_repo post-foreach done - global_hook post-foreach + hook_global post-foreach } git_dir_exists() { [ -d "$GIT_DIR" ] || fatal "no repository found for '$VCSH_REPO_NAME'" 12 } -global_hook() { +hook_global() { for hook in "$VCSH_HOOK_D/$1"*; do [ -x "$hook" ] || continue verbose "executing '$hook'" @@ -268,7 +268,7 @@ global_hook() { done } -repo_hook() { +hook_repo() { for hook in "$VCSH_HOOK_D/$VCSH_REPO_NAME.$1"*; do [ -x "$hook" ] || continue verbose "executing '$hook'" @@ -277,8 +277,8 @@ repo_hook() { } hook() { - global_hook "$1" - repo_hook "$1" + hook_global "$1" + hook_repo "$1" } init() { @@ -381,33 +381,33 @@ list_untracked_helper() { } pull() { - global_hook pre-pull + hook_global pre-pull for VCSH_REPO_NAME in $(list_has_remote); do printf '%s: ' "$VCSH_REPO_NAME" GIT_DIR=$VCSH_REPO_D/$VCSH_REPO_NAME.git; export GIT_DIR use - repo_hook pre-pull + hook_repo pre-pull git pull - repo_hook post-pull + hook_repo post-pull VCSH_COMMAND_RETURN_CODE=$? echo done - global_hook post-pull + hook_global post-pull } push() { - global_hook pre-push + hook_global pre-push for VCSH_REPO_NAME in $(list_has_remote); do printf '%s: ' "$VCSH_REPO_NAME" GIT_DIR=$VCSH_REPO_D/$VCSH_REPO_NAME.git; export GIT_DIR use - repo_hook pre-push + hook_repo pre-push git push - repo_hook post-push + hook_repo post-push VCSH_COMMAND_RETURN_CODE=$? echo done - global_hook post-push + hook_global post-push } retire() { From 66944d009b8df64e0b2ddae757a83899ff8684b7 Mon Sep 17 00:00:00 2001 From: Caleb Maclennan Date: Wed, 31 Mar 2021 22:44:36 +0300 Subject: [PATCH 061/121] Clear out makefile namespace for autotools --- BSDmakefile | 17 ------------ GNUmakefile | 51 ------------------------------------ Makefile | 75 ----------------------------------------------------- 3 files changed, 143 deletions(-) delete mode 100644 BSDmakefile delete mode 100644 GNUmakefile delete mode 100644 Makefile diff --git a/BSDmakefile b/BSDmakefile deleted file mode 100644 index 0d438a91..00000000 --- a/BSDmakefile +++ /dev/null @@ -1,17 +0,0 @@ -# BSD make-specific makefile, read only by BSD make and hence containing -# BSD make-specific extensions (e.g., "ifeq (...)", "$(shell ...)"). - -#FIXME: Conditionalize according to the "GNUmakefile" approach. - -# Default target, running all preparatory installation targets without actually -# installing. This *MUST* be the first non-"."-prefixed target in this makefile. -all: manpages - -# Install vcsh and supplementary artifacts. -install: all install-common -# Install man pages and zsh completions. - install -m 0644 $(manpages) $(DESTDIR)$(MANDIR)/man1/ - install -m 0644 $(zshcompletions) $(DESTDIR)$(ZSH_COMPLETIONS_DIR)/ - -# Define all platform-agnostic variables and rules. -.include "Makefile" diff --git a/GNUmakefile b/GNUmakefile deleted file mode 100644 index b7cbe77a..00000000 --- a/GNUmakefile +++ /dev/null @@ -1,51 +0,0 @@ -# GNU make-specific makefile, read only by GNU make and hence containing -# GNU make-specific extensions (e.g., "ifeq (...)", "$(shell ...)"). - -# Define all platform-agnostic variables and rules. -include Makefile - -# Absolute path of zsh's completions directory. Since Debian-based Linux distros -# prefer a different directory to that of most platforms, test for the existence -# of such directory before falling back to a platform-agnostic directory. -ifneq ($(wildcard $(DESTDIR)$(ZSHDIR_PREFIX)/vendor-completions),) -ZSH_COMPLETIONS_DIR:=$(ZSHDIR_PREFIX)/vendor-completions -else ifneq ($(wildcard $(DESTDIR)$(ZSHDIR_PREFIX)/site-functions),) -ZSH_COMPLETIONS_DIR:=$(ZSHDIR_PREFIX)/site-functions -endif - -# List of targets to be run both when no target is specified and when the -# "install" rule is run. -all_targets:= - -# Non-empty only if the "manpages" target is listed in $(all). -is_manpaging= - -# If Ronn is in the current $PATH, generate Ronn-based man pages by default. -ifneq ($(shell command -v "$(RONN)" 2>/dev/null),) -all_targets+= manpages -is_manpaging:=true -endif - -# Default target, running all preparatory installation targets without actually -# installing. This *MUST* be the first non-"."-prefixed target in this makefile. -all: $(all_targets) -# Notify the user of skipped targets. -ifeq ($(is_manpaging),) - @echo 'Skipping man page generation: "$(RONN)" not found.' 1>&2 -endif - -# Coerce the default target to be the prior target (rather than the first rule -# defined by the makefile included above). -.DEFAULT_GOAL:=all - -# Install vcsh and supplementary artifacts. -install: all install-common -# If the man page has been generated, install it during installation. -ifneq ($(wildcard $(manpages)),) - install -m 0644 $(manpages) $(DESTDIR)$(MANDIR)/man1/ -endif - -# If zsh's completions directory exists, install ours there during installation. -ifneq ($(ZSH_COMPLETIONS_DIR),) - install -m 0644 $(zshcompletions) $(DESTDIR)$(ZSH_COMPLETIONS_DIR)/ -endif diff --git a/Makefile b/Makefile deleted file mode 100644 index 3e487755..00000000 --- a/Makefile +++ /dev/null @@ -1,75 +0,0 @@ -# make-agnostic makefile, read by all make flavours including GNU make and hence -# consisting of only POSIX make-compliant syntax. -# -# This makefile defines all variables and rules except those required by and -# including the "all" and "install" rules, whose complexity necessitates -# conditional logic inexpressible in POSIX make-compliant syntax. - -self=vcsh - -PREFIX?=/usr -BINDIR=$(PREFIX)/bin -DOCDIR_PREFIX=$(PREFIX)/share/doc -DOCDIR=$(DOCDIR_PREFIX)/$(self) -MANDIR=$(PREFIX)/share/man -RONN ?= ronn - -# Basename of the man page to be generated. -manpages=$(self).1 - -# Basename of our zsh completions script. -zshcompletions=_$(self) - -# Absolute path of zsh's top-level data directory. -ZSHDIR_PREFIX=$(PREFIX)/share/zsh - -# Absolute path of zsh's completions directory. -ZSH_COMPLETIONS_DIR=$(ZSHDIR_PREFIX)/site-functions - -# List of abstract target names not corresponding to actual paths, preventing -# conflicts with any such paths and improving efficiency in general. -.PHONY: all clean install install-common manpages moo purge test uninstall - -# Install all paths *NOT* requiring conditional and hence non-POSIX logic. -install-common: -# Install the "vcsh" command. - install -m 0755 $(self) $(DESTDIR)$(BINDIR)/ - -# Install documentation. - install -d $(DESTDIR)$(DOCDIR) - install -m 0644 README.md $(DESTDIR)$(DOCDIR)/ - install -m 0644 doc/hooks $(DESTDIR)$(DOCDIR)/ - -# Generate the manpage. -manpages: $(manpages) - -$(self).1: doc/$(self).1.ronn - $(RONN) < doc/$(self).1.ronn > $(self).1 || rm $(self).1 - -# Remove the generated manpage. -clean: - rm -rf $(self).1 - -# Remove all previously installed paths. -uninstall: - rm -rf $(DESTDIR)$(BINDIR)/$(self) - rm -rf $(DESTDIR)$(MANDIR)/man1/$(self).1 - rm -rf $(DESTDIR)$(DOCDIR) - rm -rf $(DESTDIR)$(ZSH_COMPLETIONS_DIR)/$(zshcompletions) - -# FIXME: The "--ignore-fail-on-non-empty" option is GNU-specific. - -# Remove all previously installed paths and all empty parent directories of -# these paths. Since this is potentially harmful, this target has intentionally -# been given a non-standard name. For example, if $(PREFIX) is "/usr/local" and -# now empty due to uninstalling vcsh, this target would remove "/usr/local"! -purge: uninstall - rmdir -p --ignore-fail-on-non-empty $(DESTDIR)$(BINDIR) - rmdir -p --ignore-fail-on-non-empty $(DESTDIR)$(MANDIR)/man1 - rmdir -p --ignore-fail-on-non-empty $(DESTDIR)$(DOCDIR) - rmdir -p --ignore-fail-on-non-empty $(DESTDIR)$(ZSH_COMPLETIONS_DIR) - -# Run all unit tests if both git and Perl's prove are found. -test: - @if which git > /dev/null; then : ; else echo "'git' not found, exiting..." ; exit 1; fi - @if which prove > /dev/null; then prove; else echo "'prove' not found; not running tests"; fi From c28ba7082335cb76c0fb717ce7114586ce9297a6 Mon Sep 17 00:00:00 2001 From: Caleb Maclennan Date: Sat, 3 Apr 2021 22:09:15 +0300 Subject: [PATCH 062/121] Setup basic autotools based tooling --- Makefile.am | 10 ++++++++++ configure.ac | 8 ++++++++ vcsh => vcsh.in | 0 3 files changed, 18 insertions(+) create mode 100644 Makefile.am create mode 100644 configure.ac rename vcsh => vcsh.in (100%) diff --git a/Makefile.am b/Makefile.am new file mode 100644 index 00000000..9c2c5f0a --- /dev/null +++ b/Makefile.am @@ -0,0 +1,10 @@ +.ONESHELL: +.SECONDARY: +.SECONDEXPANSION: +.DELETE_ON_ERROR: + +licensedir = $(datarootdir)/licenses/vcsh + +dist_doc_DATA = README.md changelog doc/INSTALL.md doc/PACKAGING.md doc/README.md doc/error_codes.md 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 +bin_SCRIPTS = vcsh diff --git a/configure.ac b/configure.ac new file mode 100644 index 00000000..5d11ea3c --- /dev/null +++ b/configure.ac @@ -0,0 +1,8 @@ +AC_PREREQ([2.69]) +AC_INIT([vcsh], [1.20190619]) +AM_INIT_AUTOMAKE + +AC_CONFIG_FILES([Makefile]) +AC_CONFIG_FILES([vcsh], [chmod +x vcsh]) + +AC_OUTPUT diff --git a/vcsh b/vcsh.in similarity index 100% rename from vcsh rename to vcsh.in From 58471e2c0a5eb284e7e3728312f8268b303fcc4b Mon Sep 17 00:00:00 2001 From: Caleb Maclennan Date: Sat, 3 Apr 2021 22:23:57 +0300 Subject: [PATCH 063/121] Add machinery to automatically manage VERSION --- Makefile.am | 13 +++ build-aux/git-version-gen | 220 ++++++++++++++++++++++++++++++++++++++ configure.ac | 9 +- 3 files changed, 241 insertions(+), 1 deletion(-) create mode 100755 build-aux/git-version-gen diff --git a/Makefile.am b/Makefile.am index 9c2c5f0a..1cc017ec 100644 --- a/Makefile.am +++ b/Makefile.am @@ -8,3 +8,16 @@ licensedir = $(datarootdir)/licenses/vcsh dist_doc_DATA = README.md changelog doc/INSTALL.md doc/PACKAGING.md doc/README.md doc/error_codes.md 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 bin_SCRIPTS = vcsh + +EXTRA_DIST = .version + +BUILT_SOURCES = .version + +.version: $(shell $(AWK) '{print ".git/" $$2}' .git/HEAD 2>/dev/null ||:) + [ -e "$@" ] && mv "$@" "$@-prev" || touch "$@-prev" + $(if $<,./build-aux/git-version-gen .tarball-version,printf "$(VERSION)") > "$@" + $(CMP) -s "$@" "$@-prev" || autoreconf configure.ac --force + +dist-hook: + cd $(distdir) + echo $(VERSION) > .tarball-version diff --git a/build-aux/git-version-gen b/build-aux/git-version-gen new file mode 100755 index 00000000..e80e810e --- /dev/null +++ b/build-aux/git-version-gen @@ -0,0 +1,220 @@ +#!/usr/bin/env sh + +# Print a version string. +scriptversion=2012-03-18.17; # UTC + +# Copyright (C) 2007-2012 Free Software Foundation, Inc. +# +# 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 3 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, see . + +# This script is derived from GIT-VERSION-GEN from GIT: http://git.or.cz/. +# It may be run two ways: +# - from a git repository in which the "git describe" command below +# produces useful output (thus requiring at least one signed tag) +# - from a non-git-repo directory containing a .tarball-version file, which +# presumes this script is invoked like "./git-version-gen .tarball-version". + +# In order to use intra-version strings in your project, you will need two +# separate generated version string files: +# +# .tarball-version - present only in a distribution tarball, and not in +# a checked-out repository. Created with contents that were learned at +# the last time autoconf was run, and used by git-version-gen. Must not +# be present in either $(srcdir) or $(builddir) for git-version-gen to +# give accurate answers during normal development with a checked out tree, +# but must be present in a tarball when there is no version control system. +# Therefore, it cannot be used in any dependencies. GNUmakefile has +# hooks to force a reconfigure at distribution time to get the value +# correct, without penalizing normal development with extra reconfigures. +# +# .version - present in a checked-out repository and in a distribution +# tarball. Usable in dependencies, particularly for files that don't +# want to depend on config.h but do want to track version changes. +# Delete this file prior to any autoconf run where you want to rebuild +# files to pick up a version string change; and leave it stale to +# minimize rebuild time after unrelated changes to configure sources. +# +# As with any generated file in a VC'd directory, you should add +# /.version to .gitignore, so that you don't accidentally commit it. +# .tarball-version is never generated in a VC'd directory, so needn't +# be listed there. +# +# Use the following line in your configure.ac, so that $(VERSION) will +# automatically be up-to-date each time configure is run (and note that +# since configure.ac no longer includes a version string, Makefile rules +# should not depend on configure.ac for version updates). +# +# AC_INIT([GNU project], +# m4_esyscmd([build-aux/git-version-gen .tarball-version]), +# [bug-project@example]) +# +# Then use the following lines in your Makefile.am, so that .version +# will be present for dependencies, and so that .version and +# .tarball-version will exist in distribution tarballs. +# +# EXTRA_DIST = $(top_srcdir)/.version +# BUILT_SOURCES = $(top_srcdir)/.version +# $(top_srcdir)/.version: +# echo $(VERSION) > $@-t && mv $@-t $@ +# dist-hook: +# echo $(VERSION) > $(distdir)/.tarball-version + + +me=$0 + +version="git-version-gen $scriptversion + +Copyright 2011 Free Software Foundation, Inc. +There is NO warranty. You may redistribute this software +under the terms of the GNU General Public License. +For more information about these matters, see the files named COPYING." + +usage="\ +Usage: $me [OPTION]... \$srcdir/.tarball-version [TAG-NORMALIZATION-SED-SCRIPT] +Print a version string. + +Options: + + --prefix prefix of git tags (default 'v') + + --help display this help and exit + --version output version information and exit + +Running without arguments will suffice in most cases." + +prefix=v + +while test $# -gt 0; do + case $1 in + --help) echo "$usage"; exit 0;; + --version) echo "$version"; exit 0;; + --prefix) shift; prefix="$1";; + -*) + echo "$0: Unknown option '$1'." >&2 + echo "$0: Try '--help' for more information." >&2 + exit 1;; + *) + if test -z "$tarball_version_file"; then + tarball_version_file="$1" + elif test -z "$tag_sed_script"; then + tag_sed_script="$1" + else + echo "$0: extra non-option argument '$1'." >&2 + exit 1 + fi;; + esac + shift +done + +if test -z "$tarball_version_file"; then + echo "$usage" + exit 1 +fi + +tag_sed_script="${tag_sed_script:-s/x/x/}" + +nl=' +' + +# Avoid meddling by environment variable of the same name. +v= +v_from_git= + +# First see if there is a tarball-only version file. +# then try "git describe", then default. +if test -f $tarball_version_file +then + v=`cat $tarball_version_file` || v= + case $v in + *$nl*) v= ;; # reject multi-line output + [0-9]*) ;; + *) v= ;; + esac + test -z "$v" \ + && echo "$0: WARNING: $tarball_version_file is missing or damaged" 1>&2 +fi + +if test -n "$v" +then + : # use $v +# Otherwise, if there is at least one git commit involving the working +# 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 \ + || 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"` \ + && case $v in + $prefix[0-9]*) ;; + *) (exit 1) ;; + esac +then + # Is this a new git that lists number of commits since the last + # tag or the previous older version that did not? + # Newer: v6.10-77-g0f8faeb + # Older: v6.10-g0f8faeb + case $v in + *-*-*) : git describe is okay three part flavor ;; + *-*) + : git describe is older two part flavor + # Recreate the number of commits and rewrite such that the + # result is the same as if we were using the newer version + # of git describe. + vtag=`echo "$v" | sed 's/-.*//'` + commit_list=`git rev-list "$vtag"..HEAD 2>/dev/null` \ + || { commit_list=failed; + echo "$0: WARNING: git rev-list failed" 1>&2; } + numcommits=`echo "$commit_list" | wc -l` + v=`echo "$v" | sed "s/\(.*\)-\(.*\)/\1-$numcommits-\2/"`; + test "$commit_list" = failed && v=UNKNOWN + ;; + esac + + v=`echo "$v" | sed 's/-/.r/'`; + v_from_git=1 +else + v=UNKNOWN +fi + +v=`echo "$v" |sed "s/^$prefix//"` + +# Test whether to append the "-dirty" suffix only if the version +# string we're using came from git. I.e., skip the test if it's "UNKNOWN" +# or if it came from .tarball-version. +if test -n "$v_from_git"; then + # Don't declare a version "dirty" merely because a time stamp has changed. + git update-index --refresh > /dev/null 2>&1 + + dirty=`exec 2>/dev/null;git diff-index --name-only HEAD` || dirty= + case "$dirty" in + '') ;; + *) # Append the suffix only if there isn't one already. + case $v in + *-dirty) ;; + *) v="$v-dirty" ;; + esac ;; + esac +fi + +# Omit the trailing newline, so that m4_esyscmd can use the result directly. +echo "$v" | tr -d "$nl" + +# Local variables: +# eval: (add-hook 'write-file-hooks 'time-stamp) +# time-stamp-start: "scriptversion=" +# time-stamp-format: "%:y-%02m-%02d.%02H" +# time-stamp-time-zone: "UTC" +# time-stamp-end: "; # UTC" +# End: diff --git a/configure.ac b/configure.ac index 5d11ea3c..c8736185 100644 --- a/configure.ac +++ b/configure.ac @@ -1,7 +1,14 @@ AC_PREREQ([2.69]) -AC_INIT([vcsh], [1.20190619]) +AC_INIT([vcsh], [m4_esyscmd(build-aux/git-version-gen .tarball-version)]) +AC_CONFIG_AUX_DIR([build-aux]) AM_INIT_AUTOMAKE +AC_PROG_AWK + +AC_DEFUN([AX_PROGVAR], [AC_PATH_PROG(m4_toupper($1), m4_default($2,$1))test -n "$m4_toupper($1)" || AC_MSG_ERROR([m4_default($2,$1) is required])]) + +AX_PROGVAR([cmp]) + AC_CONFIG_FILES([Makefile]) AC_CONFIG_FILES([vcsh], [chmod +x vcsh]) From 7e72b0bbd851df3cdccd879bb1a5eec1bb327085 Mon Sep 17 00:00:00 2001 From: Caleb Maclennan Date: Sat, 3 Apr 2021 22:24:46 +0300 Subject: [PATCH 064/121] Add bootstrap script to ease builds from Git clones --- bootstrap.sh | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100755 bootstrap.sh diff --git a/bootstrap.sh b/bootstrap.sh new file mode 100755 index 00000000..0d8d2841 --- /dev/null +++ b/bootstrap.sh @@ -0,0 +1,24 @@ +#!/usr/bin/env sh +set -e + +incomplete_source () { + printf '%s\n' \ + "$1. Please either:" \ + "* $2," \ + "* or use the source packages instead of a repo archive" \ + "* or use a full Git clone." >&2 + exit 1 +} + +# This enables easy building from Github's snapshot archives +if [ ! -e ".git" ]; then + if [ ! -f ".tarball-version" ]; then + incomplete_source "No version information found" \ + "identify the correct version with \`echo \$version > .tarball-version\`" + fi +else + # Just a head start to save a ./configure cycle + ./build-aux/git-version-gen .tarball-version > .version +fi + +autoreconf --install From 04d82be71a25b4906bae2de4fe85ded549d1f61e Mon Sep 17 00:00:00 2001 From: Caleb Maclennan Date: Sat, 3 Apr 2021 22:31:32 +0300 Subject: [PATCH 065/121] Setup autoconf with project preferences --- Makefile.am | 2 ++ configure.ac | 4 +++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/Makefile.am b/Makefile.am index 1cc017ec..a01ab2f6 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,3 +1,5 @@ +ACLOCAL_AMFLAGS = -I build-aux + .ONESHELL: .SECONDARY: .SECONDEXPANSION: diff --git a/configure.ac b/configure.ac index c8736185..7c7c1c90 100644 --- a/configure.ac +++ b/configure.ac @@ -1,7 +1,9 @@ AC_PREREQ([2.69]) AC_INIT([vcsh], [m4_esyscmd(build-aux/git-version-gen .tarball-version)]) AC_CONFIG_AUX_DIR([build-aux]) -AM_INIT_AUTOMAKE +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]) AC_PROG_AWK From ee2a9aaa2963096bcc9d5745c676181a1dc2003d Mon Sep 17 00:00:00 2001 From: Caleb Maclennan Date: Sat, 3 Apr 2021 22:50:32 +0300 Subject: [PATCH 066/121] Update EditorConfig and modelines --- .editorconfig | 2 +- _vcsh | 6 ++++++ _vcsh_bash | 6 +++++- vcsh.in | 6 ++++++ 4 files changed, 18 insertions(+), 2 deletions(-) diff --git a/.editorconfig b/.editorconfig index 32d78adb..03803dee 100644 --- a/.editorconfig +++ b/.editorconfig @@ -4,6 +4,6 @@ root = true end_of_line = lf insert_final_newline = true -[vcsh] +[{vcsh.in,_vcsh,_vsh_bash}] indent_style = tab trim_trailing_whitespace = true diff --git a/_vcsh b/_vcsh index 72924ce2..f90fdebf 100644 --- a/_vcsh +++ b/_vcsh @@ -153,3 +153,9 @@ function _vcsh () { } _vcsh "$@" + +# Local Variables: +# mode:shell-script +# sh-shell:zsh +# End: +# vim: ft=zsh: diff --git a/_vcsh_bash b/_vcsh_bash index 3cfe88a6..973ae6db 100644 --- a/_vcsh_bash +++ b/_vcsh_bash @@ -135,4 +135,8 @@ _vcsh () { complete -F _vcsh vcsh -# vim: ft=sh: +# Local Variables: +# mode:shell-script +# sh-shell:bash +# End: +# vim: ft=bash: diff --git a/vcsh.in b/vcsh.in index ba289e24..11e7f131 100755 --- a/vcsh.in +++ b/vcsh.in @@ -674,3 +674,9 @@ $VCSH_COMMAND "$@" hook post-command verbose "$VCSH_COMMAND end, exiting" exit $VCSH_COMMAND_RETURN_CODE + +# Local Variables: +# mode:shell-script +# sh-shell:sh +# End: +# vim: ft=sh: From 7f1ccc6632b54196a563cbd2959784e9b0f4a037 Mon Sep 17 00:00:00 2001 From: Caleb Maclennan Date: Sat, 3 Apr 2021 22:32:24 +0300 Subject: [PATCH 067/121] Use autoconf to check dependencies and set paths to utils --- configure.ac | 7 ++++ vcsh.in | 92 +++++++++++++++++++++++++--------------------------- 2 files changed, 52 insertions(+), 47 deletions(-) diff --git a/configure.ac b/configure.ac index 7c7c1c90..0e4676fb 100644 --- a/configure.ac +++ b/configure.ac @@ -6,6 +6,13 @@ AM_SILENT_RULES([yes]) AC_CONFIG_MACRO_DIR([build-aux]) AC_PROG_AWK +AC_PROG_GREP +AC_PROG_SED + +AC_DEFUN([AX_PROGVAR], [AC_PATH_PROG(m4_toupper($1), m4_default($2,$1))test -n "$m4_toupper($1)" || AC_MSG_ERROR([m4_default($2,$1) is required])]) + +AX_PROGVAR([comm]) +AX_PROGVAR([git]) AC_DEFUN([AX_PROGVAR], [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/vcsh.in b/vcsh.in index 11e7f131..bdab3ffa 100755 --- a/vcsh.in +++ b/vcsh.in @@ -1,4 +1,4 @@ -#!/bin/sh +#!@SHELL@ # This program is licensed under the GNU GPL version 2 or later. # (c) Richard "RichiH" Hartmann , 2011-2015 @@ -159,26 +159,26 @@ info() { clone() { hook pre-clone init - git remote add origin "$GIT_REMOTE" - git checkout -b "$VCSH_BRANCH" || return $? - git config branch."$VCSH_BRANCH".remote origin - git config branch."$VCSH_BRANCH".merge refs/heads/"$VCSH_BRANCH" - if [ $(git ls-remote origin "$VCSH_BRANCH" 2> /dev/null | wc -l ) -lt 1 ]; then + @GIT@ remote add origin "$GIT_REMOTE" + @GIT@ checkout -b "$VCSH_BRANCH" || return $? + @GIT@ config branch."$VCSH_BRANCH".remote origin + @GIT@ config branch."$VCSH_BRANCH".merge refs/heads/"$VCSH_BRANCH" + if [ $(@GIT@ ls-remote origin "$VCSH_BRANCH" 2> /dev/null | wc -l ) -lt 1 ]; then info "remote is empty, not merging anything. You should add files to your new repository." # editorconfig-checker-disable-line exit fi - GIT_VERSION_MAJOR=$(git --version | sed -E -n 's/.* ([0-9]+)\..*/\1/p' ) + GIT_VERSION_MAJOR=$(@GIT@ --version | @SED@ -E -n 's/.* ([0-9]+)\..*/\1/p' ) if [ 1 -lt "$GIT_VERSION_MAJOR" ];then - git fetch origin "$VCSH_BRANCH" + @GIT@ fetch origin "$VCSH_BRANCH" else - git fetch origin + @GIT@ fetch origin fi hook pre-merge - git read-tree -n -mu origin/"$VCSH_BRANCH" \ + @GIT@ read-tree -n -mu origin/"$VCSH_BRANCH" \ || fatal "will stop after fetching and not try to merge! Once this situation has been resolved, run 'vcsh $VCSH_REPO_NAME pull' to finish cloning." 17 # editorconfig-checker-disable-line - git -c merge.ff=true merge origin/"$VCSH_BRANCH" + @GIT@ -c merge.ff=true merge origin/"$VCSH_BRANCH" hook post-merge hook post-clone retire @@ -192,7 +192,7 @@ commit() { echo "$VCSH_REPO_NAME: " GIT_DIR=$VCSH_REPO_D/$VCSH_REPO_NAME.git; export GIT_DIR use - git commit --untracked-files=no --quiet "$@" + @GIT@ commit --untracked-files=no --quiet "$@" VCSH_COMMAND_RETURN_CODE=$? echo done @@ -203,7 +203,7 @@ delete() { cd "$VCSH_BASE" || fatal "could not enter '$VCSH_BASE'" 11 use info "This operation WILL DESTROY DATA!" - files=$(git ls-files) + files=$(@GIT@ ls-files) echo "These files will be deleted: $files @@ -230,7 +230,7 @@ foreach() { # We default to prefixing `git` to all commands passed to foreach, but # allow running in general context with -g - command_prefix=git + command_prefix=@GIT@ while getopts "g" flag; do if [ x"$1" = x'-g' ]; then unset command_prefix @@ -263,7 +263,7 @@ init() { [ ! -e "$GIT_DIR" ] || fatal "'$GIT_DIR' exists" 10 mkdir -p "$VCSH_BASE" || fatal "could not create '$VCSH_BASE'" 50 cd "$VCSH_BASE" || fatal "could not enter '$VCSH_BASE'" 11 - git init --shared=false + @GIT@ init --shared=false upgrade hook post-init } @@ -276,7 +276,7 @@ list() { get_files() { GIT_DIR=$VCSH_REPO_D/$VCSH_REPO_NAME.git; export GIT_DIR - git ls-files --full-name + @GIT@ ls-files --full-name } list_tracked() { @@ -291,7 +291,7 @@ list_tracked() { } list_tracked_helper() { - sed "s,^,$(printf '%s\n' "$VCSH_BASE/" | sed 's/[,\&]/\\&/g')," | sort -u + @SED@ "s,^,$(printf '%s\n' "$VCSH_BASE/" | @SED@ 's/[,\&]/\\&/g')," | sort -u } list_tracked_by() { @@ -299,8 +299,6 @@ list_tracked_by() { } list_untracked() { - command -v 'comm' >/dev/null 2>&1 || fatal "Could not find 'comm'" - temp_file_others=$(mktemp "${TMPDIR:-/tmp}/tmp.XXXXXXXXXX") || fatal 'Could not create temp file' temp_file_untracked=$(mktemp "${TMPDIR:-/tmp}/tmp.XXXXXXXXXX") || fatal 'Could not create temp file' temp_file_untracked_copy=$(mktemp "${TMPDIR:-/tmp}/tmp.XXXXXXXXXX") || fatal 'Could not create temp file' @@ -335,7 +333,7 @@ list_untracked() { list_untracked_helper() { export GIT_DIR="$VCSH_REPO_D/$VCSH_REPO_NAME.git" - git ls-files --others $exclude_standard_opt "$directory_opt" | ( + @GIT@ ls-files --others $exclude_standard_opt "$directory_opt" | ( while read line; do echo "$line" directory_component=${line%%/*} @@ -347,7 +345,7 @@ list_untracked_helper() { cp $temp_file_others $temp_file_untracked || fatal 'Could not copy temp file' fi cp $temp_file_untracked $temp_file_untracked_copy || fatal 'Could not copy temp file' - comm -12 $temp_file_others $temp_file_untracked_copy > $temp_file_untracked + @COMM@ -12 $temp_file_others $temp_file_untracked_copy > $temp_file_untracked } pull() { @@ -356,7 +354,7 @@ pull() { printf '%s: ' "$VCSH_REPO_NAME" GIT_DIR=$VCSH_REPO_D/$VCSH_REPO_NAME.git; export GIT_DIR use - git pull + @GIT@ pull VCSH_COMMAND_RETURN_CODE=$? echo done @@ -369,7 +367,7 @@ push() { printf '%s: ' "$VCSH_REPO_NAME" GIT_DIR=$VCSH_REPO_D/$VCSH_REPO_NAME.git; export GIT_DIR use - git push + @GIT@ push VCSH_COMMAND_RETURN_CODE=$? echo done @@ -421,13 +419,13 @@ status_helper() { GIT_DIR=$VCSH_REPO_D/$1.git; export GIT_DIR VCSH_GIT_OPTIONS=$2 use - remote_tracking_branch=$(git rev-parse --abbrev-ref --symbolic-full-name @{u} 2> /dev/null) && { - commits_behind=$(git log ..${remote_tracking_branch} --oneline | wc -l) - commits_ahead=$(git log ${remote_tracking_branch}.. --oneline | wc -l) + remote_tracking_branch=$(@GIT@ rev-parse --abbrev-ref --symbolic-full-name @{u} 2> /dev/null) && { + commits_behind=$(@GIT@ log ..${remote_tracking_branch} --oneline | wc -l) + commits_ahead=$(@GIT@ log ${remote_tracking_branch}.. --oneline | wc -l) [ ${commits_behind} -ne 0 ] && echo "Behind $remote_tracking_branch by $commits_behind commits" [ ${commits_ahead} -ne 0 ] && echo "Ahead of $remote_tracking_branch by $commits_ahead commits" } - git ${VCSH_GIT_OPTIONS} status --short --untracked-files='no' + @GIT@ ${VCSH_GIT_OPTIONS} status --short --untracked-files='no' VCSH_COMMAND_RETURN_CODE=$? } @@ -436,20 +434,20 @@ upgrade() { # fake-bare repositories are not bare, actually. Set this to false # because otherwise Git complains "fatal: core.bare and core.worktree # do not make sense" - git config core.bare false + @GIT@ config core.bare false # core.worktree may be absolute or relative to $GIT_DIR, depending on # user preference if [ ! "x$VCSH_WORKTREE" = 'xabsolute' ]; then - git config core.worktree "$(cd "$GIT_DIR" && GIT_WORK_TREE=$VCSH_BASE git rev-parse --show-cdup)" + @GIT@ config core.worktree "$(cd "$GIT_DIR" && GIT_WORK_TREE=$VCSH_BASE @GIT@ rev-parse --show-cdup)" elif [ ! "x$VCSH_WORKTREE" = 'xrelative' ]; then - git config core.worktree "$VCSH_BASE" + @GIT@ config core.worktree "$VCSH_BASE" fi - [ ! "x$VCSH_GITIGNORE" = 'xnone' ] && git config core.excludesfile ".gitignore.d/$VCSH_REPO_NAME" - [ ! "x$VCSH_GITATTRIBUTES" = 'xnone' ] && git config core.attributesfile ".gitattributes.d/$VCSH_REPO_NAME" - git config vcsh.vcsh 'true' + [ ! "x$VCSH_GITIGNORE" = 'xnone' ] && @GIT@ config core.excludesfile ".gitignore.d/$VCSH_REPO_NAME" + [ ! "x$VCSH_GITATTRIBUTES" = 'xnone' ] && @GIT@ config core.attributesfile ".gitattributes.d/$VCSH_REPO_NAME" + @GIT@ config vcsh.vcsh 'true' use - [ -e "$VCSH_BASE/.gitignore.d/$VCSH_REPO_NAME" ] && git add -f "$VCSH_BASE/.gitignore.d/$VCSH_REPO_NAME" - [ -e "$VCSH_BASE/.gitattributes.d/$VCSH_REPO_NAME" ] && git add -f "$VCSH_BASE/.gitattributes.d/$VCSH_REPO_NAME" + [ -e "$VCSH_BASE/.gitignore.d/$VCSH_REPO_NAME" ] && @GIT@ add -f "$VCSH_BASE/.gitignore.d/$VCSH_REPO_NAME" + [ -e "$VCSH_BASE/.gitattributes.d/$VCSH_REPO_NAME" ] && @GIT@ add -f "$VCSH_BASE/.gitattributes.d/$VCSH_REPO_NAME" hook post-upgrade } @@ -460,7 +458,7 @@ use() { which() { output=$(for VCSH_REPO_NAME in $(list); do - get_files | grep -- "$VCSH_COMMAND_PARAMETER" | sed "s/^/$VCSH_REPO_NAME: /" + get_files | @GREP@ -- "$VCSH_COMMAND_PARAMETER" | @SED@ "s/^/$VCSH_REPO_NAME: /" done | sort -u) if [ -z "$output" ]; then fatal "'$VCSH_COMMAND_PARAMETER' does not exist" 1 @@ -478,12 +476,12 @@ write_gitignore() { use cd "$VCSH_BASE" || fatal "could not enter '$VCSH_BASE'" 11 - local GIT_VERSION="$(git --version)" - local GIT_VERSION_MAJOR=$(echo $GIT_VERSION | sed -E -n 's/.* ([0-9]+)\..*/\1/p') - local GIT_VERSION_MINOR=$(echo $GIT_VERSION | sed -E -n 's/.* ([0-9]+)\.([0-9]+)\..*/\2/p') + local GIT_VERSION="$(@GIT@ --version)" + local GIT_VERSION_MAJOR=$(echo $GIT_VERSION | @SED@ -E -n 's/.* ([0-9]+)\..*/\1/p') + local GIT_VERSION_MINOR=$(echo $GIT_VERSION | @SED@ -E -n 's/.* ([0-9]+)\.([0-9]+)\..*/\2/p') OLDIFS=$IFS IFS=$(printf '\n\t') - gitignores=$(for file in $(git ls-files); do + gitignores=$(for file in $(@GIT@ ls-files); do if [ $GIT_VERSION_MAJOR -ge 2 -a $GIT_VERSION_MINOR -ge 7 ]; then echo "$file"; else @@ -502,9 +500,9 @@ write_gitignore() { echo '*' > "$tempfile" || fatal "could not write to '$tempfile'" 57 for gitignore in $gitignores; do - echo "$gitignore" | sed 's@^@!/@' >> "$tempfile" || fatal "could not write to '$tempfile'" 57 + echo "$gitignore" | @SED@ 's@^@!/@' >> "$tempfile" || fatal "could not write to '$tempfile'" 57 if [ "x$VCSH_GITIGNORE" = 'xrecursive' ] && [ -d "$gitignore" ]; then - { echo "$gitignore/*" | sed 's@^@!/@' >> "$tempfile" || fatal "could not write to '$tempfile'" 57; } + { echo "$gitignore/*" | @SED@ 's@^@!/@' >> "$tempfile" || fatal "could not write to '$tempfile'" 57; } fi done IFS=$OLDIFS @@ -521,7 +519,7 @@ write_gitignore() { fatal "could not move '$tempfile' to '$VCSH_BASE/.gitignore.d/$VCSH_REPO_NAME'" 53 } -debug $(git version) +debug $(@GIT@ version) if [ ! "x$VCSH_GITIGNORE" = 'xexact' ] && [ ! "x$VCSH_GITIGNORE" = 'xnone' ] && [ ! "x$VCSH_GITIGNORE" = 'xrecursive' ]; then fatal "'\$VCSH_GITIGNORE' must equal 'exact', 'none', or 'recursive'" 1 @@ -575,7 +573,7 @@ elif [ "$VCSH_COMMAND" = 'help' ]; then help && exit elif [ "$VCSH_COMMAND" = 'version' ]; then echo "$SELF $VERSION" - git version + @GIT@ version exit elif [ x"$VCSH_COMMAND" = x'which' ]; then [ -z "$2" ] && fatal "$VCSH_COMMAND: please specify a filename" 1 @@ -622,7 +620,7 @@ elif [ -n "$2" ]; then GIT_DIR=$VCSH_REPO_D/$VCSH_REPO_NAME.git; export GIT_DIR [ -d "$GIT_DIR" ] || { help; exit 1; } shift 1 - set -- "git" "$@" + set -- "@GIT@" "$@" elif [ -n "$VCSH_COMMAND" ]; then VCSH_COMMAND='enter'; export VCSH_COMMAND VCSH_REPO_NAME=$1; export VCSH_REPO_NAME @@ -635,7 +633,7 @@ fi # Did we receive a directory instead of a name? # Mangle the input to fit normal operation. -if echo "$VCSH_REPO_NAME" | grep -q '/'; then +if echo "$VCSH_REPO_NAME" | @GREP@ -q '/'; then GIT_DIR=$VCSH_REPO_NAME; export GIT_DIR VCSH_REPO_NAME=$(basename "$VCSH_REPO_NAME" .git); export VCSH_REPO_NAME fi @@ -657,7 +655,7 @@ check_dir "$VCSH_REPO_D" [ ! "x$VCSH_GITATTRIBUTES" = 'xnone' ] && check_dir "$VCSH_BASE/.gitattributes.d" verbose "$VCSH_COMMAND begin" -VCSH_COMMAND=$(echo "$VCSH_COMMAND" | sed 's/-/_/g'); export VCSH_COMMAND +VCSH_COMMAND=$(echo "$VCSH_COMMAND" | @SED@ 's/-/_/g'); export VCSH_COMMAND # Source repo-specific configuration file [ -r "$XDG_CONFIG_HOME/vcsh/config.d/$VCSH_REPO_NAME" ] && . "$XDG_CONFIG_HOME/vcsh/config.d/$VCSH_REPO_NAME" From 4fe270ed3365b11b85f34583b43b2ac46fb6cab5 Mon Sep 17 00:00:00 2001 From: Caleb Maclennan Date: Sat, 3 Apr 2021 23:43:12 +0300 Subject: [PATCH 068/121] Use autoconf to set VERSION in script --- vcsh.in | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/vcsh.in b/vcsh.in index bdab3ffa..11e9f4ed 100755 --- a/vcsh.in +++ b/vcsh.in @@ -16,10 +16,10 @@ [ -n "$VCSH_DEBUG" ] && set -vx -# If '.git-HEAD' is appended to the version, you are seeing an unreleased -# version of vcsh; the master branch is supposed to be clean at all times +# If '.r-g' is appended to the version, you are seeing an unreleased +# version of vcsh; the main branch is supposed to be clean at all times # so you can most likely just use it nonetheless -VERSION='1.20141026' +VERSION='@VERSION@' SELF=$(basename $0) # Ensure all files created are accessible only to the current user. From 044525acf93bb3f0188be207cdd9693305f341b0 Mon Sep 17 00:00:00 2001 From: Caleb Maclennan Date: Sun, 4 Apr 2021 00:42:39 +0300 Subject: [PATCH 069/121] Add renamable output support, script can be named anything --- configure.ac | 2 ++ 1 file changed, 2 insertions(+) diff --git a/configure.ac b/configure.ac index 0e4676fb..3ac89b68 100644 --- a/configure.ac +++ b/configure.ac @@ -21,4 +21,6 @@ AX_PROGVAR([cmp]) AC_CONFIG_FILES([Makefile]) AC_CONFIG_FILES([vcsh], [chmod +x vcsh]) +AC_ARG_PROGRAM + AC_OUTPUT From a5737c0b411e658490bfaf561795ec2c092dfc61 Mon Sep 17 00:00:00 2001 From: Caleb Maclennan Date: Sun, 4 Apr 2021 00:04:26 +0300 Subject: [PATCH 070/121] Port manual make rules for man pages to autotools --- Makefile.am | 4 ++++ configure.ac | 1 + 2 files changed, 5 insertions(+) diff --git a/Makefile.am b/Makefile.am index a01ab2f6..2d5dce9c 100644 --- a/Makefile.am +++ b/Makefile.am @@ -9,12 +9,16 @@ licensedir = $(datarootdir)/licenses/vcsh dist_doc_DATA = README.md changelog doc/INSTALL.md doc/PACKAGING.md doc/README.md doc/error_codes.md 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_man_MANS = vcsh.1 bin_SCRIPTS = vcsh EXTRA_DIST = .version BUILT_SOURCES = .version +vcsh.1: doc/vcsh.1.ronn + $(RONN) < $< > $@ + .version: $(shell $(AWK) '{print ".git/" $$2}' .git/HEAD 2>/dev/null ||:) [ -e "$@" ] && mv "$@" "$@-prev" || touch "$@-prev" $(if $<,./build-aux/git-version-gen .tarball-version,printf "$(VERSION)") > "$@" diff --git a/configure.ac b/configure.ac index 3ac89b68..ac5a608b 100644 --- a/configure.ac +++ b/configure.ac @@ -13,6 +13,7 @@ AC_DEFUN([AX_PROGVAR], [AC_PATH_PROG(m4_toupper($1), m4_default($2,$1))test -n " AX_PROGVAR([comm]) AX_PROGVAR([git]) +AX_PROGVAR([ronn]) AC_DEFUN([AX_PROGVAR], [AC_PATH_PROG(m4_toupper($1), m4_default($2,$1))test -n "$m4_toupper($1)" || AC_MSG_ERROR([m4_default($2,$1) is required])]) From f17cb519dc1457f75cc783f322ae62723ce1eca0 Mon Sep 17 00:00:00 2001 From: Caleb Maclennan Date: Sun, 4 Apr 2021 00:13:05 +0300 Subject: [PATCH 071/121] Port manual make rules for completions to autotools --- .editorconfig | 2 +- Makefile.am | 20 ++++++++++++++++++- _vcsh_bash => completions/vcsh.bash | 6 ------ _vcsh => completions/vcsh.zsh | 6 ------ configure.ac | 31 ++++++++++++++++++++++++++--- 5 files changed, 48 insertions(+), 17 deletions(-) rename _vcsh_bash => completions/vcsh.bash (97%) rename _vcsh => completions/vcsh.zsh (97%) diff --git a/.editorconfig b/.editorconfig index 03803dee..abd7452a 100644 --- a/.editorconfig +++ b/.editorconfig @@ -4,6 +4,6 @@ root = true end_of_line = lf insert_final_newline = true -[{vcsh.in,_vcsh,_vsh_bash}] +[{vcsh.in,completions/vcsh.*}] indent_style = tab trim_trailing_whitespace = true diff --git a/Makefile.am b/Makefile.am index 2d5dce9c..2a265b66 100644 --- a/Makefile.am +++ b/Makefile.am @@ -5,6 +5,8 @@ ACLOCAL_AMFLAGS = -I build-aux .SECONDEXPANSION: .DELETE_ON_ERROR: +_vcsh = $(program_prefix)$(shell sed -e "$(program_transform_name)" <<< vcsh)$(program_suffix) + licensedir = $(datarootdir)/licenses/vcsh dist_doc_DATA = README.md changelog doc/INSTALL.md doc/PACKAGING.md doc/README.md doc/error_codes.md 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 @@ -12,13 +14,29 @@ dist_license_DATA = LICENSE CONTRIBUTORS dist_man_MANS = vcsh.1 bin_SCRIPTS = vcsh -EXTRA_DIST = .version +EXTRA_DIST = .version completions/vcsh.bash completions/vcsh.zsh BUILT_SOURCES = .version +if ENABLE_BASH_COMPLETION +bashcompletiondir = $(BASH_COMPLETION_DIR) +nodist_bashcompletion_DATA = completions/$(_vcsh) +endif + +if ENABLE_ZSH_COMPLETION +zshcompletiondir = $(ZSH_COMPLETION_DIR) +nodist_zshcompletion_DATA = completions/_$(_vcsh) +endif + vcsh.1: doc/vcsh.1.ronn $(RONN) < $< > $@ +completions/$(_vcsh): completions/vcsh.bash + cp -bf $< $@ + +completions/_$(_vcsh): completions/vcsh.zsh + cp -bf $< $@ + .version: $(shell $(AWK) '{print ".git/" $$2}' .git/HEAD 2>/dev/null ||:) [ -e "$@" ] && mv "$@" "$@-prev" || touch "$@-prev" $(if $<,./build-aux/git-version-gen .tarball-version,printf "$(VERSION)") > "$@" diff --git a/_vcsh_bash b/completions/vcsh.bash similarity index 97% rename from _vcsh_bash rename to completions/vcsh.bash index 973ae6db..b60d9cb7 100644 --- a/_vcsh_bash +++ b/completions/vcsh.bash @@ -134,9 +134,3 @@ _vcsh () { } complete -F _vcsh vcsh - -# Local Variables: -# mode:shell-script -# sh-shell:bash -# End: -# vim: ft=bash: diff --git a/_vcsh b/completions/vcsh.zsh similarity index 97% rename from _vcsh rename to completions/vcsh.zsh index f90fdebf..72924ce2 100644 --- a/_vcsh +++ b/completions/vcsh.zsh @@ -153,9 +153,3 @@ function _vcsh () { } _vcsh "$@" - -# Local Variables: -# mode:shell-script -# sh-shell:zsh -# End: -# vim: ft=zsh: diff --git a/configure.ac b/configure.ac index ac5a608b..511c649f 100644 --- a/configure.ac +++ b/configure.ac @@ -12,12 +12,37 @@ AC_PROG_SED AC_DEFUN([AX_PROGVAR], [AC_PATH_PROG(m4_toupper($1), m4_default($2,$1))test -n "$m4_toupper($1)" || AC_MSG_ERROR([m4_default($2,$1) is required])]) AX_PROGVAR([comm]) +AX_PROGVAR([cmp]) AX_PROGVAR([git]) AX_PROGVAR([ronn]) -AC_DEFUN([AX_PROGVAR], [AC_PATH_PROG(m4_toupper($1), m4_default($2,$1))test -n "$m4_toupper($1)" || AC_MSG_ERROR([m4_default($2,$1) is required])]) - -AX_PROGVAR([cmp]) +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]) +if test "x$with_bash_completion_dir" = "xyes"; then + PKG_CHECK_MODULES([BASH_COMPLETION], [bash-completion >= 2.0], + [BASH_COMPLETION_DIR="`pkg-config --variable=completionsdir bash-completion`"], + [BASH_COMPLETION_DIR="$datadir/bash-completion/completions"]) +else + BASH_COMPLETION_DIR="$with_bash_completion_dir" +fi +AC_SUBST([BASH_COMPLETION_DIR]) +AM_CONDITIONAL([ENABLE_BASH_COMPLETION],[test "x$with_bash_completion_dir" != "xno"]) + +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]) +if test "x$with_zsh_completion_dir" = "xyes"; then + ZSH_COMPLETION_DIR="$datadir/zsh/site-functions" +else + ZSH_COMPLETION_DIR="$with_zsh_completion_dir" +fi +AC_SUBST([ZSH_COMPLETION_DIR]) +AM_CONDITIONAL([ENABLE_ZSH_COMPLETION],[test "x$with_zsh_completion_dir" != "xno"]) AC_CONFIG_FILES([Makefile]) AC_CONFIG_FILES([vcsh], [chmod +x vcsh]) From 34fb3031afc81fdb9ac023236d64e1c38e206222 Mon Sep 17 00:00:00 2001 From: Caleb Maclennan Date: Sun, 4 Apr 2021 00:59:28 +0300 Subject: [PATCH 072/121] Copy perl module dependency script from autoconf-archive --- build-aux/ax_prog_perl_modules.m4 | 77 +++++++++++++++++++++++++++++++ 1 file changed, 77 insertions(+) create mode 100644 build-aux/ax_prog_perl_modules.m4 diff --git a/build-aux/ax_prog_perl_modules.m4 b/build-aux/ax_prog_perl_modules.m4 new file mode 100644 index 00000000..70b3230e --- /dev/null +++ b/build-aux/ax_prog_perl_modules.m4 @@ -0,0 +1,77 @@ +# =========================================================================== +# https://www.gnu.org/software/autoconf-archive/ax_prog_perl_modules.html +# =========================================================================== +# +# SYNOPSIS +# +# AX_PROG_PERL_MODULES([MODULES], [ACTION-IF-TRUE], [ACTION-IF-FALSE]) +# +# DESCRIPTION +# +# Checks to see if the given perl modules are available. If true the shell +# commands in ACTION-IF-TRUE are executed. If not the shell commands in +# ACTION-IF-FALSE are run. Note if $PERL is not set (for example by +# calling AC_CHECK_PROG, or AC_PATH_PROG), AC_CHECK_PROG(PERL, perl, perl) +# will be run. +# +# MODULES is a space separated list of module names. To check for a +# minimum version of a module, append the version number to the module +# name, separated by an equals sign. +# +# Example: +# +# AX_PROG_PERL_MODULES( Text::Wrap Net::LDAP=1.0.3, , +# AC_MSG_WARN(Need some Perl modules) +# +# LICENSE +# +# Copyright (c) 2009 Dean Povey +# +# Copying and distribution of this file, with or without modification, are +# permitted in any medium without royalty provided the copyright notice +# and this notice are preserved. This file is offered as-is, without any +# warranty. + +#serial 8 + +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,=,[ ])[' ]) + ]) + +# Make sure we have perl +if test -z "$PERL"; then +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) + + # 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 +else + AC_MSG_WARN(could not find perl) +fi])dnl From 3253f4ff249ab9b1432519b5fd579a9a4d877c92 Mon Sep 17 00:00:00 2001 From: Caleb Maclennan Date: Sun, 4 Apr 2021 01:02:07 +0300 Subject: [PATCH 073/121] Port manual make rules for tests to autotools --- Makefile.am | 4 ++++ configure.ac | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/Makefile.am b/Makefile.am index 2a265b66..03b4a81f 100644 --- a/Makefile.am +++ b/Makefile.am @@ -42,6 +42,10 @@ completions/_$(_vcsh): completions/vcsh.zsh $(if $<,./build-aux/git-version-gen .tarball-version,printf "$(VERSION)") > "$@" $(CMP) -s "$@" "$@-prev" || autoreconf configure.ac --force +.PHONY: test +test: + prove + dist-hook: cd $(distdir) echo $(VERSION) > .tarball-version diff --git a/configure.ac b/configure.ac index 511c649f..91b7b38e 100644 --- a/configure.ac +++ b/configure.ac @@ -14,8 +14,12 @@ AC_DEFUN([AX_PROGVAR], [AC_PATH_PROG(m4_toupper($1), m4_default($2,$1))test -n " AX_PROGVAR([comm]) AX_PROGVAR([cmp]) AX_PROGVAR([git]) +AX_PROGVAR([prove]) AX_PROGVAR([ronn]) +AX_PROG_PERL_MODULES(Shell::Command, , AC_MSG_ERROR(Perl module required for testing not found)) +AX_PROG_PERL_MODULES(Test::Most, , 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 the bash auto-completion script in this directory. @<:@default=yes@:>@]), From 448193ec00b4d40235d4380def4b82ca1f1417fb Mon Sep 17 00:00:00 2001 From: Richard Hartmann Date: Sun, 4 Apr 2021 09:25:21 +0200 Subject: [PATCH 074/121] Update mailmap (#289) Signed-off-by: Richard Hartmann --- .mailmap | 1 + 1 file changed, 1 insertion(+) diff --git a/.mailmap b/.mailmap index 65c64b49..0b983617 100644 --- a/.mailmap +++ b/.mailmap @@ -1,4 +1,5 @@ Richard Hartmann +Richard Hartmann Richard Hartmann Richard Hartmann Alexander Skurikhin From c70b72f788ed1a1819666af3baf494ece1baafc9 Mon Sep 17 00:00:00 2001 From: Kevin Lyda Date: Sun, 4 Apr 2021 14:25:24 +0100 Subject: [PATCH 075/121] First pass at shellcheck appeasement Kept going till I got stuck on one that's hard to change. 21 more to go! --- vcsh | 69 +++++++++++++++++++++++++++++++++--------------------------- 1 file changed, 38 insertions(+), 31 deletions(-) diff --git a/vcsh b/vcsh index a9982f59..76694e89 100755 --- a/vcsh +++ b/vcsh @@ -20,15 +20,15 @@ # version of vcsh; the master branch is supposed to be clean at all times # so you can most likely just use it nonetheless VERSION='1.20141026' -SELF=$(basename $0) +SELF="$(basename "$0")" # Ensure all files created are accessible only to the current user. umask 0077 fatal() { echo "$SELF: fatal: $1" >&2 - [ -z $2 ] && exit 1 - exit $2 + [ -z "$2" ] && exit 1 + exit "$2" } # We need to run getops as soon as possible so we catch -d and other @@ -56,7 +56,8 @@ shift $((OPTIND-1)) source_all() { # Source file even if it's in $PWD and does not have any slashes in it - case $1 in + # shellcheck source=/dev/null + case "$1" in */*) . "$1";; *) . "$PWD/$1";; esac; @@ -65,10 +66,12 @@ source_all() { # Read configuration and set defaults if anything's not set [ -n "$VCSH_DEBUG" ] && set -vx -: ${XDG_CONFIG_HOME:="$HOME/.config"} +: "${XDG_CONFIG_HOME:="$HOME/.config"}" # Read configuration files if there are any +# shellcheck source=/dev/null [ -r "/etc/vcsh/config" ] && . "/etc/vcsh/config" +# shellcheck source=/dev/null [ -r "$XDG_CONFIG_HOME/vcsh/config" ] && . "$XDG_CONFIG_HOME/vcsh/config" if [ -n "$VCSH_OPTION_CONFIG" ]; then # Source $VCSH_OPTION_CONFIG if it can be read and is in $PWD of $PATH @@ -81,13 +84,13 @@ fi [ -n "$VCSH_DEBUG" ] && set -vx # Read defaults -: ${VCSH_REPO_D:="$XDG_CONFIG_HOME/vcsh/repo.d"} -: ${VCSH_HOOK_D:="$XDG_CONFIG_HOME/vcsh/hooks-enabled"} -: ${VCSH_OVERLAY_D:="$XDG_CONFIG_HOME/vcsh/overlays-enabled"} -: ${VCSH_BASE:="$HOME"} -: ${VCSH_GITIGNORE:=exact} -: ${VCSH_GITATTRIBUTES:=none} -: ${VCSH_WORKTREE:=absolute} +: "${VCSH_REPO_D:="$XDG_CONFIG_HOME/vcsh/repo.d"}" +: "${VCSH_HOOK_D:="$XDG_CONFIG_HOME/vcsh/hooks-enabled"}" +: "${VCSH_OVERLAY_D:="$XDG_CONFIG_HOME/vcsh/overlays-enabled"}" +: "${VCSH_BASE:="$HOME"}" +: "${VCSH_GITIGNORE:=exact}" +: "${VCSH_GITATTRIBUTES:=none}" +: "${VCSH_WORKTREE:=absolute}" if [ ! "x$VCSH_GITIGNORE" = 'xexact' ] && [ ! "x$VCSH_GITIGNORE" = 'xnone' ] && [ ! "x$VCSH_GITIGNORE" = 'xrecursive' ]; then fatal "'\$VCSH_GITIGNORE' must equal 'exact', 'none', or 'recursive'" 1 @@ -146,11 +149,13 @@ help() { # editorconfig-checker-enable debug() { - if [ -n "$VCSH_DEBUG" ]; then echo "$SELF: debug: $@"; fi + if [ -n "$VCSH_DEBUG" ]; then echo "$SELF: debug: $*"; fi } verbose() { - if [ -n "$VCSH_DEBUG" ] || [ -n "$VCSH_VERBOSE" ]; then echo "$SELF: verbose: $@"; fi + if [ -n "$VCSH_DEBUG" ] || [ -n "$VCSH_VERBOSE" ]; then + echo "$SELF: verbose: $*" + fi } error() { @@ -170,6 +175,8 @@ clone() { git checkout -b "$VCSH_BRANCH" || return $? git config branch."$VCSH_BRANCH".remote origin git config branch."$VCSH_BRANCH".merge refs/heads/"$VCSH_BRANCH" + # BSD wc emits spaces. + # shellcheck disable=SC2046 if [ $(git ls-remote origin "$VCSH_BRANCH" 2> /dev/null | wc -l ) -lt 1 ]; then info "remote is empty, not merging anything. You should add files to your new repository." # editorconfig-checker-disable-line @@ -219,10 +226,10 @@ $files AGAIN, THIS WILL DELETE YOUR DATA! To continue, type 'Yes, do as I say'" - read answer + read -r answer [ "x$answer" = 'xYes, do as I say' ] || exit 16 for file in $files; do - rm -f $file || info "could not delete '$file', continuing with deletion" + rm -f "$file" || info "could not delete '$file', continuing with deletion" done rm -rf "$GIT_DIR" || error "could not delete '$GIT_DIR'" } @@ -299,14 +306,14 @@ init() { list() { for repo in "$VCSH_REPO_D"/*.git; do - [ -d "$repo" ] && [ -r "$repo" ] && echo "$(basename "$repo" .git)" + [ -d "$repo" ] && [ -r "$repo" ] && basename "$repo" .git done } list_has_remote() { for VCSH_REPO_NAME in $(list); do GIT_DIR=$VCSH_REPO_D/$VCSH_REPO_NAME.git; export GIT_DIR - git config branch.$VCSH_BRANCH.remote > /dev/null && echo "$VCSH_REPO_NAME" + git config branch."$VCSH_BRANCH".remote > /dev/null && echo "$VCSH_REPO_NAME" done } @@ -331,7 +338,7 @@ list_tracked_helper() { } list_tracked_by() { - list_tracked '' $2 + list_tracked '' "$2" } list_untracked() { @@ -357,33 +364,33 @@ list_untracked() { VCSH_REPO_NAME=$1; export VCSH_REPO_NAME if [ -n "$VCSH_REPO_NAME" ]; then - list_untracked_helper $VCSH_REPO_NAME + list_untracked_helper "$VCSH_REPO_NAME" else for VCSH_REPO_NAME in $(list); do - list_untracked_helper $VCSH_REPO_NAME + list_untracked_helper "$VCSH_REPO_NAME" done fi - cat $temp_file_untracked + cat "$temp_file_untracked" unset directory_opt directory_component - rm -f $temp_file_others $temp_file_untracked $temp_file_untracked_copy || fatal 'Could not delete temp files' + rm -f "$temp_file_others" "$temp_file_untracked" "$temp_file_untracked_copy" || fatal 'Could not delete temp files' } list_untracked_helper() { export GIT_DIR="$VCSH_REPO_D/$VCSH_REPO_NAME.git" git ls-files --others $exclude_standard_opt "$directory_opt" | ( - while read line; do + while read -r line; do echo "$line" directory_component=${line%%/*} [ -d "$directory_component" ] && printf '%s/\n' "$directory_component" done - ) | sort -u > $temp_file_others + ) | sort -u > "$temp_file_others" if [ -z "$ran_once" ]; then ran_once=1 - cp $temp_file_others $temp_file_untracked || fatal 'Could not copy temp file' + cp "$temp_file_others" "$temp_file_untracked" || fatal 'Could not copy temp file' fi - cp $temp_file_untracked $temp_file_untracked_copy || fatal 'Could not copy temp file' - comm -12 $temp_file_others $temp_file_untracked_copy > $temp_file_untracked + cp "$temp_file_untracked" "$temp_file_untracked_copy" || fatal 'Could not copy temp file' + comm -12 "$temp_file_others" "$temp_file_untracked_copy" > "$temp_file_untracked" } pull() { @@ -446,11 +453,11 @@ status() { COLORING="-c color.status=always" fi if [ -n "$VCSH_REPO_NAME" ]; then - status_helper $VCSH_REPO_NAME + status_helper "$VCSH_REPO_NAME" else for VCSH_REPO_NAME in $(list); do - STATUS=$(status_helper $VCSH_REPO_NAME "$COLORING") - [ -n "$STATUS" -o -z "$VCSH_STATUS_TERSE" ] && echo "$VCSH_REPO_NAME:" + STATUS="$(status_helper "$VCSH_REPO_NAME" "$COLORING")" + [ -n "$STATUS" ] || [ -z "$VCSH_STATUS_TERSE" ] && echo "$VCSH_REPO_NAME:" [ -n "$STATUS" ] && echo "$STATUS" [ -z "$VCSH_STATUS_TERSE" ] && echo done From 8eccf4d4874a6b2a1903b6760629016dfb809a78 Mon Sep 17 00:00:00 2001 From: Kevin Lyda Date: Sun, 4 Apr 2021 19:32:31 +0100 Subject: [PATCH 076/121] Pick an email address Lyda (#290) --- .mailmap | 1 + 1 file changed, 1 insertion(+) diff --git a/.mailmap b/.mailmap index 0b983617..5c8bf56a 100644 --- a/.mailmap +++ b/.mailmap @@ -2,4 +2,5 @@ Richard Hartmann Richard Hartmann Richard Hartmann Richard Hartmann +Kevin Lyda Alexander Skurikhin From 2b375c102645d2146bea6c6271a95baf5edcf889 Mon Sep 17 00:00:00 2001 From: Caleb Maclennan Date: Sun, 4 Apr 2021 01:39:33 +0300 Subject: [PATCH 077/121] Move assorted developer tooling to makefile --- Makefile.am | 7 +++++++ tools/hooks/pre-commit | 7 ------- tools/list_CONTRIBUTORS | 12 ------------ 3 files changed, 7 insertions(+), 19 deletions(-) delete mode 100755 tools/hooks/pre-commit delete mode 100755 tools/list_CONTRIBUTORS diff --git a/Makefile.am b/Makefile.am index 03b4a81f..2f47e0bc 100644 --- a/Makefile.am +++ b/Makefile.am @@ -46,6 +46,13 @@ completions/_$(_vcsh): completions/vcsh.zsh test: prove +CONTRIBUTORS: + exec > $@ + echo 'Alphabetical list of surnames of everyone who ever committed to this repository.' + echo 'Auto-generated using `make -B CONTRIBUTORS`' + echo + $(GIT) shortlog -se --all | cut -f1 --complement | sort -u -k2 + dist-hook: cd $(distdir) echo $(VERSION) > .tarball-version diff --git a/tools/hooks/pre-commit b/tools/hooks/pre-commit deleted file mode 100755 index ddb0550d..00000000 --- a/tools/hooks/pre-commit +++ /dev/null @@ -1,7 +0,0 @@ -#!/bin/sh - -# Unfortunately, Git decided to set those two during pre-commit -unset GIT_DIR -unset GIT_INDEX_FILE - -prove diff --git a/tools/list_CONTRIBUTORS b/tools/list_CONTRIBUTORS deleted file mode 100755 index 1b88451d..00000000 --- a/tools/list_CONTRIBUTORS +++ /dev/null @@ -1,12 +0,0 @@ -#!/bin/sh - -# This program is licensed under the GNU GPL version 2 or later. -# (c) Richard "RichiH" Hartmann , 2012-2014 -# For details, see LICENSE. To submit patches, you have to agree to -# license your code under the GNU GPL version 2 or later. - - -echo 'Alphabetical list of surnames of everyone who ever committed to this repository. -Auto-generated from tools/list_CONTRIBUTORS. -' -git shortlog -se --all | cut -f1 --complement | sort -u -k2 From c0b768a9bbba9f78b3f708e56e9bb22b8686b9e4 Mon Sep 17 00:00:00 2001 From: Caleb Maclennan Date: Mon, 5 Apr 2021 07:38:18 +0300 Subject: [PATCH 078/121] Ditch surname sort, 50% unreliable anyway The surname sort was a nice idea, but in this case it works out very poorly for normalization purposes: * In many cases we only have one name, in which case it was sorting on email address. * In some cases people have 3 or more name fields, it which case it was sorting on their middle initial. * In some cases the entries are not even names (e.g. Fedora Release Engineering) * Some languages do not follow the "first last" convention and sorting them based on a fixed position is just not good social etiquette. I started trying to fix the technical problems by sorting on the *last* field instead of blindly on the second column, but even that left so many anomalies it was hard to find names I knew were there. I think just a plain name sort is better in this context. --- Makefile.am | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile.am b/Makefile.am index 2f47e0bc..29ca3b17 100644 --- a/Makefile.am +++ b/Makefile.am @@ -48,10 +48,10 @@ test: CONTRIBUTORS: exec > $@ - echo 'Alphabetical list of surnames of everyone who ever committed to this repository.' + echo 'Alphabetical list of names of everyone who ever committed to this repository.' echo 'Auto-generated using `make -B CONTRIBUTORS`' echo - $(GIT) shortlog -se --all | cut -f1 --complement | sort -u -k2 + $(GIT) shortlog -se --all | cut -f1 --complement | sort -u dist-hook: cd $(distdir) From a76357051b8c3a25dd0195256421d7878c21a26d Mon Sep 17 00:00:00 2001 From: Caleb Maclennan Date: Sun, 4 Apr 2021 01:43:14 +0300 Subject: [PATCH 079/121] Regenerate contributors file --- CONTRIBUTORS | 87 +++++++++++++++++++++++++++++++++------------------- 1 file changed, 56 insertions(+), 31 deletions(-) diff --git a/CONTRIBUTORS b/CONTRIBUTORS index cf286198..8cd4d5f3 100644 --- a/CONTRIBUTORS +++ b/CONTRIBUTORS @@ -1,41 +1,66 @@ -Alphabetical list of surnames of everyone who ever committed to this repository. -Auto-generated from tools/list_CONTRIBUTORS. +Alphabetical list of names of everyone who ever committed to this repository. +Auto-generated using `make -B CONTRIBUTORS` -Skurikhin Alexander -Eric Bouchut -Dridi Boukelmoune -Rob Cornish -Vincent Demeester -Mert Dirik -Jeff Fein-Worton -Thomas Ferris Nicolaisen -martin f. krafft +Aaron Schumacher +Aaron VonderHaar Alessandro Ghedini -Dennis Gilmore -Thorsten Glaser -G.raud -Mikhail Gusarov -Valentin Haenel -Richard Hartmann -Gregor Jasny -Errietta Kostala -Yuval Langer +Alexander Skurikhin +Andrew Schwartzmeyer +arndtc +Aryel Mota Góis Caleb Maclennan -Markus Martin -mek-apelsin -Evan Pitstick -Dieter Plaetinck Corey Quinn -Pavlos Ratis +Daniel Shahaf +Dato Simó +Debian Janitor +Dennis Gilmore +Devin J. Pohly Dewey Sasser +Dieter Plaetinck +Don +Don March +Dridi Boukelmoune +Edward Betts +Eli Young +Eric Bouchut +Errietta Kostala +Evan Pitstick +Fedora Release Engineering +Felix Eckhofer +Florian Engel +Frank Terbeck Gernot Schulz -Aaron Schumacher -Andrew Schwartzmeyer -Dato Simó -Alexander Skurikhin +G.raud +Gregor Jasny +guy hughes +Harendra Kumar +James Davidson +Jeff Fein-Worton +Jochen Keil Jonathan Sternberg +Julien Lecomte +Kevin Lyda +leycec +Markus Martin +martin f. krafft Mathias Svensson -Frank Terbeck +mek-apelsin +Mert Dirik +Mikhail Gusarov mirabilos -Aaron VonderHaar +miramir +Noah Birnel +Pavlos Ratis +Richard Hartmann +Rob Cornish +Roland Hopferwieser +Skurikhin Alexander +soulofmischief <30357883+soulofmischief@users.noreply.github.com> +Thomas Ferris Nicolaisen +Thomas Tuegel +Thorsten Glaser +tikki Tony +Valentin Haenel +Vincent Demeester +Yuval Langer From bf85ba71ad11ccd6dea3536cd0d5f8e87c6e6551 Mon Sep 17 00:00:00 2001 From: Caleb Maclennan Date: Sun, 4 Apr 2021 01:58:36 +0300 Subject: [PATCH 080/121] Update CI workflow to configure before testing --- .github/workflows/test.yml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index e3a674d1..d8276628 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -8,13 +8,17 @@ jobs: uses: actions/checkout@v2 - name: Install build dependencies run: | - sudo apt-get install ruby-ronn + sudo apt-get install ronn - name: Install perl test dependencies uses: perl-actions/install-with-cpanm@v1.1 with: install: | Shell::Command Test::Most + - name: Configure + run: | + ./bootstrap.sh + ./configure - name: Run tests run: | make test From 5147fddc360961b98d01b81e56b8777731a4ccae Mon Sep 17 00:00:00 2001 From: Caleb Maclennan Date: Sun, 4 Apr 2021 02:22:48 +0300 Subject: [PATCH 081/121] Add make target for developer local linting --- Makefile.am | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Makefile.am b/Makefile.am index 29ca3b17..de507b23 100644 --- a/Makefile.am +++ b/Makefile.am @@ -46,6 +46,10 @@ completions/_$(_vcsh): completions/vcsh.zsh test: prove +.PHONY: lint +lint: + ec + CONTRIBUTORS: exec > $@ echo 'Alphabetical list of names of everyone who ever committed to this repository.' From 893695384ae687c64790dfa85eb6e86b8caa4f65 Mon Sep 17 00:00:00 2001 From: Caleb Maclennan Date: Sun, 4 Apr 2021 02:25:53 +0300 Subject: [PATCH 082/121] Update gitignore with autotools and build artifacts --- .gitignore | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/.gitignore b/.gitignore index 4dec9bf3..2562f6ab 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,18 @@ vcsh.1 *.swp .swp *.bak +.version +.version-prev +Makefile +Makefile.in +aclocal.m4 +autom4te.cache/ +build-aux/install-sh +build-aux/missing +completions/_vcsh +completions/vcsh +config.log +config.status +configure +/vcsh +vcsh-* From a6322afce17f2fe56734cc834bfdbbd11a9069fd Mon Sep 17 00:00:00 2001 From: Caleb Maclennan Date: Mon, 5 Apr 2021 08:52:03 +0300 Subject: [PATCH 083/121] Add limited self check to make sure versioning is working --- .github/workflows/test.yml | 1 + Makefile.am | 8 ++++++++ 2 files changed, 9 insertions(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index d8276628..f0f075b5 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -19,6 +19,7 @@ jobs: run: | ./bootstrap.sh ./configure + make check - name: Run tests run: | make test diff --git a/Makefile.am b/Makefile.am index de507b23..e0ff9bc4 100644 --- a/Makefile.am +++ b/Makefile.am @@ -42,6 +42,14 @@ completions/_$(_vcsh): completions/vcsh.zsh $(if $<,./build-aux/git-version-gen .tarball-version,printf "$(VERSION)") > "$@" $(CMP) -s "$@" "$@-prev" || autoreconf configure.ac --force +check: check-version + +.PHONY: check-version +check-version: vcsh | .version + grep -Fx '$(VERSION)' $| + ./$< version | $(GREP) -Ff $| + ./$< version | $(GREP) -Ff <($(GIT) version) + .PHONY: test test: prove From 7017fa2999afa676efb80a508d4fa0620018468f Mon Sep 17 00:00:00 2001 From: Richard Hartmann Date: Mon, 5 Apr 2021 08:34:03 +0200 Subject: [PATCH 084/121] Fix missing autotools replacements Signed-off-by: Richard Hartmann --- vcsh.in | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/vcsh.in b/vcsh.in index 86ee2f48..dc22eeda 100755 --- a/vcsh.in +++ b/vcsh.in @@ -164,7 +164,7 @@ info() { clone() { hook pre-clone # Check if remote is reachable. Abort early if there's a typo, TLS certificate problem, etc - git ls-remote "$GIT_REMOTE" 2> /dev/null || fatal "Can not reach '$GIT_REMOTE'" + @GIT@ ls-remote "$GIT_REMOTE" 2> /dev/null || fatal "Can not reach '$GIT_REMOTE'" init @GIT@ remote add origin "$GIT_REMOTE" @GIT@ checkout -b "$VCSH_BRANCH" || return $? @@ -252,7 +252,7 @@ foreach() { use hook_repo pre-foreach if [ -n "${VCSH_PRINT_REPO_PREFIX+x}" ]; then - $command_prefix "$@" | sed "s/^/$VCSH_REPO_NAME: /" + $command_prefix "$@" | @SED@ "s/^/$VCSH_REPO_NAME: /" else echo "$VCSH_REPO_NAME:" $command_prefix "$@" @@ -306,7 +306,7 @@ list() { list_has_remote() { for VCSH_REPO_NAME in $(list); do GIT_DIR=$VCSH_REPO_D/$VCSH_REPO_NAME.git; export GIT_DIR - git config branch.$VCSH_BRANCH.remote > /dev/null && echo "$VCSH_REPO_NAME" + @GIT@ config branch.$VCSH_BRANCH.remote > /dev/null && echo "$VCSH_REPO_NAME" done } From f95fda064d025fa91c972323e4a5fab6ebabcb9d Mon Sep 17 00:00:00 2001 From: Richard Hartmann Date: Mon, 5 Apr 2021 08:53:36 +0200 Subject: [PATCH 085/121] Release 1.20190620 Signed-off-by: Richard Hartmann --- changelog | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/changelog b/changelog index 0b84ad2f..f60bfa1b 100644 --- a/changelog +++ b/changelog @@ -1,3 +1,9 @@ +2021-04-05 Richard Hartmann + + * Release 1.20190620 + * This is a safe harbour release. + * `release` branch should ensure downstream picks it up + 2021-03-29 Richard Hartmann * Release 1.20190619 From 1a105a181a46d635820aa12cfd77a7c45dadf118 Mon Sep 17 00:00:00 2001 From: Richard Hartmann Date: Mon, 5 Apr 2021 08:59:39 +0200 Subject: [PATCH 086/121] Release v1.20190621 Signed-off-by: Richard Hartmann --- changelog | 5 +++++ vcsh | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/changelog b/changelog index f60bfa1b..9afbcd59 100644 --- a/changelog +++ b/changelog @@ -1,5 +1,10 @@ 2021-04-05 Richard Hartmann + * Release 1.20190621 + * Make version reflected in `vcsh version` correct... + +2021-03-29 Richard Hartmann + * Release 1.20190620 * This is a safe harbour release. * `release` branch should ensure downstream picks it up diff --git a/vcsh b/vcsh index 1c437977..ec9c48b2 100755 --- a/vcsh +++ b/vcsh @@ -19,7 +19,7 @@ # If '.git-HEAD' is appended to the version, you are seeing an unreleased # version of vcsh; the master branch is supposed to be clean at all times # so you can most likely just use it nonetheless -VERSION='1.20151229' +VERSION='1.20190621' SELF=$(basename $0) # Ensure all files created are accessible only to the current user. From f0bbc517c73ca6be4bcb426056d26ca0593f3f50 Mon Sep 17 00:00:00 2001 From: Richard Hartmann Date: Mon, 5 Apr 2021 09:43:12 +0200 Subject: [PATCH 087/121] Export VCSH_DEBUG and VCSH_VERBOSE This makes it possible to react to verbose and debug state from hooks. Fixes: https://github.com/RichiH/vcsh/issues/175 Signed-off-by: Richard Hartmann --- vcsh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/vcsh b/vcsh index a9982f59..daf85df5 100755 --- a/vcsh +++ b/vcsh @@ -39,11 +39,13 @@ while getopts c:dv flag; do d) set -vx VCSH_DEBUG=1 + export VCSH_DEBUG echo 'debug mode on' echo "$SELF $VERSION" ;; v) VCSH_VERBOSE=1 + export VCSH_VERBOSE echo 'verbose mode on' echo "$SELF $VERSION" ;; From 9ded1bc60c0061ce4db0db96eecf868685ab0b2e Mon Sep 17 00:00:00 2001 From: Richard Hartmann Date: Mon, 5 Apr 2021 10:18:55 +0200 Subject: [PATCH 088/121] Make VCSH_* availaible to all hooks This change should ensure that any variable starting with VCSH_ will be available to any hook. Not all of them seem useful, but that's for the hook author, not me, to dedide. Signed-off-by: Richard Hartmann --- vcsh | 42 ++++++++++++++++++++++++------------------ 1 file changed, 24 insertions(+), 18 deletions(-) diff --git a/vcsh b/vcsh index daf85df5..3694947d 100755 --- a/vcsh +++ b/vcsh @@ -19,14 +19,14 @@ # If '.git-HEAD' is appended to the version, you are seeing an unreleased # version of vcsh; the master branch is supposed to be clean at all times # so you can most likely just use it nonetheless -VERSION='1.20141026' -SELF=$(basename $0) +VCSH_VERSION='0.2021-GIT'; export VCSH_VERSION +VCSH_SELF=$(basename $0); export VCSH_SELF # Ensure all files created are accessible only to the current user. umask 0077 fatal() { - echo "$SELF: fatal: $1" >&2 + echo "$VCSH_SELF: fatal: $1" >&2 [ -z $2 ] && exit 1 exit $2 } @@ -41,16 +41,17 @@ while getopts c:dv flag; do VCSH_DEBUG=1 export VCSH_DEBUG echo 'debug mode on' - echo "$SELF $VERSION" + echo "$VCSH_SELF $VCSH_VERSION" ;; v) VCSH_VERBOSE=1 export VCSH_VERBOSE echo 'verbose mode on' - echo "$SELF $VERSION" + echo "$VCSH_SELF $VCSH_VERSION" ;; c) VCSH_OPTION_CONFIG="$OPTARG" + export VCSH_OPTION_CONFIG ;; esac done @@ -83,13 +84,13 @@ fi [ -n "$VCSH_DEBUG" ] && set -vx # Read defaults -: ${VCSH_REPO_D:="$XDG_CONFIG_HOME/vcsh/repo.d"} -: ${VCSH_HOOK_D:="$XDG_CONFIG_HOME/vcsh/hooks-enabled"} -: ${VCSH_OVERLAY_D:="$XDG_CONFIG_HOME/vcsh/overlays-enabled"} -: ${VCSH_BASE:="$HOME"} -: ${VCSH_GITIGNORE:=exact} -: ${VCSH_GITATTRIBUTES:=none} -: ${VCSH_WORKTREE:=absolute} +: ${VCSH_REPO_D:="$XDG_CONFIG_HOME/vcsh/repo.d"}; export VCSH_REPO_D +: ${VCSH_HOOK_D:="$XDG_CONFIG_HOME/vcsh/hooks-enabled"}; export VCSH_HOOK_D +: ${VCSH_OVERLAY_D:="$XDG_CONFIG_HOME/vcsh/overlays-enabled"}; export VCSH_OVERLAY_D +: ${VCSH_BASE:="$HOME"}; export VCSH_BASE +: ${VCSH_GITIGNORE:=exact}; export VCSH_GITIGNORE +: ${VCSH_GITATTRIBUTES:=none}; export VCSH_GITATTRIBUTES +: ${VCSH_WORKTREE:=absolute}; export VCSH_WORKTREE if [ ! "x$VCSH_GITIGNORE" = 'xexact' ] && [ ! "x$VCSH_GITIGNORE" = 'xnone' ] && [ ! "x$VCSH_GITIGNORE" = 'xrecursive' ]; then fatal "'\$VCSH_GITIGNORE' must equal 'exact', 'none', or 'recursive'" 1 @@ -102,7 +103,7 @@ fi # editorconfig-checker-disable help() { - echo "usage: $SELF + echo "usage: $VCSH_SELF options: -c Source file @@ -148,19 +149,19 @@ help() { # editorconfig-checker-enable debug() { - if [ -n "$VCSH_DEBUG" ]; then echo "$SELF: debug: $@"; fi + if [ -n "$VCSH_DEBUG" ]; then echo "$VCSH_SELF: debug: $@"; fi } verbose() { - if [ -n "$VCSH_DEBUG" ] || [ -n "$VCSH_VERBOSE" ]; then echo "$SELF: verbose: $@"; fi + if [ -n "$VCSH_DEBUG" ] || [ -n "$VCSH_VERBOSE" ]; then echo "$VCSH_SELF: verbose: $@"; fi } error() { - echo "$SELF: error: $1" >&2 + echo "$VCSH_SELF: error: $1" >&2 } info() { - echo "$SELF: info: $1" + echo "$VCSH_SELF: info: $1" } clone() { @@ -198,6 +199,7 @@ commit() { hook_global pre-commit shift # remove the "commit" command. for VCSH_REPO_NAME in $(list); do + export VCSH_REPO_NAME echo "$VCSH_REPO_NAME: " GIT_DIR=$VCSH_REPO_D/$VCSH_REPO_NAME.git; export GIT_DIR use @@ -248,8 +250,10 @@ foreach() { p) VCSH_PRINT_REPO_PREFIX=1 ;; esac done + export VCSH_PRINT_REPO_PREFIX shift $((OPTIND-1)) for VCSH_REPO_NAME in $(list); do + export VCSH_REPO_NAME GIT_DIR=$VCSH_REPO_D/$VCSH_REPO_NAME.git; export GIT_DIR use hook_repo pre-foreach @@ -391,6 +395,7 @@ list_untracked_helper() { pull() { hook_global pre-pull for VCSH_REPO_NAME in $(list_has_remote); do + export VCSH_REPO_NAME printf '%s: ' "$VCSH_REPO_NAME" GIT_DIR=$VCSH_REPO_D/$VCSH_REPO_NAME.git; export GIT_DIR use @@ -406,6 +411,7 @@ pull() { push() { hook_global pre-push for VCSH_REPO_NAME in $(list_has_remote); do + export VCSH_REPO_NAME printf '%s: ' "$VCSH_REPO_NAME" GIT_DIR=$VCSH_REPO_D/$VCSH_REPO_NAME.git; export GIT_DIR use @@ -616,7 +622,7 @@ if [ x"$VCSH_COMMAND" = x'clone' ]; then elif [ "$VCSH_COMMAND" = 'help' ]; then help && exit elif [ "$VCSH_COMMAND" = 'version' ]; then - echo "$SELF $VERSION" + echo "$VCSH_SELF $VCSH_VERSION" git version exit elif [ x"$VCSH_COMMAND" = x'which' ]; then From 16b27a1c6af113f2a2e8ca67d06c3f2aba7b603c Mon Sep 17 00:00:00 2001 From: Kevin Lyda Date: Mon, 5 Apr 2021 13:10:38 +0100 Subject: [PATCH 089/121] Removed the rest of the shellcheck errors --- vcsh | 28 ++++++++++++++++++++++------ 1 file changed, 22 insertions(+), 6 deletions(-) diff --git a/vcsh b/vcsh index 76694e89..9f8ff959 100755 --- a/vcsh +++ b/vcsh @@ -464,10 +464,15 @@ status() { fi } +# Warning: disabled quoting check here due to all of them relating to +# wc -l output and a deliberate lack of quoting for git args. +# shellcheck disable=SC2086 status_helper() { GIT_DIR=$VCSH_REPO_D/$1.git; export GIT_DIR VCSH_GIT_OPTIONS="-c status.relativePaths=false $2" use + # Shellcheck isn't understanding a complex block. + # shellcheck disable=SC1083 remote_tracking_branch=$(git rev-parse --abbrev-ref --symbolic-full-name @{u} 2> /dev/null) && { commits_behind=$(git log ..${remote_tracking_branch} --oneline | wc -l) commits_ahead=$(git log ${remote_tracking_branch}.. --oneline | wc -l) @@ -506,6 +511,8 @@ use() { } which() { + # It's ok to modify VCSH_REPO_NAME in a subshell. + # shellcheck disable=SC2030 output=$(for VCSH_REPO_NAME in $(list); do get_files | grep -- "$VCSH_COMMAND_PARAMETER" | sed "s/^/$VCSH_REPO_NAME: /" done | sort -u) @@ -516,6 +523,8 @@ which() { fi } +# Ignore warnings about VCSH_REPO_NAME being changed in a subshell. +# shellcheck disable=SC2031 write_gitignore() { # Don't do anything if the user does not want to write gitignore if [ "x$VCSH_GITIGNORE" = 'xnone' ]; then @@ -525,13 +534,17 @@ write_gitignore() { use cd "$VCSH_BASE" || fatal "could not enter '$VCSH_BASE'" 11 - local GIT_VERSION="$(git --version)" - local GIT_VERSION_MAJOR=$(echo $GIT_VERSION | sed -E -n 's/.* ([0-9]+)\..*/\1/p') - local GIT_VERSION_MINOR=$(echo $GIT_VERSION | sed -E -n 's/.* ([0-9]+)\.([0-9]+)\..*/\2/p') + # Works in all shells we care about. + # shellcheck disable=SC2039 + local GIT_VERSION GIT_VERSION_MAJOR GIT_VERSION_MINOR + GIT_VERSION="$(git --version)" + GIT_VERSION_MAJOR="$(echo "$GIT_VERSION" | sed -E -n 's/.* ([0-9]+)\..*/\1/p')" + GIT_VERSION_MINOR="$(echo "$GIT_VERSION" | sed -E -n 's/.* ([0-9]+)\.([0-9]+)\..*/\2/p')" OLDIFS=$IFS IFS=$(printf '\n\t') gitignores=$(for file in $(git ls-files); do - if [ $GIT_VERSION_MAJOR -ge 2 -a $GIT_VERSION_MINOR -ge 7 ]; then + if [ "$GIT_VERSION_MAJOR" -ge 2 ] \ + && [ "$GIT_VERSION_MINOR" -ge 7 ]; then echo "$file"; else while true; do @@ -568,7 +581,7 @@ write_gitignore() { fatal "could not move '$tempfile' to '$VCSH_BASE/.gitignore.d/$VCSH_REPO_NAME'" 53 } -debug $(git version) +debug "$(git version)" if [ ! "x$VCSH_GITIGNORE" = 'xexact' ] && [ ! "x$VCSH_GITIGNORE" = 'xnone' ] && [ ! "x$VCSH_GITIGNORE" = 'xrecursive' ]; then fatal "'\$VCSH_GITIGNORE' must equal 'exact', 'none', or 'recursive'" 1 @@ -707,12 +720,15 @@ verbose "$VCSH_COMMAND begin" VCSH_COMMAND=$(echo "$VCSH_COMMAND" | sed 's/-/_/g'); export VCSH_COMMAND # Source repo-specific configuration file -[ -r "$XDG_CONFIG_HOME/vcsh/config.d/$VCSH_REPO_NAME" ] && . "$XDG_CONFIG_HOME/vcsh/config.d/$VCSH_REPO_NAME" +# shellcheck source=/dev/null +[ -r "$XDG_CONFIG_HOME/vcsh/config.d/$VCSH_REPO_NAME" ] \ + && . "$XDG_CONFIG_HOME/vcsh/config.d/$VCSH_REPO_NAME" # source overlay functions for overlay in "$VCSH_OVERLAY_D/$VCSH_COMMAND"* "$VCSH_OVERLAY_D/$VCSH_REPO_NAME.$VCSH_COMMAND"*; do [ -r "$overlay" ] || continue info "sourcing '$overlay'" + # shellcheck source=/dev/null . "$overlay" done From 5d43ae61725a60d92537df3186eb531116b377db Mon Sep 17 00:00:00 2001 From: Kevin Lyda Date: Mon, 5 Apr 2021 13:58:14 +0100 Subject: [PATCH 090/121] Appease the indent gods --- vcsh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vcsh b/vcsh index 9f8ff959..ef0ab612 100755 --- a/vcsh +++ b/vcsh @@ -544,7 +544,7 @@ write_gitignore() { IFS=$(printf '\n\t') gitignores=$(for file in $(git ls-files); do if [ "$GIT_VERSION_MAJOR" -ge 2 ] \ - && [ "$GIT_VERSION_MINOR" -ge 7 ]; then + && [ "$GIT_VERSION_MINOR" -ge 7 ]; then echo "$file"; else while true; do From 2c0ba2a03bc81811feeb2eff57ce420b21e29128 Mon Sep 17 00:00:00 2001 From: Caleb Maclennan Date: Mon, 5 Apr 2021 18:28:50 +0300 Subject: [PATCH 091/121] Ignore getopts lint, we're doing partial processing --- vcsh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/vcsh b/vcsh index 7b802c88..59b06e3d 100755 --- a/vcsh +++ b/vcsh @@ -34,6 +34,7 @@ fatal() { # We need to run getops as soon as possible so we catch -d and other # options that will modify our behaviour. # Commands are handled at the end of this script. +# shellcheck disable=SC2220 while getopts c:dv flag; do case "$flag" in d) @@ -251,6 +252,7 @@ foreach() { # We default to prefixing `git` to all commands passed to foreach, but # allow running in general context with -g command_prefix=git + # shellcheck disable=SC2220 while getopts gp flag; do case "$flag" in g) unset command_prefix ;; From a1f19deb0159f554e3d21d48f9ded12b55496197 Mon Sep 17 00:00:00 2001 From: Richard Hartmann Date: Mon, 5 Apr 2021 18:18:38 +0200 Subject: [PATCH 092/121] Quote remote branch check Signed-off-by: Richard Hartmann --- vcsh | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/vcsh b/vcsh index 59b06e3d..d1e4209d 100755 --- a/vcsh +++ b/vcsh @@ -179,9 +179,7 @@ clone() { git checkout -b "$VCSH_BRANCH" || return $? git config branch."$VCSH_BRANCH".remote origin git config branch."$VCSH_BRANCH".merge refs/heads/"$VCSH_BRANCH" - # BSD wc emits spaces. - # shellcheck disable=SC2046 - if [ $(git ls-remote origin "$VCSH_BRANCH" 2> /dev/null | wc -l ) -lt 1 ]; then + if [ "$(git ls-remote origin "$VCSH_BRANCH" 2> /dev/null | wc -l )" -lt 1 ]; then info "remote is empty, not merging anything. You should add files to your new repository." # editorconfig-checker-disable-line exit From abef6277ece15ab815574a96a8cc023b020b0d22 Mon Sep 17 00:00:00 2001 From: Kevin Lyda Date: Mon, 5 Apr 2021 18:14:08 +0100 Subject: [PATCH 093/121] Sigh, shellcheck changed the warning id --- vcsh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vcsh b/vcsh index d1e4209d..748759aa 100755 --- a/vcsh +++ b/vcsh @@ -543,7 +543,7 @@ write_gitignore() { use cd "$VCSH_BASE" || fatal "could not enter '$VCSH_BASE'" 11 # Works in all shells we care about. - # shellcheck disable=SC2039 + # shellcheck disable=SC2039,SC3043 local GIT_VERSION GIT_VERSION_MAJOR GIT_VERSION_MINOR GIT_VERSION="$(git --version)" GIT_VERSION_MAJOR="$(echo "$GIT_VERSION" | sed -E -n 's/.* ([0-9]+)\..*/\1/p')" From e37ec37af51e2c2c1b2006bce9a2334d0825942d Mon Sep 17 00:00:00 2001 From: Caleb Maclennan Date: Mon, 5 Apr 2021 18:19:16 +0300 Subject: [PATCH 094/121] Add shellcheck to CI lint workflow --- .github/workflows/lint.yml | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 917862ab..74546148 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -8,3 +8,14 @@ jobs: uses: actions/checkout@v2 - name: Lint code style uses: editorconfig-checker/action-editorconfig-checker@v1.0.0 + shellcheck: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v2 + - name: Run shellcheck + uses: reviewdog/action-shellcheck@v1.0.0 + with: + pattern: vcsh + reporter: github-pr-review + github_token: ${{ github.token }} From 42d83d689901124ba30f63517a2e4a8292a0d934 Mon Sep 17 00:00:00 2001 From: Caleb Maclennan Date: Mon, 5 Apr 2021 08:52:03 +0300 Subject: [PATCH 095/121] =?UTF-8?q?Use=20GNU=20standard=20=E2=80=98make=20?= =?UTF-8?q?check=E2=80=99=20instead=20of=20=E2=80=98make=20test=E2=80=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/test.yml | 3 +-- Makefile.am | 12 +++++++++--- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index f0f075b5..e37f7d43 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -19,7 +19,6 @@ jobs: run: | ./bootstrap.sh ./configure - make check - name: Run tests run: | - make test + make check diff --git a/Makefile.am b/Makefile.am index e0ff9bc4..5dff1342 100644 --- a/Makefile.am +++ b/Makefile.am @@ -42,7 +42,10 @@ completions/_$(_vcsh): completions/vcsh.zsh $(if $<,./build-aux/git-version-gen .tarball-version,printf "$(VERSION)") > "$@" $(CMP) -s "$@" "$@-prev" || autoreconf configure.ac --force -check: check-version +check: check-version prove + +installcheck-local: + ./$(_vcsh) version .PHONY: check-version check-version: vcsh | .version @@ -50,10 +53,13 @@ check-version: vcsh | .version ./$< version | $(GREP) -Ff $| ./$< version | $(GREP) -Ff <($(GIT) version) -.PHONY: test -test: +.PHONY: prove +prove: prove +.PHONY: test +test: prove + .PHONY: lint lint: ec From 8cd10fbf9825c32c6db1a3d41decdffe13744943 Mon Sep 17 00:00:00 2001 From: Caleb Maclennan Date: Wed, 7 Apr 2021 12:45:18 +0300 Subject: [PATCH 096/121] Add make rule to run shellcheck --- Makefile.am | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/Makefile.am b/Makefile.am index 5dff1342..a129cd46 100644 --- a/Makefile.am +++ b/Makefile.am @@ -61,9 +61,16 @@ prove: test: prove .PHONY: lint -lint: +lint: lint-editor-config lint-shellcheck + +.PHONY: lint-editor-config +lint-editor-config: ec +.PHONY: lint-shellheck +lint-shellcheck: vcsh + shellcheck $< + CONTRIBUTORS: exec > $@ echo 'Alphabetical list of names of everyone who ever committed to this repository.' From 60ba9e38d09c2a973047517682856646a3484033 Mon Sep 17 00:00:00 2001 From: Caleb Maclennan Date: Wed, 7 Apr 2021 13:06:37 +0300 Subject: [PATCH 097/121] Add option for ./configure --without-man-page --- Makefile.am | 2 ++ configure.ac | 12 +++++++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/Makefile.am b/Makefile.am index a129cd46..f2567fa9 100644 --- a/Makefile.am +++ b/Makefile.am @@ -11,7 +11,9 @@ licensedir = $(datarootdir)/licenses/vcsh dist_doc_DATA = README.md changelog doc/INSTALL.md doc/PACKAGING.md doc/README.md doc/error_codes.md 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 +if ENABLE_MAN_PAGE dist_man_MANS = vcsh.1 +endif bin_SCRIPTS = vcsh EXTRA_DIST = .version completions/vcsh.bash completions/vcsh.zsh diff --git a/configure.ac b/configure.ac index 91b7b38e..55d97270 100644 --- a/configure.ac +++ b/configure.ac @@ -15,7 +15,17 @@ AX_PROGVAR([comm]) AX_PROGVAR([cmp]) AX_PROGVAR([git]) AX_PROGVAR([prove]) -AX_PROGVAR([ronn]) + + +AC_ARG_WITH([man-page], + AS_HELP_STRING([--with-man-page], + [Generate man page @<:@default=yes@:>@]), + [], + [with_man_page=yes]) +if test "x$with_man_page" = "xyes"; then + AX_PROGVAR([ronn]) +fi +AM_CONDITIONAL([ENABLE_MAN_PAGE],[test "x$with_man_page" != "xno"]) AX_PROG_PERL_MODULES(Shell::Command, , AC_MSG_ERROR(Perl module required for testing not found)) AX_PROG_PERL_MODULES(Test::Most, , AC_MSG_ERROR(Perl module required for testing not found)) From 83e116f3093e94f71500c69abe0f6bf155c7f4f1 Mon Sep 17 00:00:00 2001 From: Caleb Maclennan Date: Wed, 7 Apr 2021 13:15:09 +0300 Subject: [PATCH 098/121] Add option for ./configure --disable-tests --- Makefile.am | 6 +++++- configure.ac | 13 +++++++++---- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/Makefile.am b/Makefile.am index f2567fa9..a5a03e3f 100644 --- a/Makefile.am +++ b/Makefile.am @@ -44,7 +44,11 @@ completions/_$(_vcsh): completions/vcsh.zsh $(if $<,./build-aux/git-version-gen .tarball-version,printf "$(VERSION)") > "$@" $(CMP) -s "$@" "$@-prev" || autoreconf configure.ac --force -check: check-version prove +check: check-version + +if ENABLE_TESTS +check: prove +endif installcheck-local: ./$(_vcsh) version diff --git a/configure.ac b/configure.ac index 55d97270..26b973e9 100644 --- a/configure.ac +++ b/configure.ac @@ -14,8 +14,6 @@ AC_DEFUN([AX_PROGVAR], [AC_PATH_PROG(m4_toupper($1), m4_default($2,$1))test -n " AX_PROGVAR([comm]) AX_PROGVAR([cmp]) AX_PROGVAR([git]) -AX_PROGVAR([prove]) - AC_ARG_WITH([man-page], AS_HELP_STRING([--with-man-page], @@ -27,8 +25,15 @@ if test "x$with_man_page" = "xyes"; then fi AM_CONDITIONAL([ENABLE_MAN_PAGE],[test "x$with_man_page" != "xno"]) -AX_PROG_PERL_MODULES(Shell::Command, , AC_MSG_ERROR(Perl module required for testing not found)) -AX_PROG_PERL_MODULES(Test::Most, , AC_MSG_ERROR(Perl module required for testing not found)) +AC_ARG_ENABLE([tests], + AS_HELP_STRING([--disable-tests], [Don't require test tooling to build])) +AM_CONDITIONAL([ENABLE_TESTS],[test "x$enable_tests" != "xno"]) + +AS_IF([test "x$enable_tests" != "xno"], [ + AX_PROGVAR([prove]) + AX_PROG_PERL_MODULES(Shell::Command, , AC_MSG_ERROR(Perl module required for testing not found)) + AX_PROG_PERL_MODULES(Test::Most, , AC_MSG_ERROR(Perl module required for testing not found)) +]) AC_ARG_WITH([bash-completion-dir], AS_HELP_STRING([--with-bash-completion-dir[=PATH]], From 8b275ac914b3401ed0c1c9e010dd873b843defc6 Mon Sep 17 00:00:00 2001 From: Caleb Maclennan Date: Wed, 7 Apr 2021 13:01:03 +0300 Subject: [PATCH 099/121] Lint generated sources not input --- .github/workflows/lint.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 74546148..749157df 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -13,6 +13,10 @@ jobs: steps: - name: Checkout uses: actions/checkout@v2 + - name: Configure + run: | + ./bootstrap.sh + ./configure --without-man-page --disable-tests - name: Run shellcheck uses: reviewdog/action-shellcheck@v1.0.0 with: From 1b4d57a2e7b50258ed992b31eb23d9e61fe0c7f8 Mon Sep 17 00:00:00 2001 From: Caleb Maclennan Date: Wed, 7 Apr 2021 13:29:52 +0300 Subject: [PATCH 100/121] =?UTF-8?q?Drop=20obsolete=20=E2=80=98packaging=20?= =?UTF-8?q?branch=E2=80=99=20documentation?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Makefile.am | 2 +- README.md | 7 +++---- doc/PACKAGING.md | 44 -------------------------------------------- 3 files changed, 4 insertions(+), 49 deletions(-) delete mode 100644 doc/PACKAGING.md diff --git a/Makefile.am b/Makefile.am index a5a03e3f..fc70c400 100644 --- a/Makefile.am +++ b/Makefile.am @@ -9,7 +9,7 @@ _vcsh = $(program_prefix)$(shell sed -e "$(program_transform_name)" <<< vcsh)$(p licensedir = $(datarootdir)/licenses/vcsh -dist_doc_DATA = README.md changelog doc/INSTALL.md doc/PACKAGING.md doc/README.md doc/error_codes.md 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_doc_DATA = README.md changelog doc/INSTALL.md doc/README.md doc/error_codes.md 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 if ENABLE_MAN_PAGE dist_man_MANS = vcsh.1 diff --git a/README.md b/README.md index e1df357f..77ce7cd5 100644 --- a/README.md +++ b/README.md @@ -57,10 +57,9 @@ All slides, videos, and further information can be found # Installation A lot of modern UNIX-based systems offer packages for `vcsh`. In case yours -does not, read [INSTALL.md](doc/INSTALL.md) for install instructions or -[PACKAGING.md](doc/PACKAGING.md) to create a package yourself. If you do end -up packaging `vcsh` please let us know so we can give you your own packaging -branch in the upstream repository. +does not, read [INSTALL.md](doc/INSTALL.md) for instructions on installing from +sources or even create a package for your system. If you do end up packaging +`vcsh` please let us know so we can document package availability. # Contact diff --git a/doc/PACKAGING.md b/doc/PACKAGING.md deleted file mode 100644 index ecbfa551..00000000 --- a/doc/PACKAGING.md +++ /dev/null @@ -1,44 +0,0 @@ -# Distributions with readily available packages - -## Archlinux - -AUR does not require any packaging information within this repository. - -## Debian - -Debian packages are provided by the author in separate branches, maintained in -the upstream repository - -### Ubuntu - -Ubuntu imports Debian's package automagically. - - -## Mac OS X / Homebrew - -Homebrew does not require any packaging information within this repository. -A separate branch with a statically compiled manpage and release tags is -provided to ease the work of Homebrew packagers: - -* The static manpage because Homebrew lacks ronn -* The tag so GitHub generates tarballs Homebrew can be pointed at - - -# Supporting new distributions - -## Your own work - -If you are maintaining a package for a different distribution, please get -in touch so your work can be included in a packaging branch in the upstream -repository. -This allows others to adapt your work for their own distributions or -packaging needs. - -## Static manpage - -The "debian-squeeze" branch carries a quilt patchset with a pre-compiled -manpage and the "homebrew" one carries a static manpage. - -In case you can not build the manpage because you are missing ronn or you -prefer a precompiled manpage for another reason, please contact us; we will -gladly provide up-to-date packages with every release. From 6660d9f84a9d8278821a8d4845ddeceba7eb3575 Mon Sep 17 00:00:00 2001 From: Caleb Maclennan Date: Fri, 9 Apr 2021 10:23:32 +0300 Subject: [PATCH 101/121] =?UTF-8?q?Flesh=20out=20=E2=80=98make=20clean?= =?UTF-8?q?=E2=80=99=20to=20include=20all=20relevant=20generated=20files?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Makefile.am | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Makefile.am b/Makefile.am index fc70c400..e5b17c82 100644 --- a/Makefile.am +++ b/Makefile.am @@ -16,9 +16,10 @@ dist_man_MANS = vcsh.1 endif bin_SCRIPTS = vcsh -EXTRA_DIST = .version completions/vcsh.bash completions/vcsh.zsh +EXTRA_DIST = completions/vcsh.bash completions/vcsh.zsh BUILT_SOURCES = .version +CLEANFILES = $(BUILT_SOURCES) $(dist_man_MANS) $(bin_SCRIPTS) if ENABLE_BASH_COMPLETION bashcompletiondir = $(BASH_COMPLETION_DIR) From 462123bd97be8524ec330d24c84d18d0c11f553f Mon Sep 17 00:00:00 2001 From: Caleb Maclennan Date: Wed, 7 Apr 2021 18:47:23 +0300 Subject: [PATCH 102/121] =?UTF-8?q?Play=20nice=20with=20automake=E2=80=99s?= =?UTF-8?q?=20idiosyncrasies,=20allow=20cleanly=20skip=20tests?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Makefile.am | 6 ++++-- configure.ac | 3 ++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/Makefile.am b/Makefile.am index e5b17c82..fa2a9970 100644 --- a/Makefile.am +++ b/Makefile.am @@ -45,12 +45,14 @@ completions/_$(_vcsh): completions/vcsh.zsh $(if $<,./build-aux/git-version-gen .tarball-version,printf "$(VERSION)") > "$@" $(CMP) -s "$@" "$@-prev" || autoreconf configure.ac --force -check: check-version +_CHECKDEPS = check-version if ENABLE_TESTS -check: prove +_CHECKDEPS += prove endif +check-local: $(_CHECKDEPS) + installcheck-local: ./$(_vcsh) version diff --git a/configure.ac b/configure.ac index 26b973e9..4fbd0547 100644 --- a/configure.ac +++ b/configure.ac @@ -26,7 +26,8 @@ fi AM_CONDITIONAL([ENABLE_MAN_PAGE],[test "x$with_man_page" != "xno"]) AC_ARG_ENABLE([tests], - AS_HELP_STRING([--disable-tests], [Don't require test tooling to build])) + AS_HELP_STRING([--disable-tests], [Skip tooling requirements for running tests]), + ,[enable_tests=yes]) AM_CONDITIONAL([ENABLE_TESTS],[test "x$enable_tests" != "xno"]) AS_IF([test "x$enable_tests" != "xno"], [ From b7728b7f724d2243e831b7e17886cc65b44636e7 Mon Sep 17 00:00:00 2001 From: Caleb Maclennan Date: Sat, 10 Apr 2021 12:33:08 +0300 Subject: [PATCH 103/121] Install sample hooks in properly nested doc dir --- Makefile.am | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Makefile.am b/Makefile.am index fa2a9970..7141f69e 100644 --- a/Makefile.am +++ b/Makefile.am @@ -9,7 +9,9 @@ _vcsh = $(program_prefix)$(shell sed -e "$(program_transform_name)" <<< vcsh)$(p licensedir = $(datarootdir)/licenses/vcsh -dist_doc_DATA = README.md changelog doc/INSTALL.md doc/README.md doc/error_codes.md 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_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 if ENABLE_MAN_PAGE dist_man_MANS = vcsh.1 From ea63376d1f63b01947f14ea6ca0b76935ed05065 Mon Sep 17 00:00:00 2001 From: Caleb Maclennan Date: Sat, 10 Apr 2021 12:36:51 +0300 Subject: [PATCH 104/121] Distribute internal tooling needed to build from a source package --- Makefile.am | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile.am b/Makefile.am index 7141f69e..fdac6521 100644 --- a/Makefile.am +++ b/Makefile.am @@ -18,7 +18,7 @@ dist_man_MANS = vcsh.1 endif bin_SCRIPTS = vcsh -EXTRA_DIST = completions/vcsh.bash completions/vcsh.zsh +EXTRA_DIST = completions/vcsh.bash completions/vcsh.zsh build-aux/git-version-gen build-aux/ax_prog_perl_modules.m4 BUILT_SOURCES = .version CLEANFILES = $(BUILT_SOURCES) $(dist_man_MANS) $(bin_SCRIPTS) From bc23caed5ac7ae2466e437c570d1477f60edb267 Mon Sep 17 00:00:00 2001 From: Caleb Maclennan Date: Sat, 10 Apr 2021 14:55:55 +0300 Subject: [PATCH 105/121] Setup tests to be on by default for developers, off for users --- configure.ac | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/configure.ac b/configure.ac index 4fbd0547..9e322945 100644 --- a/configure.ac +++ b/configure.ac @@ -25,9 +25,10 @@ if test "x$with_man_page" = "xyes"; then fi AM_CONDITIONAL([ENABLE_MAN_PAGE],[test "x$with_man_page" != "xno"]) +AS_IF([test -e .tarball-version], m4_define([TESTDEF], [yes]), m4_define([TESTDEF], [no])) AC_ARG_ENABLE([tests], - AS_HELP_STRING([--disable-tests], [Skip tooling requirements for running tests]), - ,[enable_tests=yes]) + AS_HELP_STRING([--disable-tests], [Configure tooling to run tests @<:@default=TESTDEF@:>@]), + ,[enable_tests=TESTDEF]) AM_CONDITIONAL([ENABLE_TESTS],[test "x$enable_tests" != "xno"]) AS_IF([test "x$enable_tests" != "xno"], [ From 056d3a310c59a8e4144a527dd8ecea65e232b7f8 Mon Sep 17 00:00:00 2001 From: Caleb Maclennan Date: Sat, 10 Apr 2021 15:18:05 +0300 Subject: [PATCH 106/121] Allow all command path discoveries to be overridden --- configure.ac | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index 9e322945..5dd7467f 100644 --- a/configure.ac +++ b/configure.ac @@ -9,7 +9,11 @@ AC_PROG_AWK AC_PROG_GREP AC_PROG_SED -AC_DEFUN([AX_PROGVAR], [AC_PATH_PROG(m4_toupper($1), m4_default($2,$1))test -n "$m4_toupper($1)" || AC_MSG_ERROR([m4_default($2,$1) is required])]) +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]) + ]) AX_PROGVAR([comm]) AX_PROGVAR([cmp]) From 5037d9b5b1290cfd6b420b7ad3c05db32bbcec72 Mon Sep 17 00:00:00 2001 From: Caleb Maclennan Date: Sat, 10 Apr 2021 14:00:50 +0300 Subject: [PATCH 107/121] =?UTF-8?q?Fixup=20configure=20so=20that=20?= =?UTF-8?q?=E2=80=98make=20distcheck=E2=80=99=20works?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Makefile.am | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/Makefile.am b/Makefile.am index fdac6521..c9937956 100644 --- a/Makefile.am +++ b/Makefile.am @@ -21,30 +21,34 @@ bin_SCRIPTS = vcsh EXTRA_DIST = completions/vcsh.bash completions/vcsh.zsh build-aux/git-version-gen build-aux/ax_prog_perl_modules.m4 BUILT_SOURCES = .version -CLEANFILES = $(BUILT_SOURCES) $(dist_man_MANS) $(bin_SCRIPTS) +CLEANFILES = $(BUILT_SOURCES) .version-prev $(dist_man_MANS) $(bin_SCRIPTS) if ENABLE_BASH_COMPLETION bashcompletiondir = $(BASH_COMPLETION_DIR) nodist_bashcompletion_DATA = completions/$(_vcsh) +CLEANFILES += $(nodist_bashcompletion_DATA) endif if ENABLE_ZSH_COMPLETION zshcompletiondir = $(ZSH_COMPLETION_DIR) nodist_zshcompletion_DATA = completions/_$(_vcsh) +CLEANFILES += $(nodist_zshcompletion_DATA) endif vcsh.1: doc/vcsh.1.ronn $(RONN) < $< > $@ completions/$(_vcsh): completions/vcsh.bash + mkdir -p $(dir $@) cp -bf $< $@ completions/_$(_vcsh): completions/vcsh.zsh + mkdir -p $(dir $@) cp -bf $< $@ .version: $(shell $(AWK) '{print ".git/" $$2}' .git/HEAD 2>/dev/null ||:) - [ -e "$@" ] && mv "$@" "$@-prev" || touch "$@-prev" - $(if $<,./build-aux/git-version-gen .tarball-version,printf "$(VERSION)") > "$@" + [ -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 @@ -90,5 +94,4 @@ CONTRIBUTORS: $(GIT) shortlog -se --all | cut -f1 --complement | sort -u dist-hook: - cd $(distdir) - echo $(VERSION) > .tarball-version + printf "$(VERSION)" > "$(distdir)/.tarball-version" From 0c887be2d68f59fbe888ca5f719d1f5da01a8d59 Mon Sep 17 00:00:00 2001 From: Caleb Maclennan Date: Sat, 10 Apr 2021 16:19:00 +0300 Subject: [PATCH 108/121] Get program rename support working across all outputs --- Makefile.am | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/Makefile.am b/Makefile.am index c9937956..d7716534 100644 --- a/Makefile.am +++ b/Makefile.am @@ -5,9 +5,10 @@ ACLOCAL_AMFLAGS = -I build-aux .SECONDEXPANSION: .DELETE_ON_ERROR: -_vcsh = $(program_prefix)$(shell sed -e "$(program_transform_name)" <<< vcsh)$(program_suffix) +_vcsh = $(program_prefix)$(shell $(SED) -e "$(program_transform_name)" <<< vcsh)$(program_suffix) -licensedir = $(datarootdir)/licenses/vcsh +docdir = $(datarootdir)/doc/$(_vcsh) +licensedir = $(datarootdir)/licenses/$(_vcsh) dist_doc_DATA = changelog doc/INSTALL.md doc/README.md doc/error_codes.md samplehooksdir = $(docdir)/sample_hooks @@ -95,3 +96,9 @@ CONTRIBUTORS: dist-hook: printf "$(VERSION)" > "$(distdir)/.tarball-version" + +install-exec-local: + $(SED) -i -E '/^VCSH_SELF/s#".*"#"$(_vcsh)"#g' "$(DESTDIR)$(bindir)/$(_vcsh)" + +install-data-hook: + $(SED) -i -E 's#(\\fB)vcsh\b#\1$(_vcsh)#g' "$(DESTDIR)$(man1dir)/$(_vcsh).1" From 5aa5029fec0d90594d0e9e3fdf08d0bfe9dc888f Mon Sep 17 00:00:00 2001 From: Caleb Maclennan Date: Sat, 10 Apr 2021 23:32:01 +0300 Subject: [PATCH 109/121] Add makefile target to extract latest changlog segment --- Makefile.am | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Makefile.am b/Makefile.am index d7716534..11ce2ef1 100644 --- a/Makefile.am +++ b/Makefile.am @@ -65,7 +65,7 @@ installcheck-local: .PHONY: check-version check-version: vcsh | .version - grep -Fx '$(VERSION)' $| + $(GREP) -Fx '$(VERSION)' $| ./$< version | $(GREP) -Ff $| ./$< version | $(GREP) -Ff <($(GIT) version) @@ -94,6 +94,9 @@ CONTRIBUTORS: echo $(GIT) shortlog -se --all | cut -f1 --complement | sort -u +changelog-HEAD: changelog + sed -nEe '2d;s/^\t//p;/^$$/q;' $< > $@ + dist-hook: printf "$(VERSION)" > "$(distdir)/.tarball-version" From bc3c1c645059b015918f196f8f3b0bd0fe43ffdb Mon Sep 17 00:00:00 2001 From: Caleb Maclennan Date: Sat, 10 Apr 2021 23:15:29 +0300 Subject: [PATCH 110/121] Add CI workflow to test build and post source artifacts --- .github/workflows/build.yml | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 .github/workflows/build.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 00000000..f8b168a4 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,29 @@ +name: Build + +on: [push, pull_request] + +jobs: + + build: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v2 + with: + fetch-depth: 0 + - name: Fetch tags + run: | + git fetch --prune --tags ||: + - name: Configure + run: | + ./bootstrap.sh + ./configure --disable-dependency-checks + - name: Build source package + run: | + make dist + echo VERSION=$(cat .version) >> $GITHUB_ENV + - name: Post build artifacts + uses: actions/upload-artifact@v2 + with: + name: vcsh-${{ env.VERSION }} + path: vcsh-${{ env.VERSION }} From 0ffe3bdbff9a827e2555570fcbbd3bace66e2be1 Mon Sep 17 00:00:00 2001 From: Caleb Maclennan Date: Sat, 10 Apr 2021 21:45:40 +0300 Subject: [PATCH 111/121] Add CI workflow to publish GH releases --- .github/workflows/release.yml | 39 +++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 00000000..c3bdfa1b --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,39 @@ +name: Release + +on: + push: + tags: + - v*.*.* + +jobs: + + ghrelase: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v2 + - name: Configure + run: | + echo "VERSION=${GITHUB_REF#refs/*/v}" >> $GITHUB_ENV + echo "${GITHUB_REF#refs/*/v}" > .tarball-version + ./bootstrap.sh + ./configure --disable-dependency-checks + - name: Build source package + run: | + make dist + - name: Check source package behaviour + run: | + make distcheck + - name: Make sure changelog was updated + run: | + make changelog-HEAD + grep -F "* Release ${{ env.VERSION }}" changelog-HEAD + - name: Publish Release + uses: softprops/action-gh-release@v1 + with: + body_path: changelog-HEAD + files: | + vcsh-${{ env.VERSION }}.zip + vcsh-${{ env.VERSION }}.tar.xz + env: + GITHUB_TOKEN: ${{ github.token }} From 9aa21feca2dcd72c049a26b44037e6005f58d4d8 Mon Sep 17 00:00:00 2001 From: Caleb Maclennan Date: Sun, 11 Apr 2021 00:59:34 +0300 Subject: [PATCH 112/121] Backfill changelog for unreleased changes to date --- changelog | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/changelog b/changelog index 9afbcd59..a63821b0 100644 --- a/changelog +++ b/changelog @@ -1,3 +1,25 @@ +unreleased + + * Replace homegrown Makefile with Autotools for configure and build + * Post source builds as part of automated release process + * Switch to versioning scheme to semver + * Replace Travis test runner with GitHub Actions + * Make VCSH_* variables available to hooks + * More carefully handle shell quoting + * Improve handling of non-default remote names and branches + * Fix per-repo pre/post hook handling + * Output path relative to $HOME in ‘vcsh status’ + * Add flag to prefix output of ‘vcsh foreach -p’ with repo name + * Fix debugging on Windows 10 / Cygwin + * Improve option flag handling to allow multiple flags, squash bugs + * Don't require Ruby or Perl tooling to build and install + * Avoid false-positive conflicts on checkout + * Make arg optional for write-ignore subcommand + * Fix ZSH completions, improve Bash completions + * Allow use of specific path when running Git or any dependency + * Fail if hook scripts return failure codes + * Check GIT_REMOTE early on clone() + 2021-04-05 Richard Hartmann * Release 1.20190621 From f392c37a450f0d47fd81bd2ac3dcdc9f10372648 Mon Sep 17 00:00:00 2001 From: Caleb Maclennan Date: Wed, 7 Apr 2021 13:58:07 +0300 Subject: [PATCH 113/121] Overhaul install docs --- doc/INSTALL.md | 126 +++++++++++++++++++++++++++++++++++++------------ 1 file changed, 97 insertions(+), 29 deletions(-) diff --git a/doc/INSTALL.md b/doc/INSTALL.md index 3fbf129f..c2965e63 100644 --- a/doc/INSTALL.md +++ b/doc/INSTALL.md @@ -1,59 +1,127 @@ -# Pre-requisites # +# Distro Packages -If you want to build the manpage, you will need [ronn] [1]. -Debian 7.0 and above come with a package, so do most Debian clones. +Many distributions have packages ready to go. +If yours doesn't, you can install [from source](#installing-from-source). +If you package VCSH for a distro please let us know. -To install ronn on your Debian-based system, simply run +## Arch Linux - apt-get install ruby-ronn +Use your favorite AUR helper to build and install the [vcsh](https://aur.archlinux.org/packages/vcsh) package: -There are no other dependencies other than `git`, `ronn` and a POSIX shell. +```console +$ paru -S aur +``` +## CentOS / Fedora / RedHat -# Installing # +```console +$ yum install vcsh +``` - sudo make install +## Debian / Deepin / Kali Linux / Parrot / PureOS / Raspbian / Trisquel / Ubuntu -## Installing without root privileges ## +```console +$ apt install vcsh +``` - make install DESTDIR=/home/myuser/local +## Gentoo / Funtoo / LiGurOS -or simply copy the shell script into any place you like, e.g. `~/bin` +```console +$ emerge --ask dev-vcs/vcsh +``` +## GNU Guix -# Uninstalling # +```console +$ guix install vcsh +``` - sudo make uninstall +## Homebrew (macOS) / Linuxbrew -There is another, more thorough, version. Just make sure you are not running -this when you have installed to an important directory which is empty, -otherwise. +```console +$ brew install vcsh +``` -**THIS WILL DELETE /usr/local IF YOU INSTALLED THERE AND IT BECOMES EMPTY** +## KISS Linux - sudo make purge +```console +$ kiss install vcsh +``` -**THIS WILL DELETE /usr/local IF YOU INSTALLED THERE AND IT BECOMES EMPTY** +## MacPorts (macOS) -This is not in the default behaviour of `make uninstall` for obvious reasons. +```console +$ port install vcsh +``` +## NIX -# Other stuff # +```console +$ nix-env -i vcsh +``` -To clean up the generated manpage, run +## openSUSE - make clean +```console +$ zypper install vcsh +``` -To run the test suite, run +## Pardus - make test +```console +$ pisi install vcsh +``` -To run the test suite, you will need `perl`, -and the modules `Test::Most` and `Shell::Command`. +## Termux -To install the perl modules, run +```console +$ pkg install vcsh +``` - cpan install 'Test::Most' 'Shell::Command'. +# Installing from Source +First you'll want a copy of the source code. +The easiest to use place to get this is the [latest release](https://github.com/RichiH/vcsh/releases/latest) posted on GitHub. +The souree distribution will have a name such as `vcsh-2.0.0.tar.xz`. +Note under each release GitHub also shows a "Source code" link that will download a snapshot of the repository; this is **not** the file you want (unless you want to jump through extra hoops). +The official source release packages are the ones you want. + +Alternatively you may `git clone` the source repository. +Note than some extra tooling will be required over using the regular source releases. +Building from a clone will require a system with GNU Autotools installed; something not needed if using a source package. +Also source releases have prebuilt man pages; to (optionally) build them from a Git clone you will need `ronn`. +Finally building from Git clones will check for extra dependencies needed for testing, although tests can be disabled. +If starting from a clone, run `./bootstrap.sh` once before doing anything below. + +Once you have the source, it's time to let it get aquainted with your system: + +```console +$ ./configure +``` + +This command has *lots* of possible options, but the defaults should suite most use cases. +See `./configure --help` for details if you have special needs. + +Once configured, you can build: + +```console +$ make +``` + +Lastly you'll want to install it somewhere. + +```console +$ make install +``` + +If you need elevated system permissions you may need to use `sudo make install` for this step. +If you don't have such permissions and wish to install to your home directory, something like this might work: + +```console +$ ./configure --prefix=/ +$ make DESTDIR="$HOME" install-exec +``` + +This will install to `~/bin/vcsh`; add `~/bin` to your path to use. [1]: http://rtomayko.github.io/ronn/ From 9fc1d65e6d7a7f32a059694231a7250745815af6 Mon Sep 17 00:00:00 2001 From: Caleb Maclennan Date: Sun, 11 Apr 2021 01:39:40 +0300 Subject: [PATCH 114/121] Consolidate build CI workflow into test --- .github/workflows/build.yml | 29 ----------------------------- .github/workflows/test.yml | 18 ++++++++++++++++-- 2 files changed, 16 insertions(+), 31 deletions(-) delete mode 100644 .github/workflows/build.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml deleted file mode 100644 index f8b168a4..00000000 --- a/.github/workflows/build.yml +++ /dev/null @@ -1,29 +0,0 @@ -name: Build - -on: [push, pull_request] - -jobs: - - build: - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v2 - with: - fetch-depth: 0 - - name: Fetch tags - run: | - git fetch --prune --tags ||: - - name: Configure - run: | - ./bootstrap.sh - ./configure --disable-dependency-checks - - name: Build source package - run: | - make dist - echo VERSION=$(cat .version) >> $GITHUB_ENV - - name: Post build artifacts - uses: actions/upload-artifact@v2 - with: - name: vcsh-${{ env.VERSION }} - path: vcsh-${{ env.VERSION }} diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index e37f7d43..c1808e01 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -6,9 +6,14 @@ jobs: steps: - name: Checkout uses: actions/checkout@v2 - - name: Install build dependencies + with: + fetch-depth: 0 + - name: Fetch tags + run: | + git fetch --prune --tags ||: + - name: Install dependencies run: | - sudo apt-get install ronn + sudo apt install ronn - name: Install perl test dependencies uses: perl-actions/install-with-cpanm@v1.1 with: @@ -22,3 +27,12 @@ jobs: - name: Run tests run: | make check + - name: Build source package + run: | + make dist + echo VERSION=$(cat .version) >> $GITHUB_ENV + - name: Post build artifacts + uses: actions/upload-artifact@v2 + with: + name: vcsh-${{ env.VERSION }} + path: vcsh-${{ env.VERSION }}.zip From cfe70543ba349ca67c0ed8a010e4ec0aaa470f83 Mon Sep 17 00:00:00 2001 From: James Davidson Date: Fri, 2 Apr 2021 08:53:32 -0700 Subject: [PATCH 115/121] Load git completions if they are not already loaded Modern bash completion uses a delayed completion loader so that completions for commands that are never used are not loaded. This breaks vcsh git completions if no completion for git has been performed yet. To resolve this, use the git completion load function to get the completion spec for git loaded if it is not already present. --- _vcsh_bash | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/_vcsh_bash b/_vcsh_bash index 084b3eec..245b57a8 100644 --- a/_vcsh_bash +++ b/_vcsh_bash @@ -26,7 +26,14 @@ _vcsh_git_command () { COMP_WORDS[0]=git ((COMP_CWORD -= word_offset - 1)) - local cspec=$( complete -p git 2>/dev/null ) + local cspec + cspec=$( complete -p git 2>/dev/null ) + if [[ -z $cspec ]]; then + if declare -F __load_completion &> /dev/null; then + __load_completion git + cspec=$( complete -p git 2>/dev/null ) + fi + fi if [[ -n $cspec ]]; then if [[ ${cspec#* -F } != $cspec ]]; then local func=${cspec#*-F } From f52f4873b36a9c548590fde1a820f0aeda89d84f Mon Sep 17 00:00:00 2001 From: Caleb Maclennan Date: Mon, 12 Apr 2021 14:53:17 +0300 Subject: [PATCH 116/121] Make program name transformation more portable --- Makefile.am | 20 +++++++++----------- configure.ac | 3 +++ 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/Makefile.am b/Makefile.am index 11ce2ef1..581cd7a4 100644 --- a/Makefile.am +++ b/Makefile.am @@ -5,10 +5,8 @@ ACLOCAL_AMFLAGS = -I build-aux .SECONDEXPANSION: .DELETE_ON_ERROR: -_vcsh = $(program_prefix)$(shell $(SED) -e "$(program_transform_name)" <<< vcsh)$(program_suffix) - -docdir = $(datarootdir)/doc/$(_vcsh) -licensedir = $(datarootdir)/licenses/$(_vcsh) +docdir = $(datarootdir)/doc/$(TRANSFORMED_PACKAGE_NAME) +licensedir = $(datarootdir)/licenses/$(TRANSFORMED_PACKAGE_NAME) dist_doc_DATA = changelog doc/INSTALL.md doc/README.md doc/error_codes.md samplehooksdir = $(docdir)/sample_hooks @@ -26,24 +24,24 @@ CLEANFILES = $(BUILT_SOURCES) .version-prev $(dist_man_MANS) $(bin_SCRIPTS) if ENABLE_BASH_COMPLETION bashcompletiondir = $(BASH_COMPLETION_DIR) -nodist_bashcompletion_DATA = completions/$(_vcsh) +nodist_bashcompletion_DATA = completions/$(TRANSFORMED_PACKAGE_NAME) CLEANFILES += $(nodist_bashcompletion_DATA) endif if ENABLE_ZSH_COMPLETION zshcompletiondir = $(ZSH_COMPLETION_DIR) -nodist_zshcompletion_DATA = completions/_$(_vcsh) +nodist_zshcompletion_DATA = completions/_$(TRANSFORMED_PACKAGE_NAME) CLEANFILES += $(nodist_zshcompletion_DATA) endif vcsh.1: doc/vcsh.1.ronn $(RONN) < $< > $@ -completions/$(_vcsh): completions/vcsh.bash +completions/$(TRANSFORMED_PACKAGE_NAME): completions/vcsh.bash mkdir -p $(dir $@) cp -bf $< $@ -completions/_$(_vcsh): completions/vcsh.zsh +completions/_$(TRANSFORMED_PACKAGE_NAME): completions/vcsh.zsh mkdir -p $(dir $@) cp -bf $< $@ @@ -61,7 +59,7 @@ endif check-local: $(_CHECKDEPS) installcheck-local: - ./$(_vcsh) version + ./$(TRANSFORMED_PACKAGE_NAME) version .PHONY: check-version check-version: vcsh | .version @@ -101,7 +99,7 @@ dist-hook: printf "$(VERSION)" > "$(distdir)/.tarball-version" install-exec-local: - $(SED) -i -E '/^VCSH_SELF/s#".*"#"$(_vcsh)"#g' "$(DESTDIR)$(bindir)/$(_vcsh)" + $(SED) -i -E '/^VCSH_SELF/s#".*"#"$(TRANSFORMED_PACKAGE_NAME)"#g' "$(DESTDIR)$(bindir)/$(TRANSFORMED_PACKAGE_NAME)" install-data-hook: - $(SED) -i -E 's#(\\fB)vcsh\b#\1$(_vcsh)#g' "$(DESTDIR)$(man1dir)/$(_vcsh).1" + $(SED) -i -E 's#(\\fB)vcsh\b#\1$(TRANSFORMED_PACKAGE_NAME)#g' "$(DESTDIR)$(man1dir)/$(TRANSFORMED_PACKAGE_NAME).1" diff --git a/configure.ac b/configure.ac index 5dd7467f..02a93b14 100644 --- a/configure.ac +++ b/configure.ac @@ -69,6 +69,9 @@ fi AC_SUBST([ZSH_COMPLETION_DIR]) AM_CONDITIONAL([ENABLE_ZSH_COMPLETION],[test "x$with_zsh_completion_dir" != "xno"]) +TRANSFORMED_PACKAGE_NAME="$(printf "$PACKAGE_NAME" | $SED -e "${program_transform_name//\$\$/\$}")" +AC_SUBST([TRANSFORMED_PACKAGE_NAME]) + AC_CONFIG_FILES([Makefile]) AC_CONFIG_FILES([vcsh], [chmod +x vcsh]) From a7fcea3262b411474df4f8fe592ae836491eb74a Mon Sep 17 00:00:00 2001 From: Caleb Maclennan Date: Mon, 12 Apr 2021 15:01:50 +0300 Subject: [PATCH 117/121] Simplify post-install hooks using autoconf substitution --- Makefile.am | 6 --- configure.ac | 1 + doc/{vcsh.1.ronn => vcsh.1.ronn.in} | 78 ++++++++++++++--------------- vcsh.in | 2 +- 4 files changed, 41 insertions(+), 46 deletions(-) rename doc/{vcsh.1.ronn => vcsh.1.ronn.in} (76%) diff --git a/Makefile.am b/Makefile.am index 581cd7a4..ca452654 100644 --- a/Makefile.am +++ b/Makefile.am @@ -97,9 +97,3 @@ changelog-HEAD: changelog dist-hook: printf "$(VERSION)" > "$(distdir)/.tarball-version" - -install-exec-local: - $(SED) -i -E '/^VCSH_SELF/s#".*"#"$(TRANSFORMED_PACKAGE_NAME)"#g' "$(DESTDIR)$(bindir)/$(TRANSFORMED_PACKAGE_NAME)" - -install-data-hook: - $(SED) -i -E 's#(\\fB)vcsh\b#\1$(TRANSFORMED_PACKAGE_NAME)#g' "$(DESTDIR)$(man1dir)/$(TRANSFORMED_PACKAGE_NAME).1" diff --git a/configure.ac b/configure.ac index 02a93b14..a019cf3d 100644 --- a/configure.ac +++ b/configure.ac @@ -74,6 +74,7 @@ AC_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 diff --git a/doc/vcsh.1.ronn b/doc/vcsh.1.ronn.in similarity index 76% rename from doc/vcsh.1.ronn rename to doc/vcsh.1.ronn.in index c1021ae6..2300989e 100644 --- a/doc/vcsh.1.ronn +++ b/doc/vcsh.1.ronn.in @@ -3,66 +3,66 @@ vcsh(1) - Version Control System for $HOME - multiple Git repositories in $HOME ## SYNOPSIS -`vcsh` [] +`@TRANSFORMED_PACKAGE_NAME@` [] -`vcsh` clone [-b ] [] +`@TRANSFORMED_PACKAGE_NAME@` clone [-b ] [] -`vcsh` delete +`@TRANSFORMED_PACKAGE_NAME@` delete -`vcsh` enter +`@TRANSFORMED_PACKAGE_NAME@` enter -`vcsh` foreach [-g] +`@TRANSFORMED_PACKAGE_NAME@` foreach [-g] -`vcsh` help +`@TRANSFORMED_PACKAGE_NAME@` help -`vcsh` init +`@TRANSFORMED_PACKAGE_NAME@` init -`vcsh` list +`@TRANSFORMED_PACKAGE_NAME@` list -`vcsh` list-tracked [] +`@TRANSFORMED_PACKAGE_NAME@` list-tracked [] -`vcsh` list-untracked [<-a>] [<-r>] [] +`@TRANSFORMED_PACKAGE_NAME@` list-untracked [<-a>] [<-r>] [] -`vcsh` pull +`@TRANSFORMED_PACKAGE_NAME@` pull -`vcsh` push +`@TRANSFORMED_PACKAGE_NAME@` push -`vcsh` rename +`@TRANSFORMED_PACKAGE_NAME@` rename -`vcsh` run +`@TRANSFORMED_PACKAGE_NAME@` run -`vcsh` status [] +`@TRANSFORMED_PACKAGE_NAME@` status [] -`vcsh` upgrade +`@TRANSFORMED_PACKAGE_NAME@` upgrade -`vcsh` version +`@TRANSFORMED_PACKAGE_NAME@` version -`vcsh` which +`@TRANSFORMED_PACKAGE_NAME@` which -`vcsh` write-gitignore [] +`@TRANSFORMED_PACKAGE_NAME@` write-gitignore [] -`vcsh` +`@TRANSFORMED_PACKAGE_NAME@` -`vcsh` +`@TRANSFORMED_PACKAGE_NAME@` ## DESCRIPTION -`vcsh` allows you to have several `git`(1) repositories, all maintaining their +`@TRANSFORMED_PACKAGE_NAME@` allows you to have several `git`(1) repositories, all maintaining their working trees in $HOME without clobbering each other. That, in turn, means you can have one repository per config set (zsh, vim, ssh, etc), picking and choosing which configs you want to use on which machine. -`vcsh` is using a technique called fake bare Git repositories, keeping <$GIT_DIR> +`@TRANSFORMED_PACKAGE_NAME@` is using a technique called fake bare Git repositories, keeping <$GIT_DIR> in a different directory from <$GIT_WORK_TREE> which is pointed to <$HOME>. The use of symlinks is not needed in this setup, making for a cleaner setup. -`vcsh` was designed with `mr`(1) in mind so you might want to install it alongside -vcsh. That being said, you can easily use `vcsh` without `mr` if you prefer. +`@TRANSFORMED_PACKAGE_NAME@` was designed with `mr`(1) in mind so you might want to install it alongside +vcsh. That being said, you can easily use `@TRANSFORMED_PACKAGE_NAME@` without `mr` if you prefer. -A sample configuration for `vcsh` and `mr` can be found at -*https://github.com/RichiH/vcsh_mr_template* and used with `vcsh clone +A sample configuration for `@TRANSFORMED_PACKAGE_NAME@` and `mr` can be found at +*https://github.com/RichiH/vcsh_mr_template* and used with `@TRANSFORMED_PACKAGE_NAME@ clone https://github.com/RichiH/vcsh_mr_template mr`. Please note that you can always use a path instead of a name for . @@ -152,7 +152,7 @@ an interactive user. Please note that there is a somewhat magic feature for run. Instead of it accepts , as well. Anything that has a slash in it will be assumed to - be a path. `vcsh run` will then operate on this directory instead of the one + be a path. `@TRANSFORMED_PACKAGE_NAME@ run` will then operate on this directory instead of the one normally generated from the repository's name. This is needed to support mr and other scripts properly and of no concern to an interactive user. @@ -177,22 +177,22 @@ an interactive user. Shortcut to run `git` commands on a repo. Will prepend `git` to . * : - Shortcut to run `vcsh enter `. + Shortcut to run `@TRANSFORMED_PACKAGE_NAME@ enter `. ## ENVIRONMENT -As noted earlier, `vcsh` will set <$GIT_DIR> and <$GIT_WORK_TREE> to the +As noted earlier, `@TRANSFORMED_PACKAGE_NAME@` will set <$GIT_DIR> and <$GIT_WORK_TREE> to the appropriate values for fake bare Git repositories. ## CONFIG -There are several ways to turn the various knobs on `vcsh`. In order of +There are several ways to turn the various knobs on `@TRANSFORMED_PACKAGE_NAME@`. In order of ascending precedence, they are: -* `VARIABLE=foo vcsh` +* `VARIABLE=foo @TRANSFORMED_PACKAGE_NAME@` * * <$XDG_CONFIG_HOME/vcsh/config> -* `vcsh -c ` +* `@TRANSFORMED_PACKAGE_NAME@ -c ` Please note that those files are sourced. Any and all commands will be executed in the context of your shell. @@ -259,9 +259,9 @@ Less interesting knobs you could turn: ## HOOK SYSTEM -`vcsh` provides a hook system. Hook scripts must be executable and should be +`@TRANSFORMED_PACKAGE_NAME@` provides a hook system. Hook scripts must be executable and should be placed in <$XDG_CONFIG_HOME/vcsh/hooks-available>. From there, they can be -soft-linked into <$XDG_CONFIG_HOME/vcsh/hooks-enabled>; `vcsh` will only +soft-linked into <$XDG_CONFIG_HOME/vcsh/hooks-enabled>; `@TRANSFORMED_PACKAGE_NAME@` will only execute hooks that are in this directory. Hooks follow a simple format. will be run before anything is run. @@ -284,7 +284,7 @@ we can ship them by default. ## OVERLAY SYSTEM -`vcsh` also provides an overlay system. Similar to hooks, the recommended +`@TRANSFORMED_PACKAGE_NAME@` also provides an overlay system. Similar to hooks, the recommended locations are <$XDG_CONFIG_HOME/vcsh/overlays-available> and <$XDG_CONFIG_HOME/vcsh/overlays-enabled>. @@ -314,8 +314,8 @@ On Debian-based systems, this file can be found in . ## SECURITY CONSIDERATIONS -`vcsh` allows you to execute arbitrary commands via `vcsh run`. For example, -adding a `sudo`(8) rule for `vcsh` would be pretty stupid. +`@TRANSFORMED_PACKAGE_NAME@` allows you to execute arbitrary commands via `@TRANSFORMED_PACKAGE_NAME@ run`. For example, +adding a `sudo`(8) rule for `@TRANSFORMED_PACKAGE_NAME@` would be pretty stupid. Additionally, vcsh will source, i.e. execute, all files listed in . You can put any and all commands into these config files and they will be @@ -345,7 +345,7 @@ take over the name. ## AUTHOR -This manpage and `vcsh` itself were written by Richard "RichiH" Hartmann. +This manpage and `@TRANSFORMED_PACKAGE_NAME@` itself were written by Richard "RichiH" Hartmann. ## COPYRIGHT diff --git a/vcsh.in b/vcsh.in index 682cc86c..4b2c70a2 100755 --- a/vcsh.in +++ b/vcsh.in @@ -20,7 +20,7 @@ # version of vcsh; the main branch is supposed to be clean at all times # so you can most likely just use it nonetheless VCSH_VERSION='@VERSION@'; export VCSH_VERSION -VCSH_SELF="$(basename "$0")"; export VCSH_SELF +VCSH_SELF="@TRANSFORMED_PACKAGE_NAME@"; export VCSH_SELF # Ensure all files created are accessible only to the current user. umask 0077 From d73f7ee6345e45c989fb96956fe6401cff4dc0f9 Mon Sep 17 00:00:00 2001 From: James Davidson Date: Sun, 11 Apr 2021 13:05:19 -0700 Subject: [PATCH 118/121] Add EditorConfig for _vcs_bash --- .editorconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.editorconfig b/.editorconfig index 32d78adb..f273d302 100644 --- a/.editorconfig +++ b/.editorconfig @@ -4,6 +4,6 @@ root = true end_of_line = lf insert_final_newline = true -[vcsh] +[{vcsh,_vcsh_bash}] indent_style = tab trim_trailing_whitespace = true From 4661cc905c675921d6bb856711016fbc8f76725c Mon Sep 17 00:00:00 2001 From: James Davidson Date: Tue, 13 Apr 2021 08:34:12 -0700 Subject: [PATCH 119/121] Fix indetation to use tabs only --- _vcsh_bash | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/_vcsh_bash b/_vcsh_bash index 245b57a8..2ee12064 100644 --- a/_vcsh_bash +++ b/_vcsh_bash @@ -69,7 +69,7 @@ _vcsh () { unset r reponames local cmds cmds="clone delete enter foreach help init list list-tracked list-untracked - pull push rename run status upgrade version which write-gitignore" + pull push rename run status upgrade version which write-gitignore" local subcword cmd subcmd for (( subcword=1; subcword < ${#words[@]}-1; subcword++ )); do From db6408b6132bd6f119eb9034a23ec6c29faaa74e Mon Sep 17 00:00:00 2001 From: Caleb Maclennan Date: Thu, 22 Apr 2021 11:30:12 +0300 Subject: [PATCH 120/121] Propagate relative path given by pkg-config to bash completion dir --- configure.ac | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/configure.ac b/configure.ac index a019cf3d..2f0fe3a5 100644 --- a/configure.ac +++ b/configure.ac @@ -48,8 +48,8 @@ AC_ARG_WITH([bash-completion-dir], [with_bash_completion_dir=yes]) if test "x$with_bash_completion_dir" = "xyes"; then PKG_CHECK_MODULES([BASH_COMPLETION], [bash-completion >= 2.0], - [BASH_COMPLETION_DIR="`pkg-config --variable=completionsdir bash-completion`"], - [BASH_COMPLETION_DIR="$datadir/bash-completion/completions"]) + [BASH_COMPLETION_DIR="`pkg-config --define-variable=datadir=$datadir --variable=completionsdir bash-completion`"], + [BASH_COMPLETION_DIR="$datadir/bash-completion/completions"]) else BASH_COMPLETION_DIR="$with_bash_completion_dir" fi From c1ae32d08361cec1185614ea82b1e708e68db5d0 Mon Sep 17 00:00:00 2001 From: Caleb Maclennan Date: Thu, 22 Apr 2021 12:03:15 +0300 Subject: [PATCH 121/121] =?UTF-8?q?Style=20autoconf=20syntax=20more=C2=B9?= =?UTF-8?q?=20consistently?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ¹ There are no good code styles for autoconf. The mix of M4 macros and POSIX shell stuff is just going to be a mess. My only claim is that this is more consistent than it was. --- configure.ac | 84 ++++++++++++++++++++++++++++------------------------ 1 file changed, 45 insertions(+), 39 deletions(-) diff --git a/configure.ac b/configure.ac index 2f0fe3a5..19b0747d 100644 --- a/configure.ac +++ b/configure.ac @@ -5,69 +5,75 @@ 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]) +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]) + ]) + AC_PROG_AWK AC_PROG_GREP AC_PROG_SED -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]) - ]) - AX_PROGVAR([comm]) AX_PROGVAR([cmp]) AX_PROGVAR([git]) AC_ARG_WITH([man-page], - AS_HELP_STRING([--with-man-page], - [Generate man page @<:@default=yes@:>@]), - [], - [with_man_page=yes]) -if test "x$with_man_page" = "xyes"; then - AX_PROGVAR([ronn]) + AS_HELP_STRING([--with-man-page], + [Generate man page @<:@default=yes@:>@]), + [], + [with_man_page=yes]) +if test x"$with_man_page" = x"yes"; then + AX_PROGVAR([ronn]) fi -AM_CONDITIONAL([ENABLE_MAN_PAGE],[test "x$with_man_page" != "xno"]) +AM_CONDITIONAL([ENABLE_MAN_PAGE], + [test x"$with_man_page" != x"no"]) -AS_IF([test -e .tarball-version], m4_define([TESTDEF], [yes]), m4_define([TESTDEF], [no])) +AS_IF([test -e .tarball-version], + m4_define([TESTDEF], [yes]), + m4_define([TESTDEF], [no])) AC_ARG_ENABLE([tests], - AS_HELP_STRING([--disable-tests], [Configure tooling to run tests @<:@default=TESTDEF@:>@]), - ,[enable_tests=TESTDEF]) -AM_CONDITIONAL([ENABLE_TESTS],[test "x$enable_tests" != "xno"]) + AS_HELP_STRING([--disable-tests], + [Configure tooling to run tests @<:@default=TESTDEF@:>@]), + [], + [enable_tests=TESTDEF]) +AM_CONDITIONAL([ENABLE_TESTS],[test x"$enable_tests" != x"no"]) -AS_IF([test "x$enable_tests" != "xno"], [ - AX_PROGVAR([prove]) - AX_PROG_PERL_MODULES(Shell::Command, , AC_MSG_ERROR(Perl module required for testing not found)) - AX_PROG_PERL_MODULES(Test::Most, , AC_MSG_ERROR(Perl module required for testing not found)) +AS_IF([test x"$enable_tests" != x"no"], [ + AX_PROGVAR([prove]) + AX_PROG_PERL_MODULES(Shell::Command, [], + AC_MSG_ERROR(Perl module required for testing not found)) + AX_PROG_PERL_MODULES(Test::Most, [], + 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 the bash auto-completion script in this directory. @<:@default=yes@:>@]), - [], - [with_bash_completion_dir=yes]) -if test "x$with_bash_completion_dir" = "xyes"; then - 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"]) -else - BASH_COMPLETION_DIR="$with_bash_completion_dir" -fi + AS_HELP_STRING([--with-bash-completion-dir[=PATH]], + [Install bash auto-completion definitions to a directory. @<:@default=yes@:>@]), + [], + [with_bash_completion_dir=yes]) +AS_IF([test x"$with_bash_completion_dir" = x"yes"], + [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]) -AM_CONDITIONAL([ENABLE_BASH_COMPLETION],[test "x$with_bash_completion_dir" != "xno"]) +AM_CONDITIONAL([ENABLE_BASH_COMPLETION], + [test x"$with_bash_completion_dir" != x"no"]) 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]) -if test "x$with_zsh_completion_dir" = "xyes"; then + AS_HELP_STRING([--with-zsh-completion-dir[=PATH]], + [Install zsh auto-completion definitions to a directory. @<:@default=yes@:>@]), + [], + [with_zsh_completion_dir=yes]) +if test x"$with_zsh_completion_dir" = x"yes"; then ZSH_COMPLETION_DIR="$datadir/zsh/site-functions" else ZSH_COMPLETION_DIR="$with_zsh_completion_dir" fi AC_SUBST([ZSH_COMPLETION_DIR]) -AM_CONDITIONAL([ENABLE_ZSH_COMPLETION],[test "x$with_zsh_completion_dir" != "xno"]) +AM_CONDITIONAL([ENABLE_ZSH_COMPLETION], + [test x"$with_zsh_completion_dir" != x"no"]) TRANSFORMED_PACKAGE_NAME="$(printf "$PACKAGE_NAME" | $SED -e "${program_transform_name//\$\$/\$}")" AC_SUBST([TRANSFORMED_PACKAGE_NAME])