From 06bc34e586d871b688bf2abcbd46968543a5a388 Mon Sep 17 00:00:00 2001 From: DarkWiiPlayer Date: Tue, 10 Sep 2024 09:20:23 +0200 Subject: [PATCH] Add permanent mode to git as --- bin/git-as | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/bin/git-as b/bin/git-as index bdd9a08..6045dbd 100755 --- a/bin/git-as +++ b/bin/git-as @@ -1,9 +1,18 @@ #!/bin/sh user=$1 shift 1 -export GIT_AUTHOR_NAME="$(git config user.$user.name)" -export GIT_AUTHOR_EMAIL="$(git config user.$user.email)" -export GIT_COMMITTER_NAME="$(git config user.$user.name)" -export GIT_COMMITTER_EMAIL="$(git config user.$user.email)" -echo "Running as $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL>" -git "$@" +if [ -z "$@" ] +then + # Run as `eval $(git as identity)` or prepend with git command + echo export GIT_AUTHOR_NAME="'$(git config user.$user.name)'" + echo export GIT_AUTHOR_EMAIL="'$(git config user.$user.email)'" + echo export GIT_COMMITTER_NAME="'$(git config user.$user.name)'" + echo export GIT_COMMITTER_EMAIL="'$(git config user.$user.email)'" +else + export GIT_AUTHOR_NAME="$(git config user.$user.name)" + export GIT_AUTHOR_EMAIL="$(git config user.$user.email)" + export GIT_COMMITTER_NAME="$(git config user.$user.name)" + export GIT_COMMITTER_EMAIL="$(git config user.$user.email)" + echo "Running as $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL>" + git "$@" +fi