git: 548548649f9e - main - git-arc: Use --head to avoid changing the checkout.
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Wed, 17 Aug 2022 23:19:49 UTC
The branch main has been updated by jhb:
URL: https://cgit.FreeBSD.org/src/commit/?id=548548649f9e31d961db5d4956cbf53dff525054
commit 548548649f9e31d961db5d4956cbf53dff525054
Author: John Baldwin <jhb@FreeBSD.org>
AuthorDate: 2022-08-17 23:19:31 +0000
Commit: John Baldwin <jhb@FreeBSD.org>
CommitDate: 2022-08-17 23:19:31 +0000
git-arc: Use --head to avoid changing the checkout.
Rather than using 'git checkout' to move to the commit in question for
create and update, use the '--head' argument to 'arc diff'. This
avoids the need to alter the current checkout and the related bits to
save/restore HEAD in the current checkout.
Reviewed by: imp, markj
Differential Revision: https://reviews.freebsd.org/D36248
---
tools/tools/git/git-arc.sh | 34 ++++------------------------------
1 file changed, 4 insertions(+), 30 deletions(-)
diff --git a/tools/tools/git/git-arc.sh b/tools/tools/git/git-arc.sh
index b33affe459b0..66372969de04 100644
--- a/tools/tools/git/git-arc.sh
+++ b/tools/tools/git/git-arc.sh
@@ -245,8 +245,6 @@ create_one_review()
return 1
fi
- git checkout -q "$commit"
-
msg=$(mktemp)
git show -s --format='%B' "$commit" > "$msg"
printf "\nTest Plan:\n" >> "$msg"
@@ -256,7 +254,8 @@ create_one_review()
printf "%s\n" "${subscribers}" >> "$msg"
yes | env EDITOR=true \
- arc diff --message-file "$msg" --never-apply-patches --create --allow-untracked $BROWSE HEAD~
+ arc diff --message-file "$msg" --never-apply-patches --create \
+ --allow-untracked $BROWSE --head "$commit" "${commit}~"
[ $? -eq 0 ] || err "could not create Phabricator diff"
if [ -n "$parent" ]; then
@@ -333,24 +332,6 @@ show_and_prompt()
prompt
}
-save_head()
-{
- local orig
-
- if ! orig=$(git symbolic-ref --short -q HEAD); then
- orig=$(git show -s --pretty=%H HEAD)
- fi
- SAVED_HEAD=$orig
-}
-
-restore_head()
-{
- if [ -n "$SAVED_HEAD" ]; then
- git checkout -q "$SAVED_HEAD"
- SAVED_HEAD=
- fi
-}
-
build_commit_list()
{
local chash _commits commits
@@ -410,7 +391,6 @@ gitarc__create()
doprompt=
fi
- save_head
for commit in ${commits}; do
if create_one_review "$commit" "$reviewers" "$subscribers" "$prev" \
"$doprompt"; then
@@ -419,7 +399,6 @@ gitarc__create()
prev=""
fi
done
- restore_head
}
gitarc__list()
@@ -524,7 +503,6 @@ gitarc__update()
local commit commits diff
commits=$(build_commit_list "$@")
- save_head
for commit in ${commits}; do
diff=$(commit2diff "$commit")
@@ -532,14 +510,12 @@ gitarc__update()
break
fi
- git checkout -q "$commit"
-
# The linter is stupid and applies patches to the working copy.
# This would be tolerable if it didn't try to correct "misspelled" variable
# names.
- arc diff --allow-untracked --never-apply-patches --update "$diff" HEAD~
+ arc diff --allow-untracked --never-apply-patches --update "$diff" \
+ --head "$commit" "${commit}~"
done
- restore_head
}
set -e
@@ -613,6 +589,4 @@ if [ "$(git config --bool --get arc.browse 2>/dev/null || echo false)" != "false
BROWSE=--browse
fi
-trap restore_head EXIT INT
-
gitarc__"${verb}" "$@"