From nobody Fri Oct 25 13:23:27 2024 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4XZk4b73XQz5Zjnj; Fri, 25 Oct 2024 13:23:27 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R11" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4XZk4b6LPfz4KTk; Fri, 25 Oct 2024 13:23:27 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1729862607; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=CLXk0gs7jqIdE+62A/25CktaU6nh2wJzeZQpGWG2zyo=; b=u59DkJJss52dEpGe8rhCD4NPr/Ah72wmUcoDm4hC4er5BEOFzCPSM4Rzw5j43WjZyNVv92 DfWwR1DfbzGreihkSOx7gEkSvWS/ipcHOddzwpbzCAXG4zM/PdWWAjTO0YYXNtO37DKtjH M/LDTQV5diHVwtWMtyrUHtdk/mQNtl15bA2lD2stIlG/JaYZNbC06PQv61bI6XY+Dv3drB xqyyD2A1B9LsqchMgu0Xq8V2/6PR88N2ntuU/gESGq5WVxaOEI4Sg1P0J742+pFnt+k7wK pxOo+Cc55zXXlkbEgqhbdNGeNZGrwvqZEdKIRdHoxuZQvj4COHiz5yZfEYw9/g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1729862607; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=CLXk0gs7jqIdE+62A/25CktaU6nh2wJzeZQpGWG2zyo=; b=kg54c8gDwTSeGFbyjFYlHgo8JTvARQw1rsfl2ucb+y6BzoieHwvfhb+ItXR1JBB6u71xCj /6Zv1Sf90jZ5GLqcdSWVZXbY5iKhk5FCGf8FK4yg7I3g3HnY5umAyFuxhoroVJfkTEeZhm hXdZymtPsKMRndL0gUkrZGllZul33FeHnfz+XWJhyVDR2hb8GcaVqgSwq+CcLhtIOLx65M CsLtNDmvLnarrG9idvzTEEEtCpJHHq45ZiLtxXBmCbjgd0I8cer+mF7iEWrooqPtylDgMD ZRLLNkQdKemxaXtT/ge95k9WUIot1NpZ/ozPyjOcm1pYBQfcMrqCrS4i0sjrAA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1729862607; a=rsa-sha256; cv=none; b=hpj8jF8VWKngOVkYscT90HMOrnnYe9Gf+/qsjW8hGrESMGPxLTh5pVJCMXs+H9lInrQWY6 +ABtOMnQwiRlrEN9dbi7DkeOxKXC2V3j/+YmIvYzCVV1LOorYcgC4hMn9sCjv7TGDLeSCa kuaulfgsKVa+rS+nq1Z+IJvnWOr4jcvtE8qVOdNADIC1jhn5bCEc7AHAb9DlX0WsmNThYl P8m2vBGbz3Q1LOK4TNxcLAPV3vJ+G+zzyM97xROg2F2JwSgbPGNQ2yK2TOXZ90mcCu9ANd ORIkUB51GGofKkrM5TB/kyH3QCIsCf1emRWMghEvfZr0s21f7tSBvlxEg6QxNw== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4XZk4b5xgpzSb8; Fri, 25 Oct 2024 13:23:27 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 49PDNRHT041971; Fri, 25 Oct 2024 13:23:27 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 49PDNRD8041968; Fri, 25 Oct 2024 13:23:27 GMT (envelope-from git) Date: Fri, 25 Oct 2024 13:23:27 GMT Message-Id: <202410251323.49PDNRD8041968@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mateusz Piotrowski <0mp@FreeBSD.org> Subject: git: 3ab8697d9e45 - main - git-arc: Do not echo unescaped literals to jq List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: 0mp X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 3ab8697d9e45adc504142a4aa06d2b5c9245f4e6 Auto-Submitted: auto-generated The branch main has been updated by 0mp: URL: https://cgit.FreeBSD.org/src/commit/?id=3ab8697d9e45adc504142a4aa06d2b5c9245f4e6 commit 3ab8697d9e45adc504142a4aa06d2b5c9245f4e6 Author: Jose Luis Duran AuthorDate: 2024-10-25 13:20:53 +0000 Commit: Mateusz Piotrowski <0mp@FreeBSD.org> CommitDate: 2024-10-25 13:23:02 +0000 git-arc: Do not echo unescaped literals to jq Store the json blobs in temporary files instead of variables, and feed them to jq for parsing. When echoing "\n", the new line will become a literal new line, and therefore, invalid json input: ``` jq: parse error: Invalid string: control characters from U+0000 through U+001F must be escaped ... ``` To reproduce: % git arc patch -c D12345 Reviewed by: 0mp, imp, markj Approved by: markj (mentor) MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D46767 --- tools/tools/git/git-arc.sh | 41 +++++++++++++++++++++-------------------- 1 file changed, 21 insertions(+), 20 deletions(-) diff --git a/tools/tools/git/git-arc.sh b/tools/tools/git/git-arc.sh index 3261f4461dc6..cca70f61a4cd 100644 --- a/tools/tools/git/git-arc.sh +++ b/tools/tools/git/git-arc.sh @@ -548,32 +548,32 @@ patch_commit() diff=$1 reviewid=$(diff2phid "$diff") # Get the author phid for this patch - review_data=$(echo '{ - "constraints": {"phids": ["'"$reviewid"'"]} - }' | - arc_call_conduit -- differential.revision.search) - authorid=$(echo "$review_data" | jq -r '.response.data[].fields.authorPHID' ) + review_data=$(mktemp) + echo '{"constraints": {"phids": ["'"$reviewid"'"]}}' | \ + arc_call_conduit -- differential.revision.search > "$review_data" + authorid=$(jq -r '.response.data[].fields.authorPHID' "$review_data") # Get metadata about the user that submitted this patch - user_data=$(echo '{ - "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_data=$(mktemp) + echo '{"constraints": {"phids": ["'"$authorid"'"]}}' | \ + arc_call_conduit -- user.search | \ + jq -r '.response.data[].fields' > "$user_data" + user_addr=$(jq -r '.username' "$user_data") + user_name=$(jq -r '.realName' "$user_data") + rm "$user_data" # 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 '{ - "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) + diff_data=$(mktemp) + echo '{"revisionIDs": [ '"${diff#D}"' ]}' | \ + arc_call_conduit -- differential.querydiffs | + jq -r '.response | flatten | .[]' > "$diff_data" + author_addr=$(jq -r ".authorEmail?" "$diff_data" | sort -u) + author_name=$(jq -r ".authorName?" "$diff_data" | sort -u) author=$(find_author "$user_addr" "$user_name" "$author_addr" "$author_name") + rm "$diff_data" # If we had to guess, and the user didn't want to guess, abort if [ "${author}" = "ABORT" ]; then @@ -582,10 +582,11 @@ patch_commit() fi tmp=$(mktemp) - echo "$review_data" | jq -r '.response.data[].fields.title' > $tmp + jq -r '.response.data[].fields.title' "$review_data" > $tmp echo >> $tmp - echo "$review_data" | jq -r '.response.data[].fields.summary' >> $tmp + jq -r '.response.data[].fields.summary' "$review_data" >> $tmp echo >> $tmp + rm "$review_data" # XXX this leaves an extra newline in some cases. reviewers=$(diff2reviewers "$diff" | sed '/^$/d' | paste -sd ',' - | sed 's/,/, /g') if [ -n "$reviewers" ]; then