Clean up linearize fallback output formatting
Suppress git stdout/stderr noise from cherry-pick, checkout, and commit during linearization. Add delimiters and consistent indented log lines so the output is easy to scan. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
29
lib/sync.sh
29
lib/sync.sh
@@ -308,11 +308,12 @@ reverse_sync() {
|
||||
# regular commits as-is, squash only the problematic merge commits.
|
||||
# See ADR-011.
|
||||
log "WARN" "Direct push failed — linearizing history (cherry-pick + squash merges)"
|
||||
log "INFO" "─── linearize start ───"
|
||||
|
||||
local original_head
|
||||
original_head=$(git rev-parse HEAD)
|
||||
|
||||
git checkout -b "tmp-linearize-$$" "mono-filtered/${mono_branch}" 2>/dev/null \
|
||||
git checkout -b "tmp-linearize-$$" "mono-filtered/${mono_branch}" >/dev/null 2>&1 \
|
||||
|| die "Failed to create linearize branch"
|
||||
|
||||
# Reuse merge-base from step 4 (same reasoning: mono-filtered may have
|
||||
@@ -330,23 +331,27 @@ reverse_sync() {
|
||||
for sha in $commit_shas; do
|
||||
local parent_count
|
||||
parent_count=$(git cat-file -p "$sha" | grep -c "^parent ")
|
||||
local short_msg
|
||||
short_msg=$(git log -1 --format="%s" "$sha")
|
||||
|
||||
if [ "$parent_count" -le 1 ]; then
|
||||
# Regular commit — cherry-pick to preserve message and authorship
|
||||
if ! git cherry-pick "$sha" 2>/dev/null; then
|
||||
log "WARN" "Cherry-pick conflict on ${sha:0:7} — applying tree directly"
|
||||
if git cherry-pick "$sha" >/dev/null 2>&1; then
|
||||
log "INFO" " cherry-pick ${sha:0:7}: ${short_msg}"
|
||||
else
|
||||
log "WARN" " conflict ${sha:0:7} — applying tree directly"
|
||||
git cherry-pick --abort 2>/dev/null
|
||||
# Fall back to applying the exact tree diff for this commit
|
||||
local msg author_name author_email author_date
|
||||
msg=$(git log -1 --format="%B" "$sha")
|
||||
author_name=$(git log -1 --format="%an" "$sha")
|
||||
author_email=$(git log -1 --format="%ae" "$sha")
|
||||
author_date=$(git log -1 --format="%aI" "$sha")
|
||||
git diff HEAD "$sha" | git apply --index 2>/dev/null \
|
||||
git diff HEAD "$sha" | git apply --index >/dev/null 2>&1 \
|
||||
|| die "Failed to apply diff for ${sha:0:7}"
|
||||
GIT_AUTHOR_NAME="$author_name" GIT_AUTHOR_EMAIL="$author_email" \
|
||||
GIT_AUTHOR_DATE="$author_date" \
|
||||
git commit -m "$msg" || die "Failed to commit ${sha:0:7}"
|
||||
git commit -m "$msg" >/dev/null 2>&1 || die "Failed to commit ${sha:0:7}"
|
||||
log "INFO" " applied ${sha:0:7}: ${short_msg}"
|
||||
fi
|
||||
else
|
||||
# Merge commit — cherry-pick relative to first parent (squashes the merge)
|
||||
@@ -356,18 +361,22 @@ reverse_sync() {
|
||||
author_email=$(git log -1 --format="%ae" "$sha")
|
||||
author_date=$(git log -1 --format="%aI" "$sha")
|
||||
|
||||
if ! git cherry-pick -m 1 "$sha" 2>/dev/null; then
|
||||
if git cherry-pick -m 1 "$sha" >/dev/null 2>&1; then
|
||||
: # success
|
||||
else
|
||||
git cherry-pick --abort 2>/dev/null
|
||||
git diff HEAD "$sha" | git apply --index 2>/dev/null \
|
||||
git diff HEAD "$sha" | git apply --index >/dev/null 2>&1 \
|
||||
|| die "Failed to apply merge diff for ${sha:0:7}"
|
||||
GIT_AUTHOR_NAME="$author_name" GIT_AUTHOR_EMAIL="$author_email" \
|
||||
GIT_AUTHOR_DATE="$author_date" \
|
||||
git commit -m "$msg" || die "Failed to commit merge ${sha:0:7}"
|
||||
git commit -m "$msg" >/dev/null 2>&1 || die "Failed to commit merge ${sha:0:7}"
|
||||
fi
|
||||
log "INFO" "Squashed merge commit ${sha:0:7}: $(echo "$msg" | head -1)"
|
||||
log "INFO" " squash ${sha:0:7}: ${short_msg}"
|
||||
fi
|
||||
done
|
||||
|
||||
log "INFO" "─── linearize done ────"
|
||||
|
||||
push_ref="HEAD"
|
||||
linearized=true
|
||||
|
||||
|
||||
Reference in New Issue
Block a user