summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAn-Cheng Huang <ancheng@vyatta.com>2011-05-05 16:25:48 +0800
committerAn-Cheng Huang <ancheng@vyatta.com>2011-05-05 16:25:48 +0800
commit113b5ee593fd3196e2b1c828c3dd82032758e492 (patch)
treeeb098d2d067113dcecdb62e89cc7c02d8d7118cb
parent27aa05b628a0272c4c0832edbbf3936e84f533ab (diff)
downloadvyatta-cfg-napa-dev.tar.gz
vyatta-cfg-napa-dev.zip
clean up when committing no changesnapa-dev
-rwxr-xr-xetc/bash_completion.d/vyatta-cfg4
-rw-r--r--src/commit/commit-algorithm.cpp18
2 files changed, 19 insertions, 3 deletions
diff --git a/etc/bash_completion.d/vyatta-cfg b/etc/bash_completion.d/vyatta-cfg
index d3cb36d..1c6da6c 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;
}