@@ -4086,6 +4086,7 @@ void diff_setup(struct diff_options *options)
40864086 options -> interhunkcontext = diff_interhunk_context_default ;
40874087 options -> ws_error_highlight = ws_error_highlight_default ;
40884088 options -> flags .rename_empty = 1 ;
4089+ options -> objfind = NULL ;
40894090
40904091 /* pathchange left =NULL by default */
40914092 options -> change = diff_change ;
@@ -4110,22 +4111,20 @@ void diff_setup(struct diff_options *options)
41104111
41114112void diff_setup_done (struct diff_options * options )
41124113{
4113- int count = 0 ;
4114+ unsigned check_mask = DIFF_FORMAT_NAME |
4115+ DIFF_FORMAT_NAME_STATUS |
4116+ DIFF_FORMAT_CHECKDIFF |
4117+ DIFF_FORMAT_NO_OUTPUT ;
41144118
41154119 if (options -> set_default )
41164120 options -> set_default (options );
41174121
4118- if (options -> output_format & DIFF_FORMAT_NAME )
4119- count ++ ;
4120- if (options -> output_format & DIFF_FORMAT_NAME_STATUS )
4121- count ++ ;
4122- if (options -> output_format & DIFF_FORMAT_CHECKDIFF )
4123- count ++ ;
4124- if (options -> output_format & DIFF_FORMAT_NO_OUTPUT )
4125- count ++ ;
4126- if (count > 1 )
4122+ if (HAS_MULTI_BITS (options -> output_format & check_mask ))
41274123 die (_ ("--name-only, --name-status, --check and -s are mutually exclusive" ));
41284124
4125+ if (HAS_MULTI_BITS (options -> pickaxe_opts & DIFF_PICKAXE_KINDS_MASK ))
4126+ die (_ ("-G, -S and --find-object are mutually exclusive" ));
4127+
41294128 /*
41304129 * Most of the time we can say "there are changes"
41314130 * only by checking if there are changed paths, but
@@ -4175,7 +4174,7 @@ void diff_setup_done(struct diff_options *options)
41754174 /*
41764175 * Also pickaxe would not work very well if you do not say recursive
41774176 */
4178- if (options -> pickaxe )
4177+ if (options -> pickaxe_opts & DIFF_PICKAXE_KINDS_MASK )
41794178 options -> flags .recursive = 1 ;
41804179 /*
41814180 * When patches are generated, submodules diffed against the work tree
@@ -4489,6 +4488,23 @@ static int parse_ws_error_highlight_opt(struct diff_options *opt, const char *ar
44894488 return 1 ;
44904489}
44914490
4491+ static int parse_objfind_opt (struct diff_options * opt , const char * arg )
4492+ {
4493+ struct object_id oid ;
4494+
4495+ if (get_oid (arg , & oid ))
4496+ return error ("unable to resolve '%s'" , arg );
4497+
4498+ if (!opt -> objfind )
4499+ opt -> objfind = xcalloc (1 , sizeof (* opt -> objfind ));
4500+
4501+ opt -> pickaxe_opts |= DIFF_PICKAXE_KIND_OBJFIND ;
4502+ opt -> flags .recursive = 1 ;
4503+ opt -> flags .tree_in_recursive = 1 ;
4504+ oidset_insert (opt -> objfind , & oid );
4505+ return 1 ;
4506+ }
4507+
44924508int diff_opt_parse (struct diff_options * options ,
44934509 const char * * av , int ac , const char * prefix )
44944510{
@@ -4736,7 +4752,8 @@ int diff_opt_parse(struct diff_options *options,
47364752 else if ((argcount = short_opt ('O' , av , & optarg ))) {
47374753 options -> orderfile = prefix_filename (prefix , optarg );
47384754 return argcount ;
4739- }
4755+ } else if (skip_prefix (arg , "--find-object=" , & arg ))
4756+ return parse_objfind_opt (options , arg );
47404757 else if ((argcount = parse_long_opt ("diff-filter" , av , & optarg ))) {
47414758 int offending = parse_diff_filter_opt (optarg , options );
47424759 if (offending )
@@ -5783,7 +5800,7 @@ void diffcore_std(struct diff_options *options)
57835800 if (options -> break_opt != -1 )
57845801 diffcore_merge_broken ();
57855802 }
5786- if (options -> pickaxe )
5803+ if (options -> pickaxe_opts & DIFF_PICKAXE_KINDS_MASK )
57875804 diffcore_pickaxe (options );
57885805 if (options -> orderfile )
57895806 diffcore_order (options -> orderfile );
0 commit comments