Skip to contentSkip to conversation

git-filter-branch

DISCUSSION Mike Hommey 2 participants 6 messages Jun 15, 2016

lore
Share & tools
lore
#0 lore raw

Hi,

What is supposed to be the usage() of git-fetch-branch ?

git-filter-branch itself says:
git-filter-branch [-d TEMPDIR] [FILTERS] DESTBRANCH [REV-RANGE]

while the documentation doesn't explicitely talk about DESTBRANCH, expect in the form of an hypothetical /newbranch/, that you obviously don't give to the command line.

And whereas git-filter-branch itself says there is such an argument, it actually doesn't take it, and doesn't seem to be hardwired to create a new branch instead of overwriting the current one.

So what is git-filter-branch supposed to be doing ?

As a side note, if it ever happens that git-filter-branch can create a new branch, it might be nice to have each commit on the branch to have the original commit as parent, as well as its branch parent, so that they are seen as merges.

Cheers,

Mike

#1 lore raw

Hi,

Quoted 4 lines · Mike Hommey

What is supposed to be the usage() of git-fetch-branch ?

git-filter-branch itself says:
git-filter-branch [-d TEMPDIR] [FILTERS] DESTBRANCH [REV-RANGE]

This is an unfortunate left-over. The syntax described in the documentation should be right.

Quoted 3 lines

while the documentation doesn't explicitely talk about DESTBRANCH, expect in the form of an hypothetical /newbranch/, that you obviously don't give to the command line.

Hmm. I don't have time to look into this now, but the syntax is this:

	git filter-branch [<options>] [--] [<rev-options>]

Those refs that you give in the <rev-options> are rewritten. AFAIR the old values of the refs (if different) are written to refs/original/*.

Quoted 5 lines

And whereas git-filter-branch itself says there is such an argument, it actually doesn't take it, and doesn't seem to be hardwired to create a new branch instead of overwriting the current one.

So what is git-filter-branch supposed to be doing ?

To rewrite refs.

Quoted 4 lines

As a side note, if it ever happens that git-filter-branch can create a new branch, it might be nice to have each commit on the branch to have the original commit as parent, as well as its branch parent, so that they are seen as merges.

No, this will not happen. Filter-branch is meant to clean up branches, so it will rewrite the commits. However, you might be able to hack something in a parent filter.

Ciao,
Dscho

#2 lore raw
Quoted 16 lines · Johannes Schindelin

Hi,

Quoted 4 lines · Mike Hommey

What is supposed to be the usage() of git-fetch-branch ?

git-filter-branch itself says:
git-filter-branch [-d TEMPDIR] [FILTERS] DESTBRANCH [REV-RANGE]

This is an unfortunate left-over. The syntax described in the documentation should be right.

Quoted 3 lines

while the documentation doesn't explicitely talk about DESTBRANCH, expect in the form of an hypothetical /newbranch/, that you obviously don't give to the command line.

Quoted 6 lines

Hmm. I don't have time to look into this now, but the syntax is this:

	git filter-branch [<options>] [--] [<rev-options>]

Those refs that you give in the <rev-options> are rewritten. AFAIR the old values of the refs (if different) are written to refs/original/*.

In the description in the manpage:
Lets you rewrite git revision history by creating a new branch from your current branch, applying custom filters on each revision. (...)
The command takes the new branch name as a mandatory argument and the filters as optional arguments

And in example:
Now, you will get the rewritten history saved in the branch newbranch (your current branch is left untouched).

I must say this is a feature that would actually be nice to have...

Quoted 8 lines
Quoted 5 lines

And whereas git-filter-branch itself says there is such an argument, it actually doesn't take it, and doesn't seem to be hardwired to create a new branch instead of overwriting the current one.

So what is git-filter-branch supposed to be doing ?

To rewrite refs.

Quoted 8 lines
Quoted 4 lines

As a side note, if it ever happens that git-filter-branch can create a new branch, it might be nice to have each commit on the branch to have the original commit as parent, as well as its branch parent, so that they are seen as merges.

No, this will not happen. Filter-branch is meant to clean up branches, so it will rewrite the commits. However, you might be able to hack something in a parent filter.

That would need the commit id for the original commit being treated at the time, which I don't think is available in parent filters...

Mike

#3 lore raw

Hi,

Quoted 31 lines · Mike Hommey
Quoted 16 lines · Johannes Schindelin

Hi,

Quoted 4 lines · Mike Hommey

What is supposed to be the usage() of git-fetch-branch ?

git-filter-branch itself says:
git-filter-branch [-d TEMPDIR] [FILTERS] DESTBRANCH [REV-RANGE]

This is an unfortunate left-over. The syntax described in the documentation should be right.

Quoted 3 lines

while the documentation doesn't explicitely talk about DESTBRANCH, expect in the form of an hypothetical /newbranch/, that you obviously don't give to the command line.

Quoted 6 lines

Hmm. I don't have time to look into this now, but the syntax is this:

	git filter-branch [<options>] [--] [<rev-options>]

Those refs that you give in the <rev-options> are rewritten. AFAIR the old values of the refs (if different) are written to refs/original/*.

In the description in the manpage:
Lets you rewrite git revision history by creating a new branch from your current branch, applying custom filters on each revision. (...)
The command takes the new branch name as a mandatory argument and the filters as optional arguments

Quoted 5 lines

And in example:
Now, you will get the rewritten history saved in the branch newbranch (your current branch is left untouched).

I must say this is a feature that would actually be nice to have...

To compare with the old one? Use reflogs:

	git filter-branch --some-option master
	git diff master@{1}..master
Quoted 13 lines
Quoted 13 lines
Quoted 5 lines

And whereas git-filter-branch itself says there is such an argument, it actually doesn't take it, and doesn't seem to be hardwired to create a new branch instead of overwriting the current one.

So what is git-filter-branch supposed to be doing ?

To rewrite refs.

Quoted 4 lines

As a side note, if it ever happens that git-filter-branch can create a new branch, it might be nice to have each commit on the branch to have the original commit as parent, as well as its branch parent, so that they are seen as merges.

Quoted 6 lines
Quoted 3 lines

No, this will not happen. Filter-branch is meant to clean up branches, so it will rewrite the commits. However, you might be able to hack something in a parent filter.

That would need the commit id for the original commit being treated at the time, which I don't think is available in parent filters...

IIRC the "map" function will handle that.

Ciao,
Dscho

#4 lore raw
Quoted 11 lines · Johannes Schindelin
Quoted 11 lines

In the description in the manpage:
Lets you rewrite git revision history by creating a new branch from your current branch, applying custom filters on each revision. (...)
The command takes the new branch name as a mandatory argument and the filters as optional arguments

And in example:
Now, you will get the rewritten history saved in the branch newbranch (your current branch is left untouched).

Quoted 6 lines
Quoted 1 line

I must say this is a feature that would actually be nice to have...

To compare with the old one? Use reflogs:

	git filter-branch --some-option master
	git diff master@{1}..master

To have, for example, a branch tracking an upstream (svn or whatever) repository and have a branch based on it, only differing in the fact that some directories get removed.

To be more specific, I'm tracking webkit's svn repository, and want to have a branch which would be a base for making source tarballs for debian, excluding a lot of cruft (such as LayoutTests which are *huge*, or the website that also lives in the same svn trunk).

As files are added frequently in these directories, rebase or merge would not be enough, and I'd like to be able to do this with a bare repository, which rebase and merge don't allow me to...

So if you have a better idea than git-filter-branch for that, I'm open to suggestions ;)

Cheers,

Mike

#5 lore raw

Hi,

Quoted 14 lines · Mike Hommey
Quoted 13 lines · Johannes Schindelin
Quoted 12 lines

In the description in the manpage:
Lets you rewrite git revision history by creating a new branch from your current branch, applying custom filters on each revision. (...)
The command takes the new branch name as a mandatory argument and the filters as optional arguments

And in example:
Now, you will get the rewritten history saved in the branch newbranch (your current branch is left untouched).

I must say this is a feature that would actually be nice to have...

Quoted 8 lines
Quoted 4 lines

To compare with the old one? Use reflogs:

	git filter-branch --some-option master
	git diff master@{1}..master

To have, for example, a branch tracking an upstream (svn or whatever) repository and have a branch based on it, only differing in the fact that some directories get removed.

You can always achieve the same effect by

	$ git branch new-branch master
	$ git filter-branch <options> master

Anyway, I'm off for a few days.

Ciao,
Dscho