@@ -496,7 +496,7 @@ static const char *prepare_index(int argc, const char **argv, const char *prefix
496496static int run_status (FILE * fp , const char * index_file , const char * prefix , int nowarn ,
497497 struct wt_status * s )
498498{
499- unsigned char sha1 [ 20 ] ;
499+ struct object_id oid ;
500500
501501 if (s -> relative_paths )
502502 s -> prefix = prefix ;
@@ -509,9 +509,9 @@ static int run_status(FILE *fp, const char *index_file, const char *prefix, int
509509 s -> index_file = index_file ;
510510 s -> fp = fp ;
511511 s -> nowarn = nowarn ;
512- s -> is_initial = get_sha1 (s -> reference , sha1 ) ? 1 : 0 ;
512+ s -> is_initial = get_sha1 (s -> reference , oid . hash ) ? 1 : 0 ;
513513 if (!s -> is_initial )
514- hashcpy (s -> sha1_commit , sha1 );
514+ hashcpy (s -> sha1_commit , oid . hash );
515515 s -> status_format = status_format ;
516516 s -> ignore_submodule_arg = ignore_submodule_arg ;
517517
@@ -885,7 +885,7 @@ static int prepare_to_commit(const char *index_file, const char *prefix,
885885 commitable = run_status (s -> fp , index_file , prefix , 1 , s );
886886 s -> use_color = saved_color_setting ;
887887 } else {
888- unsigned char sha1 [ 20 ] ;
888+ struct object_id oid ;
889889 const char * parent = "HEAD" ;
890890
891891 if (!active_nr && read_cache () < 0 )
@@ -894,7 +894,7 @@ static int prepare_to_commit(const char *index_file, const char *prefix,
894894 if (amend )
895895 parent = "HEAD^1" ;
896896
897- if (get_sha1 (parent , sha1 )) {
897+ if (get_sha1 (parent , oid . hash )) {
898898 int i , ita_nr = 0 ;
899899
900900 for (i = 0 ; i < active_nr ; i ++ )
@@ -1332,7 +1332,7 @@ int cmd_status(int argc, const char **argv, const char *prefix)
13321332{
13331333 static struct wt_status s ;
13341334 int fd ;
1335- unsigned char sha1 [ 20 ] ;
1335+ struct object_id oid ;
13361336 static struct option builtin_status_options [] = {
13371337 OPT__VERBOSE (& verbose , N_ ("be verbose" )),
13381338 OPT_SET_INT ('s' , "short" , & status_format ,
@@ -1382,9 +1382,9 @@ int cmd_status(int argc, const char **argv, const char *prefix)
13821382
13831383 fd = hold_locked_index (& index_lock , 0 );
13841384
1385- s .is_initial = get_sha1 (s .reference , sha1 ) ? 1 : 0 ;
1385+ s .is_initial = get_sha1 (s .reference , oid . hash ) ? 1 : 0 ;
13861386 if (!s .is_initial )
1387- hashcpy (s .sha1_commit , sha1 );
1387+ hashcpy (s .sha1_commit , oid . hash );
13881388
13891389 s .ignore_submodule_arg = ignore_submodule_arg ;
13901390 s .status_format = status_format ;
@@ -1418,19 +1418,19 @@ static const char *implicit_ident_advice(void)
14181418
14191419}
14201420
1421- static void print_summary (const char * prefix , const unsigned char * sha1 ,
1421+ static void print_summary (const char * prefix , const struct object_id * oid ,
14221422 int initial_commit )
14231423{
14241424 struct rev_info rev ;
14251425 struct commit * commit ;
14261426 struct strbuf format = STRBUF_INIT ;
1427- unsigned char junk_sha1 [ 20 ] ;
1427+ struct object_id junk_oid ;
14281428 const char * head ;
14291429 struct pretty_print_context pctx = {0 };
14301430 struct strbuf author_ident = STRBUF_INIT ;
14311431 struct strbuf committer_ident = STRBUF_INIT ;
14321432
1433- commit = lookup_commit (sha1 );
1433+ commit = lookup_commit (oid -> hash );
14341434 if (!commit )
14351435 die (_ ("couldn't look up newly created commit" ));
14361436 if (parse_commit (commit ))
@@ -1477,7 +1477,7 @@ static void print_summary(const char *prefix, const unsigned char *sha1,
14771477 rev .diffopt .break_opt = 0 ;
14781478 diff_setup_done (& rev .diffopt );
14791479
1480- head = resolve_ref_unsafe ("HEAD" , 0 , junk_sha1 , NULL );
1480+ head = resolve_ref_unsafe ("HEAD" , 0 , junk_oid . hash , NULL );
14811481 if (!strcmp (head , "HEAD" ))
14821482 head = _ ("detached HEAD" );
14831483 else
@@ -1522,8 +1522,8 @@ static int git_commit_config(const char *k, const char *v, void *cb)
15221522 return git_status_config (k , v , s );
15231523}
15241524
1525- static int run_rewrite_hook (const unsigned char * oldsha1 ,
1526- const unsigned char * newsha1 )
1525+ static int run_rewrite_hook (const struct object_id * oldoid ,
1526+ const struct object_id * newoid )
15271527{
15281528 struct child_process proc = CHILD_PROCESS_INIT ;
15291529 const char * argv [3 ];
@@ -1544,7 +1544,7 @@ static int run_rewrite_hook(const unsigned char *oldsha1,
15441544 code = start_command (& proc );
15451545 if (code )
15461546 return code ;
1547- strbuf_addf (& sb , "%s %s\n" , sha1_to_hex ( oldsha1 ), sha1_to_hex ( newsha1 ));
1547+ strbuf_addf (& sb , "%s %s\n" , oid_to_hex ( oldoid ), oid_to_hex ( newoid ));
15481548 sigchain_push (SIGPIPE , SIG_IGN );
15491549 write_in_full (proc .in , sb .buf , sb .len );
15501550 close (proc .in );
@@ -1636,7 +1636,7 @@ int cmd_commit(int argc, const char **argv, const char *prefix)
16361636 struct strbuf author_ident = STRBUF_INIT ;
16371637 const char * index_file , * reflog_msg ;
16381638 char * nl ;
1639- unsigned char sha1 [ 20 ] ;
1639+ struct object_id oid ;
16401640 struct commit_list * parents = NULL ;
16411641 struct stat statbuf ;
16421642 struct commit * current_head = NULL ;
@@ -1651,10 +1651,10 @@ int cmd_commit(int argc, const char **argv, const char *prefix)
16511651 status_format = STATUS_FORMAT_NONE ; /* Ignore status.short */
16521652 s .colopts = 0 ;
16531653
1654- if (get_sha1 ("HEAD" , sha1 ))
1654+ if (get_sha1 ("HEAD" , oid . hash ))
16551655 current_head = NULL ;
16561656 else {
1657- current_head = lookup_commit_or_die (sha1 , "HEAD" );
1657+ current_head = lookup_commit_or_die (oid . hash , "HEAD" );
16581658 if (parse_commit (current_head ))
16591659 die (_ ("could not parse HEAD commit" ));
16601660 }
@@ -1759,7 +1759,7 @@ int cmd_commit(int argc, const char **argv, const char *prefix)
17591759 }
17601760
17611761 if (commit_tree_extended (sb .buf , sb .len , active_cache_tree -> sha1 ,
1762- parents , sha1 , author_ident .buf , sign_commit , extra )) {
1762+ parents , oid . hash , author_ident .buf , sign_commit , extra )) {
17631763 rollback_index_files ();
17641764 die (_ ("failed to write commit object" ));
17651765 }
@@ -1776,7 +1776,7 @@ int cmd_commit(int argc, const char **argv, const char *prefix)
17761776
17771777 transaction = ref_transaction_begin (& err );
17781778 if (!transaction ||
1779- ref_transaction_update (transaction , "HEAD" , sha1 ,
1779+ ref_transaction_update (transaction , "HEAD" , oid . hash ,
17801780 current_head
17811781 ? current_head -> object .oid .hash : null_sha1 ,
17821782 0 , sb .buf , & err ) ||
@@ -1805,13 +1805,13 @@ int cmd_commit(int argc, const char **argv, const char *prefix)
18051805 cfg = init_copy_notes_for_rewrite ("amend" );
18061806 if (cfg ) {
18071807 /* we are amending, so current_head is not NULL */
1808- copy_note_for_rewrite (cfg , current_head -> object .oid .hash , sha1 );
1808+ copy_note_for_rewrite (cfg , current_head -> object .oid .hash , oid . hash );
18091809 finish_copy_notes_for_rewrite (cfg , "Notes added by 'git commit --amend'" );
18101810 }
1811- run_rewrite_hook (current_head -> object .oid . hash , sha1 );
1811+ run_rewrite_hook (& current_head -> object .oid , & oid );
18121812 }
18131813 if (!quiet )
1814- print_summary (prefix , sha1 , !current_head );
1814+ print_summary (prefix , & oid , !current_head );
18151815
18161816 strbuf_release (& err );
18171817 return 0 ;
0 commit comments