@matheusbsbs / matheus-bagliano / commits / c369e7b805
Fork 0

Move code to clean up after a branch change to branch.c

Signed-off-by: Daniel Barkalow <barkalow@iabervon.org>

Daniel Barkalow committed Feb 7, 2008 at 11:40 UTC c369e7b805f927bb87fcf345dd19a55c8b9e6b8e
3 files changed +28 -6
branch.c
+8
@@ -138,3 +138,11 @@ void create_branch(const char *head,
138 if (real_ref)
139 free(real_ref);
140 }
141 +
142 +void remove_branch_state(void)
143 +{
144 + unlink(git_path("MERGE_HEAD"));
145 + unlink(git_path("rr-cache/MERGE_RR"));
146 + unlink(git_path("MERGE_MSG"));
147 + unlink(git_path("SQUASH_MSG"));
148 +}
branch.h
+18 -2
@@ -1,8 +1,24 @@
1 #ifndef BRANCH_H
2 #define BRANCH_H
3
4 -void create_branch(const char *head,
5 - const char *name, const char *start_name,
4 +/* Functions for acting on the information about branches. */
5 +
6 +/*
7 + * Creates a new branch, where head is the branch currently checked
8 + * out, name is the new branch name, start_name is the name of the
9 + * existing branch that the new branch should start from, force
10 + * enables overwriting an existing (non-head) branch, reflog creates a
11 + * reflog for the branch, and track causes the new branch to be
12 + * configured to merge the remote branch that start_name is a tracking
13 + * branch for (if any).
14 + */
15 +void create_branch(const char *head, const char *name, const char *start_name,
16 int force, int reflog, int track);
17
18 +/*
19 + * Remove information about the state of working on the current
20 + * branch. (E.g., MERGE_HEAD)
21 + */
22 +void remove_branch_state(void);
23 +
24 #endif
builtin-reset.c
+2 -4
@@ -16,6 +16,7 @@
16 #include "diff.h"
17 #include "diffcore.h"
18 #include "tree.h"
19 +#include "branch.h"
20
21 static const char builtin_reset_usage[] =
22 "git-reset [--mixed | --soft | --hard] [-q] [<commit-ish>] [ [--] <paths>...]";
@@ -270,10 +271,7 @@ int cmd_reset(int argc, const char **argv, const char *prefix)
271 break;
272 }
273
273 - unlink(git_path("MERGE_HEAD"));
274 - unlink(git_path("rr-cache/MERGE_RR"));
275 - unlink(git_path("MERGE_MSG"));
276 - unlink(git_path("SQUASH_MSG"));
274 + remove_branch_state();
275
276 free(reflog_action);
277