Skip to content

Commit 7cac75d

Browse files
jrosdahladmorgan
authored andcommitted
Make “git subrepo clean -f ...” delete refs correctly
Since Git can store refs in packed form (see git-pack-refs(1)), use “git update-ref -d” to delete refs instead of assuming that they are stored in the .git/refs directory.
1 parent bb6139a commit 7cac75d

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

lib/git-subrepo

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -963,11 +963,15 @@ subrepo:clean() {
963963

964964
if "$force_wanted"; then
965965
o "Remove all subrepo refs."
966-
if "$all_wanted"; then
967-
RUN rm -fr .git/refs/subrepo/
968-
else
969-
RUN rm -fr .git/refs/subrepo/$subref/
966+
local suffix=""
967+
if ! $all_wanted; then
968+
suffix="$subref/"
970969
fi
970+
git show-ref | while read hash ref; do
971+
if [[ "$ref" == refs/subrepo/$suffix* ]]; then
972+
git update-ref -d "$ref"
973+
fi
974+
done
971975
fi
972976
}
973977

0 commit comments

Comments
 (0)