From 867e59956868c6a53b91e3ed574c9224596c4b08 Mon Sep 17 00:00:00 2001 From: "Kyle J. McKay" Date: Mon, 19 Mar 2018 20:23:32 -0700 Subject: [PATCH] tg-info.sh: omit ignored dependencies Annihilated branches do not logically have dependencies. However, if they've been created by an older version of TopGit or created (incorrectly) manually, a non-empty .topdeps file could be present in the branch even though it's been annihilated. Do not show dependencies in these cases. They will be totally ignored while recursing for updates or other activities and could be misleading. Since we already know the type of branch we are showing it's easy to skip the display in this case. In addition, skip the display for new branches being created as well unless the -i or -w option has been used because they are currently in the same state. We also show dependencies for annihilated/bare branches (if there are any) when -i or -w has been used because that's what -i and -w will do for other tg commands. Signed-off-by: Kyle J. McKay --- tg-info.sh | 60 ++++++++++++++++++++++++++++++++++-------------------------- 1 file changed, 34 insertions(+), 26 deletions(-) diff --git a/tg-info.sh b/tg-info.sh index f9bbc43..9599219 100644 --- a/tg-info.sh +++ b/tg-info.sh @@ -262,34 +262,42 @@ if has_remote "$name"; then echo "* Local head is ahead of the remote head." fi -anflag= -[ "${verbose:-0}" -lt 2 ] || anflag=1 -depslist="$(get_temp topdeps)" -cat_file "refs/heads/$name:.topdeps" ${noskipiw:+$head_from} >"$depslist" 2>/dev/null -eval run_awk_topgit_msg "$tm_opt" '"refs/$topbases"' "$(awk -v p="refs/$topbases/" <"$depslist" ' - function sq(x) { - gsub(/\047/, "\047\\\047\047", x) - return "\047" x "\047" +# annihilated, empty and bare branches do not logically have any dependencies +# but we might be about to commit on an empty branch and with -i or -w it could +if + [ "$bkind" = "0" ] || [ "$bkind" = "1" ] || { + [ -n "$noskipiw" ] && [ -n "$head_from" ] } - {sub(/\r$/, "")} - NF == 1 && $0 != "" && $0 !~ /[ \t\r\n*?:[^~\\]/ {printf "%s ", sq(p $0)} -')" | awk -v an="$anflag" -v df="$depslist" ' - NF >= 2 && $1 != "" && $2 ~ /^[0-4]$/ {bt[$1] = 0 + $2} - END { - prefix = "Depends: " - while ((e = (getline adep 0) { - sub(/\r$/, "", adep) - if (adep == "" || adep ~ /[ \t\r\n*?:[^~\\]/) continue - if (!an && bt[adep] == 2) continue - suffix = "" - if (bt[adep] == 2) suffix = " (annihilated)" - print prefix adep suffix - prefix = " " +then + anflag= + [ "${verbose:-0}" -lt 2 ] || anflag=1 + depslist="$(get_temp topdeps)" + cat_file "refs/heads/$name:.topdeps" ${noskipiw:+$head_from} >"$depslist" 2>/dev/null + eval run_awk_topgit_msg "$tm_opt" '"refs/$topbases"' "$(awk -v p="refs/$topbases/" <"$depslist" ' + function sq(x) { + gsub(/\047/, "\047\\\047\047", x) + return "\047" x "\047" } - close(df) - if (e < 0) exit 2; - } -' + {sub(/\r$/, "")} + NF == 1 && $0 != "" && $0 !~ /[ \t\r\n*?:[^~\\]/ {printf "%s ", sq(p $0)} + ')" | awk -v an="$anflag" -v df="$depslist" ' + NF >= 2 && $1 != "" && $2 ~ /^[0-4]$/ {bt[$1] = 0 + $2} + END { + prefix = "Depends: " + while ((e = (getline adep 0) { + sub(/\r$/, "", adep) + if (adep == "" || adep ~ /[ \t\r\n*?:[^~\\]/) continue + if (!an && bt[adep] == 2) continue + suffix = "" + if (bt[adep] == 2) suffix = " (annihilated)" + print prefix adep suffix + prefix = " " + } + close(df) + if (e < 0) exit 2; + } + ' +fi depcheck="$(get_temp tg-depcheck)" missing_deps= -- 2.11.4.GIT