Re: [PATCH 00/26] git-log: implement new --diff-merge options

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Sergey Organov <sorganov@xxxxxxxxx> writes:

> My confusion originates from the fact that the code in revision.c sets
> rev->diff to 1 for -c/--cc , while it doesn't set it for -m, and this
> was the case *before* -c/--cc started to imply -p and -m.

Yes, all of this was from cd2bdc53 (Common option parsing for "git
log --diff" and friends, 2006-04-14).  We can see that "-m" is not
treated among the first class citizen in the output of "git show" on
the commit.  Namely, "-m" alone is merely a modifier for "-p" and
does not cause a diff to be generated (in other words, it only
affects the output if used together with "-p").

"git show cd2bdc53:git.c" would give you how "git log" looked like
back then, and how rev.diff field is used.

    static int cmd_log(int argc, const char **argv, char **envp)
    {
    ...

	prepare_revision_walk(&rev);
	setup_pager();
	while ((commit = get_revision(&rev)) != NULL) {
		if (shown && rev.diff && rev.commit_format != CMIT_FMT_ONELINE)
			putchar('\n');

We grab the next commit to show, and if we have already shown
something in the previous iteration, and if we are told to produce
patch output, we put an extra blank line after the patch for the
previous commit.  We omit that extra blank when showing the log
message in oneline format.  And then ...

		fputs(commit_prefix, stdout);
		if (rev.abbrev_commit && rev.abbrev)
			fputs(find_unique_abbrev(commit->object.sha1, rev.abbrev),
			      stdout);
		else
			fputs(sha1_to_hex(commit->object.sha1), stdout);
		if (rev.parents) {
    ...
		}
		if (rev.commit_format == CMIT_FMT_ONELINE)
			putchar(' ');
		else
			putchar('\n');
		pretty_print_commit(rev.commit_format, commit, ~0, buf,
				    LOGSIZE, rev.abbrev);
		printf("%s\n", buf);

... after showing the log message, if we were told to produce diff,

		if (rev.diff)
			log_tree_commit(&rev, commit);

we ask log_tree_commit() to show the patch.

		shown = 1;
		free(commit->buffer);
		commit->buffer = NULL;
	}
    ...

I think the code these days have most of the per-commit logic moved
to log_tree_commit() compared to the code we see above, but the
check at the beginning of log_tree_diff() we have, i.e.

    static int log_tree_diff(struct rev_info *opt, struct commit *...
    {
	int showed_log;
	struct commit_list *parents;
	struct object_id *oid;

	if (!opt->diff && !opt->diffopt.flags.exit_with_status)
		return 0;

directly corresponds to the "if rev.diff is true, then call
log_tree_commit()" in the 2006 code.



[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux