threads / patch / 11882

patch, 9 partsExport create_branch() from builtin-branch.c

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

## tl;dr

3 messages between Feb 4, 2008 and Feb 5, 2008. Diffs are folded; open one to read it.

replies: 2people: 2as markdown or json

Daniel Barkalow· Feb 4, 2008, 18:36 UTC · lore
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(-)
Show changes to 2 files +6 −2

builtin-branch.c, cache.h

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· Feb 5, 2008, 01:38 UTC · re: Daniel Barkalow · lore

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

Hi,
On Mon, 4 Feb 2008, Daniel Barkalow wrote:
Show 6 quoted lines
> 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· Feb 5, 2008, 20:39 UTC · re: Johannes Schindelin · lore

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

On Tue, 5 Feb 2008, Johannes Schindelin wrote:
Show 15 quoted lines
> 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*

← back to recent threads