From: Junio C Hamano <gitster@pobox.com>
To: git@vger.kernel.org
Subject: [PATCH 1/6] build-in git-mktree
Date: Sun, 10 May 2009 11:49:46 -0700 [thread overview]
Message-ID: <1241981391-19639-2-git-send-email-gitster@pobox.com> (raw)
In-Reply-To: <1241981391-19639-1-git-send-email-gitster@pobox.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
Makefile | 2 +-
mktree.c => builtin-mktree.c | 18 +++++++-----------
builtin.h | 1 +
git.c | 1 +
4 files changed, 10 insertions(+), 12 deletions(-)
rename mktree.c => builtin-mktree.c (91%)
diff --git a/Makefile b/Makefile
index 6e21643..9d9f0da 100644
--- a/Makefile
+++ b/Makefile
@@ -332,7 +332,6 @@ PROGRAMS += git-index-pack$X
PROGRAMS += git-merge-index$X
PROGRAMS += git-merge-tree$X
PROGRAMS += git-mktag$X
-PROGRAMS += git-mktree$X
PROGRAMS += git-pack-redundant$X
PROGRAMS += git-patch-id$X
PROGRAMS += git-shell$X
@@ -586,6 +585,7 @@ BUILTIN_OBJS += builtin-merge-base.o
BUILTIN_OBJS += builtin-merge-file.o
BUILTIN_OBJS += builtin-merge-ours.o
BUILTIN_OBJS += builtin-merge-recursive.o
+BUILTIN_OBJS += builtin-mktree.o
BUILTIN_OBJS += builtin-mv.o
BUILTIN_OBJS += builtin-name-rev.o
BUILTIN_OBJS += builtin-pack-objects.o
diff --git a/mktree.c b/builtin-mktree.c
similarity index 91%
rename from mktree.c
rename to builtin-mktree.c
index 137a095..3d05427 100644
--- a/mktree.c
+++ b/builtin-mktree.c
@@ -1,12 +1,11 @@
/*
* GIT - the stupid content tracker
*
- * Copyright (c) Junio C Hamano, 2006
+ * Copyright (c) Junio C Hamano, 2006, 2009
*/
-#include "cache.h"
+#include "builtin.h"
#include "quote.h"
#include "tree.h"
-#include "exec_cmd.h"
static struct treeent {
unsigned mode;
@@ -64,19 +63,15 @@ static void write_tree(unsigned char *sha1)
static const char mktree_usage[] = "git mktree [-z]";
-int main(int ac, char **av)
+int cmd_mktree(int ac, const char **av, const char *prefix)
{
struct strbuf sb = STRBUF_INIT;
struct strbuf p_uq = STRBUF_INIT;
unsigned char sha1[20];
int line_termination = '\n';
- git_extract_argv0_path(av[0]);
-
- setup_git_directory();
-
while ((1 < ac) && av[1][0] == '-') {
- char *arg = av[1];
+ const char *arg = av[1];
if (!strcmp("-z", arg))
line_termination = 0;
else
@@ -92,8 +87,9 @@ int main(int ac, char **av)
char *path;
ptr = sb.buf;
- /* Input is non-recursive ls-tree output format
- * mode SP type SP sha1 TAB name
+ /*
+ * Read non-recursive ls-tree output format:
+ * mode SP type SP sha1 TAB name
*/
mode = strtoul(ptr, &ntr, 8);
if (ptr == ntr || !ntr || *ntr != ' ')
diff --git a/builtin.h b/builtin.h
index 425ff8e..20427d2 100644
--- a/builtin.h
+++ b/builtin.h
@@ -72,6 +72,7 @@ extern int cmd_merge_base(int argc, const char **argv, const char *prefix);
extern int cmd_merge_ours(int argc, const char **argv, const char *prefix);
extern int cmd_merge_file(int argc, const char **argv, const char *prefix);
extern int cmd_merge_recursive(int argc, const char **argv, const char *prefix);
+extern int cmd_mktree(int argc, const char **argv, const char *prefix);
extern int cmd_mv(int argc, const char **argv, const char *prefix);
extern int cmd_name_rev(int argc, const char **argv, const char *prefix);
extern int cmd_pack_objects(int argc, const char **argv, const char *prefix);
diff --git a/git.c b/git.c
index 5a00726..7d7f949 100644
--- a/git.c
+++ b/git.c
@@ -327,6 +327,7 @@ static void handle_internal_command(int argc, const char **argv)
{ "merge-ours", cmd_merge_ours, RUN_SETUP },
{ "merge-recursive", cmd_merge_recursive, RUN_SETUP | NEED_WORK_TREE },
{ "merge-subtree", cmd_merge_recursive, RUN_SETUP | NEED_WORK_TREE },
+ { "mktree", cmd_mktree, RUN_SETUP },
{ "mv", cmd_mv, RUN_SETUP | NEED_WORK_TREE },
{ "name-rev", cmd_name_rev, RUN_SETUP },
{ "pack-objects", cmd_pack_objects, RUN_SETUP },
--
1.6.3.9.g6345d
next prev parent reply other threads:[~2009-05-10 18:50 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-05-10 13:41 questions about git-mktree Jon Seymour
2009-05-10 15:12 ` Uwe Kleine-König
2009-05-10 15:27 ` A Large Angry SCM
2009-05-10 15:31 ` Jakub Narebski
2009-05-10 16:39 ` Junio C Hamano
2009-05-10 17:10 ` Junio C Hamano
2009-05-10 18:49 ` [PATCH 0/6] Modernize mktree somewhat Junio C Hamano
2009-05-10 18:49 ` Junio C Hamano [this message]
2009-05-10 18:49 ` [PATCH 2/6] mktree: use parse-options Junio C Hamano
2009-05-10 18:49 ` [PATCH 3/6] builtin-mktree.c: use a helper function to handle one line of input Junio C Hamano
2009-05-10 18:49 ` [PATCH 4/6] mktree: do not barf on a submodule commit Junio C Hamano
2009-05-10 18:49 ` [PATCH 5/6] t1010: add mktree test Junio C Hamano
2009-05-10 18:49 ` [PATCH 6/6] mktree --missing: allow missing objects Junio C Hamano
2009-05-10 22:13 ` René Scharfe
2009-05-11 0:29 ` Junio C Hamano
2009-05-10 18:54 ` questions about git-mktree - [PATCH] proposed '--batch' option Josh Micich
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=1241981391-19639-2-git-send-email-gitster@pobox.com \
--to=gitster@pobox.com \
--cc=git@vger.kernel.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.