git-2.22.0/log-tree.c
/*
 * Show the diff of a commit.
 *
 * Return true if we printed any log info messages
 */
Show the diff of a commit.
Return true if we printed any log info messages
Show the diff of a commit . Return true if we printed any log info messages
static int log_tree_diff(struct rev_info *opt, struct commit *commit, struct log_info *log)
{
	int showed_log;
	struct commit_list *parents;
	struct object_id *oid;
	if (!opt->diff && !opt->diffopt.flags.exit_with_status)
		return 0;
	parse_commit_or_die(commit);
	oid = get_commit_tree_oid(commit);
	parents = get_saved_parents(opt, commit);
	if (!parents) {
		if (opt->show_root_diff) {
			diff_root_tree_oid(oid, "", &opt->diffopt);
			log_tree_diff_flush(opt);
		}
		return !opt->loginfo;
	}
	if (parents && parents->next) {
		if (opt->ignore_merges)
			return 0;
		else if (opt->combine_merges)
			return do_diff_combined(opt, commit);
		else if (opt->first_parent_only) {
			parse_commit_or_die(parents->item);
			diff_tree_oid(get_commit_tree_oid(parents->item),
				      oid, "", &opt->diffopt);
			log_tree_diff_flush(opt);
			return !opt->loginfo;
		}
		log->parent = parents->item;
	}
	showed_log = 0;
	for (;;) {
		struct commit *parent = parents->item;
		parse_commit_or_die(parent);
		diff_tree_oid(get_commit_tree_oid(parent),
			      oid, "", &opt->diffopt);
		log_tree_diff_flush(opt);
		showed_log |= !opt->loginfo;
		parents = parents->next;
		if (!parents)
			break;
		log->parent = parents->item;
		opt->loginfo = log;
	}
	return showed_log;
}
static int log_tree_diff ( struct rev_info * opt , struct commit * commit , struct log_info * log ) { int showed_log ; struct commit_list * parents ; struct object_id * oid ; if ( ! opt -> diff && ! opt -> diffopt . flags . exit_with_status ) return 0 ; parse_commit_or_die ( commit ) ; oid = get_commit_tree_oid ( commit ) ; parents = get_saved_parents ( opt , commit ) ; if ( ! parents ) { if ( opt -> show_root_diff ) { diff_root_tree_oid ( oid , " " , & opt -> diffopt ) ; log_tree_diff_flush ( opt ) ; } return ! opt -> loginfo ; } if ( parents && parents -> next ) { if ( opt -> ignore_merges ) return 0 ; else if ( opt -> combine_merges ) return do_diff_combined ( opt , commit ) ; else if ( opt -> first_parent_only ) { parse_commit_or_die ( parents -> item ) ; diff_tree_oid ( get_commit_tree_oid ( parents -> item ) , oid , " " , & opt -> diffopt ) ; log_tree_diff_flush ( opt ) ; return ! opt -> loginfo ; } log -> parent = parents -> item ; } showed_log = 0 ; for ( ; ; ) { struct commit * parent = parents -> item ; parse_commit_or_die ( parent ) ; diff_tree_oid ( get_commit_tree_oid ( parent ) , oid , " " , & opt -> diffopt ) ; log_tree_diff_flush ( opt ) ; showed_log |= ! opt -> loginfo ; parents = parents -> next ; if ( ! parents ) break ; log -> parent = parents -> item ; opt -> loginfo = log ; } return showed_log ; }
Show the diff of a commit.
Show the diff of a commit .
/* Root commit? */ /* More than one parent? */ /*
			 * Generate merge log entry only for the first
			 * parent, showing summary diff of the others
			 * we merged _in_.
			 */ /* If we show individual diffs, show the parent info */ /* Set up the log info for the next parent, if any.. */