Commit graph

111 commits

Author SHA1 Message Date
Johannes Sixt cfabd6eee1 filter-branch: subdirectory filter needs --full-history
When two branches are merged that modify a subdirectory (possibly in
different intermediate steps) such that both end up identical, then
rev-list chooses only one branch. But when we filter history, we want to
keep both branches. Therefore, we must use --full-history.

Signed-off-by: Johannes Sixt <johannes.sixt@telecom.at>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2007-06-09 12:24:16 -07:00
Johannes Sixt 813b4734fc filter-branch: Simplify parent computation.
We can use git rev-list --parents when we list the commits to rewrite.
It is not necessary to run git rev-list --parents for each commit in the
loop.

Signed-off-by: Johannes Sixt <johannes.sixt@telecom.at>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2007-06-09 12:20:20 -07:00
Johannes Schindelin 685ef546b6 Teach filter-branch about subdirectory filtering
With git-filter-branch --subdirectory-filter <subdirectory> you can
get at the history, as seen by a certain subdirectory. The history
of the rewritten branch will only contain commits that touched that
subdirectory, and the subdirectory will be rewritten to be the new
project root.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2007-06-09 12:16:49 -07:00
Matthias Lederhofer 9489d0f197 filter-branch: always export GIT_DIR if it is set
Currently filter-branch exports GIT_DIR only if it is an
relative path but git-sh-setup might also set GIT_DIR to an
absolute path that is not exported yet.  Additionally export
GIT_WORK_TREE with GIT_DIR to ensure that cwd is used as
working tree even for bare repositories.

Signed-off-by: Matthias Lederhofer <matled@gmx.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2007-06-06 16:08:37 -07:00
Johannes Sixt 3520e1e868 filter-branch: also don't fail in map() if a commit cannot be mapped
The map() function can be used by filters to map a commit id to its
rewritten id. Such a mapping may not exist, in which case the identity
mapping is used (the commit is returned unchanged).

In the rewrite loop, this mapping is also needed, but was done
explicitly in the same way. Use the map() function instead.

Signed-off-by: Johannes Sixt <johannes.sixt@telecom.at>
Acked-by: Johannes Schindelin <Johannes.Schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2007-06-06 12:49:16 -07:00
Johannes Sixt 2766ce2815 filter-branch: Use rev-list arguments to specify revision ranges.
A subset of commits in a branch used to be specified by options (-k, -r)
as well as the branch tip itself (-s). It is more natural (for git users)
to specify revision ranges like 'master..next' instead. This makes it so.
If no range is specified it defaults to 'HEAD'.

As a consequence, the new name of the filtered branch must be the first
non-option argument. All remaining arguments are passed to 'git rev-list'
unmodified.

The tip of the branch that gets filtered is implied: It is the first
commit that git rev-list would print for the specified range.

Signed-off-by: Johannes Sixt <johannes.sixt@telecom.at>
Acked-by: Johannes Schindelin <Johannes.Schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2007-06-06 12:49:16 -07:00
Johannes Schindelin 9840906026 filter-branch: fix behaviour of '-k'
The option '-k' says that the given commit and _all_ of its ancestors
are kept as-is.

However, if a to-be-rewritten commit branched from an ancestor of an
ancestor of a commit given with '-k', filter-branch would fail.

Example:

	A - B
	  \
	    C

If filter-branch was called with '-k B -s C', it would actually keep
B (and A as its parent), but would rewrite C, and its parent.

Noticed by Johannes Sixt.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2007-06-06 12:49:16 -07:00
Johannes Schindelin c12764b8b7 filter-branch: use $(($i+1)) instead of $((i+1))
The expression $((i+1)) is not portable at all: even some bash versions
do not grok it. So do not use it.

Noticed by Jonas Fonseca.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2007-06-06 12:31:56 -07:00
Matthias Lederhofer d674ee4cfc chmod +x git-filter-branch.sh
Signed-off-by: Matthias Lederhofer <matled@gmx.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2007-06-06 01:29:52 -07:00
Matthias Lederhofer 350d857529 filter-branch: prevent filters from reading from stdin
stdin is the list of commits when the env, tree and index
filter are executed.  The filters are not supposed to read
anything from stdin so the best is to give them /dev/null
for reading.

Signed-off-by: Matthias Lederhofer <matled@gmx.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2007-06-06 00:29:47 -07:00
Johannes Schindelin 6f6826c52b Add git-filter-branch
This script is derived from Pasky's cg-admin-rewritehist.

In fact, it _is_ the same script, minimally adapted to work without cogito.
It _should_ be able to perform the same tasks, even if only relying on
core-git programs.

All the work is Pasky's, just the adaption is mine.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Hopefully-signed-off-by: Petr "cogito master" Baudis <pasky@suse.cz>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2007-06-02 20:04:04 -07:00