git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Thomas Rast <trast@inf.ethz.ch>
Cc: git@vger.kernel.org, "Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>
Subject: Re: [PATCH] log: use true parents for diff even when rewriting
Date: Tue, 23 Jul 2013 12:55:39 -0700	[thread overview]
Message-ID: <7vob9t6og4.fsf@alter.siamese.dyndns.org> (raw)
In-Reply-To: <a598aec3e3c90de4d2c08e58ee0a4828edc80ac2.1374527806.git.trast@inf.ethz.ch> (Thomas Rast's message of "Mon, 22 Jul 2013 23:22:01 +0200")

Thomas Rast <trast@inf.ethz.ch> writes:

> +define_commit_slab(saved_parents, struct commit_list *);
> +struct saved_parents saved_parents_slab;
> +static int saved_parents_initialized;
> +
> +void save_parents(struct commit *commit)
> +{
> +	struct commit_list **pp;
> +
> +	if (!saved_parents_initialized) {
> +		init_saved_parents(&saved_parents_slab);
> +		saved_parents_initialized = 1;
> +	}
> +
> +	pp = saved_parents_at(&saved_parents_slab, commit);
> +	assert(*pp == NULL);
> +	*pp = copy_commit_list(commit->parents);
> +}
> +
> +struct commit_list *get_saved_parents(struct commit *commit)

Use "const struct commit *" here, as combine-diff.c has a const pointer.

> +{
> +	if (!saved_parents_initialized)
> +		return commit->parents;
> +
> +	return *saved_parents_at(&saved_parents_slab, commit);
> +}

clear_commit_slab() is not used, failing -Wunused -Werror compilation.

> diff --git a/revision.h b/revision.h
> index 95859ba..0717518 100644
> --- a/revision.h
> +++ b/revision.h
> @@ -273,4 +273,19 @@ enum rewrite_result {
>  
>  extern int rewrite_parents(struct rev_info *revs, struct commit *commit,
>  	rewrite_parent_fn_t rewrite_parent);
> +
> +/*
> + * Save a copy of the parent list, and return the saved copy.  This is
> + * used by the log machinery to retrieve the original parents when
> + * commit->parents has been modified by history simpification.
> + *
> + * You may only call save_parents() once per commit (this is checked
> + * for non-root commits).
> + *
> + * get_original_parents() will transparently return commit->parents if
> + * history simplification is off.
> + */
> +extern void save_parents(struct commit *commit);
> +extern struct commit_list *get_original_parents(struct commit *commit);
> +

s/_original/_saved/ here, and "const struct commit *".

By the way, when the only single parameter is a named type, you can
safely omit the name of the parameter from the declaration without
losing clarity.

>  #endif
> diff --git a/t/t6012-rev-list-simplify.sh b/t/t6012-rev-list-simplify.sh
> index 57ce239..fde5e71 100755
> --- a/t/t6012-rev-list-simplify.sh
> +++ b/t/t6012-rev-list-simplify.sh
> @@ -127,4 +127,10 @@ test_expect_success 'full history simplification without parent' '
>  	}
>  '
>  
> +test_expect_success '--full-diff is not affected by --parents' '
> +	git log -p --pretty="%H" --full-diff -- file >expected &&
> +	git log -p --pretty="%H" --full-diff --parents -- file >actual &&
> +	test_cmp expected actual
> +'
> +
>  test_done

  parent reply	other threads:[~2013-07-23 19:55 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-07-22  9:08 git log anomalities Uwe Kleine-König
2013-07-22 10:40 ` Thomas Rast
2013-07-22 21:22 ` [PATCH] log: use true parents for diff even when rewriting Thomas Rast
2013-07-22 21:48   ` Junio C Hamano
2013-07-23  7:27     ` Thomas Rast
2013-07-23  7:49       ` Uwe Kleine-König
2013-07-23 19:55   ` Junio C Hamano [this message]
2013-07-31 20:13   ` [PATCH v2] " Thomas Rast
2013-07-31 22:55     ` Jeff King

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=7vob9t6og4.fsf@alter.siamese.dyndns.org \
    --to=gitster@pobox.com \
    --cc=git@vger.kernel.org \
    --cc=trast@inf.ethz.ch \
    --cc=u.kleine-koenig@pengutronix.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).