summaryrefslogtreecommitdiffstats
path: root/git-filter-branch.sh
diff options
context:
space:
mode:
authorYuki Kokubun <orga.chem.job@gmail.com>2018-03-25 16:54:58 +0000
committerJunio C Hamano <gitster@pobox.com>2018-03-25 10:12:27 -0700
commitf78ab355e7d91c70faf41ddad9577cffc3b4ee60 (patch)
treeb0a7bb304abd2fd4c1d6163710eea8e2676ea428 /git-filter-branch.sh
parentGit 2.16.3 (diff)
downloadgit-f78ab355e7d91c70faf41ddad9577cffc3b4ee60.tar.xz
git-f78ab355e7d91c70faf41ddad9577cffc3b4ee60.zip
filter-branch: fix errors caused by refs that point at non-committish
"git filter-branch -- --all" prints error messages when processing refs that point at objects that are not committish. Such refs can be created by "git replace" with trees or blobs. And also "git tag" with trees or blobs can create such refs. Filter these problematic refs out early, before they are seen by the logic to see which refs have been modified and which have been left intact (which is where the unwanted error messages come from), and warn that these refs are left unwritten while doing so. Signed-off-by: Yuki Kokubun <orga.chem.job@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'git-filter-branch.sh')
-rwxr-xr-xgit-filter-branch.sh14
1 files changed, 12 insertions, 2 deletions
diff --git a/git-filter-branch.sh b/git-filter-branch.sh
index 1b7e4b2cdbd..41efecb284b 100755
--- a/git-filter-branch.sh
+++ b/git-filter-branch.sh
@@ -251,8 +251,18 @@ done < "$tempdir"/backup-refs
# The refs should be updated if their heads were rewritten
git rev-parse --no-flags --revs-only --symbolic-full-name \
- --default HEAD "$@" > "$tempdir"/raw-heads || exit
-sed -e '/^^/d' "$tempdir"/raw-heads >"$tempdir"/heads
+ --default HEAD "$@" > "$tempdir"/raw-refs || exit
+while read ref
+do
+ case "$ref" in ^?*) continue ;; esac
+
+ if git rev-parse --verify "$ref"^0 >/dev/null 2>&1
+ then
+ echo "$ref"
+ else
+ warn "WARNING: not rewriting '$ref' (not a committish)"
+ fi
+done >"$tempdir"/heads <"$tempdir"/raw-refs
test -s "$tempdir"/heads ||
die "You must specify a ref to rewrite."