commit 2cc9252c7c5d8b6f2068f1fdf6f5b3f76a0e6ed7
parent 1f7274bc9e4d79d77d7d4ad7ebb1eabc875cff42
Author: Mohamed Aslan <maslan@sce.carleton.ca>
Date: Mon, 6 Oct 2014 10:51:36 -0600
add support for -c flag in cmd-log.c
Diffstat:
1 file changed, 14 insertions(+), 5 deletions(-)
diff --git a/cmd-log.c b/cmd-log.c
@@ -47,14 +47,14 @@ cmd_log(int argc, char **argv)
char timestr[26];
const char *errstr;
int ch, done = 0, i, k = 0, kmax = 0;
- int fmt = 0, limited = 0;
+ int fmt = 0, limited = 0, explicit = 0;
struct session s;
struct commit *comm;
baseline_session_begin(&s, 0);
/* parse command line options */
- while ((ch = getopt(argc, argv, "f:n:")) != -1) {
+ while ((ch = getopt(argc, argv, "f:n:c:")) != -1) {
switch (ch) {
case 'f':
fmt = 1;
@@ -66,6 +66,10 @@ cmd_log(int argc, char **argv)
if (errstr != NULL)
errx(EXIT_FAILURE, "error, number (%s) is %s.", optarg, errstr);
break;
+ case 'c':
+ explicit = 1;
+ head = strdup(optarg);
+ break;
default:
exit(EXIT_FAILURE);
}
@@ -73,9 +77,11 @@ cmd_log(int argc, char **argv)
argc -= optind;
argv += optind;
- s.db_ops->branch_get_head(s.db_ctx, s.branch, &head);
- if (head == NULL)
- goto ret;
+ if (!explicit) {
+ s.db_ops->branch_get_head(s.db_ctx, s.branch, &head);
+ if (head == NULL)
+ goto ret;
+ }
if (!fmt)
fmtstr = default_fmt;
@@ -148,6 +154,9 @@ cmd_log(int argc, char **argv)
} while (!done);
ret:
+ free(head);
+ if (fmt)
+ free(fmtstr);
baseline_session_end(&s);
return EXIT_SUCCESS;
}