Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
git2
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
lvzhengyang
git2
Commits
1f6c891e
Commit
1f6c891e
authored
Nov 20, 2015
by
Edward Thomson
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #3516 from libgit2/cmn/repository-state-sequencer
repository: distinguish sequencer cherry-pick and revert
parents
69d14948
2ea40fda
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
35 additions
and
3 deletions
+35
-3
include/git2/repository.h
+2
-0
src/refs.h
+5
-0
src/repository.c
+10
-3
tests/repo/state.c
+18
-0
No files found.
include/git2/repository.h
View file @
1f6c891e
...
@@ -675,7 +675,9 @@ typedef enum {
...
@@ -675,7 +675,9 @@ typedef enum {
GIT_REPOSITORY_STATE_NONE
,
GIT_REPOSITORY_STATE_NONE
,
GIT_REPOSITORY_STATE_MERGE
,
GIT_REPOSITORY_STATE_MERGE
,
GIT_REPOSITORY_STATE_REVERT
,
GIT_REPOSITORY_STATE_REVERT
,
GIT_REPOSITORY_STATE_REVERT_SEQUENCE
,
GIT_REPOSITORY_STATE_CHERRYPICK
,
GIT_REPOSITORY_STATE_CHERRYPICK
,
GIT_REPOSITORY_STATE_CHERRYPICK_SEQUENCE
,
GIT_REPOSITORY_STATE_BISECT
,
GIT_REPOSITORY_STATE_BISECT
,
GIT_REPOSITORY_STATE_REBASE
,
GIT_REPOSITORY_STATE_REBASE
,
GIT_REPOSITORY_STATE_REBASE_INTERACTIVE
,
GIT_REPOSITORY_STATE_REBASE_INTERACTIVE
,
...
...
src/refs.h
View file @
1f6c891e
...
@@ -44,6 +44,11 @@
...
@@ -44,6 +44,11 @@
#define GIT_REBASE_APPLY_APPLYING_FILE GIT_REBASE_APPLY_DIR "applying"
#define GIT_REBASE_APPLY_APPLYING_FILE GIT_REBASE_APPLY_DIR "applying"
#define GIT_REFS_HEADS_MASTER_FILE GIT_REFS_HEADS_DIR "master"
#define GIT_REFS_HEADS_MASTER_FILE GIT_REFS_HEADS_DIR "master"
#define GIT_SEQUENCER_DIR "sequencer/"
#define GIT_SEQUENCER_HEAD_FILE GIT_SEQUENCER_DIR "head"
#define GIT_SEQUENCER_OPTIONS_FILE GIT_SEQUENCER_DIR "options"
#define GIT_SEQUENCER_TODO_FILE GIT_SEQUENCER_DIR "todo"
#define GIT_STASH_FILE "stash"
#define GIT_STASH_FILE "stash"
#define GIT_REFS_STASH_FILE GIT_REFS_DIR GIT_STASH_FILE
#define GIT_REFS_STASH_FILE GIT_REFS_DIR GIT_STASH_FILE
...
...
src/repository.c
View file @
1f6c891e
...
@@ -2222,11 +2222,17 @@ int git_repository_state(git_repository *repo)
...
@@ -2222,11 +2222,17 @@ int git_repository_state(git_repository *repo)
state
=
GIT_REPOSITORY_STATE_APPLY_MAILBOX_OR_REBASE
;
state
=
GIT_REPOSITORY_STATE_APPLY_MAILBOX_OR_REBASE
;
else
if
(
git_path_contains_file
(
&
repo_path
,
GIT_MERGE_HEAD_FILE
))
else
if
(
git_path_contains_file
(
&
repo_path
,
GIT_MERGE_HEAD_FILE
))
state
=
GIT_REPOSITORY_STATE_MERGE
;
state
=
GIT_REPOSITORY_STATE_MERGE
;
else
if
(
git_path_contains_file
(
&
repo_path
,
GIT_REVERT_HEAD_FILE
))
else
if
(
git_path_contains_file
(
&
repo_path
,
GIT_REVERT_HEAD_FILE
))
{
state
=
GIT_REPOSITORY_STATE_REVERT
;
state
=
GIT_REPOSITORY_STATE_REVERT
;
else
if
(
git_path_contains_file
(
&
repo_path
,
GIT_CHERRYPICK_HEAD_FILE
))
if
(
git_path_contains_file
(
&
repo_path
,
GIT_SEQUENCER_TODO_FILE
))
{
state
=
GIT_REPOSITORY_STATE_REVERT_SEQUENCE
;
}
}
else
if
(
git_path_contains_file
(
&
repo_path
,
GIT_CHERRYPICK_HEAD_FILE
))
{
state
=
GIT_REPOSITORY_STATE_CHERRYPICK
;
state
=
GIT_REPOSITORY_STATE_CHERRYPICK
;
else
if
(
git_path_contains_file
(
&
repo_path
,
GIT_BISECT_LOG_FILE
))
if
(
git_path_contains_file
(
&
repo_path
,
GIT_SEQUENCER_TODO_FILE
))
{
state
=
GIT_REPOSITORY_STATE_CHERRYPICK_SEQUENCE
;
}
}
else
if
(
git_path_contains_file
(
&
repo_path
,
GIT_BISECT_LOG_FILE
))
state
=
GIT_REPOSITORY_STATE_BISECT
;
state
=
GIT_REPOSITORY_STATE_BISECT
;
git_buf_free
(
&
repo_path
);
git_buf_free
(
&
repo_path
);
...
@@ -2271,6 +2277,7 @@ static const char *state_files[] = {
...
@@ -2271,6 +2277,7 @@ static const char *state_files[] = {
GIT_BISECT_LOG_FILE
,
GIT_BISECT_LOG_FILE
,
GIT_REBASE_MERGE_DIR
,
GIT_REBASE_MERGE_DIR
,
GIT_REBASE_APPLY_DIR
,
GIT_REBASE_APPLY_DIR
,
GIT_SEQUENCER_DIR
,
};
};
int
git_repository_state_cleanup
(
git_repository
*
repo
)
int
git_repository_state_cleanup
(
git_repository
*
repo
)
...
...
tests/repo/state.c
View file @
1f6c891e
...
@@ -57,6 +57,15 @@ void test_repo_state__revert(void)
...
@@ -57,6 +57,15 @@ void test_repo_state__revert(void)
assert_repo_state
(
GIT_REPOSITORY_STATE_NONE
);
assert_repo_state
(
GIT_REPOSITORY_STATE_NONE
);
}
}
void
test_repo_state__revert_sequence
(
void
)
{
setup_simple_state
(
GIT_REVERT_HEAD_FILE
);
setup_simple_state
(
GIT_SEQUENCER_TODO_FILE
);
assert_repo_state
(
GIT_REPOSITORY_STATE_REVERT_SEQUENCE
);
cl_git_pass
(
git_repository_state_cleanup
(
_repo
));
assert_repo_state
(
GIT_REPOSITORY_STATE_NONE
);
}
void
test_repo_state__cherry_pick
(
void
)
void
test_repo_state__cherry_pick
(
void
)
{
{
setup_simple_state
(
GIT_CHERRYPICK_HEAD_FILE
);
setup_simple_state
(
GIT_CHERRYPICK_HEAD_FILE
);
...
@@ -65,6 +74,15 @@ void test_repo_state__cherry_pick(void)
...
@@ -65,6 +74,15 @@ void test_repo_state__cherry_pick(void)
assert_repo_state
(
GIT_REPOSITORY_STATE_NONE
);
assert_repo_state
(
GIT_REPOSITORY_STATE_NONE
);
}
}
void
test_repo_state__cherrypick_sequence
(
void
)
{
setup_simple_state
(
GIT_CHERRYPICK_HEAD_FILE
);
setup_simple_state
(
GIT_SEQUENCER_TODO_FILE
);
assert_repo_state
(
GIT_REPOSITORY_STATE_CHERRYPICK_SEQUENCE
);
cl_git_pass
(
git_repository_state_cleanup
(
_repo
));
assert_repo_state
(
GIT_REPOSITORY_STATE_NONE
);
}
void
test_repo_state__bisect
(
void
)
void
test_repo_state__bisect
(
void
)
{
{
setup_simple_state
(
GIT_BISECT_LOG_FILE
);
setup_simple_state
(
GIT_BISECT_LOG_FILE
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment