From 4ff7e86c51fb9504dec2841dfb62f23fec61ebcd Mon Sep 17 00:00:00 2001 From: "Kyle J. McKay" Date: Sun, 18 Jun 2017 16:21:43 -0700 Subject: [PATCH] tg-summary: use run_awk_topgit_msg for all messages Instead of only using run_awk_topgit_msg for the verbose list output, use it for normal summary output too. It's faster and it produces better messages when things are missing. This makes normal summary messages match the messages output by tg info, tg checkout and tg summary --list. Nice consistency now. Signed-off-by: Kyle J. McKay --- t/t4000-bare-branch-sanity.sh | 5 ++--- t/t4100-summary.sh | 8 ++++---- tg-summary.sh | 46 +++++++++++++++++++++++++++++++++---------- 3 files changed, 42 insertions(+), 17 deletions(-) diff --git a/t/t4000-bare-branch-sanity.sh b/t/t4000-bare-branch-sanity.sh index b367b32..5baf2cd 100755 --- a/t/t4000-bare-branch-sanity.sh +++ b/t/t4000-bare-branch-sanity.sh @@ -116,13 +116,12 @@ t/branch [PATCH] use the base ' test_expect_success "($repo) "'tg summary' ' - sp=" " && # single space in there printf "%s" "\ - * boo${sp} + * boo branch boo (missing .topmsg) * t/begin [PATCH] start here D t/branch [PATCH] use the base " > expected && - tgx -C $repo summary > actual.raw && + tg -C $repo summary > actual.raw && tab=" " && # a single tab in there < actual.raw tr -s "$tab" " " > actual && test_diff expected actual diff --git a/t/t4100-summary.sh b/t/t4100-summary.sh index 651411c..19d8fd3 100755 --- a/t/t4100-summary.sh +++ b/t/t4100-summary.sh @@ -134,14 +134,14 @@ test_expect_success 'bad usage' ' ' printf "%s" "\ - basebare + basebare branch basebare (missing .topmsg) 0 reused-1level1 [PATCH] reused with one tg branch below 0 reused-1level2 [PATCH] reused with one tg branch below 0 D * reused-2level1 [PATCH] reused with two tg branches below 0 D * reused-2level2 [PATCH] reused with two tg branches below 0 D reused-multi [PATCH] multi-level reuse 0 root [PATCH] standard root branch - 0 rootdeps + 0 rootdeps branch rootdeps (missing .topmsg) 0 rootmsg [PATCH] topmsg root 0 t/branch1 [PATCH] branch1 topgit 0 * t/branch2 [PATCH] branch2 topgit @@ -292,11 +292,11 @@ t/branch3 [PATCH] branch3 topgit die failed to make pristine_list_verbose printf "%s" "\ - basebare + basebare branch basebare (missing .topmsg) 0 reused-1level2 [PATCH] reused with one tg branch below 0 D reused-multi [PATCH] multi-level reuse 0 root [PATCH] standard root branch - 0 rootdeps + 0 rootdeps branch rootdeps (missing .topmsg) 0 rootmsg [PATCH] topmsg root " > pristine_heads_only.raw || die failed to make pristine_heads_only.raw diff --git a/tg-summary.sh b/tg-summary.sh index 576504b..9b99536 100644 --- a/tg-summary.sh +++ b/tg-summary.sh @@ -309,6 +309,11 @@ processed=' ' needslist=' ' compute_ahead_list() { + refslist= + [ -z "$tg_read_only" ] || [ -z "$tg_ref_cache" ] || ! [ -s "$tg_ref_cache" ] || + refslist="-r=\"$tg_ref_cache\"" + msgsfile="$(get_temp msgslist)" + eval run_awk_topgit_msg -nokind "$refslist" '"refs/$topbases"' >"$msgsfile" [ -z "$branches" ] || [ -n "$withdeps" ] || return 0 [ -n "$withdeps" ] || origbranches="$(tg summary --topgit-heads | paste -d ' ' -s -)" aheadfile="$(get_temp aheadlist)" @@ -363,15 +368,8 @@ process_branch() ahead=' ' case "$aheadlist" in *" $name "*) ahead='*'; esac - if [ "$(ref_exists_rev "refs/heads/$name")" != "$(ref_exists_rev "refs/$topbases/$name")" ]; then - subject="$(cat_file "refs/heads/$name:.topmsg" $from | sed -n 's/^Subject: //p')" - else - # No commits yet - subject="(No commits)" - fi - - printf '%-8s %-30s\t%s\n' "$current$nonempty$remote$rem_update$deps_update$deps_missing$base_update$ahead" \ - "$name" "$subject" + printf '%-8s %s\n' "$current$nonempty$remote$rem_update$deps_update$deps_missing$base_update$ahead" \ + "$name" } if [ -n "$terse" ]; then @@ -385,8 +383,10 @@ if [ -n "$terse" ]; then exit 0 fi +msgsfile= [ -n "$graphviz$sort" ] || compute_ahead_list -get_branch_list | +process_branches() +{ while read name; do case "$exclude" in *" $name "*) continue; esac if [ -n "$graphviz$sort" ]; then @@ -413,6 +413,32 @@ get_branch_list | process_branch fi done +} +awkpgm=' +BEGIN { + if (msgsfile != "") { + while ((e = (getline msg 0) { + gsub(/[ \t]+/, " ", msg) + sub(/^ /, "", msg) + if (split(msg, scratch, " ") < 2 || + scratch[1] == "" || scratch[2] == "") continue + msg = substr(msg, length(scratch[1]) + 2) + msgs[scratch[1]] = msg + } + close(msgsfile) + } +} +{ + name = substr($0, 10) + if (name != "" && name in msgs) + printf "%-39s\t%s\n", $0, msgs[name] + else + print $0 +} +' +cmd='get_branch_list | process_branches' +[ -z "$msgsfile" ] || cmd="$cmd"' | awk -v msgsfile="$msgsfile" "$awkpgm"' +eval "$cmd" if [ -n "$graphviz" ]; then echo '}' -- 2.11.4.GIT