git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH v3] filter-branch: fix errors caused by refs that point at non-committish

From
Junio C Hamano <gitster@pobox.com>
Date
Mar 25, 2018, 16:25 UTC
Message-ID
<xmqqr2o8f7hd.fsf@gitster-ct.c.googlers.com>
In-Reply-To
<1521920467-6091-1-git-send-email-orga.chem.job@gmail.com>
Yuki Kokubun <orga.chem.job@gmail.com> writes:
> "git filter-branch -- --all" print error messages when refs that point at
> objects that are not committish.

Grammo (third-person singular 'prints' misspelt without 's'; the "when" clause has a complex subject but no verb).

Perhaps this will salvage what you meant:
	"git filter-branch -- --all" prints error messages when
	processing refs that point at objects that are not
	committish.
Show 8 quoted lines
> 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.
> ---
Please sign-off your patch (cf. Documentation/SubmittingPatches).
Otherwise this round looks good.
Thanks.
Show 52 quoted lines
>  git-filter-branch.sh     | 14 ++++++++++++--
>  t/t7003-filter-branch.sh | 14 ++++++++++++++
>  2 files changed, 26 insertions(+), 2 deletions(-)
>
> diff --git a/git-filter-branch.sh b/git-filter-branch.sh
> index 1b7e4b2..41efecb 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."
> diff --git a/t/t7003-filter-branch.sh b/t/t7003-filter-branch.sh
> index 7cb6079..04f79f3 100755
> --- a/t/t7003-filter-branch.sh
> +++ b/t/t7003-filter-branch.sh
> @@ -470,4 +470,18 @@ test_expect_success 'tree-filter deals with object name vs pathname ambiguity' '
>  	git show HEAD:$ambiguous
>  '
>  
> +test_expect_success 'rewrite repository including refs that point at non-commit object' '
> +	test_when_finished "git reset --hard original" &&
> +	tree=$(git rev-parse HEAD^{tree}) &&
> +	test_when_finished "git replace -d $tree" &&
> +	echo A >new &&
> +	git add new &&
> +	new_tree=$(git write-tree) &&
> +	git replace $tree $new_tree &&
> +	git tag -a -m "tag to a tree" treetag $new_tree &&
> +	git reset --hard HEAD &&
> +	git filter-branch -f -- --all >filter-output 2>&1 &&
> +	! fgrep fatal filter-output
> +'
> +
>  test_done
Previous: Yuki KokubunNext: Yuki Kokubun
Message 13 of 20 in “filter-branch: consider refs/replace can refer to an object other than commit”
  1. filter-branch: consider refs/replace can refer to an object other than commitYuki Kokubun, Mar 21, 2018
  2. filter-branch: consider refs can refer to an object other than commit or tagYuki Kokubun, Mar 21, 2018
  3. Junio C HamanoMar 21, 2018
  4. Yuki KokubunMar 21, 2018
  5. Junio C HamanoMar 21, 2018
  6. Yuki KokubunMar 22, 2018
  7. Junio C HamanoMar 22, 2018
  8. Yuki KokubunMar 23, 2018
  9. filter-branch: fix errors caused by refs that cannot be used with ^0Yuki Kokubun, Mar 23, 2018
  10. Junio C HamanoMar 23, 2018
  11. Yuki KokubunMar 24, 2018
  12. filter-branch: fix errors caused by refs that point at non-committishYuki Kokubun, Mar 24, 2018
  13. Junio C HamanoMar 25, 2018
  14. Yuki KokubunMar 25, 2018
  15. Junio C HamanoMar 25, 2018
  16. filter-branch: fix errors caused by refs that point at non-committishYuki Kokubun, Mar 25, 2018
  17. Yuki KokubunMar 25, 2018
  18. Junio C HamanoApr 8, 2018
  19. filter-branch: fix errors caused by refs that point at non-committishYuki Kokubun, Mar 25, 2018
  20. Junio C HamanoMar 25, 2018

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.