Simply detect if using git repository backend. gitception:// is unneeded
Simply treat absolute paths that do not lead to a HEAD file as local directory backends, and all other as git backends.
This commit is contained in:
parent
853dae8914
commit
e2de0ce73f
2 changed files with 35 additions and 26 deletions
14
README.rst
14
README.rst
|
@ -16,9 +16,10 @@ Remote helper programs are invoked by git to handle network transport.
|
||||||
This helper handles gcrypt:: URLs that will access a remote repository
|
This helper handles gcrypt:: URLs that will access a remote repository
|
||||||
encrypted with GPG, using our custom format.
|
encrypted with GPG, using our custom format.
|
||||||
|
|
||||||
Supported locations are `local`, `ssh://`, `sftp://` and
|
Supported locations are `local`, `ssh://` and `sftp://`, where the
|
||||||
`gitception://`. `gcrypt::gitception://<giturl>` allows stacking gcrypt
|
repository is stored as a set of files. If the location instead is any
|
||||||
on top of any other git transport.
|
`<giturl>`, gcrypt will store the same representation in a git
|
||||||
|
repository, and so it can be bridged over any git transport.
|
||||||
|
|
||||||
.. NOTE:: Repository format MAY STILL change, incompatibly
|
.. NOTE:: Repository format MAY STILL change, incompatibly
|
||||||
|
|
||||||
|
@ -91,6 +92,13 @@ Examples
|
||||||
git remote add cryptremote gcrypt::ssh://example.com:repo
|
git remote add cryptremote gcrypt::ssh://example.com:repo
|
||||||
git push cryptremote HEAD
|
git push cryptremote HEAD
|
||||||
|
|
||||||
|
How to use a git backend::
|
||||||
|
|
||||||
|
# notice that the target repo must already exist and its
|
||||||
|
# `master` branch will be overwritten!
|
||||||
|
git remote add gitcrypt gcrypt::git@example.com:repo
|
||||||
|
git push gitcrypt HEAD
|
||||||
|
|
||||||
Notes
|
Notes
|
||||||
=====
|
=====
|
||||||
|
|
||||||
|
|
|
@ -44,6 +44,7 @@ isnoteq() { ! iseq "$@"; }
|
||||||
# Append $2 to $1 with a newline separator
|
# Append $2 to $1 with a newline separator
|
||||||
append() { isnull "$1" || xecho "$1" && xecho "$2"; }
|
append() { isnull "$1" || xecho "$1" && xecho "$2"; }
|
||||||
isurl() { isnull "${2%%$1://*}"; }
|
isurl() { isnull "${2%%$1://*}"; }
|
||||||
|
islocalrepo() { isnull "${1##/*}" && [ ! -e "$1/HEAD" ]; }
|
||||||
|
|
||||||
xgrep() { command grep "$@" || : ; }
|
xgrep() { command grep "$@" || : ; }
|
||||||
sort_C() { LC_ALL=C command sort "$@"; }
|
sort_C() { LC_ALL=C command sort "$@"; }
|
||||||
|
@ -83,7 +84,9 @@ anon_commit()
|
||||||
GIT_AUTHOR_DATE="1356994801 -0400" GIT_COMMITTER_NAME="root" \
|
GIT_AUTHOR_DATE="1356994801 -0400" GIT_COMMITTER_NAME="root" \
|
||||||
GIT_COMMITTER_EMAIL="root@localhost" \
|
GIT_COMMITTER_EMAIL="root@localhost" \
|
||||||
GIT_COMMITTER_DATE="1356994801 -0400" \
|
GIT_COMMITTER_DATE="1356994801 -0400" \
|
||||||
git commit-tree -m "Initial commit" "$@"
|
git commit-tree "$@" <<EOF
|
||||||
|
Initial commit
|
||||||
|
EOF
|
||||||
}
|
}
|
||||||
|
|
||||||
# Get 'tree' from $1, change file $2 to obj id $3
|
# Get 'tree' from $1, change file $2 to obj id $3
|
||||||
|
@ -128,11 +131,11 @@ GET()
|
||||||
elif isurl sftp "$1"
|
elif isurl sftp "$1"
|
||||||
then
|
then
|
||||||
(exec 0>&-; curl -s -S -k "$1/$2")
|
(exec 0>&-; curl -s -S -k "$1/$2")
|
||||||
elif isurl gitception "$1"
|
elif islocalrepo "$1"
|
||||||
then
|
then
|
||||||
gitception_get "${1#gitception://}" "$2"
|
|
||||||
else
|
|
||||||
cat "$1/$2"
|
cat "$1/$2"
|
||||||
|
else
|
||||||
|
gitception_get "${1#gitception://}" "$2"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -146,22 +149,22 @@ PUT()
|
||||||
elif isurl sftp "$1"
|
elif isurl sftp "$1"
|
||||||
then
|
then
|
||||||
curl -s -S -k --ftp-create-dirs -T - "$1/$2"
|
curl -s -S -k --ftp-create-dirs -T - "$1/$2"
|
||||||
elif isurl gitception "$1"
|
elif islocalrepo "$1"
|
||||||
then
|
then
|
||||||
gitception_put "${1#gitception://}" "$2"
|
|
||||||
else
|
|
||||||
cat > "$1/$2"
|
cat > "$1/$2"
|
||||||
|
else
|
||||||
|
gitception_put "${1#gitception://}" "$2"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
# Put all PUT changes for repo $1 at once
|
# Put all PUT changes for repo $1 at once
|
||||||
PUT_FINAL()
|
PUT_FINAL()
|
||||||
{
|
{
|
||||||
if isurl gitception "$1"
|
if isurl ssh "$1" || isurl sftp "$1" || islocalrepo "$1"
|
||||||
then
|
then
|
||||||
git push --quiet -f "${1#gitception://}" "$Gref:$Gref_rbranch"
|
|
||||||
else
|
|
||||||
:
|
:
|
||||||
|
else
|
||||||
|
git push --quiet -f "${1#gitception://}" "$Gref:$Gref_rbranch"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -175,17 +178,22 @@ PUTREPO()
|
||||||
elif isurl sftp "$1"
|
elif isurl sftp "$1"
|
||||||
then
|
then
|
||||||
:
|
:
|
||||||
elif isurl gitception "$1"
|
elif islocalrepo "$1"
|
||||||
then
|
then
|
||||||
gitception_new_repo "${1#gitception://}"
|
|
||||||
else
|
|
||||||
mkdir -p "$1"
|
mkdir -p "$1"
|
||||||
|
else
|
||||||
|
gitception_new_repo "${1#gitception://}"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
CLEAN_FINAL()
|
CLEAN_FINAL()
|
||||||
{
|
{
|
||||||
isurl gitception "$1" && git update-ref -d "$Gref" || :
|
if isurl ssh "$1" || isurl sftp "$1" || islocalrepo "$1"
|
||||||
|
then
|
||||||
|
:
|
||||||
|
else
|
||||||
|
git update-ref -d "$Gref" || :
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
addsignkeyparam()
|
addsignkeyparam()
|
||||||
|
@ -518,18 +526,13 @@ EOF
|
||||||
echo_git
|
echo_git
|
||||||
}
|
}
|
||||||
|
|
||||||
# Main program, check $URL is supported
|
NAME=$1 # Remote name
|
||||||
NAME=$1
|
URL=$2 # Remote URL
|
||||||
URL=$2
|
|
||||||
( isurl ssh "$URL" || isurl sftp "$URL" ||
|
|
||||||
isurl gitception "$URL" || isnull "${URL##/*}" ) ||
|
|
||||||
echo_die "Supported URLs: gitception://<giturl>, Absolute path, sftp://, ssh://"
|
|
||||||
|
|
||||||
mkdir -p "$Localdir"
|
mkdir -p "$Localdir"
|
||||||
|
|
||||||
while read Input
|
while read Input
|
||||||
do
|
do
|
||||||
#echo_info "Got: $Input ($GITCEPTION)"
|
|
||||||
case "$Input" in
|
case "$Input" in
|
||||||
capabilities)
|
capabilities)
|
||||||
do_capabilities
|
do_capabilities
|
||||||
|
@ -556,7 +559,6 @@ do
|
||||||
args_="${Input##push }"
|
args_="${Input##push }"
|
||||||
while read InputX
|
while read InputX
|
||||||
do
|
do
|
||||||
#echo_info "Got: (for push) $InputX"
|
|
||||||
case "$InputX" in
|
case "$InputX" in
|
||||||
push\ *)
|
push\ *)
|
||||||
args_=$(append "$args_" "${InputX#push }")
|
args_=$(append "$args_" "${InputX#push }")
|
||||||
|
@ -572,7 +574,6 @@ do
|
||||||
echo_die "Unknown input!"
|
echo_die "Unknown input!"
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
#echo_info "Blank line, we are done"
|
|
||||||
CLEAN_FINAL "$URL"
|
CLEAN_FINAL "$URL"
|
||||||
exit 0
|
exit 0
|
||||||
;;
|
;;
|
||||||
|
|
Loading…
Reference in a new issue