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

Re: [PATCH] Fix filter-branch to eliminate duplicate mapped parents

From
Junio C Hamano <gitster@pobox.com>
Date
Jul 1, 2014, 15:03 UTC
Message-ID
<xmqqmwctxgrx.fsf@gitster.dls.corp.google.com>
In-Reply-To
<1404163227-30962-1-git-send-email-charles@hashpling.org>
Charles Bailey <charles@hashpling.org> writes:
> I worked on this after discovering that --prune-empty often left some
> apparently empty commits that I was wasn't expecting it to leave and
> that running filter-branch --prune-empty in a loop would often do many
> passes where it was still pruning empty former merge commits.
Good find.
Show 25 quoted lines
>
> The test is a simple example of such a case. A non-ff merge of a commit
> that only changes a file that is to be pruned gets squashed into an
> empty non-merge commit that should be pruned.
>
>  git-filter-branch.sh     |  8 +++++++-
>  t/t7003-filter-branch.sh | 11 +++++++++++
>  2 files changed, 18 insertions(+), 1 deletion(-)
>
> diff --git a/git-filter-branch.sh b/git-filter-branch.sh
> index 86d6994..c5b82a8 100755
> --- a/git-filter-branch.sh
> +++ b/git-filter-branch.sh
> @@ -332,7 +332,13 @@ while read commit parents; do
>  	parentstr=
>  	for parent in $parents; do
>  		for reparent in $(map "$parent"); do
> -			parentstr="$parentstr -p $reparent"
> +			case "$parentstr" in
> +				*" -p $reparent"*)
> +					;;
> +				*)
> +					parentstr="$parentstr -p $reparent"
> +					;;
> +			esac

The case arms seem to be indented one level too deep; I'll fix it up locally when queuing, so no need to resend.

Thanks.
Previous: Charles Bailey
Message 3 of 3 in “Fix filter-branch to eliminate duplicate mapped parents”
  1. Fix filter-branch to eliminate duplicate mapped parentsCharles Bailey, Jun 30, 2014
  2. Charles BaileyJul 1, 2014
  3. Junio C HamanoJul 1, 2014

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.