From 2719471cb97c721e929c98c6bad40a381269295e Mon Sep 17 00:00:00 2001 From: Jeffrey Armstrong Date: Thu, 2 Jan 2014 21:27:40 -0500 Subject: Files can now be queued for commit --- prism.c | 42 +++++++++++++++++++++++++++++++++++++++--- 1 file changed, 39 insertions(+), 3 deletions(-) (limited to 'prism.c') diff --git a/prism.c b/prism.c index 44bd575..ec71953 100644 --- a/prism.c +++ b/prism.c @@ -47,7 +47,35 @@ static void init_task() static void add_task(const char *filename) { - +char new_hash[33]; +int res; +struct db_file oldfile; + + if(filename == NULL) { + printf("Nothing to do...\n"); + return; + } + + printf("Adding '%s' to the queue...\n", filename); + res = get_db_fileinfo(filename, &oldfile); + if(res == PRET_NOTTRACKED) { + add_file(filename); + printf(" new file is queued\n"); + } else if(res == PRET_OK) { + res = get_file_hash(filename, new_hash); + if(strcmp(oldfile.hash, new_hash) == 0) { + printf(" ERR: %s hasn't changed", filename); + } else { + add_file(filename); + printf(" modified file is queued\n"); + } + } else + printf(" ERR: problem retrieving previous hash\n"); +} + +static void commit_task(const char *message) +{ + } static void info_task() @@ -68,9 +96,13 @@ int res; return; } else printf(" tracking %d files\n", res); + + res = disp_queue(); + if(res == PRET_READERROR) + printf(" no files in queue\n"); } -static void info_hash(const char *filename) +static void hash_task(const char *filename) { int res; char hash[33]; @@ -94,12 +126,16 @@ int main(int argc, char *argv[]) if(strcmp(argv[1], "about") == 0) banner(); + else if(strcmp(argv[1], "add") == 0 && argc == 3) + add_task(argv[2]); else if(strcmp(argv[1], "init") == 0) init_task(); else if(strcmp(argv[1], "info") == 0) info_task(); else if(strcmp(argv[1], "hash") == 0 && argc == 3) - info_hash(argv[2]); + hash_task(argv[2]); + else + printf("Error processing command...\n"); return 0; } -- cgit v1.2.3