Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F139391852
D47274.id145416.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
10 KB
Referenced Files
None
Subscribers
None
D47274.id145416.diff
View Options
diff --git a/tools/tools/git/git-arc.sh b/tools/tools/git/git-arc.sh
--- a/tools/tools/git/git-arc.sh
+++ b/tools/tools/git/git-arc.sh
@@ -34,7 +34,7 @@
warn()
{
- echo "$(basename "$0"): $1" >&2
+ printf '%s\n' "$(basename "$0"): $1" >&2
}
err()
@@ -154,7 +154,7 @@
#
get_bool_config()
{
- test "$(git config --bool --get "$1" 2>/dev/null || echo "$2")" != "false"
+ test "$(git config --bool --get "$1" 2>/dev/null || printf '%s\n' "$2")" != "false"
}
#
@@ -186,7 +186,7 @@
err "invalid diff ID $diff"
fi
- echo '{"names":["'"$diff"'"]}' |
+ printf '%s\n' '{"names":["'"$diff"'"]}' |
arc_call_conduit -- phid.lookup |
jq -r "select(.response != []) | .response.${diff}.phid"
}
@@ -201,7 +201,7 @@
fi
tmp=$(mktemp)
- echo '{"names":["'"$diff"'"]}' |
+ printf '%s\n' '{"names":["'"$diff"'"]}' |
arc_call_conduit -- phid.lookup > "$tmp"
status=$(jq -r "select(.response != []) | .response.${diff}.status" < "$tmp")
summary=$(jq -r "select(.response != []) |
@@ -215,10 +215,10 @@
diff=$(git show -s --format=%B "$commit" |
sed -nE '/^Differential Revision:[[:space:]]+(https:\/\/reviews.freebsd.org\/)?(D[0-9]+)$/{s//\2/;p;}')
- if [ -n "$diff" ] && [ "$(echo "$diff" | wc -l)" -eq 1 ]; then
- echo "$diff"
+ if [ -n "$diff" ] && [ "$(printf '%s\n' "$diff" | wc -l)" -eq 1 ]; then
+ printf '%s\n' "$diff"
else
- echo
+ printf '\n'
fi
}
@@ -228,7 +228,7 @@
{
local title
- title=$(echo "$1" | sed 's/"/\\"/g')
+ title=$(printf '%s\n' "$1" | sed 's/"/\\"/g')
arc_list --no-ansi |
awk -F': ' '{
if (substr($0, index($0, FS) + length(FS)) == "'"$title"'") {
@@ -247,7 +247,7 @@
# log.
diff=$(log2diff "$commit")
if [ -n "$diff" ]; then
- echo "$diff"
+ printf '%s\n' "$diff"
return
fi
@@ -257,11 +257,11 @@
diff=$(title2diff "$title")
if [ -z "$diff" ]; then
err "could not find review for '${title}'"
- elif [ "$(echo "$diff" | wc -l)" -ne 1 ]; then
+ elif [ "$(printf '%s\n' "$diff" | wc -l)" -ne 1 ]; then
err "found multiple reviews with the same title"
fi
- echo "$diff"
+ printf '%s\n' "$diff"
}
create_one_review()
@@ -298,7 +298,7 @@
childphid=$(diff2phid "$diff")
parentphid=$(diff2phid "$parent")
- echo '{
+ printf '%s\n' '{
"objectIdentifier": "'"${childphid}"'",
"transactions": [
{
@@ -320,15 +320,15 @@
diff=$1
reviewid=$(diff2phid "$diff")
userids=$( \
- echo '{
+ printf '%s\n' '{
"constraints": {"phids": ["'"$reviewid"'"]},
"attachments": {"reviewers": true}
}' |
arc_call_conduit -- differential.revision.search |
jq '.response.data[0].attachments.reviewers.reviewers[] | select(.status == "accepted").reviewerPHID')
if [ -n "$userids" ]; then
- echo '{
- "constraints": {"phids": ['"$(echo -n "$userids" | tr '[:space:]' ',')"']}
+ printf '%s\n' '{
+ "constraints": {"phids": ['"$(printf '%s' "$userids" | tr '[:space:]' ',')"']}
}' |
arc_call_conduit -- user.search |
jq -r '.response.data[].fields.username'
@@ -379,7 +379,7 @@
[ -n "$_commits" ] || err "invalid commit ID ${chash}"
commits="$commits $_commits"
done
- echo "$commits"
+ printf '%s\n' "$commits"
}
gitarc__create()
@@ -444,7 +444,7 @@
for commit in $commits; do
chash=$(git show -s --format='%C(auto)%h' "$commit")
- echo -n "${chash} "
+ printf '%s' "${chash} "
diff=$(log2diff "$commit")
if [ -n "$diff" ]; then
@@ -455,17 +455,17 @@
# This does not use commit2diff as it needs to handle errors
# differently and keep the entire status.
title=$(git show -s --format=%s "$commit")
- diff=$(echo "$openrevs" | \
+ diff=$(printf '%s\n' "$openrevs" | \
awk -F'D[1-9][0-9]*: ' \
- '{if ($2 == "'"$(echo "$title" | sed 's/"/\\"/g')"'") print $0}')
+ '{if ($2 == "'"$(printf '%s\n' "$title" | sed 's/"/\\"/g')"'") print $0}')
if [ -z "$diff" ]; then
- echo "No Review : $title"
- elif [ "$(echo "$diff" | wc -l)" -ne 1 ]; then
- echo -n "Ambiguous Reviews: "
- echo "$diff" | grep -E -o 'D[1-9][0-9]*:' | tr -d ':' \
+ printf '%s\n' "No Review : $title"
+ elif [ "$(printf '%s\n' "$diff" | wc -l)" -ne 1 ]; then
+ printf '%s' "Ambiguous Reviews: "
+ printf '%s\n' "$diff" | grep -E -o 'D[1-9][0-9]*:' | tr -d ':' \
| paste -sd ',' - | sed 's/,/, /g'
else
- echo "$diff" | sed -e 's/^[^ ]* *//'
+ printf '%s\n' "$diff" | sed -e 's/^[^ ]* *//'
fi
done
}
@@ -493,7 +493,7 @@
case "${addr}" in
*.*) ;; # external user
*)
- echo "${name} <${addr}@FreeBSD.org>"
+ printf '%s\n' "${name} <${addr}@FreeBSD.org>"
return
;;
esac
@@ -501,16 +501,16 @@
# Choice 2: author_addr and author_name were set in the bundle, so use
# that. We may need to filter some known bogus ones, should they crop up.
if [ -n "$author_name" -a -n "$author_addr" ]; then
- echo "${author_name} <${author_addr}>"
+ printf '%s\n' "${author_name} <${author_addr}>"
return
fi
# Choice 3: We can find this user in the FreeBSD repo. They've submited
# something before, and they happened to use an email that's somewhat
# similar to their phab username.
- email=$(git log -1 --author "$(echo "${addr}" | tr _ .)" --pretty="%aN <%aE>")
+ email=$(git log -1 --author "$(printf '%s\n' "${addr}" | tr _ .)" --pretty="%aN <%aE>")
if [ -n "${email}" ]; then
- echo "${email}"
+ printf '%s\n' "${email}"
return
fi
@@ -518,10 +518,10 @@
# to use the same name, unless the name has the word 'user' in it. This
# might not be a good idea, since names can be somewhat common (there
# are two Andrew Turners that have contributed to FreeBSD, for example).
- if ! (echo "${name}" | grep -w "[Uu]ser" -q); then
+ if ! (printf '%s\n' "${name}" | grep -w "[Uu]ser" -q); then
email=$(git log -1 --author "${name}" --pretty="%aN <%aE>")
if [ -n "$email" ]; then
- echo "$email"
+ printf '%s\n' "$email"
return
fi
fi
@@ -531,13 +531,13 @@
# Annoying fun fact: Phab replaces all non alpha-numerics with _, so we
# don't know if the prior _ are _ or + or any number of other characters.
# Since there's issues here, prompt
- a=$(printf "%s <%s>\n" "${name}" $(echo "$addr" | sed -e 's/\(.*\)_/\1@/'))
- echo "Making best guess: Truning ${addr} to ${a}"
+ a=$(printf "%s <%s>\n" "${name}" $(printf '%s\n' "$addr" | sed -e 's/\(.*\)_/\1@/'))
+ printf '%s\n' "Making best guess: Truning ${addr} to ${a}"
if ! prompt; then
- echo "ABORT"
+ printf '%s\n' "ABORT"
return
fi
- echo "${a}"
+ printf '%s\n' "${a}"
}
patch_commit()
@@ -548,31 +548,31 @@
diff=$1
reviewid=$(diff2phid "$diff")
# Get the author phid for this patch
- review_data=$(echo '{
+ review_data=$(printf '%s\n' '{
"constraints": {"phids": ["'"$reviewid"'"]}
}' |
arc_call_conduit -- differential.revision.search)
- authorid=$(echo "$review_data" | jq -r '.response.data[].fields.authorPHID' )
+ authorid=$(printf '%s\n' "$review_data" | jq -r '.response.data[].fields.authorPHID' )
# Get metadata about the user that submitted this patch
- user_data=$(echo '{
+ user_data=$(printf '%s\n' '{
"constraints": {"phids": ["'"$authorid"'"]}
}' |
arc call-conduit -- user.search | grep -v ^Warning: |
jq -r '.response.data[].fields')
- user_addr=$(echo "$user_data" | jq -r '.username')
- user_name=$(echo "$user_data" | jq -r '.realName')
+ user_addr=$(printf '%s\n' "$user_data" | jq -r '.username')
+ user_name=$(printf '%s\n' "$user_data" | jq -r '.realName')
# Dig the data out of querydiffs api endpoint, although it's deprecated,
# since it's one of the few places we can get email addresses. It's unclear
# if we can expect multiple difference ones of these. Some records don't
# have this data, so we remove all the 'null's. We sort the results and
# remove duplicates 'just to be sure' since we've not seen multiple
# records that match.
- diff_data=$(echo '{
+ diff_data=$(printf '%s\n' '{
"revisionIDs": [ '"${diff#D}"' ]
}' | arc_call_conduit -- differential.querydiffs |
jq -r '.response | flatten | .[]')
- author_addr=$(echo "$diff_data" | jq -r ".authorEmail?" | sort -u)
- author_name=$(echo "$diff_data" | jq -r ".authorName?" | sort -u)
+ author_addr=$(printf '%s\n' "$diff_data" | jq -r ".authorEmail?" | sort -u)
+ author_name=$(printf '%s\n' "$diff_data" | jq -r ".authorName?" | sort -u)
author=$(find_author "$user_addr" "$user_name" "$author_addr" "$author_name")
# If we had to guess, and the user didn't want to guess, abort
@@ -582,10 +582,10 @@
fi
tmp=$(mktemp)
- echo "$review_data" | jq -r '.response.data[].fields.title' > $tmp
- echo >> $tmp
- echo "$review_data" | jq -r '.response.data[].fields.summary' >> $tmp
- echo >> $tmp
+ printf '%s\n' "$review_data" | jq -r '.response.data[].fields.title' > $tmp
+ printf '\n' >> $tmp
+ printf '%s\n' "$review_data" | jq -r '.response.data[].fields.summary' >> $tmp
+ printf '\n' >> $tmp
# XXX this leaves an extra newline in some cases.
reviewers=$(diff2reviewers "$diff" | sed '/^$/d' | paste -sd ',' - | sed 's/,/, /g')
if [ -n "$reviewers" ]; then
@@ -621,7 +621,7 @@
for rev in "$@"; do
arc patch --skip-dependencies --nocommit --nobranch --force "$rev"
- echo "Applying ${rev}..."
+ printf '%s\n' "Applying ${rev}..."
[ $? -eq 0 ] || break
if ${commit}; then
patch_commit $rev
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Fri, Dec 12, 3:06 PM (18 h, 46 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
26899652
Default Alt Text
D47274.id145416.diff (10 KB)
Attached To
Mode
D47274: git-arc: Use printf instead of echo
Attached
Detach File
Event Timeline
Log In to Comment