From 50ff0e53d94c60860e768100f549e4dfe9110096 Mon Sep 17 00:00:00 2001 From: Jeffrey Armstrong Date: Fri, 3 Jan 2014 10:04:01 -0500 Subject: Files can now be committed to version control. Each version is stored in gzip'd form. Fix to MD5 calculation. --- prism.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'prism.c') diff --git a/prism.c b/prism.c index ec71953..3722d70 100644 --- a/prism.c +++ b/prism.c @@ -21,6 +21,8 @@ static void usage(const char *name) printf("\nUsage: %s ...\n\n", name); printf("Commands:\n\n"); printf("\tabout\tprints a banner and exits\n"); + printf("\tadd\tadds the specified file to the commit queue\n"); + printf("\tcommit\tcommits currently queued files\n"); printf("\thash\tdisplays a file's hash\n"); printf("\tinfo\tshow information about repository\n"); printf("\tinit\tinitializes this directory for versioning\n"); @@ -75,7 +77,21 @@ struct db_file oldfile; static void commit_task(const char *message) { +int fcount; +int rev; + printf("Committing queue...\n"); + fcount = disp_queue(); + if(fcount <= 0) { + printf(" ERR: no files queued\n"); + return; + } + + rev = increment_revision(); + if(commit_queue(rev) == PRET_OK) + printf(" commit completed\n"); + else + printf(" ERR: commit failed\n"); } static void info_task() @@ -128,6 +144,10 @@ int main(int argc, char *argv[]) banner(); else if(strcmp(argv[1], "add") == 0 && argc == 3) add_task(argv[2]); + else if(strcmp(argv[1], "commit") == 0 && argc == 3) + commit_task(argv[2]); + else if(strcmp(argv[1], "commit") == 0) + commit_task(NULL); else if(strcmp(argv[1], "init") == 0) init_task(); else if(strcmp(argv[1], "info") == 0) -- cgit v1.2.3