Previously, we matched all refs that had /$ref in them. And tried to verify the result as a ref. If more than one match was found, the result was not a ref, though. So only allow tags and heads to be dwim'ed. If both a tag and a head with that name exist, it will be ignored again. Caught by Johannes Sixt. Signed-off-by: Johannes Schindelin <johannes.schindelin@xxxxxx> --- On Tue, 24 Jul 2007, Johannes Sixt wrote: > Johannes Schindelin wrote: > > +# These refs should be updated if their heads were rewritten > > + > > +git rev-parse --revs-only --symbolic "$@" | > > +while read ref > > +do > > + # normalize ref > > + case "$ref" in > > + HEAD) > > + ref="$(git symbolic-ref "$ref")" > > + ;; > > + refs/*) > > + ;; > > + *) > > + ref="$(git for-each-ref --format='%(refname)' | > > + grep /"$ref")" > > + esac > > + > > + git check-ref-format "$ref" && echo "$ref" > > +done > "$tempdir"/heads > > This does not work as I'd expected it: I can't successfully say: > > git-filter-branch master > > It tells me: > > Which ref do you want to rewrite? I tried that, and happily got the same. The explanation: more than one ref matched "/master". My pattern was extremely borked. Thanks. git-filter-branch.sh | 2 +- t/t7003-filter-branch.sh | 5 +++++ 2 files changed, 6 insertions(+), 1 deletions(-) diff --git a/git-filter-branch.sh b/git-filter-branch.sh index 0ff3475..019a302 100755 --- a/git-filter-branch.sh +++ b/git-filter-branch.sh @@ -193,7 +193,7 @@ do ;; *) ref="$(git for-each-ref --format='%(refname)' | - grep /"$ref")" + grep "refs/\(tags\|heads\)/$ref$")" esac git check-ref-format "$ref" && echo "$ref" diff --git a/t/t7003-filter-branch.sh b/t/t7003-filter-branch.sh index bc6e2dd..c9a820d 100755 --- a/t/t7003-filter-branch.sh +++ b/t/t7003-filter-branch.sh @@ -159,4 +159,9 @@ test_expect_success 'barf on invalid name' ' ! git filter-branch -f HEAD^ ' +test_expect_success 'only dwim refs/heads/$ref or refs/tags/$ref' ' + git update-ref refs/remotes/origin/master HEAD && + git filter-branch -f master +' + test_done -- 1.5.3.rc2.32.g35c5b-dirty - 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