From e681d7cd9679244fe7f43ce9e66b8cf83f706d8a Mon Sep 17 00:00:00 2001 From: Andrew Robbins Date: Mon, 25 Mar 2019 01:35:45 -0400 Subject: libs/git: Commit only if any blobs were removed git_diff_check() was added for future use since it's complementary to git_diff_staged_check(). It could be used to check for a dirty worktree, for example. --- libs/git | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/libs/git b/libs/git index a83f2246..6fbd2302 100755 --- a/libs/git +++ b/libs/git @@ -141,6 +141,26 @@ git_remove() { ) } +git_diff_staged_check() { + local repository_path=$1 + + ( + cd "$repository_path" + + git diff --staged --quiet + ) +} + +git_diff_check() { + local repository_path=$1 + + ( + cd "$repository_path" + + git diff --quiet + ) +} + git_commit() { local repository_path=$1 local message=$2 @@ -340,7 +360,10 @@ git_project_prepare_blobs() { git_remove "$repository_path" "$blob" done < "$blobs_path" - git_commit "$repository_path" "Removed blobs" + if ! git_diff_staged_check "$repository_path" + then + git_commit "$repository_path" "Removed blobs" + fi } git_project_prepare_patch() { -- cgit v1.2.3-70-g09d2