Skip to content

Commit 633e355

Browse files
committed
build-in git-mktree
Signed-off-by: Junio C Hamano <[email protected]>
1 parent 6345d7a commit 633e355

File tree

4 files changed

+10
-12
lines changed

4 files changed

+10
-12
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -332,7 +332,6 @@ PROGRAMS += git-index-pack$X
332332
PROGRAMS += git-merge-index$X
333333
PROGRAMS += git-merge-tree$X
334334
PROGRAMS += git-mktag$X
335-
PROGRAMS += git-mktree$X
336335
PROGRAMS += git-pack-redundant$X
337336
PROGRAMS += git-patch-id$X
338337
PROGRAMS += git-shell$X
@@ -586,6 +585,7 @@ BUILTIN_OBJS += builtin-merge-base.o
586585
BUILTIN_OBJS += builtin-merge-file.o
587586
BUILTIN_OBJS += builtin-merge-ours.o
588587
BUILTIN_OBJS += builtin-merge-recursive.o
588+
BUILTIN_OBJS += builtin-mktree.o
589589
BUILTIN_OBJS += builtin-mv.o
590590
BUILTIN_OBJS += builtin-name-rev.o
591591
BUILTIN_OBJS += builtin-pack-objects.o

mktree.c renamed to builtin-mktree.c

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
/*
22
* GIT - the stupid content tracker
33
*
4-
* Copyright (c) Junio C Hamano, 2006
4+
* Copyright (c) Junio C Hamano, 2006, 2009
55
*/
6-
#include "cache.h"
6+
#include "builtin.h"
77
#include "quote.h"
88
#include "tree.h"
9-
#include "exec_cmd.h"
109

1110
static struct treeent {
1211
unsigned mode;
@@ -64,19 +63,15 @@ static void write_tree(unsigned char *sha1)
6463

6564
static const char mktree_usage[] = "git mktree [-z]";
6665

67-
int main(int ac, char **av)
66+
int cmd_mktree(int ac, const char **av, const char *prefix)
6867
{
6968
struct strbuf sb = STRBUF_INIT;
7069
struct strbuf p_uq = STRBUF_INIT;
7170
unsigned char sha1[20];
7271
int line_termination = '\n';
7372

74-
git_extract_argv0_path(av[0]);
75-
76-
setup_git_directory();
77-
7873
while ((1 < ac) && av[1][0] == '-') {
79-
char *arg = av[1];
74+
const char *arg = av[1];
8075
if (!strcmp("-z", arg))
8176
line_termination = 0;
8277
else
@@ -92,8 +87,9 @@ int main(int ac, char **av)
9287
char *path;
9388

9489
ptr = sb.buf;
95-
/* Input is non-recursive ls-tree output format
96-
* mode SP type SP sha1 TAB name
90+
/*
91+
* Read non-recursive ls-tree output format:
92+
* mode SP type SP sha1 TAB name
9793
*/
9894
mode = strtoul(ptr, &ntr, 8);
9995
if (ptr == ntr || !ntr || *ntr != ' ')

builtin.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ extern int cmd_merge_base(int argc, const char **argv, const char *prefix);
7272
extern int cmd_merge_ours(int argc, const char **argv, const char *prefix);
7373
extern int cmd_merge_file(int argc, const char **argv, const char *prefix);
7474
extern int cmd_merge_recursive(int argc, const char **argv, const char *prefix);
75+
extern int cmd_mktree(int argc, const char **argv, const char *prefix);
7576
extern int cmd_mv(int argc, const char **argv, const char *prefix);
7677
extern int cmd_name_rev(int argc, const char **argv, const char *prefix);
7778
extern int cmd_pack_objects(int argc, const char **argv, const char *prefix);

git.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -327,6 +327,7 @@ static void handle_internal_command(int argc, const char **argv)
327327
{ "merge-ours", cmd_merge_ours, RUN_SETUP },
328328
{ "merge-recursive", cmd_merge_recursive, RUN_SETUP | NEED_WORK_TREE },
329329
{ "merge-subtree", cmd_merge_recursive, RUN_SETUP | NEED_WORK_TREE },
330+
{ "mktree", cmd_mktree, RUN_SETUP },
330331
{ "mv", cmd_mv, RUN_SETUP | NEED_WORK_TREE },
331332
{ "name-rev", cmd_name_rev, RUN_SETUP },
332333
{ "pack-objects", cmd_pack_objects, RUN_SETUP },

0 commit comments

Comments
 (0)