{"thread":{"id":"11952","subject":"[PATCH v2 10/11] Move code to clean up after a branch change to branch.c","startedAt":"2008-02-07T16:40:16Z","lastAt":"2008-02-07T16:40:16Z","messageCount":1,"participants":["Daniel Barkalow"],"isPatch":true,"patchVersion":2,"patchTotal":11},"messages":[{"id":"67832","messageId":"alpine.LNX.1.00.0802071134560.13593@iabervon.org","threadId":"11952","inReplyTo":null,"subject":"[PATCH v2 10/11] Move code to clean up after a branch change to branch.c","fromName":"Daniel Barkalow","fromEmail":"barkalow@iabervon.org","sentAt":"2008-02-07T16:40:16Z","receivedAt":"2008-02-07T16:40:16Z","isPatch":true,"sender":{"key":"barkalow@iabervon.org","avatar":"https://avatars.githubusercontent.com/u/55364219?v=4"},"body":"Signed-off-by: Daniel Barkalow <barkalow@iabervon.org>\n---\nThis or a related function should perhaps also be used by builtin-commit, \nwhich is removing some but not all of these.\n\n branch.c        |    8 ++++++++\n branch.h        |   20 ++++++++++++++++++--\n builtin-reset.c |    6 ++----\n 3 files changed, 28 insertions(+), 6 deletions(-)\n\ndiff --git a/branch.c b/branch.c\nindex 45ab820..1fc8788 100644\n--- a/branch.c\n+++ b/branch.c\n@@ -138,3 +138,11 @@ void create_branch(const char *head,\n \tif (real_ref)\n \t\tfree(real_ref);\n }\n+\n+void remove_branch_state(void)\n+{\n+\tunlink(git_path(\"MERGE_HEAD\"));\n+\tunlink(git_path(\"rr-cache/MERGE_RR\"));\n+\tunlink(git_path(\"MERGE_MSG\"));\n+\tunlink(git_path(\"SQUASH_MSG\"));\n+}\ndiff --git a/branch.h b/branch.h\nindex 8bcd9dc..d30abe0 100644\n--- a/branch.h\n+++ b/branch.h\n@@ -1,8 +1,24 @@\n #ifndef BRANCH_H\n #define BRANCH_H\n \n-void create_branch(const char *head,\n-\t\t   const char *name, const char *start_name,\n+/* Functions for acting on the information about branches. */\n+\n+/*\n+ * Creates a new branch, where head is the branch currently checked\n+ * out, name is the new branch name, start_name is the name of the\n+ * existing branch that the new branch should start from, force\n+ * enables overwriting an existing (non-head) branch, reflog creates a\n+ * reflog for the branch, and track causes the new branch to be\n+ * configured to merge the remote branch that start_name is a tracking\n+ * branch for (if any).\n+ */\n+void create_branch(const char *head, const char *name, const char *start_name,\n \t\t   int force, int reflog, int track);\n \n+/*\n+ * Remove information about the state of working on the current\n+ * branch. (E.g., MERGE_HEAD)\n+ */\n+void remove_branch_state(void);\n+\n #endif\ndiff --git a/builtin-reset.c b/builtin-reset.c\nindex 3bec06b..af0037e 100644\n--- a/builtin-reset.c\n+++ b/builtin-reset.c\n@@ -16,6 +16,7 @@\n #include \"diff.h\"\n #include \"diffcore.h\"\n #include \"tree.h\"\n+#include \"branch.h\"\n \n static const char builtin_reset_usage[] =\n \"git-reset [--mixed | --soft | --hard] [-q] [<commit-ish>] [ [--] <paths>...]\";\n@@ -270,10 +271,7 @@ int cmd_reset(int argc, const char **argv, const char *prefix)\n \t\tbreak;\n \t}\n \n-\tunlink(git_path(\"MERGE_HEAD\"));\n-\tunlink(git_path(\"rr-cache/MERGE_RR\"));\n-\tunlink(git_path(\"MERGE_MSG\"));\n-\tunlink(git_path(\"SQUASH_MSG\"));\n+\tremove_branch_state();\n \n \tfree(reflog_action);\n \n-- \n1.5.4\n"}]}