From: Junio C Hamano Date: Tue, 10 Apr 2018 07:28:23 +0000 (+0900) Subject: Merge branch 'yk/filter-branch-non-committish-refs' X-Git-Tag: v2.18.0-rc0~152 X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/9aa3a4c406e1db08269cc8f6e8757555bd771120?ds=inline;hp=-c Merge branch 'yk/filter-branch-non-committish-refs' when refs that do not point at committish are given, "git filter-branch" gave a misleading error messages. This has been corrected. * yk/filter-branch-non-committish-refs: filter-branch: fix errors caused by refs that point at non-committish --- 9aa3a4c406e1db08269cc8f6e8757555bd771120 diff --combined git-filter-branch.sh index 2587a01b9b,41efecb284..64f21547c1 --- a/git-filter-branch.sh +++ b/git-filter-branch.sh @@@ -251,8 -251,18 +251,18 @@@ done < "$tempdir"/backup-ref # 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." @@@ -310,7 -320,7 +320,7 @@@ git rev-list --reverse --topo-order --d die "Could not get the commits" commits=$(wc -l <../revs | tr -d " ") -test $commits -eq 0 && die "Found nothing to rewrite" +test $commits -eq 0 && die_with_status 2 "Found nothing to rewrite" # Rewrite the commits report_progress () @@@ -627,12 -637,12 +637,12 @@@ the print H "$_:$f\n" or die; } close(H) or die;' || die "Unable to save state") - state_tree=$(/bin/echo -e "100644 blob $state_blob\tfilter.map" | git mktree) + state_tree=$(printf '100644 blob %s\tfilter.map\n' "$state_blob" | git mktree) if test -n "$state_commit" then - state_commit=$(/bin/echo "Sync" | git commit-tree "$state_tree" -p "$state_commit") + state_commit=$(echo "Sync" | git commit-tree "$state_tree" -p "$state_commit") else - state_commit=$(/bin/echo "Sync" | git commit-tree "$state_tree" ) + state_commit=$(echo "Sync" | git commit-tree "$state_tree" ) fi git update-ref "$state_branch" "$state_commit" fi