Re: [BUG] rewriting history with filter-branch --commit-filter

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

 



On Wed, Aug 20, 2014 at 10:16:11AM +0200, Davide Fiorentino wrote:

> I was in the need to rewrite author name and email and commit date for a single commit and I guess I found a bug.
> I run this git-filter script
> 
> $ git filter-branch --commit-filter ‘
>     if [ "$GIT_COMMIT"="9cfca27" ]; 
>         then GIT_AUTHOR_NAME=“Michelle”; 
>             GIT_AUTHOR_EMAIL=“michelle@xxxxxxxxx”; 
>             GIT_AUTHOR_DATE="2009-12-31T23:59:59”; 
>             git commit-tree "$@“; 
>         else 
>             git commit-tree "$@“;
>     fi' HEAD
> 
> and found that all history was rewritten as if “Michelle” not only commit 9cfca27.

The filter snippets you provide to filter-branch are shell script. The
`[` command (aka `test`) is just another shell command, and follows the
usual whitespace splitting rules. In your command:

  [ "$GIT_COMMIT"="9cfca27" ]

it sees only one single argument, all concatenated together. A single
argument given to `test` is the same as `test -n`: it tells you whether
the string is empty, so this conditional is always true. You wanted:

  [ "$GIT_COMMIT" = "9cfca27" ]

instead. The whitespace makes the "=" a separate argument, and the
command knows it's an operator. You should also use the full commit id,
as that is what will be in $GIT_COMMIT.

-Peff
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[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]