config/vcsh.git
5 years agohooks: set up sparse checkout after cloning the vcsh repository master
Antonio Ospite [Thu, 24 Jan 2019 14:56:36 +0000 (15:56 +0100)]
hooks: set up sparse checkout after cloning the vcsh repository

Make sure to correctly configure sparse checkout right after the vcsh
repository has been cloned with 'vcsh clone'.

This is needed to avoid leaving conflicting files (e.g. README) in the
working tree, which would prevent other vcsh repositories from being
cloned without errors.

5 years agohooks: factor out an update-working-tree.sh script
Antonio Ospite [Thu, 24 Jan 2019 14:54:48 +0000 (15:54 +0100)]
hooks: factor out an update-working-tree.sh script

In some cases the working tree needs to be updated outside of
populate-sparsely.sh (which is meant for a post-enter hook), so split
out this task from the main script.

5 years agohooks: rename sparse-checkout.sh to enable-sparse-checkout.sh
Antonio Ospite [Thu, 24 Jan 2019 14:51:31 +0000 (15:51 +0100)]
hooks: rename sparse-checkout.sh to enable-sparse-checkout.sh

Rename the sparse-checkout.sh script to enable-sparse-checkout.sh to
better illustrate what the script actually does.

In particular the new name should communicate that the script does not
update the working tree itself but it just enable sparse checkout
support, leaving the working tree update to other git commands
(read-tree, checkout, etc.).

6 years agoFix shellcheck warnings
Antonio Ospite [Mon, 17 Dec 2018 09:32:23 +0000 (10:32 +0100)]
Fix shellcheck warnings

Fix the following warnings from shellcheck:

-----------------------------------------------------------------------
In populate-fully.sh line 18:
  if kill -0 $(cat "$LOCKDIR/pid") 2>/dev/null;
             ^-- SC2046: Quote this to prevent word splitting.

In populate-sparsely.sh line 18:
. "$XDG_CONFIG_HOME/vcsh/hooks-available/sparse-checkout.sh"
^-- SC1090: Can't follow non-constant source. Use a directive to specify location.
-----------------------------------------------------------------------

6 years agoAdd submodule-update-foreach.sh and a post-pull hook for it
Antonio Ospite [Mon, 17 Dec 2018 09:16:38 +0000 (10:16 +0100)]
Add submodule-update-foreach.sh and a post-pull hook for it

Update submodules also after a "vcsh pull" command.

This requires a whole new script because vcsh does not call post-pull
hooks after pulling each repositories, it only calls the hook once after
pulling all of them.

See https://github.com/RichiH/vcsh/issues/213

When the issue gets fixed submodule-update-foreach.sh can be removed and
post-pull.00-submodule-init can link to submodule-update.sh

6 years agosubmodule-update.sh: check git version before running submodule commands
Antonio Ospite [Mon, 17 Dec 2018 09:03:10 +0000 (10:03 +0100)]
submodule-update.sh: check git version before running submodule commands

Git submodules in vcsh can only be supported reliably with git >= 2.20.0
which supports reading the .gitmodules file even when it is not checked
out in the working tree.

To recap, the need for git >= 2.20 is imposed by the following facts:

  - vcsh repositories share their working trees in $HOME;

  - if files with the same name (e.g. README, LICENSE) are present in
    different repositories they would conflict when checked out in
    $HOME;

  - sparse-checkout can solve the issue by preventing colliding files
    between repositories from being checked out, this includes the
    .gitmodules file;

  - submodules command require the .gitmodules file;

  - from git 2.20 the .gitmodules file can be accessed from the
    repository object store when the file is not in the working tree,
    this enables submodules usage with "vcsh run".

Now that the version check is in place, re-enable the post-clone hook to
update submodules automatically after cloning a repository.

6 years agosparse-checkout.sh: don't do anything if the repository does not exist
Antonio Ospite [Fri, 14 Dec 2018 15:07:20 +0000 (16:07 +0100)]
sparse-checkout.sh: don't do anything if the repository does not exist

6 years agopopulate-fully.sh: don't enter the repository if updating working tree fails
Antonio Ospite [Thu, 13 Dec 2018 23:51:28 +0000 (00:51 +0100)]
populate-fully.sh: don't enter the repository if updating working tree fails

If updating the working tree failed exit the whole vcsh process to
prevent entering the repository and doing more damage.

6 years agohooks-available: avoid some errors with empty repositories
Antonio Ospite [Thu, 13 Dec 2018 23:15:05 +0000 (00:15 +0100)]
hooks-available: avoid some errors with empty repositories

When entering a repository which has just been created the HEAD
reference does not exist yet  and "git read-tree -mu HEAD" would
complain loudly about that, giving a confusing error to users.

Avoid the error by checking the validity of HEAD before updating the
working tree.

6 years agopopulate-fully.sh: force entering the repository if the lock not valid anymore
Antonio Ospite [Thu, 13 Dec 2018 23:10:02 +0000 (00:10 +0100)]
populate-fully.sh: force entering the repository if the lock not valid anymore

If the vcsh instance which previously acquired the lock does not exist
anymore, the lock is invalid and can be taken by the current instance
for the repository it is entering.

6 years agopopulate-sparsely.sh: explain why the script exits if there is no lock
Antonio Ospite [Thu, 13 Dec 2018 22:54:36 +0000 (23:54 +0100)]
populate-sparsely.sh: explain why the script exits if there is no lock

The reason why the script exits if there is no lock was given in the
commit message when the check was added, but reading the code after some
time I could not remember it, so just put the explanation in a comment
to make the life easier for the reader.

6 years agopopulate-fully.sh: don't do anything if the repository does not exist
Antonio Ospite [Thu, 13 Dec 2018 22:47:47 +0000 (23:47 +0100)]
populate-fully.sh: don't do anything if the repository does not exist

The pre-enter hook is called even when trying to enter an invalid
repository, vcsh only checks the repository validity later on.

Anticipate the check and avoid calling git commands on an invalid
repository as they would just fail and confuse the user.

6 years agoFix the git terminology by always referring to the "working tree"
Antonio Ospite [Thu, 13 Dec 2018 15:52:16 +0000 (16:52 +0100)]
Fix the git terminology by always referring to the "working tree"

The set of files checked out by git is called the "working tree", avoid
other definitions like "working directory" or "work dir".

6 years agopopulate-sparsely.sh: exit gracefully if LOCKDIR does not exist
Antonio Ospite [Tue, 8 May 2018 16:30:55 +0000 (18:30 +0200)]
populate-sparsely.sh: exit gracefully if LOCKDIR does not exist

If LOCKDIR does not exist it means that the lock is not active so
there's no need to do anything.

6 years agohooks-enabled: don't call submodule-update.sh from hooks for now
Antonio Ospite [Tue, 8 May 2018 11:11:22 +0000 (13:11 +0200)]
hooks-enabled: don't call submodule-update.sh from hooks for now

In the current setup executing git submodules commands from 'vcsh run'
invocations would fail because the '.gitmodules' file would not be
checked out.

For now it's only safe to call git submodules commands after entering
the repository with 'vcsh enter'.

6 years agoREADME: mention that the idea came from John Whitley
Antonio Ospite [Tue, 8 May 2018 11:07:51 +0000 (13:07 +0200)]
README: mention that the idea came from John Whitley

6 years agoInitial import
Antonio Ospite [Tue, 8 May 2018 07:48:34 +0000 (09:48 +0200)]
Initial import