From: Lars Hjemli <hjemli@gmail.com>
To: Junio C Hamano <junkio@cox.net>
Cc: git@vger.kernel.org
Subject: [PATCH] Git-branch: fix regression and style issues
Date: Tue, 24 Oct 2006 01:51:03 +0200
Date: Tue, 24 Oct 2006 01:45:46 +0200 [thread overview]
Message-ID: <11616474633074-git-send-email-hjemli@gmail.com> (raw)
In-Reply-To: <7vk62qwtk7.fsf@assigned-by-dhcp.cox.net>
This is on top of my previuos patch to builtin-branch.c
Signed-off-by: Lars Hjemli <hjemli@gmail.com>
---
builtin-branch.c | 17 ++++++++---------
builtin.h | 2 +-
2 files changed, 9 insertions(+), 10 deletions(-)
diff --git a/builtin-branch.c b/builtin-branch.c
index 3105efd..ffc2db0 100755
--- a/builtin-branch.c
+++ b/builtin-branch.c
@@ -11,7 +11,7 @@ #include "commit.h"
#include "builtin.h"
static const char builtin_branch_usage[] =
-"git-branch [(-d | -D) <branchname>] | [[-f] <branchname> [<start-point>]] | -r";
+"git-branch (-d | -D) <branchname> | [-l] [-f] <branchname> [<start-point>] | [-r]";
static const char *head;
@@ -74,7 +74,7 @@ static void delete_branches(int argc, co
printf("Error deleting branch '%s'\n", argv[i]);
else
printf("Deleted branch %s.\n", argv[i]);
-
+
free(name);
}
}
@@ -82,11 +82,11 @@ static void delete_branches(int argc, co
static int ref_index, ref_alloc;
static char **ref_list;
-static int append_ref(const char *refname, const unsigned char *sha1, int flags,
+static int append_ref(const char *refname, const unsigned char *sha1, int flags,
void *cb_data)
{
if (ref_index >= ref_alloc) {
- ref_alloc = ref_alloc > 0 ? ref_alloc * 2 : 16;
+ ref_alloc = alloc_nr(ref_alloc);
ref_list = xrealloc(ref_list, ref_alloc * sizeof(char *));
}
@@ -137,14 +137,14 @@ static void create_branch(const char *na
die("Cannot force update the current branch.");
}
- if (get_sha1(start, sha1))
+ if (get_sha1(mkpath("%s^0", start), sha1))
die("Not a valid branch point: '%s'.", start);
lock = lock_any_ref_for_update(ref, NULL);
if (!lock)
die("Failed to lock ref for update: %s.", strerror(errno));
-
- if (reflog){
+
+ if (reflog) {
log_all_ref_updates = 1;
snprintf(msg, sizeof msg, "branch: Created from %s", start);
}
@@ -199,9 +199,8 @@ int cmd_branch(int argc, const char **ar
die("Failed to resolve HEAD as a valid ref.");
if (strncmp(head, "refs/heads/", 11))
die("HEAD not found below refs/heads!");
-
head += 11;
-
+
if (delete)
delete_branches(argc - i, argv + i, force_delete);
else if (i == argc)
diff --git a/builtin.h b/builtin.h
index 144d299..9b4749f 100644
--- a/builtin.h
+++ b/builtin.h
@@ -15,8 +15,8 @@ extern int write_tree(unsigned char *sha
extern int cmd_add(int argc, const char **argv, const char *prefix);
extern int cmd_annotate(int argc, const char **argv, const char *prefix);
extern int cmd_apply(int argc, const char **argv, const char *prefix);
-extern int cmd_branch(int argc, const char **argv, const char *prefix);
extern int cmd_archive(int argc, const char **argv, const char *prefix);
+extern int cmd_branch(int argc, const char **argv, const char *prefix);
extern int cmd_cat_file(int argc, const char **argv, const char *prefix);
extern int cmd_checkout_index(int argc, const char **argv, const char *prefix);
extern int cmd_check_ref_format(int argc, const char **argv, const char *prefix);
--
1.4.3.1.g4604-dirty
prev parent reply other threads:[~2006-10-23 23:51 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-10-23 21:40 [PATCH] Make git-branch a builtin Lars Hjemli
2006-10-23 21:55 ` Shawn Pearce
2006-10-23 23:19 ` Petr Baudis
2006-10-23 23:44 ` Junio C Hamano
2006-10-24 5:44 ` Shawn Pearce
2006-10-24 6:43 ` Junio C Hamano
2006-10-24 6:55 ` Shawn Pearce
2006-10-24 11:39 ` Petr Baudis
2006-10-24 17:00 ` Junio C Hamano
2006-10-23 22:34 ` Junio C Hamano
2006-10-23 23:51 ` Lars Hjemli [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=11616474633074-git-send-email-hjemli@gmail.com \
--to=hjemli@gmail.com \
--cc=git@vger.kernel.org \
--cc=junkio@cox.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).