summaryrefslogtreecommitdiff
path: root/sequencer.c
diff options
context:
space:
mode:
authorRamkumar Ramachandra <artagnon@gmail.com>2011-08-04 16:09:11 +0530
committerJunio C Hamano <gitster@pobox.com>2011-08-04 15:41:21 -0700
commit26ae337be11e440420d8ec7ce415425daaabe573 (patch)
treef1a4a054c319020cab33f64a42f8faba210c92dc /sequencer.c
parent21b14778a9b033d80b3e5757d9576da13ba446cd (diff)
downloadgit-26ae337be11e440420d8ec7ce415425daaabe573.tar.gz
revert: Introduce --reset to remove sequencer state
To explicitly remove the sequencer state for a fresh cherry-pick or revert invocation, introduce a new subcommand called "--reset" to remove the sequencer state. Take the opportunity to publicly expose the sequencer paths, and a generic function called "remove_sequencer_state" that various git programs can use to remove the sequencer state in a uniform manner; "git reset" uses it later in this series. Introducing this public API is also in line with our long-term goal of eventually factoring out functions from revert.c into a generic commit sequencer. Signed-off-by: Ramkumar Ramachandra <artagnon@gmail.com> Signed-off-by: Jonathan Nieder <jrnieder@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'sequencer.c')
-rw-r--r--sequencer.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/sequencer.c b/sequencer.c
new file mode 100644
index 0000000000..bc2c046aab
--- /dev/null
+++ b/sequencer.c
@@ -0,0 +1,19 @@
+#include "cache.h"
+#include "sequencer.h"
+#include "strbuf.h"
+#include "dir.h"
+
+void remove_sequencer_state(int aggressive)
+{
+ struct strbuf seq_dir = STRBUF_INIT;
+ struct strbuf seq_old_dir = STRBUF_INIT;
+
+ strbuf_addf(&seq_dir, "%s", git_path(SEQ_DIR));
+ strbuf_addf(&seq_old_dir, "%s", git_path(SEQ_OLD_DIR));
+ remove_dir_recursively(&seq_old_dir, 0);
+ rename(git_path(SEQ_DIR), git_path(SEQ_OLD_DIR));
+ if (aggressive)
+ remove_dir_recursively(&seq_old_dir, 0);
+ strbuf_release(&seq_dir);
+ strbuf_release(&seq_old_dir);
+}