Yuki Kokubun <orga.chem.job@xxxxxxxxx> writes: >> Yuki Kokubun <orga.chem.job@xxxxxxxxx> writes: >> >> >> Yuki Kokubun <orga.chem.job@xxxxxxxxx> writes: >> >> >> >> > "git filter-branch -- --all" can be confused when refs that refer to objects >> >> > other than commits or tags exists. >> ... > > I meant the confusion is abnormal messages from the output of "git filter-branch -- --all". OK, so it is not that the program logic gets confused and ends up performing a wrong rewrite, but mostly that it gives confusing messages. > For example, this is an output of "git filter-branch -- --all": > > Rewrite bcdbd016c77df3d5641a3cf820b2ed46ba7bf3b4 (5/5) (0 seconds passed, remaining 0 predicted) > WARNING: Ref 'refs/heads/master' is unchanged > WARNING: Ref 'refs/heads/no-newline' is unchanged > WARNING: Ref 'refs/heads/original' is unchanged These are worth keeping, as I think existing users expect to see them. > error: object 1bf53b49c26465454e4ac377f2ed3f91bb1d6ac1 is a tree, not a commit > error: object 1bf53b49c26465454e4ac377f2ed3f91bb1d6ac1 is a tree, not a commit > fatal: ambiguous argument 'refs/replace/8a2016f3730cad8309c110f819c855403ed0a5b9^0': unknown revision or path not in the working tree. > Use '--' to separate paths from revisions, like this: > 'git <command> [<revision>...] -- [<file>...]' > WARNING: Ref 'refs/replace/8a2016f3730cad8309c110f819c855403ed0a5b9' is unchanged > WARNING: Ref 'refs/tags/add-file' is unchanged > WARNING: Ref 'refs/tags/file' is unchanged > error: object 1bf53b49c26465454e4ac377f2ed3f91bb1d6ac1 is a tree, not a commit > error: object 1bf53b49c26465454e4ac377f2ed3f91bb1d6ac1 is a tree, not a commit > fatal: ambiguous argument 'refs/tags/treetag^0': unknown revision or path not in the working tree. > Use '--' to separate paths from revisions, like this: > 'git <command> [<revision>...] -- [<file>...]' > WARNING: Ref 'refs/tags/treetag' is unchanged I think these warning messages should be kept, especially if we are to keep the warning messages for the unchanged branches. However, the internal error messages are unwanted--these are implementation details that reach the conclusion, i.e. the ref we were asked to rewrite ended up being unchanged hence we did not touch it. However, if we pre-filter to limit the refs in "$tempdir/heads" to those that are committish (i.e. those that pass "$ref^0") like the patch and subsequent discussion suggests, wouldn't we lose the warning for these replace refs and non-committish tags. We perhaps could do something like: git rev-parse --no-flags ... >"$tempdir/raw-heads" || exit while read ref do case "$ref" in ^?*) continue ;; esac if git rev-parse --verify "$ref^0" 2>/dev/null then echo "$ref" else warn "WARNING: not rewriting '$ref' (not a committish)" fi done >"$tempdir/heads" <"$tempdir/raw-heads" (note: the else clause is new, relative to my earlier suggestion).