diff options
| author | Jeffrey Armstrong <jeffrey.armstrong@approximatrix.com> | 2014-01-02 21:27:40 -0500 |
|---|---|---|
| committer | Jeffrey Armstrong <jeffrey.armstrong@approximatrix.com> | 2014-01-02 21:27:40 -0500 |
| commit | 2719471cb97c721e929c98c6bad40a381269295e (patch) | |
| tree | 81b2e1e790faed8881114d3922c2a2ed8fdcf6f3 /prism.c | |
| parent | eb626bd8ee3fddae050dbf9babfbea19961a36f2 (diff) | |
| download | prism-2719471cb97c721e929c98c6bad40a381269295e.tar.gz prism-2719471cb97c721e929c98c6bad40a381269295e.zip | |
Files can now be queued for commit
Diffstat (limited to 'prism.c')
| -rw-r--r-- | prism.c | 42 |
1 files changed, 39 insertions, 3 deletions
@@ -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;
}
|
