# [PATCH 7/9] Export create_branch() from builtin-branch.c

3 messages from 2008-02-04 to 2008-02-05. Participants: Daniel Barkalow, Johannes Schindelin.
Thread: https://gitlist.dev/t/11882

## Daniel Barkalow, 2008-02-04 18:36

Subject: [PATCH 7/9] Export create_branch() from builtin-branch.c
Message-ID: <alpine.LNX.1.00.0802041336010.13593@iabervon.org>
URL: https://gitlist.dev/e/alpine.LNX.1.00.0802041336010.13593%40iabervon.org

```
You can also create branches, in exactly the same way, with checkout -b.

Signed-off-by: Daniel Barkalow <barkalow@iabervon.org>
---
 builtin-branch.c |    4 ++--
 cache.h          |    4 ++++
 2 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/builtin-branch.c b/builtin-branch.c
index 089cae5..04e377d 100644
--- a/builtin-branch.c
+++ b/builtin-branch.c
@@ -422,8 +422,8 @@ static int setup_tracking(const char *new_ref, const char *orig_ref)
 	return 0;
 }
 
-static void create_branch(const char *name, const char *start_name,
-			  int force, int reflog, int track)
+void create_branch(const char *name, const char *start_name,
+		   int force, int reflog, int track)
 {
 	struct ref_lock *lock;
 	struct commit *commit;
diff --git a/cache.h b/cache.h
index e4aeff0..97edbf1 100644
--- a/cache.h
+++ b/cache.h
@@ -680,6 +680,10 @@ extern int convert_to_working_tree(const char *path, const char *src, size_t len
 /* add */
 void add_files_to_cache(int verbose, const char *prefix, const char **pathspec);
 
+/* branch */
+void create_branch(const char *name, const char *start_name,
+		   int force, int reflog, int track);
+
 /* diff.c */
 extern int diff_auto_refresh_index;
 
-- 
1.5.4

```

## Johannes Schindelin, 2008-02-05 01:38

Subject: Re: [PATCH 7/9] Export create_branch() from builtin-branch.c
Message-ID: <alpine.LSU.1.00.0802050136440.8543@racer.site>
URL: https://gitlist.dev/e/alpine.LSU.1.00.0802050136440.8543%40racer.site
In-Reply-To: <alpine.LNX.1.00.0802041336010.13593@iabervon.org>

```
Hi,

On Mon, 4 Feb 2008, Daniel Barkalow wrote:

> You can also create branches, in exactly the same way, with checkout -b.
> 
> Signed-off-by: Daniel Barkalow <barkalow@iabervon.org>
> ---
>  builtin-branch.c |    4 ++--
>  cache.h          |    4 ++++

Note that builtin-branch.c is not part of libgit.a, so you are only moving 
the declaration into the "libgit" part.

Maybe it would be better to move this function, say, into refs.c?

Ciao,
Dscho

```

## Daniel Barkalow, 2008-02-05 20:39

Subject: Re: [PATCH 7/9] Export create_branch() from builtin-branch.c
Message-ID: <alpine.LNX.1.00.0802042139170.13593@iabervon.org>
URL: https://gitlist.dev/e/alpine.LNX.1.00.0802042139170.13593%40iabervon.org
In-Reply-To: <alpine.LSU.1.00.0802050136440.8543@racer.site>

```
On Tue, 5 Feb 2008, Johannes Schindelin wrote:

> Hi,
> 
> On Mon, 4 Feb 2008, Daniel Barkalow wrote:
> 
> > You can also create branches, in exactly the same way, with checkout -b.
> > 
> > Signed-off-by: Daniel Barkalow <barkalow@iabervon.org>
> > ---
> >  builtin-branch.c |    4 ++--
> >  cache.h          |    4 ++++
> 
> Note that builtin-branch.c is not part of libgit.a, so you are only moving 
> the declaration into the "libgit" part.
> 
> Maybe it would be better to move this function, say, into refs.c?

I think it's actually time to start a branch.{c,h} library file for 
operations that deal with the porcelain-ish information about branches. 
This would go there, and a function to discard MERGE_HEAD and similar 
files (whatever they are, which isn't currently collected anywhere 
authoritative). Probably also most of the other stuff that should be 
shared between reset and checkout, too, and functions should probably 
migrate there from builtin-branch and builtin-checkout as they become 
needed, leaving the builtin-* code as command-line parsing and calls to 
these functions. In any case, I'll start with this.

	-Daniel
*This .sig left intentionally blank*

```
