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

2014-08-20 Thread Davide Fiorentino
Hi,

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=“miche...@email.com”; 
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.

I also tried using full length commit id and a non-existing commit id: nothing 
changes.
In the following example to replicate the replicate the bug I’m using a 
non-existing commit id to make the effect more evident.


$ git --version
git version 2.0.1

$ mkdir project

$ cd project

$ git init

$ for i in 1 2 3; do echo foo  foo$i.txt; git add foo$i.txt; git commit -m 
foo$i; done
[master (root-commit) 89dec6e] foo1
 1 file changed, 1 insertion(+)
 create mode 100644 foo1.txt
[master 8a3c8e5] foo2
 1 file changed, 1 insertion(+)
 create mode 100644 foo2.txt
[master a3ca061] foo3
 1 file changed, 1 insertion(+)
 create mode 100644 foo3.txt

$ git log --graph --all --pretty=format:'%C(yellow)%h%C(cyan)%d%Creset %s 
%C(white)- %an, %ar%Creset'
* a3ca061 (HEAD, master) foo3 - David, 4 seconds ago
* 8a3c8e5 foo2 - David, 4 seconds ago
* 89dec6e foo1 - David, 4 seconds ago

$ git filter-branch --commit-filter '
if [ $GIT_COMMIT=308add7 ]; 
then GIT_AUTHOR_NAME=Michelle; 
GIT_AUTHOR_EMAIL=miche...@email.com; 
GIT_AUTHOR_DATE=2009-12-31T23:59:59; 
git commit-tree $@; 
else 
git commit-tree $@;
fi' HEAD

$ git log --graph --all --pretty=format:'%C(yellow)%h%C(cyan)%d%Creset %s 
%C(white)- %an, %ar%Creset'
* 8937dff (HEAD, master) foo3 - Michelle, 4 years, 8 months ago
* 30e494e foo2 - Michelle, 4 years, 8 months ago
* 2a2ba4f foo1 - Michelle, 4 years, 8 months ago
* a3ca061 (refs/original/refs/heads/master) foo3 - David, 8 seconds ago
* 8a3c8e5 foo2 - David, 8 seconds ago
* 89dec6e foo1 - David, 8 seconds ago

$ git log
commit 8937dff7e6a3f5545c2242e3fd5d33acbabe6df4
Author: Michelle miche...@email.com
Date:   Thu Dec 31 23:59:59 2009 +0100

foo3

commit 30e494ef27f16c5456e66214ea46b780581dfb48
Author: Michelle miche...@email.com
Date:   Thu Dec 31 23:59:59 2009 +0100

foo2

commit 2a2ba4fd6b9627e237a12b47570a3f020a202b55
Author: Michelle miche...@email.com
Date:   Thu Dec 31 23:59:59 2009 +0100

foo1


using env-filter, I managed to rewrite the history with this:

$ git filter-branch --env-filter '
 
name=$GIT_AUTHOR_NAME
email=$GIT_AUTHOR_EMAIL
 
if [ $GIT_COMMIT = 89dec6e4bc1fb3cff694ea83f5ed900dad43449e ]
then
name=Michelle
email=miche...@email.com
fi

export GIT_AUTHOR_NAME=“$name
export GIT_AUTHOR_EMAIL=“$email
'

Hope this helped.

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


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

2014-08-20 Thread Davide Fiorentino
Damn! I haven’t seen that missing space.

Thank you Peff!

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


Re: Why are submodules not automatically handled by default or at least configurable to do so?

2015-10-27 Thread Davide Fiorentino
Why not set alias(es) for that?

Best,
Davide
> On 27 Oct 2015, at 10:50, Nick  wrote:
> 
> I too am interested in finding ways to automate working with submodules, as 
> it's a particular pain point with my colleagues.  They frequently shoot 
> themselves in the foot trying to branch and merge a project with submodules, 
> resulting in a broken build and grumpy comments about git (or possibly about 
> me, as the "Git Advocate").  And they're right, it is awkward.
> 
> Whether or not any sensible default configuration exists, users do need a way 
> to avoid excessively complicated workflows, or people are just going to avoid 
> using submodules, or perhaps Git. Hand-rolled solutions might be better than 
> nothing, but I would expect that this is a common issue which would benefit 
> from a built-in solution.  For instance, so that one can branch and merge the 
> whole project without duplicating the work for each submodule.
> 
> Am I correct in thinking there isn't anything which does these kind of things 
> yet?
> 
> Thanks!
> 
> Nick
> --
> To unsubscribe from this list: send the line "unsubscribe git" in
> the body of a message to majord...@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

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