summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xetc/bash_completion.d/20vyatta-cfg17
-rw-r--r--src/commit2.c11
2 files changed, 25 insertions, 3 deletions
diff --git a/etc/bash_completion.d/20vyatta-cfg b/etc/bash_completion.d/20vyatta-cfg
index 22178e1..070d50f 100755
--- a/etc/bash_completion.d/20vyatta-cfg
+++ b/etc/bash_completion.d/20vyatta-cfg
@@ -97,7 +97,22 @@ show ()
commit ()
{
- if /opt/vyatta/sbin/my_commit "$@"; then
+ local comment="commit"
+ local next=0
+ local -a args=()
+ for arg in "$@"; do
+ if [ "$next" == "1" ]; then
+ comment=$arg
+ next=0;
+ elif [ "$arg" == "comment" ]; then
+ next=1
+ else
+ args[${#args[@]}]="$arg"
+ fi
+ done
+ args+=("-C '$comment'")
+
+ if /opt/vyatta/sbin/my_commit "${args[@]}"; then
vyatta_cli_shell_api markSessionUnsaved
fi
}
diff --git a/src/commit2.c b/src/commit2.c
index 884d2fe..51bb7dd 100644
--- a/src/commit2.c
+++ b/src/commit2.c
@@ -133,12 +133,13 @@ main(int argc, char** argv)
boolean full_commit_check = FALSE;
boolean break_priority = FALSE;
boolean disable_hook = FALSE;
+ char *commit_comment = NULL;
/* this is needed before calling certain glib functions */
g_type_init();
//grab inputs
- while ((ch = getopt(argc, argv, "dpthsecoafbr")) != -1) {
+ while ((ch = getopt(argc, argv, "dpthsecoafbrC:")) != -1) {
switch (ch) {
case 'd':
g_debug = TRUE;
@@ -177,6 +178,9 @@ main(int argc, char** argv)
case 'r':
disable_hook = TRUE;
break;
+ case 'C':
+ commit_comment = strdup(optarg);
+ break;
default:
usage();
exit(0);
@@ -374,7 +378,10 @@ main(int argc, char** argv)
if (strcmp(dirp->d_name, ".") != 0 &&
strcmp(dirp->d_name, "..") != 0) {
char buf[MAX_LENGTH_DIR_PATH*sizeof(char)];
- sprintf(buf,"%s/%s",COMMIT_HOOK_DIR,dirp->d_name);
+ if (commit_comment == NULL) {
+ commit_comment="commit";
+ }
+ sprintf(buf,"%s/%s %s",COMMIT_HOOK_DIR,dirp->d_name, commit_comment);
syslog(LOG_DEBUG,"Starting commit hook: %s",buf);
if (system(buf) == -1) {
syslog(LOG_WARNING,"Error on call to hook: %s", buf);