<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">NAME
    Git::Bunch - Manage gitbunch directory (directory which contain git
    repos)

VERSION
    version 0.14

SYNOPSIS
    To check the status of bunch (will do a 'git status' for each git repo
    inside the bunch and report which repos are 'unclean', e.g. needs
    commit, has untracked files, etc):

     % gitbunch check ~/repos

    To synchronize bunch to another (will do a 'git pull' for each git repo,
    and do an rsync for everything else):

     % gitbunch sync ~/repos /mnt/laptop/repos

    To backup bunch (will only rsync .git/ for each git repo to destination,
    and rsync everything else in full):

     % gitbunch backup ~/repos /media/flashdisk

DESCRIPTION
    A gitbunch or bunch directory is just a term I coined to refer to a
    directory which contains, well, a bunch of git repositories. It can also
    contain other stuffs like files and non-git repositories (but they must
    be dot-dirs). Example:

     repos/            -&gt; a gitbunch dir
       proj1/          -&gt; a git repo
       proj2/          -&gt; ditto
       perl-Git-Bunch/ -&gt; ditto
       ...
       .foo/           -&gt; a non-git dir
       README.txt      -&gt; file

    A little bit of history: after git got popular, in 2008 I started using
    it for software projects, replacing Subversion and Bazaar. Soon, I moved
    everything to git: notes &amp; writings, Emacs .org agenda files,
    configuration, even temporary downloads/browser-saved HTML files.
    Currently, except large media files, all my personal data resides in git
    repositories. I put them all in ~/repos (and add symlinks to various
    places for convenience). This setup makes it easy to sync to laptops,
    backup to disk, etc. Git::Bunch is the library/script I wrote to do
    this.

    See also File::RsyBak, which I wrote to backup everything else.

FUNCTIONS
    None of the functions are exported by default, but they are exportable.

  backup_bunch(%args) -&gt; [STATUS_CODE, ERR_MSG, RESULT]
    Backup bunch directory to another directory using rsync.

    Simply uses rsync to copy bunch directory to another, except that for
    all git projects, only .git/ will be rsync-ed. This utilizes the fact
    that .git/ contains the whole project's data, the working copy can be
    checked out from .git/.

    Will run check_bunch first and require all repos to be clean before
    running the backup, unless 'check' is turned off.

    Note: Saving only .git/ subdirectory saves disk space, but will not save
    uncommited changes, untracked files, or .gitignore'd files. Make sure
    you have committed everything to git before doing backup. Also note that
    if you need to restore files, they will be checked out from the
    repository, and the original ctime/mtime information is not preserved.
    backup_bunch() does store this information for you by saving the output
    of 'ls -laR' command, but have *not* implemented routine to restore this
    data into restored files.

    Returns a 3-element arrayref. STATUS_CODE is 200 on success, or an error
    code between 3xx-5xx (just like in HTTP). ERR_MSG is a string containing
    error message, RESULT is the actual result.

    Arguments ("*" denotes required arguments):

    *   source* =&gt; *str*

        Directory to check.

    *   target* =&gt; *str*

        Destination bunch.

    *   backup =&gt; *bool* (default 1)

        Whether to do actual backup/rsync.

        You can set backup=0 and index=1 to only run indexing, for example.

    *   check =&gt; *bool* (default 1)

        Whether to check bunch first before doing backup.

    *   delete_excluded =&gt; *bool*

        Delete excluded repos in target.

    *   exclude_files =&gt; *bool*

        Exclude files from processing.

        This only applies to 'backup_bunch' and 'sync_bunch' operations.
        Operations like 'check_bunch' and 'exec_bunch' already ignore these
        and only operate on git repos.

    *   exclude_non_git_dirs =&gt; *bool*

        Exclude non-git dirs from processing.

        This only applies to 'backup_bunch' and 'sync_bunch' operations.
        Operations like 'check_bunch' and 'exec_bunch' already ignore these
        and only operate on git repos.

    *   exclude_repos =&gt; *array*

        Exclude some repos from processing.

    *   exclude_repos_pat =&gt; *str*

        Specify regex pattern of repos to exclude.

    *   extra_rsync_opts =&gt; *array*

        Pass extra options to rsync command.

        Extra options to pass to rsync command. Note that the options will
        be shell quoted, , so you should pass it unquoted, e.g.
        ['--exclude', '/Program Files'].

    *   include_repos =&gt; *array*

        Aliases: repos

        Specific git repos to sync, if not specified all repos in the bunch
        will be processed.

    *   include_repos_pat =&gt; *str*

        Specify regex pattern of repos to include.

    *   index =&gt; *bool* (default 1)

        Whether to do "ls -laR" after backup.

  check_bunch(%args) -&gt; [STATUS_CODE, ERR_MSG, RESULT]
    Check status of git repositories inside gitbunch directory.

    Will perform a 'git status' for each git repositories inside the bunch
    and report which repositories are clean/unclean.

    Will die if can't chdir into bunch or git repository.

    Returns a 3-element arrayref. STATUS_CODE is 200 on success, or an error
    code between 3xx-5xx (just like in HTTP). ERR_MSG is a string containing
    error message, RESULT is the actual result.

    Arguments ("*" denotes required arguments):

    *   source* =&gt; *str*

        Directory to check.

    *   exclude_files =&gt; *bool*

        Exclude files from processing.

        This only applies to 'backup_bunch' and 'sync_bunch' operations.
        Operations like 'check_bunch' and 'exec_bunch' already ignore these
        and only operate on git repos.

    *   exclude_non_git_dirs =&gt; *bool*

        Exclude non-git dirs from processing.

        This only applies to 'backup_bunch' and 'sync_bunch' operations.
        Operations like 'check_bunch' and 'exec_bunch' already ignore these
        and only operate on git repos.

    *   exclude_repos =&gt; *array*

        Exclude some repos from processing.

    *   exclude_repos_pat =&gt; *str*

        Specify regex pattern of repos to exclude.

    *   include_repos =&gt; *array*

        Aliases: repos

        Specific git repos to sync, if not specified all repos in the bunch
        will be processed.

    *   include_repos_pat =&gt; *str*

        Specify regex pattern of repos to include.

  exec_bunch(%args) -&gt; [STATUS_CODE, ERR_MSG, RESULT]
    Execute a command for each repo in the bunch.

    For each git repository in the bunch, will chdir to it and execute
    specified command.

    Returns a 3-element arrayref. STATUS_CODE is 200 on success, or an error
    code between 3xx-5xx (just like in HTTP). ERR_MSG is a string containing
    error message, RESULT is the actual result.

    Arguments ("*" denotes required arguments):

    *   source* =&gt; *str*

        Directory to check.

    *   command* =&gt; *str* (default 0)

        Command to execute.

    *   exclude_files =&gt; *bool*

        Exclude files from processing.

        This only applies to 'backup_bunch' and 'sync_bunch' operations.
        Operations like 'check_bunch' and 'exec_bunch' already ignore these
        and only operate on git repos.

    *   exclude_non_git_dirs =&gt; *bool*

        Exclude non-git dirs from processing.

        This only applies to 'backup_bunch' and 'sync_bunch' operations.
        Operations like 'check_bunch' and 'exec_bunch' already ignore these
        and only operate on git repos.

    *   exclude_repos =&gt; *array*

        Exclude some repos from processing.

    *   exclude_repos_pat =&gt; *str*

        Specify regex pattern of repos to exclude.

    *   include_repos =&gt; *array*

        Aliases: repos

        Specific git repos to sync, if not specified all repos in the bunch
        will be processed.

    *   include_repos_pat =&gt; *str*

        Specify regex pattern of repos to include.

  sync_bunch(%args) -&gt; [STATUS_CODE, ERR_MSG, RESULT]
    Synchronize bunch to another bunch.

    For each git repository in the bunch, will perform a 'git pull' from the
    destination for each branch. If repository in destination doesn't exist,
    it will be rsync-ed first from source. When 'git pull' fails, will exit
    to let you fix the problem manually.

    For all other non-git repos, will simply synchronize by one-way rsync.

    Returns a 3-element arrayref. STATUS_CODE is 200 on success, or an error
    code between 3xx-5xx (just like in HTTP). ERR_MSG is a string containing
    error message, RESULT is the actual result.

    Arguments ("*" denotes required arguments):

    *   source* =&gt; *str*

        Directory to check.

    *   target* =&gt; *str*

        Destination bunch.

    *   delete_branch =&gt; *bool* (default 0)

        Whether to delete branches in dest repos not existing in source
        repos.

    *   exclude_files =&gt; *bool*

        Exclude files from processing.

        This only applies to 'backup_bunch' and 'sync_bunch' operations.
        Operations like 'check_bunch' and 'exec_bunch' already ignore these
        and only operate on git repos.

    *   exclude_non_git_dirs =&gt; *bool*

        Exclude non-git dirs from processing.

        This only applies to 'backup_bunch' and 'sync_bunch' operations.
        Operations like 'check_bunch' and 'exec_bunch' already ignore these
        and only operate on git repos.

    *   exclude_repos =&gt; *array*

        Exclude some repos from processing.

    *   exclude_repos_pat =&gt; *str*

        Specify regex pattern of repos to exclude.

    *   include_repos =&gt; *array*

        Aliases: repos

        Specific git repos to sync, if not specified all repos in the bunch
        will be processed.

    *   include_repos_pat =&gt; *str*

        Specify regex pattern of repos to include.

    *   rsync_opt_maintain_ownership =&gt; *bool* (default 0)

        Whether or not, when rsync-ing from source, we use -a (= -rlptgoD)
        or -rlptD (-a minus -go).

        Sometimes using -a results in failure to preserve permission modes
        on sshfs-mounted filesystem, while -rlptD succeeds, so by default we
        don't maintain ownership. If you need to maintain ownership (e.g.
        you run as root and the repos are not owned by root), turn this
        option on.

FAQ
TODO
SEE ALSO
AUTHOR
    Steven Haryanto &lt;stevenharyanto@gmail.com&gt;

COPYRIGHT AND LICENSE
    This software is copyright (c) 2011 by Steven Haryanto.

    This is free software; you can redistribute it and/or modify it under
    the same terms as the Perl 5 programming language system itself.

</pre></body></html>