cmd-checkout.c (1712B)
1 /* 2 * Copyright (c) 2014 Mohamed Aslan <maslan@sce.carleton.ca> 3 * 4 * Permission to use, copy, modify, and distribute this software for any 5 * purpose with or without fee is hereby granted, provided that the above 6 * copyright notice and this permission notice appear in all copies. 7 * 8 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 9 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 10 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 11 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 12 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 13 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 14 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 15 */ 16 17 #include <stdio.h> 18 #include <stdlib.h> /* EXIT_FAILURE */ 19 #include <string.h> /* strstr(3) */ 20 #include <limits.h> /* PATH_MAX */ 21 #include <fcntl.h> /* open(2) */ 22 #include <unistd.h> /* getcwd(3) */ 23 #include <err.h> /* errx(3) */ 24 25 #include "defaults.h" 26 #include "session.h" 27 #include "cmd.h" 28 29 extern int objdb_baseline_get_ops(struct objdb_ops **); 30 extern int dircache_simple_get_ops(struct dircache_ops **); 31 32 int cmd_branch(int, char **); 33 34 static int 35 checkout(struct session *s, const char *branch_name) { 36 return EXIT_SUCCESS; 37 } 38 39 int 40 cmd_checkout(int argc, char **argv) 41 { 42 struct session s; 43 44 baseline_session_begin(&s, 0); 45 46 if (argc == 2) { /* 1 arg */ 47 if (checkout(&s, argv[1]) == EXIT_FAILURE) 48 errx(EXIT_FAILURE, "failed to checkout branch \'%s\'", argv[1]); 49 } 50 else{ 51 errx(EXIT_FAILURE, "wrong number of parameters for command \'checkout\'"); 52 } 53 54 baseline_session_end(&s); 55 return EXIT_SUCCESS; 56 }