The plan to build a generic sequencer involves fist writing the functionality into builtin/revert.c (for cherry-pick and revert), and then factoring it out into sequencer.c and exposing it through sequencer.h as a nice API. As a prelude to this, announce the location of the sequencer state in sequencer.h and write a function to remove it. Later in the series, two indepenent Git programs, namely cherry-pick/ revert and reset, will use this to save and clear sequencer state in a uniform manner. Signed-off-by: Ramkumar Ramachandra <artagnon@xxxxxxxxx> --- Makefile | 2 ++ sequencer.c | 17 +++++++++++++++++ sequencer.h | 14 ++++++++++++++ 3 files changed, 33 insertions(+), 0 deletions(-) create mode 100644 sequencer.c create mode 100644 sequencer.h diff --git a/Makefile b/Makefile index f8c72e1..4ac09df 100644 --- a/Makefile +++ b/Makefile @@ -551,6 +551,7 @@ LIB_H += rerere.h LIB_H += resolve-undo.h LIB_H += revision.h LIB_H += run-command.h +LIB_H += sequencer.h LIB_H += sha1-array.h LIB_H += sha1-lookup.h LIB_H += sideband.h @@ -655,6 +656,7 @@ LIB_OBJS += revision.o LIB_OBJS += run-command.o LIB_OBJS += server-info.o LIB_OBJS += setup.o +LIB_OBJS += sequencer.o LIB_OBJS += sha1-array.o LIB_OBJS += sha1-lookup.o LIB_OBJS += sha1_file.o diff --git a/sequencer.c b/sequencer.c new file mode 100644 index 0000000..8c1de63 --- /dev/null +++ b/sequencer.c @@ -0,0 +1,17 @@ +#include "cache.h" +#include "sequencer.h" +#include "strbuf.h" +#include "dir.h" + +void remove_sequencer_state(void) +{ + 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)); + strbuf_release(&seq_dir); + strbuf_release(&seq_old_dir); +} diff --git a/sequencer.h b/sequencer.h new file mode 100644 index 0000000..673616b --- /dev/null +++ b/sequencer.h @@ -0,0 +1,14 @@ +#ifndef SEQUENCER_H +#define SEQUENCER_H + +#define SEQ_DIR "sequencer" +#define SEQ_OLD_DIR "sequencer-old" +#define SEQ_HEAD_FILE "sequencer/head" +#define SEQ_TODO_FILE "sequencer/todo" + +/* Removes SEQ_OLD_DIR and renames SEQ_DIR to SEQ_OLD_DIR, ignoring + * any errors. Intended to be used by 'git reset --hard'. + */ +void remove_sequencer_state(void); + +#endif -- 1.7.5.GIT -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html