From 882b08e7beaa2c62f6f200fe22854b405774dc33 Mon Sep 17 00:00:00 2001 From: "Kyle J. McKay" Date: Sun, 10 Jul 2016 07:12:29 -0700 Subject: [PATCH] hg-fast-export.sh: prune notes on missing marks If --hg-hash is given and any marks were found to be missing (i.e. gc'd), prune the refs/notes/hg tree if it exists. Signed-off-by: Kyle J. McKay --- hg-fast-export.sh | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/hg-fast-export.sh b/hg-fast-export.sh index 35d9860..331979c 100755 --- a/hg-fast-export.sh +++ b/hg-fast-export.sh @@ -94,6 +94,17 @@ if [ -f "$GIT_DIR/$PFX-$SFX_MARKS" -a -s "$GIT_DIR/$PFX-$SFX_MARKS" ] ; then LC_ALL=C sed 's/^:\([^ ][^ ]*\) \([^ ][^ ]*\)$/\2 \1/' <"$GIT_DIR/$PFX-$SFX_MARKS" | \ git cat-file --batch-check=':%(rest) %(objectname)' | \ LC_ALL=C sed '/ missing$/d' >"$GIT_DIR/$PFX-$SFX_MARKS.old" + notes= + for arg; do if [ "$arg" = "--hg-hash" ]; then notes=1; break; fi; done + # for --hg-hash run "notes prune" on refs/notes/hg if it exists and any marks were missing + if [ -n "$notes" ] && \ + git rev-parse --quiet --verify refs/notes/hg >/dev/null && \ + ! LC_ALL=C cmp -s "$GIT_DIR/$PFX-$SFX_MARKS" "$GIT_DIR/$PFX-$SFX_MARKS.old"; then + nm='hg-fast-export' + GIT_AUTHOR_NAME="$nm" GIT_COMMITTER_NAME="$nm" \ + GIT_AUTHOR_EMAIL="$nm" GIT_COMMITTER_EMAIL="$nm" \ + git notes --ref=refs/notes/hg prune + fi else # make sure we have a marks cache >"$GIT_DIR/$PFX-$SFX_MARKS.old" -- 2.11.4.GIT