@@ -628,59 +628,6 @@ static void write_tree_trivial(unsigned char *sha1)
628628 die (_ ("git write-tree failed to write a tree" ));
629629}
630630
631- static const char * merge_argument (struct commit * commit )
632- {
633- if (commit )
634- return sha1_to_hex (commit -> object .sha1 );
635- else
636- return EMPTY_TREE_SHA1_HEX ;
637- }
638-
639- int try_merge_command (const char * strategy , size_t xopts_nr ,
640- const char * * xopts , struct commit_list * common ,
641- const char * head_arg , struct commit_list * remotes )
642- {
643- const char * * args ;
644- int i = 0 , x = 0 , ret ;
645- struct commit_list * j ;
646- struct strbuf buf = STRBUF_INIT ;
647-
648- args = xmalloc ((4 + xopts_nr + commit_list_count (common ) +
649- commit_list_count (remotes )) * sizeof (char * ));
650- strbuf_addf (& buf , "merge-%s" , strategy );
651- args [i ++ ] = buf .buf ;
652- for (x = 0 ; x < xopts_nr ; x ++ ) {
653- char * s = xmalloc (strlen (xopts [x ])+ 2 + 1 );
654- strcpy (s , "--" );
655- strcpy (s + 2 , xopts [x ]);
656- args [i ++ ] = s ;
657- }
658- for (j = common ; j ; j = j -> next )
659- args [i ++ ] = xstrdup (merge_argument (j -> item ));
660- args [i ++ ] = "--" ;
661- args [i ++ ] = head_arg ;
662- for (j = remotes ; j ; j = j -> next )
663- args [i ++ ] = xstrdup (merge_argument (j -> item ));
664- args [i ] = NULL ;
665- ret = run_command_v_opt (args , RUN_GIT_CMD );
666- strbuf_release (& buf );
667- i = 1 ;
668- for (x = 0 ; x < xopts_nr ; x ++ )
669- free ((void * )args [i ++ ]);
670- for (j = common ; j ; j = j -> next )
671- free ((void * )args [i ++ ]);
672- i += 2 ;
673- for (j = remotes ; j ; j = j -> next )
674- free ((void * )args [i ++ ]);
675- free (args );
676- discard_cache ();
677- if (read_cache () < 0 )
678- die (_ ("failed to read the cache" ));
679- resolve_undo_clear ();
680-
681- return ret ;
682- }
683-
684631static int try_merge_strategy (const char * strategy , struct commit_list * common ,
685632 struct commit_list * remoteheads ,
686633 struct commit * head , const char * head_arg )
@@ -762,56 +709,6 @@ static int count_unmerged_entries(void)
762709 return ret ;
763710}
764711
765- int checkout_fast_forward (const unsigned char * head , const unsigned char * remote )
766- {
767- struct tree * trees [MAX_UNPACK_TREES ];
768- struct unpack_trees_options opts ;
769- struct tree_desc t [MAX_UNPACK_TREES ];
770- int i , fd , nr_trees = 0 ;
771- struct dir_struct dir ;
772- struct lock_file * lock_file = xcalloc (1 , sizeof (struct lock_file ));
773-
774- refresh_cache (REFRESH_QUIET );
775-
776- fd = hold_locked_index (lock_file , 1 );
777-
778- memset (& trees , 0 , sizeof (trees ));
779- memset (& opts , 0 , sizeof (opts ));
780- memset (& t , 0 , sizeof (t ));
781- if (overwrite_ignore ) {
782- memset (& dir , 0 , sizeof (dir ));
783- dir .flags |= DIR_SHOW_IGNORED ;
784- setup_standard_excludes (& dir );
785- opts .dir = & dir ;
786- }
787-
788- opts .head_idx = 1 ;
789- opts .src_index = & the_index ;
790- opts .dst_index = & the_index ;
791- opts .update = 1 ;
792- opts .verbose_update = 1 ;
793- opts .merge = 1 ;
794- opts .fn = twoway_merge ;
795- setup_unpack_trees_porcelain (& opts , "merge" );
796-
797- trees [nr_trees ] = parse_tree_indirect (head );
798- if (!trees [nr_trees ++ ])
799- return -1 ;
800- trees [nr_trees ] = parse_tree_indirect (remote );
801- if (!trees [nr_trees ++ ])
802- return -1 ;
803- for (i = 0 ; i < nr_trees ; i ++ ) {
804- parse_tree (trees [i ]);
805- init_tree_desc (t + i , trees [i ]-> buffer , trees [i ]-> size );
806- }
807- if (unpack_trees (nr_trees , t , & opts ))
808- return -1 ;
809- if (write_cache (fd , active_cache , active_nr ) ||
810- commit_locked_index (lock_file ))
811- die (_ ("unable to write new index file" ));
812- return 0 ;
813- }
814-
815712static void split_merge_strategies (const char * string , struct strategy * * list ,
816713 int * nr , int * alloc )
817714{
@@ -1424,7 +1321,8 @@ int cmd_merge(int argc, const char **argv, const char *prefix)
14241321 }
14251322
14261323 if (checkout_fast_forward (head_commit -> object .sha1 ,
1427- commit -> object .sha1 )) {
1324+ commit -> object .sha1 ,
1325+ overwrite_ignore )) {
14281326 ret = 1 ;
14291327 goto done ;
14301328 }
0 commit comments