33 *
44 * Copyright (c) Junio C Hamano, 2006, 2009
55 */
6- #define USE_THE_REPOSITORY_VARIABLE
76#include "builtin.h"
87#include "gettext.h"
98#include "hex.h"
@@ -46,7 +45,7 @@ static int ent_compare(const void *a_, const void *b_)
4645 b -> name , b -> len , b -> mode );
4746}
4847
49- static void write_tree (struct object_id * oid )
48+ static void write_tree (struct repository * repo , struct object_id * oid )
5049{
5150 struct strbuf buf ;
5251 size_t size ;
@@ -60,10 +59,10 @@ static void write_tree(struct object_id *oid)
6059 for (i = 0 ; i < used ; i ++ ) {
6160 struct treeent * ent = entries [i ];
6261 strbuf_addf (& buf , "%o %s%c" , ent -> mode , ent -> name , '\0' );
63- strbuf_add (& buf , ent -> oid .hash , the_hash_algo -> rawsz );
62+ strbuf_add (& buf , ent -> oid .hash , repo -> hash_algo -> rawsz );
6463 }
6564
66- odb_write_object (the_repository -> objects , buf .buf , buf .len , OBJ_TREE , oid );
65+ odb_write_object (repo -> objects , buf .buf , buf .len , OBJ_TREE , oid );
6766 strbuf_release (& buf );
6867}
6968
@@ -72,7 +71,7 @@ static const char *const mktree_usage[] = {
7271 NULL
7372};
7473
75- static void mktree_line (char * buf , int nul_term_line , int allow_missing )
74+ static void mktree_line (struct repository * repo , char * buf , int nul_term_line , int allow_missing )
7675{
7776 char * ptr , * ntr ;
7877 const char * p ;
@@ -93,7 +92,7 @@ static void mktree_line(char *buf, int nul_term_line, int allow_missing)
9392 die ("input format error: %s" , buf );
9493 ptr = ntr + 1 ; /* type */
9594 ntr = strchr (ptr , ' ' );
96- if (!ntr || parse_oid_hex (ntr + 1 , & oid , & p ) ||
95+ if (!ntr || parse_oid_hex_algop (ntr + 1 , & oid , & p , repo -> hash_algo ) ||
9796 * p != '\t' )
9897 die ("input format error: %s" , buf );
9998
@@ -124,7 +123,7 @@ static void mktree_line(char *buf, int nul_term_line, int allow_missing)
124123
125124 /* Check the type of object identified by oid without fetching objects */
126125 oi .typep = & obj_type ;
127- if (odb_read_object_info_extended (the_repository -> objects , & oid , & oi ,
126+ if (odb_read_object_info_extended (repo -> objects , & oid , & oi ,
128127 OBJECT_INFO_LOOKUP_REPLACE |
129128 OBJECT_INFO_QUICK |
130129 OBJECT_INFO_SKIP_FETCH_OBJECT ) < 0 )
@@ -155,7 +154,7 @@ static void mktree_line(char *buf, int nul_term_line, int allow_missing)
155154int cmd_mktree (int ac ,
156155 const char * * av ,
157156 const char * prefix ,
158- struct repository * repo UNUSED )
157+ struct repository * repo )
159158{
160159 struct strbuf sb = STRBUF_INIT ;
161160 struct object_id oid ;
@@ -187,7 +186,7 @@ int cmd_mktree(int ac,
187186 break ;
188187 die ("input format error: (blank line only valid in batch mode)" );
189188 }
190- mktree_line (sb .buf , nul_term_line , allow_missing );
189+ mktree_line (repo , sb .buf , nul_term_line , allow_missing );
191190 }
192191 if (is_batch_mode && got_eof && used < 1 ) {
193192 /*
@@ -197,7 +196,7 @@ int cmd_mktree(int ac,
197196 */
198197 ; /* skip creating an empty tree */
199198 } else {
200- write_tree (& oid );
199+ write_tree (repo , & oid );
201200 puts (oid_to_hex (& oid ));
202201 fflush (stdout );
203202 }
0 commit comments