Code

'build' scripts before installing.
authorJunio C Hamano <junkio@cox.net>
Fri, 9 Sep 2005 01:50:33 +0000 (18:50 -0700)
committerJunio C Hamano <junkio@cox.net>
Fri, 9 Sep 2005 01:50:33 +0000 (18:50 -0700)
Earlier we renamed git-foo.sh to git-foo while installing, which
was mostly done by inertia than anything else.  This however
made writing tests to use scripts harder.

This patch builds the scripts the same way as we build binaries
from their sources.  As a side effect, you can now specify
non-standard paths you have your Perl binary is in when running
the make.

Signed-off-by: Junio C Hamano <junkio@cox.net>
Makefile
git.sh [new file with mode: 0755]
git.sh.in [deleted file]
t/t1005-read-tree-m-2way-emu23.sh
t/t3200-branch.sh
t/t5400-send-pack.sh

index d3d0855e03227c3e7796f9ed0e4fa390ad0d0afa..0f01b5b420efec6f3cd5ab7b868bdda9c2c55272 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -142,6 +142,13 @@ ifeq ($(shell uname -s),SunOS)
        PLATFORM_DEFINES += -DNO_GETDOMAINNAME=1
 endif
 
+ifndef SHELL_PATH
+       SHELL_PATH = /bin/sh
+endif
+ifndef PERL_PATH
+       PERL_PATH = /usr/bin/perl
+endif
+
 ifndef NO_OPENSSL
        LIB_OBJS += epoch.o
        OPENSSL_LIBSSL = -lssl
@@ -179,21 +186,32 @@ endif
 
 DEFINES += '-DSHA1_HEADER=$(SHA1_HEADER)'
 
-SCRIPTS = $(SCRIPT_SH) $(SCRIPT_PERL) gitk
+SCRIPTS = $(patsubst %.sh,%,$(SCRIPT_SH)) \
+         $(patsubst %.perl,%,$(SCRIPT_PERL)) gitk
 
 ### Build rules
 
-all: $(PROGRAMS) git.sh
+all: $(PROGRAMS) $(SCRIPTS)
 
 all:
        $(MAKE) -C templates
 
-git.sh: git.sh.in Makefile
+git: git.sh Makefile
        rm -f $@+ $@
-       sed -e 's/@@GIT_VERSION@@/$(GIT_VERSION)/g' <$@.in >$@+
+       sed -e 's/@@GIT_VERSION@@/$(GIT_VERSION)/g' <$@.sh >$@+
        chmod +x $@+
        mv $@+ $@
 
+$(filter-out git,$(patsubst %.sh,%,$(SCRIPT_SH))) : % : %.sh
+       rm -f $@
+       sed -e '1s|#!.*/sh|#!$(SHELL_PATH)|' $@.sh >$@
+       chmod +x $@
+
+$(patsubst %.perl,%,$(SCRIPT_PERL)) : % : %.perl
+       rm -f $@
+       sed -e '1s|#!.*perl|#!$(PERL_PATH)|' $@.perl >$@
+       chmod +x $@
+
 %.o: %.c
        $(CC) -o $*.o -c $(ALL_CFLAGS) $<
 %.o: %.S
@@ -250,19 +268,8 @@ check:
 
 install: $(PROGRAMS) $(SCRIPTS)
        $(INSTALL) -m755 -d $(DESTDIR)$(bindir)
-       $(INSTALL) $(PROGRAMS) $(DESTDIR)$(bindir)
-       @for s in $(SCRIPTS); \
-       do \
-               case "$$s" in \
-               *.*) \
-                       e=`expr "$$s" : '\(.*\)\.[^.]*$$'` ;; \
-               *) \
-                       e="$$s" ;; \
-               esac && \
-               echo ": install $$s $(DESTDIR)$(bindir)/$$e" && \
-               $(INSTALL) $$s $(DESTDIR)$(bindir)/$$e || exit; \
-       done
-       $(INSTALL) git-revert.sh $(DESTDIR)$(bindir)/git-cherry-pick
+       $(INSTALL) $(PROGRAMS) $(SCRIPTS) $(DESTDIR)$(bindir)
+       $(INSTALL) git-revert $(DESTDIR)$(bindir)/git-cherry-pick
        sh ./cmd-rename.sh $(DESTDIR)$(bindir)
        $(MAKE) -C templates install
 
@@ -299,7 +306,8 @@ deb: dist
 
 clean:
        rm -f *.o mozilla-sha1/*.o ppc/*.o $(PROGRAMS) $(LIB_FILE)
-       rm -f git-core.spec git.sh
+       rm -f $(filter-out gitk,$(SCRIPTS))
+       rm -f git-core.spec
        rm -rf $(GIT_TARNAME)
        rm -f $(GIT_TARNAME).tar.gz git-core_$(GIT_VERSION)-*.tar.gz
        rm -f git-core_$(GIT_VERSION)-*.deb git-core_$(GIT_VERSION)-*.dsc
diff --git a/git.sh b/git.sh
new file mode 100755 (executable)
index 0000000..178d0f0
--- /dev/null
+++ b/git.sh
@@ -0,0 +1,32 @@
+#!/bin/sh
+
+cmd=
+path=$(dirname $0)
+case "$#" in
+0)     ;;
+*)     cmd="$1"
+       shift
+       case "$cmd" in
+       -v|--v|--ve|--ver|--vers|--versi|--versio|--version)
+               echo "git version @@GIT_VERSION@@"
+               exit 0 ;;
+       esac
+       test -x $path/git-$cmd && exec $path/git-$cmd "$@" ;;
+esac
+
+echo "Usage: git COMMAND [OPTIONS] [TARGET]"
+if [ -n "$cmd" ]; then
+    echo " git command '$cmd' not found: commands are:"
+else
+    echo " git commands are:"
+fi
+
+cat <<\EOF
+    add apply archimport bisect branch checkout cherry clone
+    commit count-objects cvsimport diff fetch format-patch
+    fsck-cache get-tar-commit-id init-db log ls-remote octopus
+    pack-objects parse-remote patch-id prune pull push rebase
+    relink rename repack request-pull reset resolve revert
+    send-email shortlog show-branch status tag verify-tag
+    whatchanged
+EOF
diff --git a/git.sh.in b/git.sh.in
deleted file mode 100755 (executable)
index 178d0f0..0000000
--- a/git.sh.in
+++ /dev/null
@@ -1,32 +0,0 @@
-#!/bin/sh
-
-cmd=
-path=$(dirname $0)
-case "$#" in
-0)     ;;
-*)     cmd="$1"
-       shift
-       case "$cmd" in
-       -v|--v|--ve|--ver|--vers|--versi|--versio|--version)
-               echo "git version @@GIT_VERSION@@"
-               exit 0 ;;
-       esac
-       test -x $path/git-$cmd && exec $path/git-$cmd "$@" ;;
-esac
-
-echo "Usage: git COMMAND [OPTIONS] [TARGET]"
-if [ -n "$cmd" ]; then
-    echo " git command '$cmd' not found: commands are:"
-else
-    echo " git commands are:"
-fi
-
-cat <<\EOF
-    add apply archimport bisect branch checkout cherry clone
-    commit count-objects cvsimport diff fetch format-patch
-    fsck-cache get-tar-commit-id init-db log ls-remote octopus
-    pack-objects parse-remote patch-id prune pull push rebase
-    relink rename repack request-pull reset resolve revert
-    send-email shortlog show-branch status tag verify-tag
-    whatchanged
-EOF
index 00c332a1407a86096cbaf06ef5d8ec613a412190..258a372ed717a1250473364c7be9c7920062bd0e 100755 (executable)
@@ -25,7 +25,7 @@ In the test, these paths are used:
 read_tree_twoway () {
     git-read-tree --emu23 "$1" "$2" &&
     git-ls-files --stage &&
-    git-merge-index ../../git-merge-one-file.sh -a &&
+    git-merge-index git-merge-one-file -a &&
     git-ls-files --stage
 }
 
index 6e363984446bd9d9cb34a78fdffd1b1de6544e9c..5f98f64de16560d9f6599623e7424efac9dc407f 100755 (executable)
@@ -13,12 +13,12 @@ handled.  Specifically, that a bogus branch is not created.
 test_expect_success \
     'prepare an trivial repository' \
     'echo Hello > A &&
-     ../../git-update-index --add A &&
-     ../../git-commit.sh -m "Initial commit."'
+     git-update-index --add A &&
+     git-commit -m "Initial commit."'
 
 test_expect_failure \
     'git branch --help should return error code' \
-    '../../git-branch.sh --help'
+    'git-branch --help'
 
 test_expect_failure \
     'git branch --help should not have created a bogus branch' \
index fb8320d755ab38ca7b3f1d7965ceeeb336b12e65..59ce77b6b42eceaf953e955b79723753deb10033 100755 (executable)
@@ -21,9 +21,9 @@ test_expect_success setup '
            parent=$commit || return 1
        done &&
        echo "$commit" >.git/HEAD &&
-       git-clone.sh -l ./. victim &&
+       git-clone -l ./. victim &&
        cd victim &&
-       git-log.sh &&
+       git-log &&
        cd .. &&
        echo $zero >.git/HEAD &&
        parent=$zero &&
@@ -35,7 +35,7 @@ test_expect_success setup '
        done &&
        echo "$commit" >.git/HEAD &&
        echo Rebase &&
-       git-log.sh'
+       git-log'
 
 test_expect_success \
         'pushing rewound head should not barf but require --force' '