All of lore.kernel.org
 help / color / mirror / Atom feed
From: Johannes Sixt <j.sixt@viscovery.net>
To: Yann Simon <yann.simon.fr@gmail.com>
Cc: git <git@vger.kernel.org>
Subject: Re: help with git filter-branch
Date: Thu, 18 Mar 2010 16:19:11 +0100	[thread overview]
Message-ID: <4BA2446F.1080002@viscovery.net> (raw)
In-Reply-To: <551f769b1003180743n2b2dde99laf00aa9bfe0141bf@mail.gmail.com>

Yann Simon schrieb:
> The idea is to add a missing parent to a certain commit.
> I wrote the following bash script:
> 
> #!/bin/sh
> die () {
>     echo >&2 "$@"
>     exit 1
> }
> [ "$#" -eq 3 ] || die "usage: add_parent <commit_to_update>
> <present_parent> <parent_to_add>"
> git filter-branch --parent-filter \
>     'test $GIT_COMMIT = $1 && \
>     echo "-p $2 -p $3" \
>     || cat' \
>     --tag-name-filter 'cat' \
>     $2..master
> 
> When I try to use it an a test repository, I get the following error:
> 
> ./add_parent.sh ad12d20974cad91ddedd055f5335b7471e48dd1d
> 1541f3ae456556edc7e15cead1ae76f470961be0
> 88b5d6f190f9d7135148c67c4d949c0c06e179ff
> Rewrite ad12d20974cad91ddedd055f5335b7471e48dd1d (1/1)test: 3: =:
> argument expected

The $1, $2, $3 are expanded too late in your script, namely when the
--parent-filter is evaluated, not when it is passed as argument to
filter-branch. Make it

git filter-branch --parent-filter "
	test \$GIT_COMMIT = $1 &&
	echo -p $2 -p $3 ||
	cat" \
	--tag-name-filter cat \
	$2..master

Of course, you can achieve this particular task slightly easier using a
graft as the manual of filter-branch shows.

-- Hannes

      reply	other threads:[~2010-03-18 15:19 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-03-18 14:43 help with git filter-branch Yann Simon
2010-03-18 15:19 ` Johannes Sixt [this message]

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

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

  git send-email \
    --in-reply-to=4BA2446F.1080002@viscovery.net \
    --to=j.sixt@viscovery.net \
    --cc=git@vger.kernel.org \
    --cc=yann.simon.fr@gmail.com \
    /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.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.