From b170479336afa1577c70db5d9c9a8c0c86441245 Mon Sep 17 00:00:00 2001 From: Andrew Robbins Date: Mon, 11 Mar 2019 14:15:44 -0400 Subject: libs/git: Clean up after patch fails to apply A patch failing to apply shouldn't leave the repository in such a state where manual intervention is necessary to reset it. --- libs/git | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'libs') diff --git a/libs/git b/libs/git index 1ca2358e..03df3537 100755 --- a/libs/git +++ b/libs/git @@ -179,7 +179,8 @@ git_patch() { cd "$repository_path" git checkout "$branch" 2> /dev/null > /dev/null - git am "$patch" + + git am "$patch" || git am --abort ) } -- cgit v1.2.3-70-g09d2 From 53ab906c8ecdbfc204887b20f8ed157caf4e0314 Mon Sep 17 00:00:00 2001 From: Andrew Robbins Date: Mon, 11 Mar 2019 14:53:06 -0400 Subject: libs/git: Prefix branch names with "libreboot-" This is a slight mitigation against branch name collisions. More robust handling should be added in the future but this is simple enough and provides some clear indication which branches have been created by the build system. --- libs/git | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'libs') diff --git a/libs/git b/libs/git index 03df3537..3d9facee 100755 --- a/libs/git +++ b/libs/git @@ -15,6 +15,7 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . +BRANCH_PREFIX="libreboot-" DOTGIT=".git" HEAD="HEAD" ORIGIN_HEAD="origin/HEAD" @@ -325,7 +326,7 @@ git_project_prepare_patch() { local configs_path="$project_path/$CONFIGS" local prepare_branch local prepare_path - local branch=$project + local branch=$BRANCH_PREFIX$project local argument local path @@ -371,7 +372,7 @@ git_project_prepare_revision() { local configs_path="$project_path/$CONFIGS" local prepare_branch local prepare_revision - local branch=$project + local branch=$BRANCH_PREFIX$project local argument local path @@ -416,7 +417,7 @@ git_project_prepare_check() { local project_path=$(project_path "$project") local configs_path="$project_path/$CONFIGS" local prepare_branch - local branch=$project + local branch=$BRANCH_PREFIX$project local argument local path @@ -458,7 +459,7 @@ git_project_prepare_clean() { local repository_path=$(git_project_repository_path "$repository") local prepare_branch - local branch=$project + local branch=$BRANCH_PREFIX$project local argument for argument in "" "$@" @@ -500,7 +501,7 @@ git_project_checkout() { local repository_path=$(git_project_repository_path "$repository") local checkout_branch - local branch=$project + local branch=$BRANCH_PREFIX$project local argument for argument in "" "$@" @@ -560,7 +561,7 @@ git_project_release() { local repository_path=$(git_project_repository_path "$repository") local release_branch - local branch=$project + local branch=$BRANCH_PREFIX$project local argument for argument in "" "$@" @@ -601,7 +602,7 @@ git_project_release_check() { local repository_path=$(git_project_repository_path "$repository") local release_branch - local branch=$project + local branch=$BRANCH_PREFIX$project local argument for argument in "" "$@" -- cgit v1.2.3-70-g09d2 From 925564a0653486f4076de06e2498bf75bb9f2f85 Mon Sep 17 00:00:00 2001 From: Andrew Robbins Date: Tue, 12 Mar 2019 22:35:59 -0400 Subject: libs/git: Create branch name based on argument list There was a bug where only $project was used as the branch name due to some faulty logic which checked for the existence of a revision file before setting the variables "prepare_branch" and "prepare_path". The bug in this case was that prepare_branch would be set to the value of $branch in only the first iteration of the for loop since in almost all cases there is only one revision file that exists for a given project, regardless of the arguments provided. Explained another way, in order for the proper branch name to be used a revision file would have had to exist in every target directory. This was an issue because only one branch was ever operated on (named $project), meaning if actions were performed on many targets then only the last to run would be represented in the project's repository--making tracking down some bugs a bit harder. With this fixed we now create a branch for every possible project or tool configuration and leaves us with a log for each. --- libs/git | 20 ++------------------ 1 file changed, 2 insertions(+), 18 deletions(-) (limited to 'libs') diff --git a/libs/git b/libs/git index 3d9facee..48499921 100755 --- a/libs/git +++ b/libs/git @@ -344,13 +344,6 @@ git_project_prepare_patch() { branch="$branch-$argument" fi - local revision_path="$configs_path/$path/$REVISION" - - if ! [[ -f "$revision_path" ]] - then - continue - fi - prepare_branch=$branch prepare_path=$path done @@ -392,13 +385,11 @@ git_project_prepare_revision() { local revision_path="$configs_path/$path/$REVISION" - if ! [[ -f "$revision_path" ]] - then - continue + if [[ -f $revision_path ]]; then + prepare_revision=$(< "$revision_path") fi prepare_branch=$branch - prepare_revision=$(cat "$revision_path") done if [[ -n "$prepare_branch" ]] @@ -435,13 +426,6 @@ git_project_prepare_check() { branch="$branch-$argument" fi - local revision_path="$configs_path/$path/$REVISION" - - if ! [[ -f "$revision_path" ]] - then - continue - fi - prepare_branch=$branch done -- cgit v1.2.3-70-g09d2 From bd84ece1d42d00d48357ab31ca85a2f2f546fd84 Mon Sep 17 00:00:00 2001 From: Andrew Robbins Date: Wed, 13 Mar 2019 20:02:05 -0400 Subject: libs/git: Actually patch recursively Previously the only way patching would work is if for every target there existed a corresponding directory under $project/$PATCHES, e.g: "./libreboot update coreboot x200 8MiB corebootfb grub" would require the "grub" directory and its parents: "projects/coreboot/patches/x200/8MiB/corebootfb/grub" Now you only need target-specific patch directories if you need them; I believe this was the intended behavior. Superfluous quotes were removed for readability. --- libs/git | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'libs') diff --git a/libs/git b/libs/git index 48499921..5f48005d 100755 --- a/libs/git +++ b/libs/git @@ -228,25 +228,25 @@ git_project_check() { } git_project_patch_recursive() { - local project="$1" - local repository="$2" - local branch="$3" - local path="${4:-.}" + local project=$1 + local repository=$2 + local branch=$3 + local path=$4 - local repository_path="$(git_project_repository_path "$repository")" - local project_path="$(project_path "$project")" - local patches_path="$project_path/$PATCHES/$path" + local repository_path=$(git_project_repository_path "$repository") + local project_path=$(project_path "$project") + local patches_path=$project_path/$PATCHES/$path - if ! [[ -d "$patches_path" ]]; then + if ! [[ -d $project_path/$PATCHES ]]; then return fi - if [[ "$path" != "." ]]; then + if [[ $path != . ]]; then git_project_patch_recursive "$project" "$repository" "$branch" "$(dirname "$path")" fi for patch in "$patches_path"/[!.]*.@(patch|diff); do - if [[ "${patch##*.}" == "patch" ]]; then + if [[ ${patch##*.} == patch ]]; then git_patch "$repository_path" "$branch" "$patch" else diff_patch_file "$repository_path" "$patch" -- cgit v1.2.3-70-g09d2 From a4bcf4852289c58852b308eab94e9bc48b7ef814 Mon Sep 17 00:00:00 2001 From: Andrew Robbins Date: Wed, 13 Mar 2019 21:04:07 -0400 Subject: libs/git: Apply patches before removing blobs Patching before removing blobs is cleaner since patches are applied against a freshly created and checked out branch at the specified revision. Applying patches first also seems to reduce the likelihood of failed patching attempts due to a nebulous error about files not matching the git index (but doesn't eliminate it). More debugging required. --- libs/git | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'libs') diff --git a/libs/git b/libs/git index 5f48005d..16dd5411 100755 --- a/libs/git +++ b/libs/git @@ -289,8 +289,8 @@ git_project_prepare() { shift git_project_prepare_revision "$project" "$repository" "$@" - git_project_prepare_blobs "$project" "$repository" "$@" git_project_prepare_patch "$project" "$repository" "$@" + git_project_prepare_blobs "$project" "$repository" "$@" } git_project_prepare_blobs() { -- cgit v1.2.3-70-g09d2