-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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>
- Loading branch information
Ramkumar Ramachandra
authored and
Junio C Hamano
committed
Aug 4, 2011
1 parent
21b1477
commit 26ae337
Showing
8 changed files
with
111 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
--reset:: | ||
Forget about the current operation in progress. Can be used | ||
to clear the sequencer state after a failed cherry-pick or | ||
revert. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#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 | ||
* '--reset' subcommand. | ||
*/ | ||
void remove_sequencer_state(int aggressive); | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters