From: Johannes Schindelin <Johannes.Schindelin@gmx.de>
To: Johannes Sixt <J.Sixt@eudaptics.com>
Cc: gitster@pobox.com, git@vger.kernel.org
Subject: [PATCH] filter-branch: rewrite only refs which were not excluded by the options
Date: Tue, 24 Jul 2007 12:06:21 +0100 (BST) [thread overview]
Message-ID: <Pine.LNX.4.64.0707241205480.14781@racer.site> (raw)
In-Reply-To: <46A5C615.24C24F0F@eudaptics.com>
The rev-list options can exclude some -- or all -- refs:
git filter-branch <some-filter> master ^master
Without this patch, these refs are assumed to be deleted, or worse, they
are rewritten to some bogus merge bases.
So really exclude excluded refs from being rewritten. This also allows
you to safely call
git filter-branch <some-filter> --all <rev-list options>
to rewrite _all_ branches and tags.
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
---
On Tue, 24 Jul 2007, Johannes Sixt wrote:
> Johannes Schindelin wrote:
>
> > +# NEEDSWORK: we should sort the unmapped refs topologically first
> > +while read ref
> > +do
> > + sha1=$(git rev-parse "$ref"^0)
> > + test -f "$workdir"/../map/$sha1 && continue
> > + # Assign the boundarie(s) in the set of rewritten commits
> > + # as the replacement commit(s).
> > + # (This would look a bit nicer if --not --stdin worked.)
> > + for p in $((cd "$workdir"/../map; ls | sed "s/^/^/") |
> > + git rev-list $ref --boundary --stdin |
> > + sed -n "s/^-//p")
> > + do
> > + map $p >> "$workdir"/../map/$sha1
> > + done
> > +done < "$tempdir"/heads
>
> This logic seems to be borked, and I don't grok it. I was trying this:
>
> git-filter-branch -- --since=2007.01.10 \
> refs/heads/topic refs/heads/master
Actually, the error lay somewhere else. If excluded, topic should
not have been a rewrite candidate.
There might be something else looming here: what to do with
git filter-branch --subdir-filter subdir/ topic master \
^$(git merge-base topic master)
when topic has no changes to the subdirectory, but master has?
I guess the safest would be to 'test -f "$workdir"/../map/$p', and
if at least one is not there, leave 'topic' as is. If at least
one is there, however, we want to warn the user that this is not
possible. (Something like: this was an unchanged ancestor: $p1,
but that was a changed one: $p2. Make up your mind what you
want.)
git-filter-branch.sh | 9 ++++++++-
t/t7003-filter-branch.sh | 9 +++++++++
2 files changed, 17 insertions(+), 1 deletions(-)
diff --git a/git-filter-branch.sh b/git-filter-branch.sh
index 019a302..49b0f00 100755
--- a/git-filter-branch.sh
+++ b/git-filter-branch.sh
@@ -181,6 +181,7 @@ export GIT_DIR GIT_WORK_TREE=.
# These refs should be updated if their heads were rewritten
+negatives="$(git rev-parse --revs-only "$@" | grep "^\^")"
git rev-parse --revs-only --symbolic "$@" |
while read ref
do
@@ -196,7 +197,13 @@ do
grep "refs/\(tags\|heads\)/$ref$")"
esac
- git check-ref-format "$ref" && echo "$ref"
+ # make sure we have a valid ref
+ git check-ref-format "$ref" || continue
+
+ # if the ref has been excluded by the other options, skip it
+ test -z "$(git rev-list -1 "$ref" $negatives)" && continue
+
+ echo "$ref"
done > "$tempdir"/heads
test -s "$tempdir"/heads ||
diff --git a/t/t7003-filter-branch.sh b/t/t7003-filter-branch.sh
index c9a820d..667eda7 100755
--- a/t/t7003-filter-branch.sh
+++ b/t/t7003-filter-branch.sh
@@ -164,4 +164,13 @@ test_expect_success 'only dwim refs/heads/$ref or refs/tags/$ref' '
git filter-branch -f master
'
+test_expect_success 'do not update uninteresting refs' '
+ branch=$(git rev-parse branch) &&
+ master=$(git rev-parse master) &&
+ git filter-branch -f --env-filter "GIT_AUTHOR_EMAIL=xy@probl.em" \
+ master ^removed-author branch &&
+ test $branch = $(git rev-parse branch) &&
+ test $master != $(git rev-parse master)
+'
+
test_done
--
1.5.3.rc2.32.g35c5b-dirty
next prev parent reply other threads:[~2007-07-24 11:06 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-07-23 17:34 [PATCH] filter-branch: Big syntax change; support rewriting multiple refs Johannes Schindelin
2007-07-24 5:35 ` Junio C Hamano
2007-07-24 9:10 ` Johannes Schindelin
2007-07-24 9:27 ` [PATCH] filter-branch: Big syntax change; support rewriting multiplerefs Johannes Sixt
2007-07-24 10:36 ` [PATCH] filter-branch: when dwim'ing a ref, only allow heads and tags Johannes Schindelin
2007-07-24 11:04 ` [PATCH] filter-branch: when dwim'ing a ref, only allow heads andtags Johannes Sixt
2007-07-24 11:20 ` Johannes Schindelin
2007-07-24 11:27 ` [PATCH] filter-branch: when dwim'ing a ref, only allow heads and tags Johannes Schindelin
2007-07-24 11:06 ` Johannes Schindelin [this message]
2007-07-24 11:23 ` [PATCH] filter-branch: rewrite only refs which were not excluded bythe options Johannes Sixt
2007-07-24 11:33 ` Johannes Schindelin
2007-07-24 13:32 ` [PATCH] filter-branch: rewrite only refs which were not excludedbythe options Johannes Sixt
2007-07-24 13:41 ` Johannes Schindelin
2007-07-24 14:08 ` Johannes Sixt
2007-07-24 14:21 ` Johannes Schindelin
2007-07-24 15:03 ` Johannes Sixt
2007-07-24 19:52 ` Johannes Schindelin
2007-07-24 13:42 ` [REVISED PATCH] filter-branch: rewrite only unexcluded refs Johannes Schindelin
2007-07-24 13:33 ` [PATCH] filter-branch: rewrite only refs which were not excludedbythe options Johannes Sixt
2007-07-24 13:46 ` Johannes Schindelin
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=Pine.LNX.4.64.0707241205480.14781@racer.site \
--to=johannes.schindelin@gmx.de \
--cc=J.Sixt@eudaptics.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).