From d596118d7a9b104db10e64b2680a30ea80f1439c Mon Sep 17 00:00:00 2001 From: Jonathan Nieder Date: Sat, 10 Dec 2011 07:06:12 -0600 Subject: [PATCH] revert: stop creating and removing sequencer-old directory Now that "git reset" no longer implicitly removes .git/sequencer that the operator may or may not have wanted to keep, the logic to write a backup copy of .git/sequencer and remove it when stale is not needed any more. Simplify the sequencer API and repository layout by dropping it. Signed-off-by: Jonathan Nieder Signed-off-by: Junio C Hamano --- builtin/revert.c | 6 +++--- sequencer.c | 32 +++++++++++++------------------- sequencer.h | 32 ++++++++++++-------------------- 3 files changed, 28 insertions(+), 42 deletions(-) rewrite sequencer.c (62%) rewrite sequencer.h (65%) diff --git a/builtin/revert.c b/builtin/revert.c index 5dcfa6ba69..028bcbcd75 100644 --- a/builtin/revert.c +++ b/builtin/revert.c @@ -944,7 +944,7 @@ static int sequencer_rollback(struct replay_opts *opts) } if (reset_for_rollback(sha1)) goto fail; - remove_sequencer_state(1); + remove_sequencer_state(); strbuf_release(&buf); return 0; fail: @@ -1026,7 +1026,7 @@ static int pick_commits(struct commit_list *todo_list, struct replay_opts *opts) * Sequence of picks finished successfully; cleanup by * removing the .git/sequencer directory */ - remove_sequencer_state(1); + remove_sequencer_state(); return 0; } @@ -1084,7 +1084,7 @@ static int pick_revisions(struct replay_opts *opts) * one that is being continued */ if (opts->subcommand == REPLAY_REMOVE_STATE) { - remove_sequencer_state(1); + remove_sequencer_state(); return 0; } if (opts->subcommand == REPLAY_ROLLBACK) diff --git a/sequencer.c b/sequencer.c dissimilarity index 62% index bc2c046aab..d1f28a6945 100644 --- a/sequencer.c +++ b/sequencer.c @@ -1,19 +1,13 @@ -#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); -} +#include "cache.h" +#include "sequencer.h" +#include "strbuf.h" +#include "dir.h" + +void remove_sequencer_state(void) +{ + struct strbuf seq_dir = STRBUF_INIT; + + strbuf_addf(&seq_dir, "%s", git_path(SEQ_DIR)); + remove_dir_recursively(&seq_dir, 0); + strbuf_release(&seq_dir); +} diff --git a/sequencer.h b/sequencer.h dissimilarity index 65% index f435fdb4b1..2d4528f292 100644 --- a/sequencer.h +++ b/sequencer.h @@ -1,20 +1,12 @@ -#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" -#define SEQ_OPTS_FILE "sequencer/opts" - -/* - * Removes SEQ_OLD_DIR and renames SEQ_DIR to SEQ_OLD_DIR, ignoring - * any errors. Intended to be used by 'git reset'. - * - * With the aggressive flag, it additionally removes SEQ_OLD_DIR, - * ignoring any errors. Inteded to be used by the sequencer's - * '--quit' subcommand. - */ -void remove_sequencer_state(int aggressive); - -#endif +#ifndef SEQUENCER_H +#define SEQUENCER_H + +#define SEQ_DIR "sequencer" +#define SEQ_HEAD_FILE "sequencer/head" +#define SEQ_TODO_FILE "sequencer/todo" +#define SEQ_OPTS_FILE "sequencer/opts" + +/* Removes SEQ_DIR. */ +extern void remove_sequencer_state(void); + +#endif -- 2.11.4.GIT