Skip to content

Commit

Permalink
basic rollback on the first stage of migration
Browse files Browse the repository at this point in the history
tag relocation is unlikely to fail

Signed-off-by: Denis Zalevskiy <denis.zalevskiy@jolla.com>
  • Loading branch information
Denis Zalevskiy committed Oct 25, 2014
1 parent 2e9d4ee commit 0557420
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 12 deletions.
37 changes: 31 additions & 6 deletions tools/git-vault-gc.sh
Expand Up @@ -79,10 +79,39 @@ fi

cmd=$(gen_cmd)

function git_gc {
echo "GC"
git prune
git gc --aggressive
echo "PRUNE+"
git prune
}

function rollback {
echo "ROLLBACK"
git reset --hard
git clean -fd
git checkout master
git branch -D migrate
for t in $(git tag | grep '^migrate/'); do
git tag -d "$t"
done
git_gc
error "during migration"
}

export -f rollback

eval "$cmd" || error "$cmd"

echo "REPLACE MASTER"
# do it separetely to be on the safe side
(git branch -D master && git branch -m migrate master) || error "replacing master"

echo "CLEAR REFLOG"
git reflog expire --expire=now --all || error "exiring reflog"

echo "Removing dangling blobs"
echo "REMOVING DANGLING BLOBS"
for obj in $(git fsck --unreachable master \
| grep '^unreachable blob' \
| sed 's/unreachable blob //'); do
Expand All @@ -95,9 +124,5 @@ for obj in $(git fsck --unreachable master \
|| echo "No such blob $blob"
done
done
echo "git prune+gc"
git prune
git gc --aggressive
echo "git prune"
git prune
git_gc
echo "OK"
11 changes: 5 additions & 6 deletions tools/git-vault-rebase-generate.awk
Expand Up @@ -98,16 +98,15 @@ $1 == "start" {
}

END {
for (i = 1; i <= length(move_tags); i++) {
push_command(move_tags[i]);
}
push_command("git branch -D master");
push_command("git branch -m migrate master");
res = ""
res = "(("
sep = ""
for (i = 1; i <= length(commands); i++) {
res = res sep commands[i];
sep = " && \\\n\t"
}
res = res ") || rollback)"
for (i = 1; i <= length(move_tags); i++) {
res = res sep move_tags[i];
}
print res;
}

0 comments on commit 0557420

Please sign in to comment.