URI: 
       Add root dir option - dedup - deduplicating backup program
  HTML git clone git://bitreich.org/dedup/ git://enlrupgkhuxnvlhsf6lc3fziv5h2hhfrinws65d7roiv6bfj7d652fid.onion/dedup/
   DIR Log
   DIR Files
   DIR Refs
   DIR Tags
   DIR README
   DIR LICENSE
       ---
   DIR commit 367928d1742c6f7b12720e6c60a9292e6b708c7c
   DIR parent 34990ad2e3066a5fd23cebc22b997dff63ac272a
  HTML Author: sin <sin@2f30.org>
       Date:   Wed, 21 Mar 2018 16:08:11 +0000
       
       Add root dir option
       
       Thanks lostd!
       
       Diffstat:
         M README                              |      18 +++++++++---------
         M dedup.c                             |      12 ++++++++++--
       
       2 files changed, 19 insertions(+), 11 deletions(-)
       ---
   DIR diff --git a/README b/README
       @@ -4,29 +4,29 @@ used in a pipeline with tar/gpg etc.
        dedup only handles a single file at a time, so using tar is advised.
        For example, to dedup a tar file you can invoke dedup as follows:
        
       -    tar cf - ~/bak | dedup
       +    tar cf - ~/bak | dedup -r ~/bak-dedup
        
       -This will create .{cache,index,store} files in the current directory.
       -The store file contains all the unique blocks.  The index file
       -contains all the revisions of files that have been deduplicated.  Each
       -revision is identified by its SHA256 hash.  The cache file is only
       -used to speed up block comparison.
       +This will create .{cache,index,store} files in the ~/bak-dedup
       +directory.  The store file contains all the unique blocks.  The index
       +file contains all the revisions of files that have been deduplicated.
       +Each revision is identified by its SHA256 hash.  The cache file is
       +only used to speed up block comparison.
        
        To list all known revisions run:
        
       -    dedup -l
       +    dedup -r ~/bak-dedup -l
        
        You will get a list of hashes.  Each hash corresponds to a single file
        (in this case, a tar archive).
        
        To extract a file from the deduplicated store run:
        
       -    dedup -e <hash> > bak.tar
       +    dedup -r ~/bak-dedup -e <hash> > bak.tar
        
        You can mix dedup with other programs like gpg(1).  For example to
        perform a remote backup you can use the following command:
        
       -    tar cf - ~/bak | gpg -c | ssh user@host dedup
       +    tar cf - ~/bak | gpg -c | ssh user@host dedup -r ~/bak-dedup
        
        Cheers,
        sin
   DIR diff --git a/dedup.c b/dedup.c
       @@ -519,14 +519,14 @@ term(void)
        void
        usage(void)
        {
       -        fprintf(stderr, "usage: %s [-clv] [-e id] [file]\n", argv0);
       +        fprintf(stderr, "usage: %s [-clv] [-e id] [-r root] [file]\n", argv0);
                exit(1);
        }
        
        int
        main(int argc, char *argv[])
        {
       -        char *id = NULL;
       +        char *id = NULL, *root = NULL;
                int fd = -1, lflag = 0, cflag = 0;
        
                ARGBEGIN {
       @@ -539,6 +539,9 @@ main(int argc, char *argv[])
                case 'l':
                        lflag = 1;
                        break;
       +        case 'r':
       +                root = EARGF(usage());
       +                break;
                case 'v':
                        verbose = 1;
                        break;
       @@ -549,6 +552,11 @@ main(int argc, char *argv[])
                if (argc > 1)
                        usage();
        
       +        if (root != NULL) {
       +                mkdir(root, 0700);
       +                chdir(root);
       +        }
       +
                init();
        
                if (cflag) {