diff options
-rwxr-xr-x | etc/bash_completion.d/vyatta-cfg | 4 | ||||
-rw-r--r-- | src/commit/commit-algorithm.cpp | 18 |
2 files changed, 19 insertions, 3 deletions
diff --git a/etc/bash_completion.d/vyatta-cfg b/etc/bash_completion.d/vyatta-cfg index d59f7bd..0a62267 100755 --- a/etc/bash_completion.d/vyatta-cfg +++ b/etc/bash_completion.d/vyatta-cfg @@ -126,9 +126,7 @@ commit () args+=("-C '$comment'") export COMMIT_VIA=cli - if /opt/vyatta/sbin/my_commit "${args[@]}"; then - vyatta_cli_shell_api markSessionUnsaved - fi + /opt/vyatta/sbin/my_commit "${args[@]}" unset COMMIT_VIA } diff --git a/src/commit/commit-algorithm.cpp b/src/commit/commit-algorithm.cpp index 89a6dfe..ad775df 100644 --- a/src/commit/commit-algorithm.cpp +++ b/src/commit/commit-algorithm.cpp @@ -1136,6 +1136,21 @@ commit::doCommit(Cstore& cs, CfgNode& cfg1, CfgNode& cfg2) CfgNode *root = getCommitTree(&cfg1, &cfg2, p); if (!root) { OUTPUT_USER("No configuration changes to commit\n"); + /* call the low-level commitConfig() function with a dummy structure + * representing successful commit on the whole tree. this is equivalent + * to copying the whole working config back to the active config. since + * the two are "logically" the same, this is redundant in most cases. + * however, in some cases, this gives the low-level implementation a + * chance to clean up any intermediate state that are no longer needed. + */ + Cpath rp; + auto_ptr<CfgNode> cn(new CfgNode(rp, NULL, NULL, NULL, 0, &cs, false)); + PrioNode pn(cn.get()); + pn.setSucceeded(true); + if (!cs.commitConfig(pn)) { + OUTPUT_USER("Failed to generate committed config\n"); + return false; + } return true; } @@ -1186,6 +1201,9 @@ commit::doCommit(Cstore& cs, CfgNode& cfg1, CfgNode& cfg2) OUTPUT_USER("Failed to clear committed markers\n"); ret = false; } + if (ret) { + ret = cs.markSessionUnsaved(); + } return ret; } |