git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] log: use true parents for diff even when rewriting

From
Junio C Hamano <gitster@pobox.com>
Date
Jul 23, 2013, 19:55 UTC
Message-ID
<7vob9t6og4.fsf@alter.siamese.dyndns.org>
In-Reply-To
<a598aec3e3c90de4d2c08e58ee0a4828edc80ac2.1374527806.git.trast@inf.ethz.ch>
Thomas Rast <trast@inf.ethz.ch> writes:
Show 19 quoted lines
> +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.
Show 6 quoted lines
> +{
> +	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.
Show 23 quoted lines
> 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.

Show 16 quoted lines
>  #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
Previous: Uwe Kleine-KönigNext: Thomas Rast
Message 7 of 9 in “git log anomalities”
  1. Uwe Kleine-KönigJul 22, 2013
  2. Thomas RastJul 22, 2013
  3. log: use true parents for diff even when rewritingThomas Rast, Jul 22, 2013
  4. Junio C HamanoJul 22, 2013
  5. Thomas RastJul 23, 2013
  6. Uwe Kleine-KönigJul 23, 2013
  7. Junio C HamanoJul 23, 2013
  8. log: use true parents for diff even when rewritingThomas Rast, Jul 31, 2013
  9. Jeff KingJul 31, 2013

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.