aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorroot <root@localhost>2013-02-14 00:00:00 +0000
committerroot <root@localhost>2013-02-14 00:00:00 +0000
commit1960c8ede07f486f8987ccadb01a77586e531d06 (patch)
tree55ba8b8c775b7cfbf1cafaa9bd52e7d9fcaf72a9
parenta0232a9a67ed587bea17c0355354d248f593940b (diff)
downloadgit-remote-gcrypt-1960c8ede07f486f8987ccadb01a77586e531d06.zip
git-remote-gcrypt-1960c8ede07f486f8987ccadb01a77586e531d06.tar.gz
git-remote-gcrypt-1960c8ede07f486f8987ccadb01a77586e531d06.tar.bz2
Use git rev-list --stdin and cat-file --batch-check
-rwxr-xr-xgit-remote-gcrypt21
1 files changed, 15 insertions, 6 deletions
diff --git a/git-remote-gcrypt b/git-remote-gcrypt
index eb34688..02a889e 100755
--- a/git-remote-gcrypt
+++ b/git-remote-gcrypt
@@ -213,7 +213,14 @@ pack_hash()
xecho "${hash_%:}"
}
-
+# Pass the branch/ref by pipe to git
+safe_git_rev_parse()
+{
+ local out_=
+ out_=$(xecho "$1" | git cat-file --batch-check)
+ out_=${out_%%*missing}
+ xecho "${out_%% *}"
+}
check_recipients()
{
@@ -400,7 +407,7 @@ do_push()
if isnonnull "$Branchlist"
then
remote_has=$(xecho "$Branchlist" |
- cut -f1 -d' ' | sed -e 's/^\(.\)/^&/' | tr '\n' ' ')
+ cut -f1 -d' ' | sed -e 's/^\(.\)/^&/')
fi
while read line_ # from <<
@@ -409,9 +416,9 @@ do_push()
splitcolon "${line_#+}"
if isnonnull "$prefix_"
then
- remote_want="$remote_want$prefix_ "
+ remote_want=$(append "$remote_want" "$prefix_")
Branchlist=$(append "$Branchlist" \
- "$(git rev-parse "$prefix_") $suffix_")
+ "$(safe_git_rev_parse "$prefix_") $suffix_")
else
: # FIXME delete branch
fi
@@ -424,8 +431,10 @@ EOF
TmpPack_Encrypted="$Localdir/tmp_pack_ENCRYPTED_.$$"
TmpObjlist="$Localdir/tmp_packrevlist.$$"
- git rev-list --objects $remote_has $remote_want -- | \
- tee "$TmpObjlist" | \
+
+ append "$remote_has" "$remote_want" |
+ git rev-list --objects --stdin -- |
+ tee "$TmpObjlist" |
git pack-objects --stdout | ENCRYPT > "$TmpPack_Encrypted"
# Only send pack if we have any objects to send
if [ -s "$TmpObjlist" ]