Skip to content

Commit abb7c7b

Browse files
dschoJunio C Hamano
authored andcommitted
Optionally work without python
In some setups (notably server setups) you do not need that dependency. Gracefully handle the absence of python when NO_PYTHON is defined. Signed-off-by: Johannes E. Schindelin <Johannes.Schindelin@gmx.de> Signed-off-by: Junio C Hamano <junkio@cox.net>
1 parent 289c4b3 commit abb7c7b

File tree

7 files changed

+32
-1
lines changed

7 files changed

+32
-1
lines changed

Makefile

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@ all:
5858
# Define NO_ACCURATE_DIFF if your diff program at least sometimes misses
5959
# a missing newline at the end of the file.
6060
#
61+
# Define NO_PYTHON if you want to loose all benefits of the recursive merge.
62+
#
6163
# Define COLLISION_CHECK below if you believe that SHA1's
6264
# 1461501637330902918203684832716283019655932542976 hashes do not give you
6365
# sufficient guarantee that no collisions between objects will ever happen.
@@ -442,6 +444,7 @@ $(patsubst %.sh,%,$(SCRIPT_SH)) : % : %.sh
442444
sed -e '1s|#!.*/sh|#!$(call shq,$(SHELL_PATH))|' \
443445
-e 's/@@GIT_VERSION@@/$(GIT_VERSION)/g' \
444446
-e 's/@@NO_CURL@@/$(NO_CURL)/g' \
447+
-e 's/@@NO_PYTHON@@/$(NO_PYTHON)/g' \
445448
$@.sh >$@
446449
chmod +x $@
447450

@@ -521,6 +524,12 @@ doc:
521524

522525
### Testing rules
523526

527+
# GNU make supports exporting all variables by "export" without parameters.
528+
# However, the environment gets quite big, and some programs have problems
529+
# with that.
530+
531+
export NO_PYTHON
532+
524533
test: all
525534
$(MAKE) -C t/ all
526535

git-merge.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@ LF='
1313
all_strategies='recursive octopus resolve stupid ours'
1414
default_strategies='recursive'
1515
use_strategies=
16+
if test "@@NO_PYTHON@@"; then
17+
all_strategies='resolve octopus stupid ours'
18+
default_strategies='resolve'
19+
fi
1620

1721
dropsave() {
1822
rm -f -- "$GIT_DIR/MERGE_HEAD" "$GIT_DIR/MERGE_MSG" \

t/Makefile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@ shellquote = '$(call shq,$(1))'
1515

1616
T = $(wildcard t[0-9][0-9][0-9][0-9]-*.sh)
1717

18+
ifdef NO_PYTHON
19+
GIT_TEST_OPTS += --no-python
20+
endif
21+
1822
all: $(T) clean
1923

2024
$(T):

t/t0000-basic.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ fi
4242

4343
. ./test-lib.sh
4444

45-
"$PYTHON" -c 'import subprocess' || {
45+
test "$no_python" || "$PYTHON" -c 'import subprocess' || {
4646
echo >&2 'Your python seem to lack "subprocess" module.
4747
Please check INSTALL document.'
4848
exit 1

t/t6021-merge-criss-cross.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,12 @@
1010
test_description='Test criss-cross merge'
1111
. ./test-lib.sh
1212

13+
if test "$no_python"; then
14+
echo "Skipping: no python => no recursive merge"
15+
test_done
16+
exit 0
17+
fi
18+
1319
test_expect_success 'prepare repository' \
1420
'echo "1
1521
2

t/t6022-merge-rename.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,12 @@
33
test_description='Merge-recursive merging renames'
44
. ./test-lib.sh
55

6+
if test "$no_python"; then
7+
echo "Skipping: no python => no recursive merge"
8+
test_done
9+
exit 0
10+
fi
11+
612
test_expect_success setup \
713
'
814
cat >A <<\EOF &&

t/test-lib.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,8 @@ do
6363
exit 0 ;;
6464
-v|--v|--ve|--ver|--verb|--verbo|--verbos|--verbose)
6565
verbose=t; shift ;;
66+
--no-python)
67+
no_python=t; shift ;;
6668
*)
6769
break ;;
6870
esac

0 commit comments

Comments
 (0)