Skip to content

Commit 98fe9e6

Browse files
peffgitster
authored andcommitted
filter-branch: drop multiple-ancestor warning
When a ref maps to a commit that is neither rewritten nor kept by filter-branch (e.g., because it was eliminated by rev-list's pathspec selection), we rewrite it to its nearest ancestor. Since the initial commit in 6f6826c (Add git-filter-branch, 2007-06-03), we have warned when there are multiple such ancestors in the map file. However, the warning code is impossible to trigger these days. Since a0e4639 (filter-branch: fix ref rewriting with --subdirectory-filter, 2008-08-12), we find the ancestor using "rev-list -1", so it can only ever have a single value. This code is made doubly confusing by the fact that we append to the map file when mapping ancestors. However, this can never yield multiple values because: - we explicitly check whether the map already exists, and if so, do nothing (so our "append" will always be to a file that does not exist) - even if we were to try mapping twice, the process to do so is deterministic. I.e., we'd always end up with the same ancestor for a given sha1. So warning about it would be pointless; there is no ambiguity. So swap out the warning code for a BUG (which we'll simplify further in the next commit). And let's stop using the append operator to make the ancestor-mapping code less confusing. Signed-off-by: Jeff King <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 6d875d1 commit 98fe9e6

File tree

1 file changed

+2
-9
lines changed

1 file changed

+2
-9
lines changed

git-filter-branch.sh

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -492,7 +492,7 @@ then
492492
sha1=$(git rev-parse "$ref"^0)
493493
test -f "$workdir"/../map/$sha1 && continue
494494
ancestor=$(git rev-list --simplify-merges -1 "$ref" "$@")
495-
test "$ancestor" && echo $(map $ancestor) >> "$workdir"/../map/$sha1
495+
test "$ancestor" && echo $(map $ancestor) >"$workdir"/../map/$sha1
496496
done < "$tempdir"/heads
497497
fi
498498

@@ -534,14 +534,7 @@ do
534534
fi
535535
;;
536536
*)
537-
# NEEDSWORK: possibly add -Werror, making this an error
538-
warn "WARNING: '$ref' was rewritten into multiple commits:"
539-
warn "$rewritten"
540-
warn "WARNING: Ref '$ref' points to the first one now."
541-
rewritten=$(echo "$rewritten" | head -n 1)
542-
git update-ref -m "filter-branch: rewrite to first" \
543-
"$ref" $rewritten $sha1 ||
544-
die "Could not rewrite $ref"
537+
die "BUG: multiple ancestors in map file?"
545538
;;
546539
esac
547540
git update-ref -m "filter-branch: backup" "$orig_namespace$ref" $sha1 ||

0 commit comments

Comments
 (0)