mirror of
https://github.com/git/git
synced 2024-11-05 18:59:29 +00:00
26ae337be1
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>
19 lines
526 B
C
19 lines
526 B
C
#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);
|
|
}
|