From 2e649f71e0bc00324654788b7c9c1c7efe5490d9 Mon Sep 17 00:00:00 2001 From: Sergio Durigan Junior Date: Wed, 25 Jul 2018 17:35:59 -0400 Subject: [PATCH] Improve error handling on generate-* scripts --- generate-git-repo-from-patches.sh | 6 ++++++ generate-patches-from-git-repo.sh | 4 ++++ 2 files changed, 10 insertions(+) diff --git a/generate-git-repo-from-patches.sh b/generate-git-repo-from-patches.sh index 8f68477..490cca9 100755 --- a/generate-git-repo-from-patches.sh +++ b/generate-git-repo-from-patches.sh @@ -35,8 +35,14 @@ test -f _git_upstream_commit || die "Cannot find _git_upstream_commit file." test -f _patch_order || die "Cannot find _patch_order file." last_ancestor_commit=`cat _git_upstream_commit` + cd $1 + +git name-rev $last_ancestor_commit +test $? -eq 0 || die "Could not find $last_ancestor_commit in the repository $1. Did you run 'git fetch'?" + git checkout $last_ancestor_commit for p in `cat ../_patch_order` ; do git am ../$p + test $? -eq 0 || die "Could not apply patch '$p'." done diff --git a/generate-patches-from-git-repo.sh b/generate-patches-from-git-repo.sh index 3d454b7..faa64a2 100755 --- a/generate-patches-from-git-repo.sh +++ b/generate-patches-from-git-repo.sh @@ -51,6 +51,10 @@ for f in `cat _patch_order` ; do done cd $1 + +git name-rev $commit_or_tag +test $? -eq 0 || die "Could not find $commit_or_tag in the repository. Did you run 'git fetch'?" + idx=1 common_ancestor=`git merge-base HEAD $commit_or_tag`