chiark
/
gitweb
/
~ianmdlvl
/
dgit.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
62c2e5b
)
tests: gitrepo-edit: wip, before new layout
author
Ian Jackson
<ijackson@chiark.greenend.org.uk>
Sun, 16 Feb 2014 15:34:51 +0000
(15:34 +0000)
committer
Ian Jackson
<ijackson@chiark.greenend.org.uk>
Wed, 5 Mar 2014 18:29:06 +0000
(18:29 +0000)
tests/gitrepo-edit
patch
|
blob
|
history
diff --git
a/tests/gitrepo-edit
b/tests/gitrepo-edit
index 97bbd2c438c71002234a9ab24f04991e04f382b5..27be703a64b5747973fdb70dfdffb9f4d0848c44 100755
(executable)
--- a/
tests/gitrepo-edit
+++ b/
tests/gitrepo-edit
@@
-2,18
+2,15
@@
set -e
fail () { echo >&2 "$0: $*"; exit 1; }
set -e
fail () { echo >&2 "$0: $*"; exit 1; }
-case "$1" in
-edit|done) mode=$1
-fi
-
-case "$*.$1" in
-1.-*) fail "no options understood" ;;
-1.*) arg="$1"; shift ;;
-*) fail "need one arg" ;;
+case "$#.$1" in
+2.edit|2.done) mode="$1"; arg="$2" ;;
+2.-*) fail "no options understood" ;;
+*) fail "usage: gitrepo-edit edit|done DIRECTORY" ;;
esac
case "$arg" in
*.git.tar) base=${arg%.tar} ;;
esac
case "$arg" in
*.git.tar) base=${arg%.tar} ;;
+*.git.edit) base=${arg%.edit} ;;
*.git) base=${arg} ;;
*) fail "arg must end in .git[.tar]" ;;
esac
*.git) base=${arg} ;;
*) fail "arg must end in .git[.tar]" ;;
esac
@@
-29,6
+26,7
@@
tryat_pre () {
tryat_edit () {
local b="$1"
tryat_edit () {
local b="$1"
+ local i="$2"
if test -d "$b.edit"; then
echo "$b.edit already exists"
exit 0
if test -d "$b.edit"; then
echo "$b.edit already exists"
exit 0
@@
-36,7
+34,7
@@
tryat_edit () {
if test -f "$b.tar"; then
mkdir "$b.tmp"
(set -e; cd "$b.tmp"; tar xf "$b.tar")
if test -f "$b.tar"; then
mkdir "$b.tmp"
(set -e; cd "$b.tmp"; tar xf "$b.tar")
- mv "$b.tmp/$
b
" "$b.edit"
+ mv "$b.tmp/$
i
" "$b.edit"
rm "$b.tar"
rm -rf "$b.tmp"
echo "$b.edit ready"
rm "$b.tar"
rm -rf "$b.tmp"
echo "$b.edit ready"
@@
-46,10
+44,11
@@
tryat_edit () {
tryat_done () {
local b="$1"
tryat_done () {
local b="$1"
+ local i="$2"
if test -d "$b.edit"; then
mkdir "$b.tmp"
if test -d "$b.edit"; then
mkdir "$b.tmp"
- cp -al "$b.edit" "$b.tmp/$
b
"
- (set -e; cd "$b.tmp"; tar cf "$b.tmp/tar")
+ cp -al "$b.edit" "$b.tmp/$
i
"
+ (set -e; cd "$b.tmp"; tar cf "$b.tmp/tar
$i
")
mv "$b.tmp/tar" "$b.tar"
rm -rf "$b.tmp"
mv "$b.edit" "$b.tmp"
mv "$b.tmp/tar" "$b.tar"
rm -rf "$b.tmp"
mv "$b.edit" "$b.tmp"
@@
-65,11
+64,13
@@
tryat_done () {
tryat () {
local b="$1"
tryat () {
local b="$1"
+ local i="${b##*/}"
+ case "$i" in *_*.git) i="${i%_*.git}.git";; esac
if ! test -f "$b.tar" && ! test -f "$b.edit"; then
return
fi
if ! test -f "$b.tar" && ! test -f "$b.edit"; then
return
fi
- tryat_pre "$b"
- tryat_$mode "$b"
+ tryat_pre "$b"
"$i"
+ tryat_$mode "$b"
"$i"
fail "unexpected situation in $b.*"
}
fail "unexpected situation in $b.*"
}
@@
-81,5
+82,6
@@
case "$arg" in
tryat "$pwd/$base"
tryat "$pwd/git-srcs/$base"
tryat "$pwd/tests/git-srcs/$base"
tryat "$pwd/$base"
tryat "$pwd/git-srcs/$base"
tryat "$pwd/tests/git-srcs/$base"
+ fail "could not find $base..."
;;
esac
;;
esac