diff options
author | root <root@localhost> | 2012-11-23 20:03:14 +0400 |
---|---|---|
committer | root <root@localhost> | 2012-11-23 20:03:14 +0400 |
commit | 698bc260c3a9904004da62f6d32393e2f358842e (patch) | |
tree | 766c6383eadb6d16e93aa80a094d33a1ea759a70 /git-remote-gcrypt | |
parent | 1cbe51f2e15609c2711b72a4ed5f950ba57238cc (diff) | |
download | git-remote-gcrypt-698bc260c3a9904004da62f6d32393e2f358842e.zip git-remote-gcrypt-698bc260c3a9904004da62f6d32393e2f358842e.tar.gz git-remote-gcrypt-698bc260c3a9904004da62f6d32393e2f358842e.tar.bz2 |
Update Branchlist using filter_remove
Diffstat (limited to 'git-remote-gcrypt')
-rwxr-xr-x | git-remote-gcrypt | 35 |
1 files changed, 20 insertions, 15 deletions
diff --git a/git-remote-gcrypt b/git-remote-gcrypt index 33a5d20..f0cf43f 100755 --- a/git-remote-gcrypt +++ b/git-remote-gcrypt @@ -54,13 +54,6 @@ isurl() { isnull "${2%%$1://*}"; } islocalrepo() { isnull "${1##/*}" && [ ! -e "$1/HEAD" ]; } xgrep() { command grep "$@" || : ; } -sort_C() { LC_ALL=C command sort "$@"; } -sort_stable_k2() -{ - awk '{ printf("%08d\t%s\n", NR, $0) }' | sort_C -k 3,3 -k 1,1 |cut -f 2- -} - -tac() { sed '1!G;h;$!d'; } # setvar is used for named return variables # $1 *must* be a valid variable name, $2 is any value @@ -120,6 +113,21 @@ pick_fields() setvar "$f_ret_var" "$f_result_" } +# Remove all lines matching $2 (full line) +# $1 return variable name +# $2 filter word +# $3 input value +filter_remove() +{ + local f_line= f_result_= IFS= + IFS=$Newline + for f_line in $3 + do + isnull "${f_line##$2}" || append_to @f_result_ "$f_line" + done + setvar "$1" "$f_result_" +} + # Take all lines matching $2 (anchored front) # $1 return variable name # $2 filter word @@ -709,8 +717,7 @@ do_push() # file's hash. The manifest is updated with the pack id. # The manifest is encrypted. local rev_list= src_= dst_= line_= pack_id= key_= obj_= \ - did_repack= pack_delete= \ - del_hash=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + did_repack= pack_delete= ensure_connected @@ -730,21 +737,19 @@ do_push() do # +src:dst -- remove leading + then split at : splitcolon "${line_#+}" @src_ @dst_ + + filter_remove @Branchlist "$Hex40 $dst_" "$Branchlist" + if isnonnull "$src_" then append_to @rev_list "$src_" obj_=$(xecho "$src_" | safe_git_rev_parse) - else - obj_=$del_hash # Mark for deletion + append_to @Branchlist "$obj_ $dst_" fi - append_to @Branchlist "$obj_ $dst_" done <<EOF $1 EOF - Branchlist=$(xecho "$Branchlist" | sort_stable_k2 | tac | uniq -s 40 | - xgrep -v "^$del_hash") - TmpPack_Encrypted="$Localdir/tmp_pack_ENCRYPTED_.$$" TmpObjlist="$Localdir/tmp_packrevlist.$$" key_=$(genkey "$Packkey_bytes") |