aboutsummaryrefslogtreecommitdiffstats
path: root/contrib
diff options
context:
space:
mode:
Diffstat (limited to 'contrib')
-rw-r--r--contrib/buildsystems/CMakeLists.txt390
-rw-r--r--contrib/buildsystems/Generators.pm42
-rw-r--r--contrib/buildsystems/Generators/QMake.pm189
-rw-r--r--contrib/buildsystems/Generators/Vcproj.pm579
-rw-r--r--contrib/buildsystems/Generators/Vcxproj.pm402
-rwxr-xr-xcontrib/buildsystems/engine.pl395
-rwxr-xr-xcontrib/buildsystems/generate29
-rw-r--r--contrib/buildsystems/git-version.in1
-rwxr-xr-xcontrib/buildsystems/parse.pl228
-rw-r--r--contrib/coccinelle/commit.cocci3
-rw-r--r--contrib/coccinelle/meson.build79
-rw-r--r--contrib/coccinelle/the_repository.cocci2
-rw-r--r--contrib/completion/git-completion.bash68
-rw-r--r--contrib/completion/meson.build34
-rw-r--r--contrib/contacts/Makefile2
-rw-r--r--contrib/contacts/git-contacts.adoc (renamed from contrib/contacts/git-contacts.txt)0
-rw-r--r--contrib/contacts/meson.build55
-rw-r--r--contrib/credential/libsecret/Makefile3
-rw-r--r--contrib/credential/libsecret/git-credential-libsecret.c10
-rw-r--r--contrib/credential/libsecret/meson.build9
-rw-r--r--contrib/credential/meson.build3
-rwxr-xr-xcontrib/credential/netrc/git-credential-netrc.perl14
-rw-r--r--contrib/credential/netrc/meson.build22
-rwxr-xr-xcontrib/credential/netrc/t-git-credential-netrc.sh2
-rwxr-xr-xcontrib/credential/netrc/test.pl15
-rw-r--r--contrib/credential/osxkeychain/Makefile1
-rw-r--r--contrib/credential/osxkeychain/git-credential-osxkeychain.c2
-rw-r--r--contrib/credential/osxkeychain/meson.build9
-rw-r--r--contrib/credential/wincred/Makefile3
-rw-r--r--contrib/credential/wincred/git-credential-wincred.c2
-rw-r--r--contrib/credential/wincred/meson.build5
-rw-r--r--contrib/diff-highlight/DiffHighlight.pm2
-rw-r--r--contrib/diff-highlight/Makefile3
-rw-r--r--contrib/diff-highlight/t/Makefile5
-rw-r--r--contrib/emacs/README33
-rw-r--r--contrib/emacs/git-blame.el6
-rw-r--r--contrib/emacs/git.el6
-rw-r--r--contrib/examples/README20
-rwxr-xr-xcontrib/git-resurrect.sh181
-rw-r--r--contrib/hooks/multimail/README.Git7
-rwxr-xr-xcontrib/hooks/post-receive-email759
-rwxr-xr-xcontrib/hooks/pre-auto-gc-battery42
-rwxr-xr-xcontrib/hooks/setgitperms.perl214
-rwxr-xr-xcontrib/hooks/update-paranoid421
-rw-r--r--contrib/libgit-rs/Cargo.lock77
-rw-r--r--contrib/libgit-rs/Cargo.toml17
-rw-r--r--contrib/libgit-rs/README.md13
-rw-r--r--contrib/libgit-rs/build.rs4
-rw-r--r--contrib/libgit-rs/src/config.rs106
-rw-r--r--contrib/libgit-rs/src/lib.rs1
-rw-r--r--contrib/libgit-rs/testdata/config12
-rw-r--r--contrib/libgit-rs/testdata/config22
-rw-r--r--contrib/libgit-rs/testdata/config32
-rw-r--r--contrib/libgit-sys/Cargo.lock69
-rw-r--r--contrib/libgit-sys/Cargo.toml19
-rw-r--r--contrib/libgit-sys/README.md4
-rw-r--r--contrib/libgit-sys/build.rs35
-rw-r--r--contrib/libgit-sys/public_symbol_export.c59
-rw-r--r--contrib/libgit-sys/public_symbol_export.h18
-rw-r--r--contrib/libgit-sys/src/lib.rs79
-rwxr-xr-xcontrib/long-running-filter/example.pl2
-rw-r--r--contrib/meson.build6
-rw-r--r--contrib/mw-to-git/.gitignore2
-rw-r--r--contrib/mw-to-git/.perlcriticrc28
-rw-r--r--contrib/mw-to-git/Git/Mediawiki.pm101
-rw-r--r--contrib/mw-to-git/Makefile58
-rwxr-xr-xcontrib/mw-to-git/bin-wrapper/git14
-rwxr-xr-xcontrib/mw-to-git/git-mw.perl368
-rwxr-xr-xcontrib/mw-to-git/git-remote-mediawiki.perl1390
-rw-r--r--contrib/mw-to-git/git-remote-mediawiki.txt7
-rw-r--r--contrib/mw-to-git/t/.gitignore4
-rw-r--r--contrib/mw-to-git/t/Makefile31
-rw-r--r--contrib/mw-to-git/t/README124
-rwxr-xr-xcontrib/mw-to-git/t/install-wiki.sh55
-rw-r--r--contrib/mw-to-git/t/push-pull-tests.sh144
-rwxr-xr-xcontrib/mw-to-git/t/t9360-mw-to-git-clone.sh257
-rwxr-xr-xcontrib/mw-to-git/t/t9361-mw-to-git-push-pull.sh24
-rwxr-xr-xcontrib/mw-to-git/t/t9362-mw-to-git-utf8.sh347
-rwxr-xr-xcontrib/mw-to-git/t/t9363-mw-to-git-export-import.sh218
-rwxr-xr-xcontrib/mw-to-git/t/t9364-pull-by-rev.sh17
-rwxr-xr-xcontrib/mw-to-git/t/t9365-continuing-queries.sh23
-rwxr-xr-xcontrib/mw-to-git/t/test-gitmw-lib.sh432
-rwxr-xr-xcontrib/mw-to-git/t/test-gitmw.pl223
-rw-r--r--contrib/mw-to-git/t/test.config40
-rw-r--r--contrib/persistent-https/LICENSE202
-rw-r--r--contrib/persistent-https/Makefile40
-rw-r--r--contrib/persistent-https/README72
-rw-r--r--contrib/persistent-https/client.go189
-rw-r--r--contrib/persistent-https/main.go82
-rw-r--r--contrib/persistent-https/proxy.go190
-rw-r--r--contrib/persistent-https/socket.go97
-rw-r--r--contrib/remote-helpers/README15
-rwxr-xr-xcontrib/remote-helpers/git-remote-bzr11
-rwxr-xr-xcontrib/remote-helpers/git-remote-hg11
-rwxr-xr-xcontrib/remotes2config.sh33
-rwxr-xr-xcontrib/stats/git-common-hash26
-rwxr-xr-xcontrib/stats/mailmap.pl70
-rw-r--r--contrib/subtree/.gitignore2
-rw-r--r--contrib/subtree/Makefile25
-rw-r--r--contrib/subtree/README2
-rw-r--r--contrib/subtree/git-subtree.adoc (renamed from contrib/subtree/git-subtree.txt)19
-rwxr-xr-xcontrib/subtree/git-subtree.sh66
-rw-r--r--contrib/subtree/meson.build73
-rw-r--r--contrib/subtree/t/Makefile5
-rwxr-xr-xcontrib/subtree/t/t7900-subtree.sh113
-rw-r--r--contrib/thunderbird-patch-inline/README20
-rwxr-xr-xcontrib/thunderbird-patch-inline/appp.sh55
-rw-r--r--contrib/workdir/.gitattributes1
-rwxr-xr-xcontrib/workdir/git-new-workdir105
109 files changed, 1307 insertions, 8936 deletions
diff --git a/contrib/buildsystems/CMakeLists.txt b/contrib/buildsystems/CMakeLists.txt
index 62af7b33d2..25b495fa73 100644
--- a/contrib/buildsystems/CMakeLists.txt
+++ b/contrib/buildsystems/CMakeLists.txt
@@ -83,23 +83,12 @@ if(NOT SH_EXE)
"On Windows, you can get it as part of 'Git for Windows' install at https://gitforwindows.org/")
endif()
-#Create GIT-VERSION-FILE using GIT-VERSION-GEN
-if(NOT EXISTS ${CMAKE_SOURCE_DIR}/GIT-VERSION-FILE)
- message("Generating GIT-VERSION-FILE")
- execute_process(COMMAND ${SH_EXE} ${CMAKE_SOURCE_DIR}/GIT-VERSION-GEN
- WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})
-endif()
-
-#Parse GIT-VERSION-FILE to get the version
-file(STRINGS ${CMAKE_SOURCE_DIR}/GIT-VERSION-FILE git_version REGEX "GIT_VERSION = (.*)")
-string(REPLACE "GIT_VERSION = " "" git_version ${git_version})
-string(FIND ${git_version} "GIT" location)
-if(location EQUAL -1)
- string(REGEX MATCH "[0-9]*\\.[0-9]*\\.[0-9]*" git_version ${git_version})
-else()
- string(REGEX MATCH "[0-9]*\\.[0-9]*" git_version ${git_version})
- string(APPEND git_version ".0") #for building from a snapshot
-endif()
+message("Generating Git version")
+execute_process(COMMAND ${SH_EXE} "${CMAKE_SOURCE_DIR}/GIT-VERSION-GEN"
+ "${CMAKE_SOURCE_DIR}"
+ "${CMAKE_SOURCE_DIR}/contrib/buildsystems/git-version.in"
+ "${CMAKE_BINARY_DIR}/git-version")
+file(STRINGS "${CMAKE_BINARY_DIR}/git-version" git_version)
project(git
VERSION ${git_version}
@@ -110,8 +99,8 @@ project(git
#TODO Enable NLS on windows natively
#macros for parsing the Makefile for sources and scripts
-macro(parse_makefile_for_sources list_var regex)
- file(STRINGS ${CMAKE_SOURCE_DIR}/Makefile ${list_var} REGEX "^${regex} \\+=(.*)")
+macro(parse_makefile_for_sources list_var makefile regex)
+ file(STRINGS ${makefile} ${list_var} REGEX "^${regex} \\+=(.*)")
string(REPLACE "${regex} +=" "" ${list_var} ${${list_var}})
string(REPLACE "$(COMPAT_OBJS)" "" ${list_var} ${${list_var}}) #remove "$(COMPAT_OBJS)" This is only for libgit.
string(STRIP ${${list_var}} ${list_var}) #remove trailing/leading whitespaces
@@ -240,10 +229,7 @@ add_compile_definitions(PAGER_ENV="LESS=FRX LV=-c"
GIT_HTML_PATH="share/doc/git-doc"
DEFAULT_HELP_FORMAT="html"
DEFAULT_GIT_TEMPLATE_DIR="share/git-core/templates"
- GIT_VERSION="${PROJECT_VERSION}.GIT"
- GIT_USER_AGENT="git/${PROJECT_VERSION}.GIT"
- BINDIR="bin"
- GIT_BUILT_FROM_COMMIT="")
+ BINDIR="bin")
if(WIN32)
set(FALLBACK_RUNTIME_PREFIX /mingw64)
@@ -652,60 +638,79 @@ set(EXCLUSION_PROGS_CACHE ${EXCLUSION_PROGS} CACHE STRING "Programs not built" F
if(NOT EXISTS ${CMAKE_BINARY_DIR}/command-list.h OR NOT EXCLUSION_PROGS_CACHE STREQUAL EXCLUSION_PROGS)
list(REMOVE_ITEM EXCLUSION_PROGS empty)
message("Generating command-list.h")
- execute_process(COMMAND ${SH_EXE} ${CMAKE_SOURCE_DIR}/generate-cmdlist.sh ${EXCLUSION_PROGS} command-list.txt
- WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
- OUTPUT_FILE ${CMAKE_BINARY_DIR}/command-list.h)
+ execute_process(COMMAND "${SH_EXE}" "${CMAKE_SOURCE_DIR}/generate-cmdlist.sh"
+ ${EXCLUSION_PROGS}
+ "${CMAKE_SOURCE_DIR}"
+ "${CMAKE_BINARY_DIR}/command-list.h")
endif()
if(NOT EXISTS ${CMAKE_BINARY_DIR}/config-list.h)
message("Generating config-list.h")
- execute_process(COMMAND ${SH_EXE} ${CMAKE_SOURCE_DIR}/generate-configlist.sh
- WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
- OUTPUT_FILE ${CMAKE_BINARY_DIR}/config-list.h)
+ execute_process(COMMAND "${SH_EXE}" "${CMAKE_SOURCE_DIR}/generate-configlist.sh"
+ "${CMAKE_SOURCE_DIR}"
+ "${CMAKE_BINARY_DIR}/config-list.h")
endif()
if(NOT EXISTS ${CMAKE_BINARY_DIR}/hook-list.h)
message("Generating hook-list.h")
- execute_process(COMMAND ${SH_EXE} ${CMAKE_SOURCE_DIR}/generate-hooklist.sh
- WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
- OUTPUT_FILE ${CMAKE_BINARY_DIR}/hook-list.h)
+ execute_process(COMMAND "${SH_EXE}" ${CMAKE_SOURCE_DIR}/generate-hooklist.sh
+ "${CMAKE_SOURCE_DIR}"
+ "${CMAKE_BINARY_DIR}/hook-list.h")
endif()
include_directories(${CMAKE_BINARY_DIR})
#build
#libgit
-parse_makefile_for_sources(libgit_SOURCES "LIB_OBJS")
+parse_makefile_for_sources(libgit_SOURCES ${CMAKE_SOURCE_DIR}/Makefile "LIB_OBJS")
list(TRANSFORM libgit_SOURCES PREPEND "${CMAKE_SOURCE_DIR}/")
list(TRANSFORM compat_SOURCES PREPEND "${CMAKE_SOURCE_DIR}/")
+
+add_custom_command(OUTPUT "${CMAKE_BINARY_DIR}/version-def.h"
+ COMMAND "${SH_EXE}" "${CMAKE_SOURCE_DIR}/GIT-VERSION-GEN"
+ "${CMAKE_SOURCE_DIR}"
+ "${CMAKE_SOURCE_DIR}/version-def.h.in"
+ "${CMAKE_BINARY_DIR}/version-def.h"
+ DEPENDS "${SH_EXE}" "${CMAKE_SOURCE_DIR}/GIT-VERSION-GEN"
+ "${CMAKE_SOURCE_DIR}/version-def.h.in"
+ VERBATIM)
+list(APPEND libgit_SOURCES "${CMAKE_BINARY_DIR}/version-def.h")
+
add_library(libgit ${libgit_SOURCES} ${compat_SOURCES})
#libxdiff
-parse_makefile_for_sources(libxdiff_SOURCES "XDIFF_OBJS")
+parse_makefile_for_sources(libxdiff_SOURCES ${CMAKE_SOURCE_DIR}/Makefile "XDIFF_OBJS")
list(TRANSFORM libxdiff_SOURCES PREPEND "${CMAKE_SOURCE_DIR}/")
add_library(xdiff STATIC ${libxdiff_SOURCES})
#reftable
-parse_makefile_for_sources(reftable_SOURCES "REFTABLE_OBJS")
+parse_makefile_for_sources(reftable_SOURCES ${CMAKE_SOURCE_DIR}/Makefile "REFTABLE_OBJS")
list(TRANSFORM reftable_SOURCES PREPEND "${CMAKE_SOURCE_DIR}/")
add_library(reftable STATIC ${reftable_SOURCES})
if(WIN32)
+ add_custom_command(OUTPUT ${CMAKE_BINARY_DIR}/git.rc
+ COMMAND "${SH_EXE}" "${CMAKE_SOURCE_DIR}/GIT-VERSION-GEN"
+ "${CMAKE_SOURCE_DIR}"
+ "${CMAKE_SOURCE_DIR}/git.rc.in"
+ "${CMAKE_BINARY_DIR}/git.rc"
+ DEPENDS "${CMAKE_SOURCE_DIR}/GIT-VERSION-GEN"
+ "${CMAKE_SOURCE_DIR}/git.rc.in"
+ VERBATIM)
+
if(NOT MSVC)#use windres when compiling with gcc and clang
add_custom_command(OUTPUT ${CMAKE_BINARY_DIR}/git.res
- COMMAND ${WINDRES_EXE} -O coff -DMAJOR=${PROJECT_VERSION_MAJOR} -DMINOR=${PROJECT_VERSION_MINOR}
- -DMICRO=${PROJECT_VERSION_PATCH} -DPATCHLEVEL=0 -DGIT_VERSION="\\\"${PROJECT_VERSION}.GIT\\\""
- -i ${CMAKE_SOURCE_DIR}/git.rc -o ${CMAKE_BINARY_DIR}/git.res
+ COMMAND ${WINDRES_EXE} -O coff -i ${CMAKE_BINARY_DIR}/git.rc -o ${CMAKE_BINARY_DIR}/git.res
+ DEPENDS "${CMAKE_BINARY_DIR}/git.rc"
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
VERBATIM)
else()#MSVC use rc
add_custom_command(OUTPUT ${CMAKE_BINARY_DIR}/git.res
- COMMAND ${CMAKE_RC_COMPILER} /d MAJOR=${PROJECT_VERSION_MAJOR} /d MINOR=${PROJECT_VERSION_MINOR}
- /d MICRO=${PROJECT_VERSION_PATCH} /d PATCHLEVEL=0 /d GIT_VERSION="${PROJECT_VERSION}.GIT"
- /fo ${CMAKE_BINARY_DIR}/git.res ${CMAKE_SOURCE_DIR}/git.rc
+ COMMAND ${CMAKE_RC_COMPILER} /fo ${CMAKE_BINARY_DIR}/git.res ${CMAKE_BINARY_DIR}/git.rc
+ DEPENDS "${CMAKE_BINARY_DIR}/git.rc"
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
VERBATIM)
endif()
@@ -752,7 +757,7 @@ elseif(UNIX)
endif()
#git
-parse_makefile_for_sources(git_SOURCES "BUILTIN_OBJS")
+parse_makefile_for_sources(git_SOURCES ${CMAKE_SOURCE_DIR}/Makefile "BUILTIN_OBJS")
list(TRANSFORM git_SOURCES PREPEND "${CMAKE_SOURCE_DIR}/")
add_executable(git ${CMAKE_SOURCE_DIR}/git.c ${git_SOURCES})
@@ -834,70 +839,91 @@ set(git_shell_scripts
${git_sh_scripts} ${git_shlib_scripts} git-instaweb)
foreach(script ${git_shell_scripts})
- file(STRINGS ${CMAKE_SOURCE_DIR}/${script}.sh content NEWLINE_CONSUME)
- string(REPLACE "@SHELL_PATH@" "${SHELL_PATH}" content "${content}")
- string(REPLACE "@@DIFF@@" "diff" content "${content}")
- string(REPLACE "@LOCALEDIR@" "${LOCALEDIR}" content "${content}")
- string(REPLACE "@GITWEBDIR@" "${GITWEBDIR}" content "${content}")
- string(REPLACE "@@NO_CURL@@" "" content "${content}")
- string(REPLACE "@@USE_GETTEXT_SCHEME@@" "" content "${content}")
- string(REPLACE "# @@BROKEN_PATH_FIX@@" "" content "${content}")
- string(REPLACE "@@PERL@@" "${PERL_PATH}" content "${content}")
- string(REPLACE "@@PAGER_ENV@@" "LESS=FRX LV=-c" content "${content}")
- file(WRITE ${CMAKE_BINARY_DIR}/${script} ${content})
-endforeach()
-
-#perl scripts
-parse_makefile_for_scripts(git_perl_scripts "SCRIPT_PERL" ".perl")
+ if ("${script}" IN_LIST git_sh_scripts)
+ string(REPLACE ".sh" "" shell_gen_path "${script}")
+ else()
+ set(shell_gen_path "${script}")
+ endif()
-#create perl header
-file(STRINGS ${CMAKE_SOURCE_DIR}/perl/header_templates/fixed_prefix.template.pl perl_header )
-string(REPLACE "@@PATHSEP@@" ":" perl_header "${perl_header}")
-string(REPLACE "@@INSTLIBDIR@@" "${INSTLIBDIR}" perl_header "${perl_header}")
-
-foreach(script ${git_perl_scripts})
- file(STRINGS ${CMAKE_SOURCE_DIR}/${script}.perl content NEWLINE_CONSUME)
- string(REPLACE "#!/usr/bin/perl" "#!/usr/bin/perl\n${perl_header}\n" content "${content}")
- string(REPLACE "@@GIT_VERSION@@" "${PROJECT_VERSION}" content "${content}")
- file(WRITE ${CMAKE_BINARY_DIR}/${script} ${content})
+ add_custom_command(OUTPUT "${CMAKE_BINARY_DIR}/${shell_gen_path}"
+ COMMAND "${SH_EXE}" "${CMAKE_SOURCE_DIR}/generate-script.sh"
+ "${CMAKE_SOURCE_DIR}/${script}.sh"
+ "${CMAKE_BINARY_DIR}/${shell_gen_path}"
+ "${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS"
+ DEPENDS "${CMAKE_SOURCE_DIR}/generate-script.sh"
+ "${CMAKE_SOURCE_DIR}/${script}.sh"
+ VERBATIM)
+ list(APPEND shell_gen ${CMAKE_BINARY_DIR}/${shell_gen_path})
endforeach()
+add_custom_target(shell-gen ALL DEPENDS ${shell_gen})
-#python script
-file(STRINGS ${CMAKE_SOURCE_DIR}/git-p4.py content NEWLINE_CONSUME)
-string(REPLACE "#!/usr/bin/env python" "#!/usr/bin/python" content "${content}")
-file(WRITE ${CMAKE_BINARY_DIR}/git-p4 ${content})
-
+#perl scripts
+parse_makefile_for_scripts(git_perl_scripts "SCRIPT_PERL" "")
#perl modules
file(GLOB_RECURSE perl_modules "${CMAKE_SOURCE_DIR}/perl/*.pm")
+list(TRANSFORM perl_modules REPLACE "${CMAKE_SOURCE_DIR}/" "")
-foreach(pm ${perl_modules})
- string(REPLACE "${CMAKE_SOURCE_DIR}/perl/" "" file_path ${pm})
- file(STRINGS ${pm} content NEWLINE_CONSUME)
- string(REPLACE "@@LOCALEDIR@@" "${LOCALEDIR}" content "${content}")
- string(REPLACE "@@NO_PERL_CPAN_FALLBACKS@@" "" content "${content}")
- file(WRITE ${CMAKE_BINARY_DIR}/perl/build/lib/${file_path} ${content})
-#test-lib.sh requires perl/build/lib to be the build directory of perl modules
+#create perl header
+file(STRINGS ${CMAKE_SOURCE_DIR}/perl/header_templates/fixed_prefix.template.pl perl_header )
+string(REPLACE "@PATHSEP@" ":" perl_header "${perl_header}")
+string(REPLACE "@INSTLIBDIR@" "${INSTLIBDIR}" perl_header "${perl_header}")
+file(WRITE ${CMAKE_BINARY_DIR}/GIT-PERL-HEADER ${perl_header})
+
+add_custom_command(OUTPUT "${CMAKE_BINARY_DIR}/GIT-VERSION-FILE"
+ COMMAND "${SH_EXE}" "${CMAKE_SOURCE_DIR}/GIT-VERSION-GEN"
+ "${CMAKE_SOURCE_DIR}"
+ "${CMAKE_SOURCE_DIR}/GIT-VERSION-FILE.in"
+ "${CMAKE_BINARY_DIR}/GIT-VERSION-FILE"
+ DEPENDS ${SH_EXE} "${CMAKE_SOURCE_DIR}/GIT-VERSION-GEN"
+ "${CMAKE_SOURCE_DIR}/GIT-VERSION-FILE.in"
+ VERBATIM)
+
+foreach(script ${git_perl_scripts} ${perl_modules})
+ string(REPLACE ".perl" "" perl_gen_path "${script}")
+
+ get_filename_component(perl_gen_dir "${perl_gen_path}" DIRECTORY)
+ if(script MATCHES "\.pm$")
+ string(REGEX REPLACE "^perl" "perl/build/lib" perl_gen_dir "${perl_gen_dir}")
+ string(REGEX REPLACE "^perl" "perl/build/lib" perl_gen_path "${perl_gen_path}")
+ endif()
+ file(MAKE_DIRECTORY "${CMAKE_BINARY_DIR}/${perl_gen_dir}")
+
+ add_custom_command(OUTPUT "${CMAKE_BINARY_DIR}/${perl_gen_path}"
+ COMMAND "${SH_EXE}" "${CMAKE_SOURCE_DIR}/generate-perl.sh"
+ "${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS"
+ "${CMAKE_BINARY_DIR}/GIT-VERSION-FILE"
+ "${CMAKE_BINARY_DIR}/GIT-PERL-HEADER"
+ "${CMAKE_SOURCE_DIR}/${script}"
+ "${CMAKE_BINARY_DIR}/${perl_gen_path}"
+ DEPENDS "${CMAKE_SOURCE_DIR}/generate-perl.sh"
+ "${CMAKE_SOURCE_DIR}/${script}"
+ "${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS"
+ "${CMAKE_BINARY_DIR}/GIT-VERSION-FILE"
+ VERBATIM)
+ list(APPEND perl_gen ${CMAKE_BINARY_DIR}/${perl_gen_path})
endforeach()
-
-
-#templates
-file(GLOB templates "${CMAKE_SOURCE_DIR}/templates/*")
-list(TRANSFORM templates REPLACE "${CMAKE_SOURCE_DIR}/templates/" "")
-list(REMOVE_ITEM templates ".gitignore")
-list(REMOVE_ITEM templates "Makefile")
-list(REMOVE_ITEM templates "blt")# Prevents an error when reconfiguring for in source builds
-
-list(REMOVE_ITEM templates "branches--")
-file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/templates/blt/branches) #create branches
-
+add_custom_target(perl-gen ALL DEPENDS ${perl_gen})
+
+# Python script
+add_custom_command(OUTPUT "${CMAKE_BINARY_DIR}/git-p4"
+ COMMAND "${SH_EXE}" "${CMAKE_SOURCE_DIR}/generate-python.sh"
+ "${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS"
+ "${CMAKE_SOURCE_DIR}/git-p4.py"
+ "${CMAKE_BINARY_DIR}/git-p4"
+ DEPENDS "${CMAKE_SOURCE_DIR}/generate-python.sh"
+ "${CMAKE_SOURCE_DIR}/git-p4.py"
+ "${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS"
+ VERBATIM)
+add_custom_target(python-gen ALL DEPENDS "${CMAKE_BINARY_DIR}/git-p4")
+
+#${CMAKE_SOURCE_DIR}/Makefile templates
+parse_makefile_for_sources(templates ${CMAKE_SOURCE_DIR}/templates/Makefile "TEMPLATES")
+string(REPLACE " " ";" templates ${templates})
#templates have @.*@ replacement so use configure_file instead
foreach(tm ${templates})
- string(REPLACE "--" "/" blt_tm ${tm})
- string(REPLACE "this" "" blt_tm ${blt_tm})# for this--
- configure_file(${CMAKE_SOURCE_DIR}/templates/${tm} ${CMAKE_BINARY_DIR}/templates/blt/${blt_tm} @ONLY)
+ configure_file(${CMAKE_SOURCE_DIR}/templates/${tm} ${CMAKE_BINARY_DIR}/templates/blt/${tm} @ONLY)
endforeach()
-
#translations
if(MSGFMT_EXE)
file(GLOB po_files "${CMAKE_SOURCE_DIR}/po/*.po")
@@ -971,14 +997,18 @@ add_executable(test-fake-ssh ${CMAKE_SOURCE_DIR}/t/helper/test-fake-ssh.c)
target_link_libraries(test-fake-ssh common-main)
#unit-tests
-parse_makefile_for_sources(unit-test_SOURCES "UNIT_TEST_OBJS")
+parse_makefile_for_sources(unit-test_SOURCES ${CMAKE_SOURCE_DIR}/Makefile "UNIT_TEST_OBJS")
list(TRANSFORM unit-test_SOURCES REPLACE "\\$\\(UNIT_TEST_DIR\\)/" "${CMAKE_SOURCE_DIR}/t/unit-tests/")
add_library(unit-test-lib STATIC ${unit-test_SOURCES})
+parse_makefile_for_sources(clar-test_SOURCES ${CMAKE_SOURCE_DIR}/Makefile "CLAR_TEST_OBJS")
+list(TRANSFORM clar-test_SOURCES REPLACE "\\$\\(UNIT_TEST_DIR\\)/" "${CMAKE_SOURCE_DIR}/t/unit-tests/")
+add_library(clar-test-lib STATIC ${clar-test_SOURCES})
+
parse_makefile_for_scripts(unit_test_PROGRAMS "UNIT_TEST_PROGRAMS" "")
foreach(unit_test ${unit_test_PROGRAMS})
add_executable("${unit_test}" "${CMAKE_SOURCE_DIR}/t/unit-tests/${unit_test}.c")
- target_link_libraries("${unit_test}" unit-test-lib common-main)
+ target_link_libraries("${unit_test}" unit-test-lib clar-test-lib common-main)
set_target_properties("${unit_test}"
PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/t/unit-tests/bin)
if(MSVC)
@@ -1002,49 +1032,31 @@ foreach(unit_test ${unit_test_PROGRAMS})
endforeach()
parse_makefile_for_scripts(clar_test_SUITES "CLAR_TEST_SUITES" "")
-
-set(clar_decls "")
-set(clar_cbs "")
-set(clar_cbs_count 0)
-set(clar_suites "static struct clar_suite _clar_suites[] = {\n")
-list(LENGTH clar_test_SUITES clar_suites_count)
-foreach(suite ${clar_test_SUITES})
- file(STRINGS "${CMAKE_SOURCE_DIR}/t/unit-tests/${suite}.c" decls
- REGEX "^void test_${suite}__[a-zA-Z_0-9][a-zA-Z_0-9]*\\(void\\)$")
-
- list(LENGTH decls decls_count)
- string(REGEX REPLACE "void (test_${suite}__([a-zA-Z_0-9]*))\\(void\\)" " { \"\\2\", &\\1 },\n" cbs ${decls})
- string(JOIN "" cbs ${cbs})
- list(TRANSFORM decls PREPEND "extern ")
- string(JOIN ";\n" decls ${decls})
-
- string(APPEND clar_decls "${decls};\n")
- string(APPEND clar_cbs
- "static const struct clar_func _clar_cb_${suite}[] = {\n"
- ${cbs}
- "};\n")
- string(APPEND clar_suites
- " {\n"
- " \"${suite}\",\n"
- " { NULL, NULL },\n"
- " { NULL, NULL },\n"
- " _clar_cb_${suite}, ${decls_count}, 1\n"
- " },\n")
- math(EXPR clar_cbs_count "${clar_cbs_count}+${decls_count}")
-endforeach()
-string(APPEND clar_suites
- "};\n"
- "static const size_t _clar_suite_count = ${clar_suites_count};\n"
- "static const size_t _clar_callback_count = ${clar_cbs_count};\n")
-file(WRITE "${CMAKE_BINARY_DIR}/t/unit-tests/clar-decls.h" "${clar_decls}")
-file(WRITE "${CMAKE_BINARY_DIR}/t/unit-tests/clar.suite" "${clar_decls}" "${clar_cbs}" "${clar_suites}")
-
list(TRANSFORM clar_test_SUITES PREPEND "${CMAKE_SOURCE_DIR}/t/unit-tests/")
list(TRANSFORM clar_test_SUITES APPEND ".c")
-add_library(unit-tests-lib ${clar_test_SUITES} "${CMAKE_SOURCE_DIR}/t/unit-tests/clar/clar.c")
-target_include_directories(unit-tests-lib PRIVATE "${CMAKE_SOURCE_DIR}/t/unit-tests")
-add_executable(unit-tests "${CMAKE_SOURCE_DIR}/t/unit-tests/unit-test.c")
-target_link_libraries(unit-tests unit-tests-lib common-main)
+add_custom_command(OUTPUT "${CMAKE_BINARY_DIR}/t/unit-tests/clar-decls.h"
+ COMMAND ${SH_EXE} ${CMAKE_SOURCE_DIR}/t/unit-tests/generate-clar-decls.sh
+ "${CMAKE_BINARY_DIR}/t/unit-tests/clar-decls.h"
+ ${clar_test_SUITES}
+ DEPENDS ${CMAKE_SOURCE_DIR}/t/unit-tests/generate-clar-decls.sh
+ ${clar_test_SUITES}
+ VERBATIM)
+add_custom_command(OUTPUT "${CMAKE_BINARY_DIR}/t/unit-tests/clar.suite"
+ COMMAND ${SH_EXE} "${CMAKE_SOURCE_DIR}/t/unit-tests/generate-clar-suites.sh"
+ "${CMAKE_BINARY_DIR}/t/unit-tests/clar-decls.h"
+ "${CMAKE_BINARY_DIR}/t/unit-tests/clar.suite"
+ DEPENDS "${CMAKE_SOURCE_DIR}/t/unit-tests/generate-clar-suites.sh"
+ "${CMAKE_BINARY_DIR}/t/unit-tests/clar-decls.h"
+ VERBATIM)
+
+add_library(unit-tests-lib ${clar_test_SUITES}
+ "${CMAKE_BINARY_DIR}/t/unit-tests/clar-decls.h"
+ "${CMAKE_BINARY_DIR}/t/unit-tests/clar.suite"
+)
+target_include_directories(clar-test-lib PUBLIC "${CMAKE_BINARY_DIR}/t/unit-tests")
+target_include_directories(unit-tests-lib PUBLIC "${CMAKE_BINARY_DIR}/t/unit-tests")
+add_executable(unit-tests)
+target_link_libraries(unit-tests unit-tests-lib clar-test-lib common-main)
set_target_properties(unit-tests
PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/t/unit-tests/bin)
if(MSVC)
@@ -1055,7 +1067,7 @@ if(MSVC)
endif()
#test-tool
-parse_makefile_for_sources(test-tool_SOURCES "TEST_BUILTINS_OBJS")
+parse_makefile_for_sources(test-tool_SOURCES ${CMAKE_SOURCE_DIR}/Makefile "TEST_BUILTINS_OBJS")
add_library(test-lib OBJECT ${CMAKE_SOURCE_DIR}/t/unit-tests/test-lib.c)
list(TRANSFORM test-tool_SOURCES PREPEND "${CMAKE_SOURCE_DIR}/t/helper/")
@@ -1074,29 +1086,35 @@ endif()
#wrapper scripts
set(wrapper_scripts
- git git-upload-pack git-receive-pack git-upload-archive git-shell git-remote-ext scalar)
+ git git-upload-pack git-receive-pack git-upload-archive git-shell scalar)
set(wrapper_test_scripts
test-fake-ssh test-tool)
foreach(script ${wrapper_scripts})
- file(STRINGS ${CMAKE_SOURCE_DIR}/wrap-for-bin.sh content NEWLINE_CONSUME)
- string(REPLACE "@@BUILD_DIR@@" "${CMAKE_BINARY_DIR}" content "${content}")
- string(REPLACE "@@PROG@@" "${script}${EXE_EXTENSION}" content "${content}")
+ file(STRINGS ${CMAKE_SOURCE_DIR}/bin-wrappers/wrap-for-bin.sh content NEWLINE_CONSUME)
+ string(REPLACE "@BUILD_DIR@" "${CMAKE_BINARY_DIR}" content "${content}")
+ string(REPLACE "@TEMPLATE_DIR@" "'${CMAKE_BINARY_DIR}/templates/blt'" content "${content}")
+ string(REPLACE "@PROG@" "${CMAKE_BINARY_DIR}/${script}${EXE_EXTENSION}" content "${content}")
file(WRITE ${CMAKE_BINARY_DIR}/bin-wrappers/${script} ${content})
endforeach()
foreach(script ${wrapper_test_scripts})
- file(STRINGS ${CMAKE_SOURCE_DIR}/wrap-for-bin.sh content NEWLINE_CONSUME)
- string(REPLACE "@@BUILD_DIR@@" "${CMAKE_BINARY_DIR}" content "${content}")
- string(REPLACE "@@PROG@@" "t/helper/${script}${EXE_EXTENSION}" content "${content}")
+ file(STRINGS ${CMAKE_SOURCE_DIR}/bin-wrappers/wrap-for-bin.sh content NEWLINE_CONSUME)
+ string(REPLACE "@BUILD_DIR@" "${CMAKE_BINARY_DIR}" content "${content}")
+ string(REPLACE "@TEMPLATE_DIR@" "'${CMAKE_BINARY_DIR}/templates/blt'" content "${content}")
+ string(REPLACE "@PROG@" "${CMAKE_BINARY_DIR}/t/helper/${script}${EXE_EXTENSION}" content "${content}")
file(WRITE ${CMAKE_BINARY_DIR}/bin-wrappers/${script} ${content})
endforeach()
-file(STRINGS ${CMAKE_SOURCE_DIR}/wrap-for-bin.sh content NEWLINE_CONSUME)
-string(REPLACE "@@BUILD_DIR@@" "${CMAKE_BINARY_DIR}" content "${content}")
-string(REPLACE "@@PROG@@" "git-cvsserver" content "${content}")
+file(STRINGS ${CMAKE_SOURCE_DIR}/bin-wrappers/wrap-for-bin.sh content NEWLINE_CONSUME)
+string(REPLACE "@BUILD_DIR@" "${CMAKE_BINARY_DIR}" content "${content}")
+string(REPLACE "@TEMPLATE_DIR@" "'${CMAKE_BINARY_DIR}/templates/blt'" content "${content}")
+string(REPLACE "@GIT_TEXTDOMAINDIR@" "${CMAKE_BINARY_DIR}/po/build/locale" content "${content}")
+string(REPLACE "@GITPERLLIB@" "${CMAKE_BINARY_DIR}/perl/build/lib" content "${content}")
+string(REPLACE "@MERGE_TOOLS_DIR@" "${CMAKE_SOURCE_DIR}/mergetools" content "${content}")
+string(REPLACE "@PROG@" "${CMAKE_BINARY_DIR}/git-cvsserver" content "${content}")
file(WRITE ${CMAKE_BINARY_DIR}/bin-wrappers/git-cvsserver ${content})
#options for configuring test options
@@ -1109,6 +1127,7 @@ set(DIFF diff)
set(PYTHON_PATH /usr/bin/python)
set(TAR tar)
set(NO_CURL )
+set(NO_ICONV )
set(NO_EXPAT )
set(USE_LIBPCRE2 )
set(NO_PERL )
@@ -1122,6 +1141,10 @@ if(NOT CURL_FOUND)
set(NO_CURL 1)
endif()
+if(NOT Iconv_FOUND)
+ SET(NO_ICONV 1)
+endif()
+
if(NOT EXPAT_FOUND)
set(NO_EXPAT 1)
endif()
@@ -1138,26 +1161,59 @@ if(NOT PYTHON_TESTS)
set(NO_PYTHON 1)
endif()
-file(WRITE ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "SHELL_PATH='${SHELL_PATH}'\n")
-file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "TEST_SHELL_PATH='${TEST_SHELL_PATH}'\n")
-file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "PERL_PATH='${PERL_PATH}'\n")
-file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "DIFF='${DIFF}'\n")
-file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "PYTHON_PATH='${PYTHON_PATH}'\n")
-file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "TAR='${TAR}'\n")
-file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "NO_CURL='${NO_CURL}'\n")
-file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "NO_EXPAT='${NO_EXPAT}'\n")
-file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "NO_PERL='${NO_PERL}'\n")
-file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "NO_PTHREADS='${NO_PTHREADS}'\n")
-file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "NO_UNIX_SOCKETS='${NO_UNIX_SOCKETS}'\n")
-file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "PAGER_ENV='${PAGER_ENV}'\n")
-file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "X='${EXE_EXTENSION}'\n")
-file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "NO_GETTEXT='${NO_GETTEXT}'\n")
-file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "RUNTIME_PREFIX='${RUNTIME_PREFIX}'\n")
-file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "NO_PYTHON='${NO_PYTHON}'\n")
-file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "SUPPORTS_SIMPLE_IPC='${SUPPORTS_SIMPLE_IPC}'\n")
+file(STRINGS ${CMAKE_SOURCE_DIR}/GIT-BUILD-OPTIONS.in git_build_options NEWLINE_CONSUME)
+string(REPLACE "@BROKEN_PATH_FIX@" "" git_build_options "${git_build_options}")
+string(REPLACE "@DIFF@" "'${DIFF}'" git_build_options "${git_build_options}")
+string(REPLACE "@FSMONITOR_DAEMON_BACKEND@" "win32" git_build_options "${git_build_options}")
+string(REPLACE "@FSMONITOR_OS_SETTINGS@" "win32" git_build_options "${git_build_options}")
+string(REPLACE "@GITWEBDIR@" "'${GITWEBDIR}'" git_build_options "${git_build_options}")
+string(REPLACE "@GIT_INTEROP_MAKE_OPTS@" "" git_build_options "${git_build_options}")
+string(REPLACE "@GIT_PERF_LARGE_REPO@" "" git_build_options "${git_build_options}")
+string(REPLACE "@GIT_PERF_MAKE_COMMAND@" "" git_build_options "${git_build_options}")
+string(REPLACE "@GIT_PERF_MAKE_OPTS@" "" git_build_options "${git_build_options}")
+string(REPLACE "@GIT_PERF_REPEAT_COUNT@" "" git_build_options "${git_build_options}")
+string(REPLACE "@GIT_PERF_REPO@" "" git_build_options "${git_build_options}")
+string(REPLACE "@GIT_SOURCE_DIR@" "${CMAKE_SOURCE_DIR}" git_build_options "${git_build_options}")
+string(REPLACE "@GIT_TEST_CMP@" "" git_build_options "${git_build_options}")
+string(REPLACE "@GIT_TEST_CMP_USE_COPIED_CONTEXT@" "" git_build_options "${git_build_options}")
+string(REPLACE "@GIT_TEST_GITPERLLIB@" "'${CMAKE_BINARY_DIR}/perl/build/lib'" git_build_options "${git_build_options}")
+string(REPLACE "@GIT_TEST_INDEX_VERSION@" "" git_build_options "${git_build_options}")
+string(REPLACE "@GIT_TEST_OPTS@" "" git_build_options "${git_build_options}")
+string(REPLACE "@GIT_TEST_PERL_FATAL_WARNINGS@" "" git_build_options "${git_build_options}")
+string(REPLACE "@GIT_TEST_TEMPLATE_DIR@" "'${CMAKE_BINARY_DIR}/templates/blt'" git_build_options "${git_build_options}")
+string(REPLACE "@GIT_TEST_TEXTDOMAINDIR@" "'${CMAKE_BINARY_DIR}/po/build/locale'" git_build_options "${git_build_options}")
+string(REPLACE "@GIT_TEST_UTF8_LOCALE@" "" git_build_options "${git_build_options}")
+string(REPLACE "@LOCALEDIR@" "'${LOCALEDIR}'" git_build_options "${git_build_options}")
+string(REPLACE "@NO_CURL@" "${NO_CURL}" git_build_options "${git_build_options}")
+string(REPLACE "@NO_EXPAT@" "${NO_EXPAT}" git_build_options "${git_build_options}")
+string(REPLACE "@NO_GETTEXT@" "${NO_GETTEXT}" git_build_options "${git_build_options}")
+string(REPLACE "@NO_GITWEB@" "1" git_build_options "${git_build_options}")
+string(REPLACE "@NO_ICONV@" "${NO_ICONV}" git_build_options "${git_build_options}")
+string(REPLACE "@NO_PERL@" "${NO_PERL}" git_build_options "${git_build_options}")
+string(REPLACE "@NO_PERL_CPAN_FALLBACKS@" "" git_build_options "${git_build_options}")
+string(REPLACE "@NO_PTHREADS@" "${NO_PTHREADS}" git_build_options "${git_build_options}")
+string(REPLACE "@NO_PYTHON@" "${NO_PYTHON}" git_build_options "${git_build_options}")
+string(REPLACE "@NO_REGEX@" "" git_build_options "${git_build_options}")
+string(REPLACE "@NO_UNIX_SOCKETS@" "${NO_UNIX_SOCKETS}" git_build_options "${git_build_options}")
+string(REPLACE "@PAGER_ENV@" "'${PAGER_ENV}'" git_build_options "${git_build_options}")
+string(REPLACE "@PERL_LOCALEDIR@" "'${LOCALEDIR}'" git_build_options "${git_build_options}")
+string(REPLACE "@PERL_PATH@" "'${PERL_PATH}'" git_build_options "${git_build_options}")
+string(REPLACE "@PYTHON_PATH@" "'${PYTHON_PATH}'" git_build_options "${git_build_options}")
+string(REPLACE "@RUNTIME_PREFIX@" "'${RUNTIME_PREFIX}'" git_build_options "${git_build_options}")
+string(REPLACE "@SANITIZE_ADDRESS@" "" git_build_options "${git_build_options}")
+string(REPLACE "@SANITIZE_LEAK@" "" git_build_options "${git_build_options}")
+string(REPLACE "@SHELL_PATH@" "'${SHELL_PATH}'" git_build_options "${git_build_options}")
+string(REPLACE "@TAR@" "'${TAR}'" git_build_options "${git_build_options}")
+string(REPLACE "@TEST_OUTPUT_DIRECTORY@" "" git_build_options "${git_build_options}")
+string(REPLACE "@TEST_SHELL_PATH@" "'${TEST_SHELL_PATH}'" git_build_options "${git_build_options}")
+string(REPLACE "@USE_GETTEXT_SCHEME@" "" git_build_options "${git_build_options}")
+string(REPLACE "@USE_LIBPCRE2@" "" git_build_options "${git_build_options}")
+string(REPLACE "@WITH_BREAKING_CHANGES@" "" git_build_options "${git_build_options}")
+string(REPLACE "@X@" "${EXE_EXTENSION}" git_build_options "${git_build_options}")
if(USE_VCPKG)
- file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "PATH=\"$PATH:$TEST_DIRECTORY/../compat/vcbuild/vcpkg/installed/x64-windows/bin\"\n")
+ string(APPEND git_build_options "PATH=\"$PATH:$TEST_DIRECTORY/../compat/vcbuild/vcpkg/installed/x64-windows/bin\"\n")
endif()
+file(WRITE ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS ${git_build_options})
#Make the tests work when building out of the source tree
get_filename_component(CACHE_PATH ${CMAKE_CURRENT_LIST_DIR}/../../CMakeCache.txt ABSOLUTE)
diff --git a/contrib/buildsystems/Generators.pm b/contrib/buildsystems/Generators.pm
deleted file mode 100644
index aa4cbaa2ad..0000000000
--- a/contrib/buildsystems/Generators.pm
+++ /dev/null
@@ -1,42 +0,0 @@
-package Generators;
-require Exporter;
-
-use strict;
-use File::Basename;
-no strict 'refs';
-use vars qw($VERSION @AVAILABLE);
-
-our $VERSION = '1.00';
-our(@ISA, @EXPORT, @EXPORT_OK, @AVAILABLE);
-@ISA = qw(Exporter);
-
-BEGIN {
- local(*D);
- my $me = $INC{"Generators.pm"};
- die "Couldn't find myself in \@INC, which is required to load the generators!" if ("$me" eq "");
- $me = dirname($me);
- if (opendir(D,"$me/Generators")) {
- foreach my $gen (readdir(D)) {
- next unless ($gen =~ /\.pm$/);
- require "${me}/Generators/$gen";
- $gen =~ s,\.pm,,;
- push(@AVAILABLE, $gen);
- }
- closedir(D);
- my $gens = join(', ', @AVAILABLE);
- }
-
- push @EXPORT_OK, qw(available);
-}
-
-sub available {
- return @AVAILABLE;
-}
-
-sub generate {
- my ($gen, $git_dir, $out_dir, $rel_dir, %build_structure) = @_;
- return eval("Generators::${gen}::generate(\$git_dir, \$out_dir, \$rel_dir, \%build_structure)") if grep(/^$gen$/, @AVAILABLE);
- die "Generator \"${gen}\" is not available!\nAvailable generators are: @AVAILABLE\n";
-}
-
-1;
diff --git a/contrib/buildsystems/Generators/QMake.pm b/contrib/buildsystems/Generators/QMake.pm
deleted file mode 100644
index ff3b657e61..0000000000
--- a/contrib/buildsystems/Generators/QMake.pm
+++ /dev/null
@@ -1,189 +0,0 @@
-package Generators::QMake;
-require Exporter;
-
-use strict;
-use vars qw($VERSION);
-
-our $VERSION = '1.00';
-our(@ISA, @EXPORT, @EXPORT_OK, @AVAILABLE);
-@ISA = qw(Exporter);
-
-BEGIN {
- push @EXPORT_OK, qw(generate);
-}
-
-sub generate {
- my ($git_dir, $out_dir, $rel_dir, %build_structure) = @_;
-
- my @libs = @{$build_structure{"LIBS"}};
- foreach (@libs) {
- createLibProject($_, $git_dir, $out_dir, $rel_dir, %build_structure);
- }
-
- my @apps = @{$build_structure{"APPS"}};
- foreach (@apps) {
- createAppProject($_, $git_dir, $out_dir, $rel_dir, %build_structure);
- }
-
- createGlueProject($git_dir, $out_dir, $rel_dir, %build_structure);
- return 0;
-}
-
-sub createLibProject {
- my ($libname, $git_dir, $out_dir, $rel_dir, %build_structure) = @_;
- print "Generate $libname lib project\n";
- $rel_dir = "../$rel_dir";
-
- my $sources = join(" \\\n\t", sort(map("$rel_dir/$_", @{$build_structure{"LIBS_${libname}_SOURCES"}})));
- my $defines = join(" \\\n\t", sort(@{$build_structure{"LIBS_${libname}_DEFINES"}}));
- my $includes= join(" \\\n\t", sort(map("$rel_dir/$_", @{$build_structure{"LIBS_${libname}_INCLUDES"}})));
- my $cflags = join(" ", sort(@{$build_structure{"LIBS_${libname}_CFLAGS"}}));
-
- my $cflags_debug = $cflags;
- $cflags_debug =~ s/-MT/-MTd/;
- $cflags_debug =~ s/-O.//;
-
- my $cflags_release = $cflags;
- $cflags_release =~ s/-MTd/-MT/;
-
- my @tmp = @{$build_structure{"LIBS_${libname}_LFLAGS"}};
- my @tmp2 = ();
- foreach (@tmp) {
- if (/^-LTCG/) {
- } elsif (/^-L/) {
- $_ =~ s/^-L/-LIBPATH:$rel_dir\//;
- }
- push(@tmp2, $_);
- }
- my $lflags = join(" ", sort(@tmp));
-
- my $target = $libname;
- $target =~ s/\//_/g;
- $defines =~ s/-D//g;
- $defines =~ s/"/\\\\"/g;
- $includes =~ s/-I//g;
- mkdir "$target" || die "Could not create the directory $target for lib project!\n";
- open F, ">$target/$target.pro" || die "Could not open $target/$target.pro for writing!\n";
- print F << "EOM";
-TEMPLATE = lib
-TARGET = $target
-DESTDIR = $rel_dir
-
-CONFIG -= qt
-CONFIG += static
-
-QMAKE_CFLAGS =
-QMAKE_CFLAGS_RELEASE = $cflags_release
-QMAKE_CFLAGS_DEBUG = $cflags_debug
-QMAKE_LIBFLAGS = $lflags
-
-DEFINES += \\
- $defines
-
-INCLUDEPATH += \\
- $includes
-
-SOURCES += \\
- $sources
-EOM
- close F;
-}
-
-sub createAppProject {
- my ($appname, $git_dir, $out_dir, $rel_dir, %build_structure) = @_;
- print "Generate $appname app project\n";
- $rel_dir = "../$rel_dir";
-
- my $sources = join(" \\\n\t", sort(map("$rel_dir/$_", @{$build_structure{"APPS_${appname}_SOURCES"}})));
- my $defines = join(" \\\n\t", sort(@{$build_structure{"APPS_${appname}_DEFINES"}}));
- my $includes= join(" \\\n\t", sort(map("$rel_dir/$_", @{$build_structure{"APPS_${appname}_INCLUDES"}})));
- my $cflags = join(" ", sort(@{$build_structure{"APPS_${appname}_CFLAGS"}}));
-
- my $cflags_debug = $cflags;
- $cflags_debug =~ s/-MT/-MTd/;
- $cflags_debug =~ s/-O.//;
-
- my $cflags_release = $cflags;
- $cflags_release =~ s/-MTd/-MT/;
-
- my $libs;
- foreach (sort(@{$build_structure{"APPS_${appname}_LIBS"}})) {
- $_ =~ s/\//_/g;
- $libs .= " $_";
- }
- my @tmp = @{$build_structure{"APPS_${appname}_LFLAGS"}};
- my @tmp2 = ();
- foreach (@tmp) {
- # next if ($_ eq "-NODEFAULTLIB:MSVCRT.lib");
- if (/^-LTCG/) {
- } elsif (/^-L/) {
- $_ =~ s/^-L/-LIBPATH:$rel_dir\//;
- }
- push(@tmp2, $_);
- }
- my $lflags = join(" ", sort(@tmp));
-
- my $target = $appname;
- $target =~ s/\.exe//;
- $target =~ s/\//_/g;
- $defines =~ s/-D//g;
- $defines =~ s/"/\\\\"/g;
- $includes =~ s/-I//g;
- mkdir "$target" || die "Could not create the directory $target for app project!\n";
- open F, ">$target/$target.pro" || die "Could not open $target/$target.pro for writing!\n";
- print F << "EOM";
-TEMPLATE = app
-TARGET = $target
-DESTDIR = $rel_dir
-
-CONFIG -= qt embed_manifest_exe
-CONFIG += console
-
-QMAKE_CFLAGS =
-QMAKE_CFLAGS_RELEASE = $cflags_release
-QMAKE_CFLAGS_DEBUG = $cflags_debug
-QMAKE_LFLAGS = $lflags
-LIBS = $libs
-
-DEFINES += \\
- $defines
-
-INCLUDEPATH += \\
- $includes
-
-win32:QMAKE_LFLAGS += -LIBPATH:$rel_dir
-else: QMAKE_LFLAGS += -L$rel_dir
-
-SOURCES += \\
- $sources
-EOM
- close F;
-}
-
-sub createGlueProject {
- my ($git_dir, $out_dir, $rel_dir, %build_structure) = @_;
- my $libs = join(" \\ \n", map("\t$_|$_.pro", @{$build_structure{"LIBS"}}));
- my $apps = join(" \\ \n", map("\t$_|$_.pro", @{$build_structure{"APPS"}}));
- $libs =~ s/\.a//g;
- $libs =~ s/\//_/g;
- $libs =~ s/\|/\//g;
- $apps =~ s/\.exe//g;
- $apps =~ s/\//_/g;
- $apps =~ s/\|/\//g;
-
- my $filename = $out_dir;
- $filename =~ s/.*\/([^\/]+)$/$1/;
- $filename =~ s/\/$//;
- print "Generate glue project $filename.pro\n";
- open F, ">$filename.pro" || die "Could not open $filename.pro for writing!\n";
- print F << "EOM";
-TEMPLATE = subdirs
-CONFIG += ordered
-SUBDIRS += \\
-$libs \\
-$apps
-EOM
- close F;
-}
-
-1;
diff --git a/contrib/buildsystems/Generators/Vcproj.pm b/contrib/buildsystems/Generators/Vcproj.pm
deleted file mode 100644
index 737647e76a..0000000000
--- a/contrib/buildsystems/Generators/Vcproj.pm
+++ /dev/null
@@ -1,579 +0,0 @@
-package Generators::Vcproj;
-require Exporter;
-
-use strict;
-use vars qw($VERSION);
-use Digest::SHA qw(sha256_hex);
-
-our $VERSION = '1.00';
-our(@ISA, @EXPORT, @EXPORT_OK, @AVAILABLE);
-@ISA = qw(Exporter);
-
-BEGIN {
- push @EXPORT_OK, qw(generate);
-}
-
-sub generate_guid ($) {
- my $hex = sha256_hex($_[0]);
- $hex =~ s/^(.{8})(.{4})(.{4})(.{4})(.{12}).*/{$1-$2-$3-$4-$5}/;
- $hex =~ tr/a-z/A-Z/;
- return $hex;
-}
-
-sub generate {
- my ($git_dir, $out_dir, $rel_dir, %build_structure) = @_;
- my @libs = @{$build_structure{"LIBS"}};
- foreach (@libs) {
- createLibProject($_, $git_dir, $out_dir, $rel_dir, \%build_structure);
- }
-
- my @apps = @{$build_structure{"APPS"}};
- foreach (@apps) {
- createAppProject($_, $git_dir, $out_dir, $rel_dir, \%build_structure);
- }
-
- createGlueProject($git_dir, $out_dir, $rel_dir, %build_structure);
- return 0;
-}
-
-sub createLibProject {
- my ($libname, $git_dir, $out_dir, $rel_dir, $build_structure) = @_;
- print "Generate $libname vcproj lib project\n";
- $rel_dir = "..\\$rel_dir";
- $rel_dir =~ s/\//\\/g;
-
- my $target = $libname;
- $target =~ s/\//_/g;
- $target =~ s/\.a//;
-
- my $uuid = generate_guid($libname);
- $$build_structure{"LIBS_${target}_GUID"} = $uuid;
-
- my @srcs = sort(map("$rel_dir\\$_", @{$$build_structure{"LIBS_${libname}_SOURCES"}}));
- my @sources;
- foreach (@srcs) {
- $_ =~ s/\//\\/g;
- push(@sources, $_);
- }
- my $defines = join(",", sort(@{$$build_structure{"LIBS_${libname}_DEFINES"}}));
- my $includes= join(";", sort(map("&quot;$rel_dir\\$_&quot;", @{$$build_structure{"LIBS_${libname}_INCLUDES"}})));
- my $cflags = join(" ", sort(@{$$build_structure{"LIBS_${libname}_CFLAGS"}}));
- $cflags =~ s/\"/&quot;/g;
- $cflags =~ s/</&lt;/g;
- $cflags =~ s/>/&gt;/g;
-
- my $cflags_debug = $cflags;
- $cflags_debug =~ s/-MT/-MTd/;
- $cflags_debug =~ s/-O.//;
-
- my $cflags_release = $cflags;
- $cflags_release =~ s/-MTd/-MT/;
-
- my @tmp = @{$$build_structure{"LIBS_${libname}_LFLAGS"}};
- my @tmp2 = ();
- foreach (@tmp) {
- if (/^-LTCG/) {
- } elsif (/^-L/) {
- $_ =~ s/^-L/-LIBPATH:$rel_dir\//;
- }
- push(@tmp2, $_);
- }
- my $lflags = join(" ", sort(@tmp));
-
- $defines =~ s/-D//g;
- $defines =~ s/\"/\\&quot;/g;
- $defines =~ s/</&lt;/g;
- $defines =~ s/>/&gt;/g;
- $defines =~ s/\'//g;
- $includes =~ s/-I//g;
- mkdir "$target" || die "Could not create the directory $target for lib project!\n";
- open F, ">$target/$target.vcproj" || die "Could not open $target/$target.pro for writing!\n";
- binmode F, ":crlf";
- print F << "EOM";
-<?xml version="1.0" encoding = "Windows-1252"?>
-<VisualStudioProject
- ProjectType="Visual C++"
- Version="9,00"
- Name="$target"
- ProjectGUID="$uuid">
- <Platforms>
- <Platform
- Name="Win32"/>
- </Platforms>
- <ToolFiles>
- </ToolFiles>
- <Configurations>
- <Configuration
- Name="Debug|Win32"
- OutputDirectory="$rel_dir"
- ConfigurationType="4"
- CharacterSet="0"
- IntermediateDirectory="\$(ProjectDir)\$(ConfigurationName)"
- >
- <Tool
- Name="VCPreBuildEventTool"
- />
- <Tool
- Name="VCCustomBuildTool"
- />
- <Tool
- Name="VCXMLDataGeneratorTool"
- />
- <Tool
- Name="VCMIDLTool"
- />
- <Tool
- Name="VCCLCompilerTool"
- AdditionalOptions="$cflags_debug"
- Optimization="0"
- InlineFunctionExpansion="1"
- AdditionalIncludeDirectories="$includes"
- PreprocessorDefinitions="WIN32,_DEBUG,$defines"
- MinimalRebuild="true"
- RuntimeLibrary="1"
- UsePrecompiledHeader="0"
- ProgramDataBaseFileName="\$(IntDir)\\\$(TargetName).pdb"
- WarningLevel="3"
- DebugInformationFormat="3"
- />
- <Tool
- Name="VCManagedResourceCompilerTool"
- />
- <Tool
- Name="VCResourceCompilerTool"
- />
- <Tool
- Name="VCPreLinkEventTool"
- />
- <Tool
- Name="VCLibrarianTool"
- SuppressStartupBanner="true"
- />
- <Tool
- Name="VCALinkTool"
- />
- <Tool
- Name="VCXDCMakeTool"
- />
- <Tool
- Name="VCBscMakeTool"
- />
- <Tool
- Name="VCFxCopTool"
- />
- <Tool
- Name="VCPostBuildEventTool"
- />
- </Configuration>
- <Configuration
- Name="Release|Win32"
- OutputDirectory="$rel_dir"
- ConfigurationType="4"
- CharacterSet="0"
- WholeProgramOptimization="1"
- IntermediateDirectory="\$(ProjectDir)\$(ConfigurationName)"
- >
- <Tool
- Name="VCPreBuildEventTool"
- />
- <Tool
- Name="VCCustomBuildTool"
- />
- <Tool
- Name="VCXMLDataGeneratorTool"
- />
- <Tool
- Name="VCMIDLTool"
- />
- <Tool
- Name="VCCLCompilerTool"
- AdditionalOptions="$cflags_release"
- Optimization="2"
- InlineFunctionExpansion="1"
- EnableIntrinsicFunctions="true"
- AdditionalIncludeDirectories="$includes"
- PreprocessorDefinitions="WIN32,NDEBUG,$defines"
- RuntimeLibrary="0"
- EnableFunctionLevelLinking="true"
- UsePrecompiledHeader="0"
- ProgramDataBaseFileName="\$(IntDir)\\\$(TargetName).pdb"
- WarningLevel="3"
- DebugInformationFormat="3"
- />
- <Tool
- Name="VCManagedResourceCompilerTool"
- />
- <Tool
- Name="VCResourceCompilerTool"
- />
- <Tool
- Name="VCPreLinkEventTool"
- />
- <Tool
- Name="VCLibrarianTool"
- SuppressStartupBanner="true"
- />
- <Tool
- Name="VCALinkTool"
- />
- <Tool
- Name="VCXDCMakeTool"
- />
- <Tool
- Name="VCBscMakeTool"
- />
- <Tool
- Name="VCFxCopTool"
- />
- <Tool
- Name="VCPostBuildEventTool"
- />
- </Configuration>
- </Configurations>
- <Files>
- <Filter
- Name="Source Files"
- Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx"
- UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}">
-EOM
- foreach(@sources) {
- print F << "EOM";
- <File
- RelativePath="$_"/>
-EOM
- }
- print F << "EOM";
- </Filter>
- </Files>
- <Globals>
- </Globals>
-</VisualStudioProject>
-EOM
- close F;
-}
-
-sub createAppProject {
- my ($appname, $git_dir, $out_dir, $rel_dir, $build_structure) = @_;
- print "Generate $appname vcproj app project\n";
- $rel_dir = "..\\$rel_dir";
- $rel_dir =~ s/\//\\/g;
-
- my $target = $appname;
- $target =~ s/\//_/g;
- $target =~ s/\.exe//;
-
- my $uuid = generate_guid($appname);
- $$build_structure{"APPS_${target}_GUID"} = $uuid;
-
- my @srcs = sort(map("$rel_dir\\$_", @{$$build_structure{"APPS_${appname}_SOURCES"}}));
- my @sources;
- foreach (@srcs) {
- $_ =~ s/\//\\/g;
- push(@sources, $_);
- }
- my $defines = join(",", sort(@{$$build_structure{"APPS_${appname}_DEFINES"}}));
- my $includes= join(";", sort(map("&quot;$rel_dir\\$_&quot;", @{$$build_structure{"APPS_${appname}_INCLUDES"}})));
- my $cflags = join(" ", sort(@{$$build_structure{"APPS_${appname}_CFLAGS"}}));
- $cflags =~ s/\"/&quot;/g;
- $cflags =~ s/</&lt;/g;
- $cflags =~ s/>/&gt;/g;
-
- my $cflags_debug = $cflags;
- $cflags_debug =~ s/-MT/-MTd/;
- $cflags_debug =~ s/-O.//;
-
- my $cflags_release = $cflags;
- $cflags_release =~ s/-MTd/-MT/;
-
- my $libs;
- foreach (sort(@{$$build_structure{"APPS_${appname}_LIBS"}})) {
- $_ =~ s/\//_/g;
- $libs .= " $_";
- }
- my @tmp = @{$$build_structure{"APPS_${appname}_LFLAGS"}};
- my @tmp2 = ();
- foreach (@tmp) {
- if (/^-LTCG/) {
- } elsif (/^-L/) {
- $_ =~ s/^-L/-LIBPATH:$rel_dir\//;
- }
- push(@tmp2, $_);
- }
- my $lflags = join(" ", sort(@tmp)) . " -LIBPATH:$rel_dir";
-
- $defines =~ s/-D//g;
- $defines =~ s/\"/\\&quot;/g;
- $defines =~ s/</&lt;/g;
- $defines =~ s/>/&gt;/g;
- $defines =~ s/\'//g;
- $defines =~ s/\\\\/\\/g;
- $includes =~ s/-I//g;
- mkdir "$target" || die "Could not create the directory $target for lib project!\n";
- open F, ">$target/$target.vcproj" || die "Could not open $target/$target.pro for writing!\n";
- binmode F, ":crlf";
- print F << "EOM";
-<?xml version="1.0" encoding = "Windows-1252"?>
-<VisualStudioProject
- ProjectType="Visual C++"
- Version="9,00"
- Name="$target"
- ProjectGUID="$uuid">
- <Platforms>
- <Platform
- Name="Win32"/>
- </Platforms>
- <ToolFiles>
- </ToolFiles>
- <Configurations>
- <Configuration
- Name="Debug|Win32"
- OutputDirectory="$rel_dir"
- ConfigurationType="1"
- CharacterSet="0"
- IntermediateDirectory="\$(ProjectDir)\$(ConfigurationName)"
- >
- <Tool
- Name="VCPreBuildEventTool"
- />
- <Tool
- Name="VCCustomBuildTool"
- />
- <Tool
- Name="VCXMLDataGeneratorTool"
- />
- <Tool
- Name="VCMIDLTool"
- />
- <Tool
- Name="VCCLCompilerTool"
- AdditionalOptions="$cflags_debug"
- Optimization="0"
- InlineFunctionExpansion="1"
- AdditionalIncludeDirectories="$includes"
- PreprocessorDefinitions="WIN32,_DEBUG,$defines"
- MinimalRebuild="true"
- RuntimeLibrary="1"
- UsePrecompiledHeader="0"
- ProgramDataBaseFileName="\$(IntDir)\\\$(TargetName).pdb"
- WarningLevel="3"
- DebugInformationFormat="3"
- />
- <Tool
- Name="VCManagedResourceCompilerTool"
- />
- <Tool
- Name="VCResourceCompilerTool"
- />
- <Tool
- Name="VCPreLinkEventTool"
- />
- <Tool
- Name="VCLinkerTool"
- AdditionalDependencies="$libs"
- AdditionalOptions="$lflags"
- LinkIncremental="2"
- GenerateDebugInformation="true"
- SubSystem="1"
- TargetMachine="1"
- />
- <Tool
- Name="VCALinkTool"
- />
- <Tool
- Name="VCXDCMakeTool"
- />
- <Tool
- Name="VCBscMakeTool"
- />
- <Tool
- Name="VCFxCopTool"
- />
- <Tool
- Name="VCPostBuildEventTool"
- />
- </Configuration>
- <Configuration
- Name="Release|Win32"
- OutputDirectory="$rel_dir"
- ConfigurationType="1"
- CharacterSet="0"
- WholeProgramOptimization="1"
- IntermediateDirectory="\$(ProjectDir)\$(ConfigurationName)"
- >
- <Tool
- Name="VCPreBuildEventTool"
- />
- <Tool
- Name="VCCustomBuildTool"
- />
- <Tool
- Name="VCXMLDataGeneratorTool"
- />
- <Tool
- Name="VCMIDLTool"
- />
- <Tool
- Name="VCCLCompilerTool"
- AdditionalOptions="$cflags_release"
- Optimization="2"
- InlineFunctionExpansion="1"
- EnableIntrinsicFunctions="true"
- AdditionalIncludeDirectories="$includes"
- PreprocessorDefinitions="WIN32,NDEBUG,$defines"
- RuntimeLibrary="0"
- EnableFunctionLevelLinking="true"
- UsePrecompiledHeader="0"
- ProgramDataBaseFileName="\$(IntDir)\\\$(TargetName).pdb"
- WarningLevel="3"
- DebugInformationFormat="3"
- />
- <Tool
- Name="VCManagedResourceCompilerTool"
- />
- <Tool
- Name="VCResourceCompilerTool"
- />
- <Tool
- Name="VCPreLinkEventTool"
- />
- <Tool
- Name="VCLinkerTool"
- AdditionalDependencies="$libs"
- AdditionalOptions="$lflags"
- LinkIncremental="1"
- GenerateDebugInformation="true"
- SubSystem="1"
- TargetMachine="1"
- OptimizeReferences="2"
- EnableCOMDATFolding="2"
- />
- <Tool
- Name="VCALinkTool"
- />
- <Tool
- Name="VCXDCMakeTool"
- />
- <Tool
- Name="VCBscMakeTool"
- />
- <Tool
- Name="VCFxCopTool"
- />
- <Tool
- Name="VCPostBuildEventTool"
- />
- </Configuration>
- </Configurations>
- <Files>
- <Filter
- Name="Source Files"
- Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx"
- UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}">
-EOM
- foreach(@sources) {
- print F << "EOM";
- <File
- RelativePath="$_"/>
-EOM
- }
- print F << "EOM";
- </Filter>
- </Files>
- <Globals>
- </Globals>
-</VisualStudioProject>
-EOM
- close F;
-}
-
-sub createGlueProject {
- my ($git_dir, $out_dir, $rel_dir, %build_structure) = @_;
- print "Generate solutions file\n";
- $rel_dir = "..\\$rel_dir";
- $rel_dir =~ s/\//\\/g;
- my $SLN_HEAD = "Microsoft Visual Studio Solution File, Format Version 10.00\n# Visual Studio 2008\n";
- my $SLN_PRE = "Project(\"{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}\") = ";
- my $SLN_POST = "\nEndProject\n";
-
- my @libs = @{$build_structure{"LIBS"}};
- my @tmp;
- foreach (@libs) {
- $_ =~ s/\//_/g;
- $_ =~ s/\.a//;
- push(@tmp, $_);
- }
- @libs = @tmp;
-
- my @apps = @{$build_structure{"APPS"}};
- @tmp = ();
- foreach (@apps) {
- $_ =~ s/\//_/g;
- $_ =~ s/\.exe//;
- if ($_ eq "git" ) {
- unshift(@tmp, $_);
- } else {
- push(@tmp, $_);
- }
- }
- @apps = @tmp;
-
- open F, ">git.sln" || die "Could not open git.sln for writing!\n";
- binmode F, ":crlf";
- print F "$SLN_HEAD";
-
- my $uuid_libgit = $build_structure{"LIBS_libgit_GUID"};
- my $uuid_xdiff_lib = $build_structure{"LIBS_xdiff_lib_GUID"};
- foreach (@apps) {
- my $appname = $_;
- my $uuid = $build_structure{"APPS_${appname}_GUID"};
- print F "$SLN_PRE";
- print F "\"${appname}\", \"${appname}\\${appname}.vcproj\", \"${uuid}\"\n";
- print F " ProjectSection(ProjectDependencies) = postProject\n";
- print F " ${uuid_libgit} = ${uuid_libgit}\n";
- print F " ${uuid_xdiff_lib} = ${uuid_xdiff_lib}\n";
- print F " EndProjectSection";
- print F "$SLN_POST";
- }
- foreach (@libs) {
- my $libname = $_;
- my $uuid = $build_structure{"LIBS_${libname}_GUID"};
- print F "$SLN_PRE";
- print F "\"${libname}\", \"${libname}\\${libname}.vcproj\", \"${uuid}\"";
- print F "$SLN_POST";
- }
-
- print F << "EOM";
-Global
- GlobalSection(SolutionConfigurationPlatforms) = preSolution
- Debug|Win32 = Debug|Win32
- Release|Win32 = Release|Win32
- EndGlobalSection
-EOM
- print F << "EOM";
- GlobalSection(ProjectConfigurationPlatforms) = postSolution
-EOM
- foreach (@apps) {
- my $appname = $_;
- my $uuid = $build_structure{"APPS_${appname}_GUID"};
- print F "\t\t${uuid}.Debug|Win32.ActiveCfg = Debug|Win32\n";
- print F "\t\t${uuid}.Debug|Win32.Build.0 = Debug|Win32\n";
- print F "\t\t${uuid}.Release|Win32.ActiveCfg = Release|Win32\n";
- print F "\t\t${uuid}.Release|Win32.Build.0 = Release|Win32\n";
- }
- foreach (@libs) {
- my $libname = $_;
- my $uuid = $build_structure{"LIBS_${libname}_GUID"};
- print F "\t\t${uuid}.Debug|Win32.ActiveCfg = Debug|Win32\n";
- print F "\t\t${uuid}.Debug|Win32.Build.0 = Debug|Win32\n";
- print F "\t\t${uuid}.Release|Win32.ActiveCfg = Release|Win32\n";
- print F "\t\t${uuid}.Release|Win32.Build.0 = Release|Win32\n";
- }
-
- print F << "EOM";
- EndGlobalSection
-EndGlobal
-EOM
- close F;
-}
-
-1;
diff --git a/contrib/buildsystems/Generators/Vcxproj.pm b/contrib/buildsystems/Generators/Vcxproj.pm
deleted file mode 100644
index b2e68a1671..0000000000
--- a/contrib/buildsystems/Generators/Vcxproj.pm
+++ /dev/null
@@ -1,402 +0,0 @@
-package Generators::Vcxproj;
-require Exporter;
-
-use strict;
-use vars qw($VERSION);
-use Digest::SHA qw(sha256_hex);
-
-our $VERSION = '1.00';
-our(@ISA, @EXPORT, @EXPORT_OK, @AVAILABLE);
-@ISA = qw(Exporter);
-
-BEGIN {
- push @EXPORT_OK, qw(generate);
-}
-
-sub generate_guid ($) {
- my $hex = sha256_hex($_[0]);
- $hex =~ s/^(.{8})(.{4})(.{4})(.{4})(.{12}).*/{$1-$2-$3-$4-$5}/;
- $hex =~ tr/a-z/A-Z/;
- return $hex;
-}
-
-sub generate {
- my ($git_dir, $out_dir, $rel_dir, %build_structure) = @_;
- my @libs = @{$build_structure{"LIBS"}};
- foreach (@libs) {
- createProject($_, $git_dir, $out_dir, $rel_dir, \%build_structure, 1);
- }
-
- my @apps = @{$build_structure{"APPS"}};
- foreach (@apps) {
- createProject($_, $git_dir, $out_dir, $rel_dir, \%build_structure, 0);
- }
-
- createGlueProject($git_dir, $out_dir, $rel_dir, %build_structure);
- return 0;
-}
-
-sub createProject {
- my ($name, $git_dir, $out_dir, $rel_dir, $build_structure, $static_library) = @_;
- my $label = $static_library ? "lib" : "app";
- my $prefix = $static_library ? "LIBS_" : "APPS_";
- my $config_type = $static_library ? "StaticLibrary" : "Application";
- print "Generate $name vcxproj $label project\n";
- my $cdup = $name;
- $cdup =~ s/[^\/]+/../g;
- $cdup =~ s/\//\\/g;
- $rel_dir = $rel_dir eq "." ? $cdup : "$cdup\\$rel_dir";
- $rel_dir =~ s/\//\\/g;
-
- my $target = $name;
- if ($static_library) {
- $target =~ s/\.a//;
- } else {
- $target =~ s/\.exe//;
- }
-
- my $uuid = generate_guid($name);
- $$build_structure{"$prefix${target}_GUID"} = $uuid;
- my $vcxproj = $target;
- $vcxproj =~ s/(.*\/)?(.*)/$&\/$2.vcxproj/;
- $vcxproj =~ s/([^\/]*)(\/lib)\/(lib.vcxproj)/$1$2\/$1_$3/;
- $$build_structure{"$prefix${target}_VCXPROJ"} = $vcxproj;
-
- my @srcs = sort(map("$rel_dir\\$_", @{$$build_structure{"$prefix${name}_SOURCES"}}));
- my @sources;
- foreach (@srcs) {
- $_ =~ s/\//\\/g;
- push(@sources, $_);
- }
- my $defines = join(";", sort(@{$$build_structure{"$prefix${name}_DEFINES"}}));
- my $includes= join(";", sort(map { s/^-I//; s/\//\\/g; File::Spec->file_name_is_absolute($_) ? $_ : "$rel_dir\\$_" } @{$$build_structure{"$prefix${name}_INCLUDES"}}));
- my $cflags = join(" ", sort(map { s/^-[GLMOWZ].*//; s/.* .*/"$&"/; $_; } @{$$build_structure{"$prefix${name}_CFLAGS"}}));
- $cflags =~ s/</&lt;/g;
- $cflags =~ s/>/&gt;/g;
-
- my $libs_release = "\n ";
- my $libs_debug = "\n ";
- if (!$static_library && $name ne 'headless-git') {
- $libs_release = join(";", sort(grep /^(?!libgit\.lib|xdiff\/lib\.lib|vcs-svn\/lib\.lib|reftable\/libreftable\.lib)/, @{$$build_structure{"$prefix${name}_LIBS"}}));
- $libs_debug = $libs_release;
- $libs_debug =~ s/zlib\.lib/zlibd\.lib/g;
- $libs_debug =~ s/libexpat\.lib/libexpatd\.lib/g;
- $libs_debug =~ s/libcurl\.lib/libcurl-d\.lib/g;
- }
-
- $defines =~ s/-D//g;
- $defines =~ s/</&lt;/g;
- $defines =~ s/>/&gt;/g;
- $defines =~ s/\'//g;
-
- die "Could not create the directory $target for $label project!\n" unless (-d "$target" || mkdir "$target");
-
- open F, ">$vcxproj" or die "Could not open $vcxproj for writing!\n";
- binmode F, ":crlf :utf8";
- print F chr(0xFEFF);
- print F << "EOM";
-<?xml version="1.0" encoding="utf-8"?>
-<Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
- <ItemGroup Label="ProjectConfigurations">
- <ProjectConfiguration Include="Debug|Win32">
- <Configuration>Debug</Configuration>
- <Platform>Win32</Platform>
- </ProjectConfiguration>
- <ProjectConfiguration Include="Release|Win32">
- <Configuration>Release</Configuration>
- <Platform>Win32</Platform>
- </ProjectConfiguration>
- <ProjectConfiguration Include="Debug|x64">
- <Configuration>Debug</Configuration>
- <Platform>x64</Platform>
- </ProjectConfiguration>
- <ProjectConfiguration Include="Release|x64">
- <Configuration>Release</Configuration>
- <Platform>x64</Platform>
- </ProjectConfiguration>
- </ItemGroup>
- <PropertyGroup Label="Globals">
- <ProjectGuid>$uuid</ProjectGuid>
- <Keyword>Win32Proj</Keyword>
- <VCPKGArch Condition="'\$(Platform)'=='Win32'">x86-windows</VCPKGArch>
- <VCPKGArch Condition="'\$(Platform)'!='Win32'">x64-windows</VCPKGArch>
- <VCPKGArchDirectory>$cdup\\compat\\vcbuild\\vcpkg\\installed\\\$(VCPKGArch)</VCPKGArchDirectory>
- <VCPKGBinDirectory Condition="'\$(Configuration)'=='Debug'">\$(VCPKGArchDirectory)\\debug\\bin</VCPKGBinDirectory>
- <VCPKGLibDirectory Condition="'\$(Configuration)'=='Debug'">\$(VCPKGArchDirectory)\\debug\\lib</VCPKGLibDirectory>
- <VCPKGBinDirectory Condition="'\$(Configuration)'!='Debug'">\$(VCPKGArchDirectory)\\bin</VCPKGBinDirectory>
- <VCPKGLibDirectory Condition="'\$(Configuration)'!='Debug'">\$(VCPKGArchDirectory)\\lib</VCPKGLibDirectory>
- <VCPKGIncludeDirectory>\$(VCPKGArchDirectory)\\include</VCPKGIncludeDirectory>
- <VCPKGLibs Condition="'\$(Configuration)'=='Debug'">$libs_debug</VCPKGLibs>
- <VCPKGLibs Condition="'\$(Configuration)'!='Debug'">$libs_release</VCPKGLibs>
- </PropertyGroup>
- <Import Project="\$(VCTargetsPath)\\Microsoft.Cpp.Default.props" />
- <PropertyGroup Condition="'\$(Configuration)'=='Debug'" Label="Configuration">
- <UseDebugLibraries>true</UseDebugLibraries>
- <LinkIncremental>true</LinkIncremental>
- </PropertyGroup>
- <PropertyGroup Condition="'\$(Configuration)'=='Release'" Label="Configuration">
- <UseDebugLibraries>false</UseDebugLibraries>
- <WholeProgramOptimization>true</WholeProgramOptimization>
- </PropertyGroup>
- <PropertyGroup>
- <ConfigurationType>$config_type</ConfigurationType>
- <PlatformToolset>v140</PlatformToolset>
- <!-- <CharacterSet>UTF-8</CharacterSet> -->
- <OutDir>..\\</OutDir>
- <!-- <IntDir>\$(ProjectDir)\$(Configuration)\\</IntDir> -->
- </PropertyGroup>
- <Import Project="\$(VCTargetsPath)\\Microsoft.Cpp.props" />
- <ImportGroup Label="ExtensionSettings">
- </ImportGroup>
- <ImportGroup Label="Shared">
- </ImportGroup>
- <ImportGroup Label="PropertySheets">
- <Import Project="\$(UserRootDir)\\Microsoft.Cpp.\$(Platform).user.props" Condition="exists('\$(UserRootDir)\\Microsoft.Cpp.\$(Platform).user.props')" Label="LocalAppDataPlatform" />
- </ImportGroup>
- <PropertyGroup Label="UserMacros" />
- <PropertyGroup>
- <GenerateManifest>false</GenerateManifest>
- <EnableManagedIncrementalBuild>true</EnableManagedIncrementalBuild>
- </PropertyGroup>
- <ItemDefinitionGroup>
- <ClCompile>
- <AdditionalOptions>$cflags %(AdditionalOptions)</AdditionalOptions>
- <AdditionalIncludeDirectories>$cdup;$cdup\\compat;$cdup\\compat\\regex;$cdup\\compat\\win32;$cdup\\compat\\poll;$cdup\\compat\\vcbuild\\include;\$(VCPKGIncludeDirectory);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- <EnableParallelCodeGeneration />
- <InlineFunctionExpansion>OnlyExplicitInline</InlineFunctionExpansion>
- <PrecompiledHeader />
- <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
- </ClCompile>
- <Lib>
- <SuppressStartupBanner>true</SuppressStartupBanner>
- </Lib>
- <Link>
- <AdditionalLibraryDirectories>\$(VCPKGLibDirectory);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
- <AdditionalDependencies>\$(VCPKGLibs);\$(AdditionalDependencies)</AdditionalDependencies>
- <AdditionalOptions>invalidcontinue.obj %(AdditionalOptions)</AdditionalOptions>
- <EntryPointSymbol>wmainCRTStartup</EntryPointSymbol>
- <ManifestFile>$cdup\\compat\\win32\\git.manifest</ManifestFile>
- <SubSystem>Console</SubSystem>
- </Link>
-EOM
- if ($target eq 'libgit') {
- print F << "EOM";
- <PreBuildEvent Condition="!Exists('$cdup\\compat\\vcbuild\\vcpkg\\installed\\\$(VCPKGArch)\\include\\openssl\\ssl.h')">
- <Message>Initialize VCPKG</Message>
- <Command>del "$cdup\\compat\\vcbuild\\vcpkg"</Command>
- <Command>call "$cdup\\compat\\vcbuild\\vcpkg_install.bat"</Command>
- </PreBuildEvent>
-EOM
- }
- print F << "EOM";
- </ItemDefinitionGroup>
- <ItemDefinitionGroup Condition="'\$(Platform)'=='Win32'">
- <Link>
- <TargetMachine>MachineX86</TargetMachine>
- </Link>
- </ItemDefinitionGroup>
- <ItemDefinitionGroup Condition="'\$(Configuration)'=='Debug'">
- <ClCompile>
- <Optimization>Disabled</Optimization>
- <PreprocessorDefinitions>WIN32;_DEBUG;$defines;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
- </ClCompile>
- <Link>
- <GenerateDebugInformation>true</GenerateDebugInformation>
- </Link>
- </ItemDefinitionGroup>
- <ItemDefinitionGroup Condition="'\$(Configuration)'=='Release'">
- <ClCompile>
- <Optimization>MaxSpeed</Optimization>
- <IntrinsicFunctions>true</IntrinsicFunctions>
- <PreprocessorDefinitions>WIN32;NDEBUG;$defines;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
- <FunctionLevelLinking>true</FunctionLevelLinking>
- <FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
- </ClCompile>
- <Link>
- <GenerateDebugInformation>true</GenerateDebugInformation>
- <EnableCOMDATFolding>true</EnableCOMDATFolding>
- <OptimizeReferences>true</OptimizeReferences>
- </Link>
- </ItemDefinitionGroup>
- <ItemGroup>
-EOM
- foreach(@sources) {
- print F << "EOM";
- <ClCompile Include="$_" />
-EOM
- }
- print F << "EOM";
- </ItemGroup>
-EOM
- if ((!$static_library || $target =~ 'vcs-svn' || $target =~ 'xdiff') && !($name =~ /headless-git/)) {
- my $uuid_libgit = $$build_structure{"LIBS_libgit_GUID"};
- my $uuid_libreftable = $$build_structure{"LIBS_reftable/libreftable_GUID"};
- my $uuid_xdiff_lib = $$build_structure{"LIBS_xdiff/lib_GUID"};
-
- print F << "EOM";
- <ItemGroup>
- <ProjectReference Include="$cdup\\libgit\\libgit.vcxproj">
- <Project>$uuid_libgit</Project>
- <ReferenceOutputAssembly>false</ReferenceOutputAssembly>
- </ProjectReference>
-EOM
- if (!($name =~ /xdiff|libreftable/)) {
- print F << "EOM";
- <ProjectReference Include="$cdup\\reftable\\libreftable\\libreftable.vcxproj">
- <Project>$uuid_libreftable</Project>
- <ReferenceOutputAssembly>false</ReferenceOutputAssembly>
- </ProjectReference>
-EOM
- }
- if (!($name =~ 'xdiff')) {
- print F << "EOM";
- <ProjectReference Include="$cdup\\xdiff\\lib\\xdiff_lib.vcxproj">
- <Project>$uuid_xdiff_lib</Project>
- <ReferenceOutputAssembly>false</ReferenceOutputAssembly>
- </ProjectReference>
-EOM
- }
- if ($name =~ /(test-(line-buffer|svn-fe)|^git-remote-testsvn)\.exe$/) {
- my $uuid_vcs_svn_lib = $$build_structure{"LIBS_vcs-svn/lib_GUID"};
- print F << "EOM";
- <ProjectReference Include="$cdup\\vcs-svn\\lib\\vcs-svn_lib.vcxproj">
- <Project>$uuid_vcs_svn_lib</Project>
- <ReferenceOutputAssembly>false</ReferenceOutputAssembly>
- </ProjectReference>
-EOM
- }
- print F << "EOM";
- </ItemGroup>
-EOM
- }
- print F << "EOM";
- <Import Project="\$(VCTargetsPath)\\Microsoft.Cpp.targets" />
-EOM
- if (!$static_library) {
- print F << "EOM";
- <Target Name="${target}_AfterBuild" AfterTargets="AfterBuild">
- <ItemGroup>
- <DLLsAndPDBs Include="\$(VCPKGBinDirectory)\\*.dll;\$(VCPKGBinDirectory)\\*.pdb" />
- </ItemGroup>
- <Copy SourceFiles="@(DLLsAndPDBs)" DestinationFolder="\$(OutDir)" SkipUnchangedFiles="true" UseHardlinksIfPossible="true" />
- <MakeDir Directories="..\\templates\\blt\\branches" />
- </Target>
-EOM
- }
- if ($target eq 'git') {
- print F " <Import Project=\"LinkOrCopyBuiltins.targets\" />\n";
- }
- if ($target eq 'git-remote-http') {
- print F " <Import Project=\"LinkOrCopyRemoteHttp.targets\" />\n";
- }
- print F << "EOM";
-</Project>
-EOM
- close F;
-}
-
-sub createGlueProject {
- my ($git_dir, $out_dir, $rel_dir, %build_structure) = @_;
- print "Generate solutions file\n";
- $rel_dir = "..\\$rel_dir";
- $rel_dir =~ s/\//\\/g;
- my $SLN_HEAD = "Microsoft Visual Studio Solution File, Format Version 11.00\n# Visual Studio 2010\n";
- my $SLN_PRE = "Project(\"{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}\") = ";
- my $SLN_POST = "\nEndProject\n";
-
- my @libs = @{$build_structure{"LIBS"}};
- my @tmp;
- foreach (@libs) {
- $_ =~ s/\.a//;
- push(@tmp, $_);
- }
- @libs = @tmp;
-
- my @apps = @{$build_structure{"APPS"}};
- @tmp = ();
- foreach (@apps) {
- $_ =~ s/\.exe//;
- if ($_ eq "git" ) {
- unshift(@tmp, $_);
- } else {
- push(@tmp, $_);
- }
- }
- @apps = @tmp;
-
- open F, ">git.sln" || die "Could not open git.sln for writing!\n";
- binmode F, ":crlf :utf8";
- print F chr(0xFEFF);
- print F "$SLN_HEAD";
-
- foreach (@apps) {
- my $appname = $_;
- my $uuid = $build_structure{"APPS_${appname}_GUID"};
- print F "$SLN_PRE";
- my $vcxproj = $build_structure{"APPS_${appname}_VCXPROJ"};
- $vcxproj =~ s/\//\\/g;
- $appname =~ s/.*\///;
- print F "\"${appname}\", \"${vcxproj}\", \"${uuid}\"";
- print F "$SLN_POST";
- }
- foreach (@libs) {
- my $libname = $_;
- my $uuid = $build_structure{"LIBS_${libname}_GUID"};
- print F "$SLN_PRE";
- my $vcxproj = $build_structure{"LIBS_${libname}_VCXPROJ"};
- $vcxproj =~ s/\//\\/g;
- $libname =~ s/\//_/g;
- print F "\"${libname}\", \"${vcxproj}\", \"${uuid}\"";
- print F "$SLN_POST";
- }
-
- print F << "EOM";
-Global
- GlobalSection(SolutionConfigurationPlatforms) = preSolution
- Debug|x64 = Debug|x64
- Debug|x86 = Debug|x86
- Release|x64 = Release|x64
- Release|x86 = Release|x86
- EndGlobalSection
-EOM
- print F << "EOM";
- GlobalSection(ProjectConfigurationPlatforms) = postSolution
-EOM
- foreach (@apps) {
- my $appname = $_;
- my $uuid = $build_structure{"APPS_${appname}_GUID"};
- print F "\t\t${uuid}.Debug|x64.ActiveCfg = Debug|x64\n";
- print F "\t\t${uuid}.Debug|x64.Build.0 = Debug|x64\n";
- print F "\t\t${uuid}.Debug|x86.ActiveCfg = Debug|Win32\n";
- print F "\t\t${uuid}.Debug|x86.Build.0 = Debug|Win32\n";
- print F "\t\t${uuid}.Release|x64.ActiveCfg = Release|x64\n";
- print F "\t\t${uuid}.Release|x64.Build.0 = Release|x64\n";
- print F "\t\t${uuid}.Release|x86.ActiveCfg = Release|Win32\n";
- print F "\t\t${uuid}.Release|x86.Build.0 = Release|Win32\n";
- }
- foreach (@libs) {
- my $libname = $_;
- my $uuid = $build_structure{"LIBS_${libname}_GUID"};
- print F "\t\t${uuid}.Debug|x64.ActiveCfg = Debug|x64\n";
- print F "\t\t${uuid}.Debug|x64.Build.0 = Debug|x64\n";
- print F "\t\t${uuid}.Debug|x86.ActiveCfg = Debug|Win32\n";
- print F "\t\t${uuid}.Debug|x86.Build.0 = Debug|Win32\n";
- print F "\t\t${uuid}.Release|x64.ActiveCfg = Release|x64\n";
- print F "\t\t${uuid}.Release|x64.Build.0 = Release|x64\n";
- print F "\t\t${uuid}.Release|x86.ActiveCfg = Release|Win32\n";
- print F "\t\t${uuid}.Release|x86.Build.0 = Release|Win32\n";
- }
-
- print F << "EOM";
- EndGlobalSection
- GlobalSection(SolutionProperties) = preSolution
- HideSolutionNode = FALSE
- EndGlobalSection
-EndGlobal
-EOM
- close F;
-}
-
-1;
diff --git a/contrib/buildsystems/engine.pl b/contrib/buildsystems/engine.pl
deleted file mode 100755
index 069be7e4be..0000000000
--- a/contrib/buildsystems/engine.pl
+++ /dev/null
@@ -1,395 +0,0 @@
-#!/usr/bin/perl -w
-######################################################################
-# Do not call this script directly!
-#
-# The generate script ensures that @INC is correct before the engine
-# is executed.
-#
-# Copyright (C) 2009 Marius Storm-Olsen <mstormo@gmail.com>
-######################################################################
-use strict;
-use File::Basename;
-use File::Spec;
-use Cwd;
-use Generators;
-use Text::ParseWords;
-
-my (%build_structure, %compile_options, @makedry);
-my $out_dir = getcwd();
-my $git_dir = $out_dir;
-$git_dir =~ s=\\=/=g;
-$git_dir = dirname($git_dir) while (!-e "$git_dir/git.c" && "$git_dir" ne "");
-die "Couldn't find Git repo" if ("$git_dir" eq "");
-
-my @gens = Generators::available();
-my $gen = "Vcproj";
-
-sub showUsage
-{
- my $genlist = join(', ', @gens);
- print << "EOM";
-generate usage:
- -g <GENERATOR> --gen <GENERATOR> Specify the buildsystem generator (default: $gen)
- Available: $genlist
- -o <PATH> --out <PATH> Specify output directory generation (default: .)
- --make-out <PATH> Write the output of GNU Make into a file
- -i <FILE> --in <FILE> Specify input file, instead of running GNU Make
- -h,-? --help This help
-EOM
- exit 0;
-}
-
-# Parse command-line options
-my $make_out;
-while (@ARGV) {
- my $arg = shift @ARGV;
- if ("$arg" eq "-h" || "$arg" eq "--help" || "$arg" eq "-?") {
- showUsage();
- exit(0);
- } elsif("$arg" eq "--out" || "$arg" eq "-o") {
- $out_dir = shift @ARGV;
- } elsif("$arg" eq "--make-out") {
- $make_out = shift @ARGV;
- } elsif("$arg" eq "--gen" || "$arg" eq "-g") {
- $gen = shift @ARGV;
- } elsif("$arg" eq "--in" || "$arg" eq "-i") {
- my $infile = shift @ARGV;
- open(F, "<$infile") || die "Couldn't open file $infile";
- @makedry = <F>;
- close(F);
- } else {
- die "Unknown option: " . $arg;
- }
-}
-
-# NOT using File::Spec->rel2abs($path, $base) here, as
-# it fails badly for me in the msysgit environment
-$git_dir = File::Spec->rel2abs($git_dir);
-$out_dir = File::Spec->rel2abs($out_dir);
-my $rel_dir = makeOutRel2Git($git_dir, $out_dir);
-
-# Print some information so the user feels informed
-print << "EOM";
------
-Generator: $gen
-Git dir: $git_dir
-Out dir: $out_dir
------
-Running GNU Make to figure out build structure...
-EOM
-
-# Pipe a make --dry-run into a variable, if not already loaded from file
-# Capture the make dry stderr to file for review (will be empty for a release build).
-
-my $ErrsFile = "msvc-build-makedryerrors.txt";
-@makedry = `make -C $git_dir -n MSVC=1 SKIP_VCPKG=1 V=1 2>$ErrsFile`
-if !@makedry;
-# test for an empty Errors file and remove it
-unlink $ErrsFile if -f -z $ErrsFile;
-
-if (defined $make_out) {
- open OUT, ">" . $make_out;
- print OUT @makedry;
- close OUT;
-}
-
-# Parse the make output into usable info
-parseMakeOutput();
-
-# Finally, ask the generator to start generating..
-Generators::generate($gen, $git_dir, $out_dir, $rel_dir, %build_structure);
-
-# main flow ends here
-# -------------------------------------------------------------------------------------------------
-
-
-# 1) path: /foo/bar/baz 2) path: /foo/bar/baz 3) path: /foo/bar/baz
-# base: /foo/bar/baz/temp base: /foo/bar base: /tmp
-# rel: .. rel: baz rel: ../foo/bar/baz
-sub makeOutRel2Git
-{
- my ($path, $base) = @_;
- my $rel;
- if ("$path" eq "$base") {
- return ".";
- } elsif ($base =~ /^$path/) {
- # case 1
- my $tmp = $base;
- $tmp =~ s/^$path//;
- foreach (split('/', $tmp)) {
- $rel .= "../" if ("$_" ne "");
- }
- } elsif ($path =~ /^$base/) {
- # case 2
- $rel = $path;
- $rel =~ s/^$base//;
- $rel = "./$rel";
- } else {
- my $tmp = $base;
- foreach (split('/', $tmp)) {
- $rel .= "../" if ("$_" ne "");
- }
- $rel .= $path;
- }
- $rel =~ s/\/\//\//g; # simplify
- $rel =~ s/\/$//; # don't end with /
- return $rel;
-}
-
-sub parseMakeOutput
-{
- print "Parsing GNU Make output to figure out build structure...\n";
- my $line = 0;
- while (my $text = shift @makedry) {
- my $ate_next;
- do {
- $ate_next = 0;
- $line++;
- chomp $text;
- chop $text if ($text =~ /\r$/);
- if ($text =~ /\\$/) {
- $text =~ s/\\$//;
- $text .= shift @makedry;
- $ate_next = 1;
- }
- } while($ate_next);
-
- if ($text =~ /^test /) {
- # options to test (eg -o) may be mistaken for linker options
- next;
- }
-
- if ($text =~ /^(mkdir|msgfmt) /) {
- # options to the Portable Object translations
- # the line "mkdir ... && msgfmt ..." contains no linker options
- next;
- }
-
- if($text =~ / -c /) {
- # compilation
- handleCompileLine($text, $line);
-
- } elsif ($text =~ / -o /) {
- # linking executable
- handleLinkLine($text, $line);
-
- } elsif ($text =~ /\.o / && $text =~ /\.a /) {
- # libifying
- handleLibLine($text, $line);
-#
-# } elsif ($text =~ /^cp /) {
-# # copy file around
-#
-# } elsif ($text =~ /^rm -f /) {
-# # shell command
-#
-# } elsif ($text =~ /^make[ \[]/) {
-# # make output
-#
-# } elsif ($text =~ /^echo /) {
-# # echo to file
-#
-# } elsif ($text =~ /^if /) {
-# # shell conditional
-#
-# } elsif ($text =~ /^tclsh /) {
-# # translation stuff
-#
-# } elsif ($text =~ /^umask /) {
-# # handling boilerplates
-#
-# } elsif ($text =~ /\$\(\:\)/) {
-# # ignore
-#
-# } elsif ($text =~ /^FLAGS=/) {
-# # flags check for dependencies
-#
-# } elsif ($text =~ /^'\/usr\/bin\/perl' -MError -e/) {
-# # perl commands for copying files
-#
-# } elsif ($text =~ /generate-cmdlist\.sh/) {
-# # command for generating list of commands
-#
-# } elsif ($text =~ /new locations or Tcl/) {
-# # command for detecting Tcl/Tk changes
-#
-# } elsif ($text =~ /mkdir -p/) {
-# # command creating path
-#
-# } elsif ($text =~ /: no custom templates yet/) {
-# # whatever
-#
-# } else {
-# print "Unhandled (line: $line): $text\n";
- }
- }
-
-# use Data::Dumper;
-# print "Parsed build structure:\n";
-# print Dumper(%build_structure);
-}
-
-# variables for the compilation part of each step
-my (@defines, @incpaths, @cflags, @sources);
-
-sub clearCompileStep
-{
- @defines = ();
- @incpaths = ();
- @cflags = ();
- @sources = ();
-}
-
-sub removeDuplicates
-{
- my (%dupHash, $entry);
- %dupHash = map { $_, 1 } @defines;
- @defines = keys %dupHash;
-
- %dupHash = map { $_, 1 } @incpaths;
- @incpaths = keys %dupHash;
-
- %dupHash = map { $_, 1 } @cflags;
- @cflags = keys %dupHash;
-}
-
-sub handleCompileLine
-{
- my ($line, $lineno) = @_;
- my @parts = shellwords($line);
- my $sourcefile;
- shift(@parts); # ignore cmd
- while (my $part = shift @parts) {
- if ("$part" eq "-o") {
- # ignore object file
- shift @parts;
- } elsif ("$part" eq "-c") {
- # ignore compile flag
- } elsif ("$part" eq "-c") {
- } elsif ($part =~ /^.?-I/) {
- push(@incpaths, $part);
- } elsif ($part =~ /^.?-D/) {
- push(@defines, $part);
- } elsif ($part =~ /^-/) {
- push(@cflags, $part);
- } elsif ($part =~ /\.(c|cc|cpp)$/) {
- $sourcefile = $part;
- } else {
- die "Unhandled compiler option @ line $lineno: $part";
- }
- }
- @{$compile_options{"${sourcefile}_CFLAGS"}} = @cflags;
- @{$compile_options{"${sourcefile}_DEFINES"}} = @defines;
- @{$compile_options{"${sourcefile}_INCPATHS"}} = @incpaths;
- clearCompileStep();
-}
-
-sub handleLibLine
-{
- my ($line, $lineno) = @_;
- my (@objfiles, @lflags, $libout, $part);
- # kill cmd and rm 'prefix'
- $line =~ s/^rm -f .* && .* rcs //;
- my @parts = shellwords($line);
- while ($part = shift @parts) {
- if ($part =~ /^-/) {
- push(@lflags, $part);
- } elsif ($part =~ /\.(o|obj)$/) {
- push(@objfiles, $part);
- } elsif ($part =~ /\.(a|lib)$/) {
- $libout = $part;
- $libout =~ s/\.a$//;
- } else {
- die "Unhandled lib option @ line $lineno: $part";
- }
- }
-# print "LibOut: '$libout'\nLFlags: @lflags\nOfiles: @objfiles\n";
-# exit(1);
- foreach (@objfiles) {
- my $sourcefile = $_;
- $sourcefile =~ s/\.o$/.c/;
- push(@sources, $sourcefile);
- push(@cflags, @{$compile_options{"${sourcefile}_CFLAGS"}});
- push(@defines, @{$compile_options{"${sourcefile}_DEFINES"}});
- push(@incpaths, @{$compile_options{"${sourcefile}_INCPATHS"}});
- }
- removeDuplicates();
-
- push(@{$build_structure{"LIBS"}}, $libout);
- @{$build_structure{"LIBS_${libout}"}} = ("_DEFINES", "_INCLUDES", "_CFLAGS", "_SOURCES",
- "_OBJECTS");
- @{$build_structure{"LIBS_${libout}_DEFINES"}} = @defines;
- @{$build_structure{"LIBS_${libout}_INCLUDES"}} = @incpaths;
- @{$build_structure{"LIBS_${libout}_CFLAGS"}} = @cflags;
- @{$build_structure{"LIBS_${libout}_LFLAGS"}} = @lflags;
- @{$build_structure{"LIBS_${libout}_SOURCES"}} = @sources;
- @{$build_structure{"LIBS_${libout}_OBJECTS"}} = @objfiles;
- clearCompileStep();
-}
-
-sub handleLinkLine
-{
- my ($line, $lineno) = @_;
- my (@objfiles, @lflags, @libs, $appout, $part);
- my @parts = shellwords($line);
- shift(@parts); # ignore cmd
- while ($part = shift @parts) {
- if ($part =~ /^-IGNORE/) {
- push(@lflags, $part);
- } elsif ($part =~ /^-[GRIMDO]/) {
- # eat compiler flags
- } elsif ("$part" eq "-o") {
- $appout = shift @parts;
- } elsif ("$part" eq "-lz") {
- push(@libs, "zlib.lib");
- } elsif ("$part" eq "-lcrypto") {
- push(@libs, "libcrypto.lib");
- } elsif ("$part" eq "-lssl") {
- push(@libs, "libssl.lib");
- } elsif ("$part" eq "-lcurl") {
- push(@libs, "libcurl.lib");
- } elsif ("$part" eq "-lexpat") {
- push(@libs, "libexpat.lib");
- } elsif ("$part" eq "-liconv") {
- push(@libs, "iconv.lib");
- } elsif ($part =~ /^[-\/]/) {
- push(@lflags, $part);
- } elsif ($part =~ /\.(a|lib)$/) {
- $part =~ s/\.a$/.lib/;
- push(@libs, $part);
- } elsif ($part eq 'invalidcontinue.obj') {
- # ignore - known to MSVC
- } elsif ($part =~ /\.o$/) {
- push(@objfiles, $part);
- } elsif ($part =~ /\.obj$/) {
- # do nothing, 'make' should not be producing .obj, only .o files
- } else {
- die "Unhandled link option @ line $lineno: $part";
- }
- }
-# print "AppOut: '$appout'\nLFlags: @lflags\nLibs : @libs\nOfiles: @objfiles\n";
-# exit(1);
- foreach (@objfiles) {
- my $sourcefile = $_;
- $sourcefile =~ s/^headless-git\.o$/compat\/win32\/headless.c/;
- $sourcefile =~ s/\.o$/.c/;
- push(@sources, $sourcefile);
- push(@cflags, @{$compile_options{"${sourcefile}_CFLAGS"}});
- push(@defines, @{$compile_options{"${sourcefile}_DEFINES"}});
- push(@incpaths, @{$compile_options{"${sourcefile}_INCPATHS"}});
- }
- removeDuplicates();
-
- removeDuplicates();
- push(@{$build_structure{"APPS"}}, $appout);
- @{$build_structure{"APPS_${appout}"}} = ("_DEFINES", "_INCLUDES", "_CFLAGS", "_LFLAGS",
- "_SOURCES", "_OBJECTS", "_LIBS");
- @{$build_structure{"APPS_${appout}_DEFINES"}} = @defines;
- @{$build_structure{"APPS_${appout}_INCLUDES"}} = @incpaths;
- @{$build_structure{"APPS_${appout}_CFLAGS"}} = @cflags;
- @{$build_structure{"APPS_${appout}_LFLAGS"}} = @lflags;
- @{$build_structure{"APPS_${appout}_SOURCES"}} = @sources;
- @{$build_structure{"APPS_${appout}_OBJECTS"}} = @objfiles;
- @{$build_structure{"APPS_${appout}_LIBS"}} = @libs;
- clearCompileStep();
-}
diff --git a/contrib/buildsystems/generate b/contrib/buildsystems/generate
deleted file mode 100755
index bc10f25ff2..0000000000
--- a/contrib/buildsystems/generate
+++ /dev/null
@@ -1,29 +0,0 @@
-#!/usr/bin/perl -w
-######################################################################
-# Generate buildsystem files
-#
-# This script generate buildsystem files based on the output of a
-# GNU Make --dry-run, enabling Windows users to develop Git with their
-# trusted IDE with native projects.
-#
-# Note:
-# It is not meant as *the* way of building Git with MSVC, but merely a
-# convenience. The correct way of building Git with MSVC is to use the
-# GNU Make tool to build with the maintained Makefile in the root of
-# the project. If you have the msysgit environment installed and
-# available in your current console, together with the Visual Studio
-# environment you wish to build for, all you have to do is run the
-# command:
-# make MSVC=1
-#
-# Copyright (C) 2009 Marius Storm-Olsen <mstormo@gmail.com>
-######################################################################
-use strict;
-use File::Basename;
-use Cwd;
-
-my $git_dir = getcwd();
-$git_dir =~ s=\\=/=g;
-$git_dir = dirname($git_dir) while (!-e "$git_dir/git.c" && "$git_dir" ne "");
-die "Couldn't find Git repo" if ("$git_dir" eq "");
-exec join(" ", ("PERL5LIB=${git_dir}/contrib/buildsystems ${git_dir}/contrib/buildsystems/engine.pl", @ARGV));
diff --git a/contrib/buildsystems/git-version.in b/contrib/buildsystems/git-version.in
new file mode 100644
index 0000000000..9750505ae7
--- /dev/null
+++ b/contrib/buildsystems/git-version.in
@@ -0,0 +1 @@
+@GIT_MAJOR_VERSION@.@GIT_MINOR_VERSION@.@GIT_MICRO_VERSION@
diff --git a/contrib/buildsystems/parse.pl b/contrib/buildsystems/parse.pl
deleted file mode 100755
index c9656ece99..0000000000
--- a/contrib/buildsystems/parse.pl
+++ /dev/null
@@ -1,228 +0,0 @@
-#!/usr/bin/perl -w
-######################################################################
-# Do not call this script directly!
-#
-# The generate script ensures that @INC is correct before the engine
-# is executed.
-#
-# Copyright (C) 2009 Marius Storm-Olsen <mstormo@gmail.com>
-######################################################################
-use strict;
-use File::Basename;
-use Cwd;
-
-my $file = $ARGV[0];
-die "No file provided!" if !defined $file;
-
-my ($cflags, $target, $type, $line);
-
-open(F, "<$file") || die "Couldn't open file $file";
-my @data = <F>;
-close(F);
-
-while (my $text = shift @data) {
- my $ate_next;
- do {
- $ate_next = 0;
- $line++;
- chomp $text;
- chop $text if ($text =~ /\r$/);
- if ($text =~ /\\$/) {
- $text =~ s/\\$//;
- $text .= shift @data;
- $ate_next = 1;
- }
- } while($ate_next);
-
- if($text =~ / -c /) {
- # compilation
- handleCompileLine($text, $line);
-
- } elsif ($text =~ / -o /) {
- # linking executable
- handleLinkLine($text, $line);
-
- } elsif ($text =~ /\.o / && $text =~ /\.a /) {
- # libifying
- handleLibLine($text, $line);
-
-# } elsif ($text =~ /^cp /) {
-# # copy file around
-#
-# } elsif ($text =~ /^rm -f /) {
-# # shell command
-#
-# } elsif ($text =~ /^make[ \[]/) {
-# # make output
-#
-# } elsif ($text =~ /^echo /) {
-# # echo to file
-#
-# } elsif ($text =~ /^if /) {
-# # shell conditional
-#
-# } elsif ($text =~ /^tclsh /) {
-# # translation stuff
-#
-# } elsif ($text =~ /^umask /) {
-# # handling boilerplates
-#
-# } elsif ($text =~ /\$\(\:\)/) {
-# # ignore
-#
-# } elsif ($text =~ /^FLAGS=/) {
-# # flags check for dependencies
-#
-# } elsif ($text =~ /^'\/usr\/bin\/perl' -MError -e/) {
-# # perl commands for copying files
-#
-# } elsif ($text =~ /generate-cmdlist\.sh/) {
-# # command for generating list of commands
-#
-# } elsif ($text =~ /^test / && $text =~ /|| rm -f /) {
-# # commands removing executables, if they exist
-#
-# } elsif ($text =~ /new locations or Tcl/) {
-# # command for detecting Tcl/Tk changes
-#
-# } elsif ($text =~ /mkdir -p/) {
-# # command creating path
-#
-# } elsif ($text =~ /: no custom templates yet/) {
-# # whatever
-
- } else {
-# print "Unhandled (line: $line): $text\n";
- }
-}
-close(F);
-
-# use Data::Dumper;
-# print "Parsed build structure:\n";
-# print Dumper(%build_structure);
-
-# -------------------------------------------------------------------
-# Functions under here
-# -------------------------------------------------------------------
-my (%build_structure, @defines, @incpaths, @cflags, @sources);
-
-sub clearCompileStep
-{
- @defines = ();
- @incpaths = ();
- @cflags = ();
- @sources = ();
-}
-
-sub removeDuplicates
-{
- my (%dupHash, $entry);
- %dupHash = map { $_, 1 } @defines;
- @defines = keys %dupHash;
-
- %dupHash = map { $_, 1 } @incpaths;
- @incpaths = keys %dupHash;
-
- %dupHash = map { $_, 1 } @cflags;
- @cflags = keys %dupHash;
-
- %dupHash = map { $_, 1 } @sources;
- @sources = keys %dupHash;
-}
-
-sub handleCompileLine
-{
- my ($line, $lineno) = @_;
- my @parts = split(' ', $line);
- shift(@parts); # ignore cmd
- while (my $part = shift @parts) {
- if ("$part" eq "-o") {
- # ignore object file
- shift @parts;
- } elsif ("$part" eq "-c") {
- # ignore compile flag
- } elsif ("$part" eq "-c") {
- } elsif ($part =~ /^.?-I/) {
- push(@incpaths, $part);
- } elsif ($part =~ /^.?-D/) {
- push(@defines, $part);
- } elsif ($part =~ /^-/) {
- push(@cflags, $part);
- } elsif ($part =~ /\.(c|cc|cpp)$/) {
- push(@sources, $part);
- } else {
- die "Unhandled compiler option @ line $lineno: $part";
- }
- }
- #print "Sources: @sources\nCFlags: @cflags\nDefine: @defines\nIncpat: @incpaths\n";
- #exit(1);
-}
-
-sub handleLibLine
-{
- my ($line, $lineno) = @_;
- my (@objfiles, @lflags, $libout, $part);
- # kill cmd and rm 'prefix'
- $line =~ s/^rm -f .* && .* rcs //;
- my @parts = split(' ', $line);
- while ($part = shift @parts) {
- if ($part =~ /^-/) {
- push(@lflags, $part);
- } elsif ($part =~ /\.(o|obj)$/) {
- push(@objfiles, $part);
- } elsif ($part =~ /\.(a|lib)$/) {
- $libout = $part;
- } else {
- die "Unhandled lib option @ line $lineno: $part";
- }
- }
- #print "LibOut: '$libout'\nLFlags: @lflags\nOfiles: @objfiles\n";
- #exit(1);
- removeDuplicates();
- push(@{$build_structure{"LIBS"}}, $libout);
- @{$build_structure{"LIBS_${libout}"}} = ("_DEFINES", "_INCLUDES", "_CFLAGS", "_SOURCES",
- "_OBJECTS");
- @{$build_structure{"LIBS_${libout}_DEFINES"}} = @defines;
- @{$build_structure{"LIBS_${libout}_INCLUDES"}} = @incpaths;
- @{$build_structure{"LIBS_${libout}_CFLAGS"}} = @cflags;
- @{$build_structure{"LIBS_${libout}_SOURCES"}} = @sources;
- @{$build_structure{"LIBS_${libout}_OBJECTS"}} = @objfiles;
- clearCompileStep();
-}
-
-sub handleLinkLine
-{
- my ($line, $lineno) = @_;
- my (@objfiles, @lflags, @libs, $appout, $part);
- my @parts = split(' ', $line);
- shift(@parts); # ignore cmd
- while ($part = shift @parts) {
- if ($part =~ /^-[GRIDO]/) {
- # eat compiler flags
- } elsif ("$part" eq "-o") {
- $appout = shift @parts;
- } elsif ($part =~ /^-/) {
- push(@lflags, $part);
- } elsif ($part =~ /\.(a|lib)$/) {
- push(@libs, $part);
- } elsif ($part =~ /\.(o|obj)$/) {
- push(@objfiles, $part);
- } else {
- die "Unhandled lib option @ line $lineno: $part";
- }
- }
- #print "AppOut: '$appout'\nLFlags: @lflags\nLibs : @libs\nOfiles: @objfiles\n";
- #exit(1);
- removeDuplicates();
- push(@{$build_structure{"APPS"}}, $appout);
- @{$build_structure{"APPS_${appout}"}} = ("_DEFINES", "_INCLUDES", "_CFLAGS", "_LFLAGS",
- "_SOURCES", "_OBJECTS", "_LIBS");
- @{$build_structure{"APPS_${appout}_DEFINES"}} = @defines;
- @{$build_structure{"APPS_${appout}_INCLUDES"}} = @incpaths;
- @{$build_structure{"APPS_${appout}_CFLAGS"}} = @cflags;
- @{$build_structure{"APPS_${appout}_LFLAGS"}} = @lflags;
- @{$build_structure{"APPS_${appout}_SOURCES"}} = @sources;
- @{$build_structure{"APPS_${appout}_OBJECTS"}} = @objfiles;
- @{$build_structure{"APPS_${appout}_LIBS"}} = @libs;
- clearCompileStep();
-}
diff --git a/contrib/coccinelle/commit.cocci b/contrib/coccinelle/commit.cocci
index af6dd4c20c..c5284604c5 100644
--- a/contrib/coccinelle/commit.cocci
+++ b/contrib/coccinelle/commit.cocci
@@ -25,7 +25,8 @@ expression s;
// functions, then the recommended transformation will be bogus with
// repo_get_commit_tree() on the LHS.
@@
-identifier f !~ "^(repo_get_commit_tree|get_commit_tree_in_graph_one|load_tree_for_commit|set_commit_tree)$";
+identifier f != { repo_get_commit_tree, get_commit_tree_in_graph_one,
+ load_tree_for_commit, set_commit_tree };
expression c;
@@
f(...) {<...
diff --git a/contrib/coccinelle/meson.build b/contrib/coccinelle/meson.build
new file mode 100644
index 0000000000..dc3f73c2e7
--- /dev/null
+++ b/contrib/coccinelle/meson.build
@@ -0,0 +1,79 @@
+coccinelle_opt = get_option('coccinelle').require(
+ fs.exists(meson.project_source_root() / '.git'),
+ error_message: 'coccinelle can only be run from a git checkout',
+)
+
+spatch = find_program('spatch', required: coccinelle_opt)
+if not spatch.found()
+ subdir_done()
+endif
+
+rules = [
+ 'array.cocci',
+ 'commit.cocci',
+ 'config_fn_ctx.pending.cocci',
+ 'equals-null.cocci',
+ 'flex_alloc.cocci',
+ 'free.cocci',
+ 'git_config_number.cocci',
+ 'hashmap.cocci',
+ 'index-compatibility.cocci',
+ 'object_id.cocci',
+ 'preincr.cocci',
+ 'qsort.cocci',
+ 'refs.cocci',
+ 'strbuf.cocci',
+ 'swap.cocci',
+ 'the_repository.cocci',
+ 'xcalloc.cocci',
+ 'xopen.cocci',
+ 'xstrdup_or_null.cocci',
+ 'xstrncmpz.cocci',
+]
+
+concatenated_rules = custom_target(
+ command: [
+ 'cat', '@INPUT@',
+ ],
+ input: rules,
+ output: 'rules.cocci',
+ capture: true,
+)
+
+coccinelle_sources = []
+foreach source : run_command(git, '-C', meson.project_source_root(), 'ls-files', '--deduplicate', '*.c', third_party_excludes, check: true).stdout().split()
+ coccinelle_sources += source
+endforeach
+
+coccinelle_headers = []
+foreach header : headers_to_check
+ coccinelle_headers += meson.project_source_root() / header
+endforeach
+
+patches = [ ]
+foreach source : coccinelle_sources
+ patches += custom_target(
+ command: [
+ spatch,
+ '--all-includes',
+ '--sp-file', concatenated_rules,
+ '--patch', meson.project_source_root(),
+ '@INPUT@',
+ ],
+ input: meson.project_source_root() / source,
+ output: source.underscorify() + '.patch',
+ capture: true,
+ depend_files: coccinelle_headers,
+ )
+endforeach
+
+concatenated_patch = custom_target(
+ command: [
+ 'cat', '@INPUT@',
+ ],
+ input: patches,
+ output: 'cocci.patch',
+ capture: true,
+)
+
+alias_target('coccicheck', concatenated_patch)
diff --git a/contrib/coccinelle/the_repository.cocci b/contrib/coccinelle/the_repository.cocci
index 765ad68967..ea7fe1c8db 100644
--- a/contrib/coccinelle/the_repository.cocci
+++ b/contrib/coccinelle/the_repository.cocci
@@ -77,7 +77,7 @@
|
- diff_setup
+ repo_diff_setup
-// object-store.h
+// odb.h
|
- read_object_file
+ repo_read_object_file
diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
index 3d4dff3185..e3d88b0672 100644
--- a/contrib/completion/git-completion.bash
+++ b/contrib/completion/git-completion.bash
@@ -234,6 +234,17 @@ __git_dequote ()
done
}
+# Prints the number of slash-separated components in a path.
+# 1: Path to count components of.
+__git_count_path_components ()
+{
+ local path="$1"
+ local relative="${path#/}"
+ relative="${relative%/}"
+ local slashes="/${relative//[^\/]}"
+ echo "${#slashes}"
+}
+
# The following function is based on code from:
#
# bash_completion - programmable completion functions for bash 3.2+
@@ -779,16 +790,39 @@ __git_tags ()
__git_dwim_remote_heads ()
{
local pfx="${1-}" cur_="${2-}" sfx="${3-}"
- local fer_pfx="${pfx//\%/%%}" # "escape" for-each-ref format specifiers
# employ the heuristic used by git checkout and git switch
# Try to find a remote branch that cur_es the completion word
# but only output if the branch name is unique
- __git for-each-ref --format="$fer_pfx%(refname:strip=3)$sfx" \
- --sort="refname:strip=3" \
- ${GIT_COMPLETION_IGNORE_CASE+--ignore-case} \
- "refs/remotes/*/$cur_*" "refs/remotes/*/$cur_*/**" | \
- uniq -u
+ local awk_script='
+ function casemap(s) {
+ if (ENVIRON["IGNORE_CASE"])
+ return tolower(s)
+ else
+ return s
+ }
+ BEGIN {
+ split(ENVIRON["REMOTES"], remotes, /\n/)
+ for (i in remotes)
+ remotes[i] = "refs/remotes/" casemap(remotes[i])
+ cur_ = casemap(ENVIRON["CUR_"])
+ }
+ {
+ ref_case = casemap($0)
+ for (i in remotes) {
+ if (index(ref_case, remotes[i] "/" cur_) == 1) {
+ branch = substr($0, length(remotes[i] "/") + 1)
+ print ENVIRON["PFX"] branch ENVIRON["SFX"]
+ break
+ }
+ }
+ }
+ '
+ __git for-each-ref --format='%(refname)' refs/remotes/ |
+ PFX="$pfx" SFX="$sfx" CUR_="$cur_" \
+ IGNORE_CASE=${GIT_COMPLETION_IGNORE_CASE+1} \
+ REMOTES="$(__git_remotes | sort -r)" awk "$awk_script" |
+ sort | uniq -u
}
# Lists refs from the local (by default) or from a remote repository.
@@ -894,7 +928,8 @@ __git_refs ()
case "HEAD" in
$match*|$umatch*) echo "${pfx}HEAD$sfx" ;;
esac
- __git for-each-ref --format="$fer_pfx%(refname:strip=3)$sfx" \
+ local strip="$(__git_count_path_components "refs/remotes/$remote")"
+ __git for-each-ref --format="$fer_pfx%(refname:strip=$strip)$sfx" \
${GIT_COMPLETION_IGNORE_CASE+--ignore-case} \
"refs/remotes/$remote/$match*" \
"refs/remotes/$remote/$match*/**"
@@ -2331,7 +2366,7 @@ _git_mergetool ()
return
;;
--*)
- __gitcomp "--tool= --prompt --no-prompt --gui --no-gui"
+ __gitcomp "--tool= --tool-help --prompt --no-prompt --gui --no-gui"
return
;;
esac
@@ -2737,12 +2772,17 @@ __git_compute_config_vars_all ()
__git_config_vars_all="$(git --no-pager help --config)"
}
+__git_indirect()
+{
+ eval printf '%s' "\"\$$1\""
+}
+
__git_compute_first_level_config_vars_for_section ()
{
local section="$1"
__git_compute_config_vars
local this_section="__git_first_level_config_vars_for_section_${section}"
- test -n "${!this_section}" ||
+ test -n "$(__git_indirect "${this_section}")" ||
printf -v "__git_first_level_config_vars_for_section_${section}" %s \
"$(echo "$__git_config_vars" | awk -F. "/^${section}\.[a-z]/ { print \$2 }")"
}
@@ -2752,7 +2792,7 @@ __git_compute_second_level_config_vars_for_section ()
local section="$1"
__git_compute_config_vars_all
local this_section="__git_second_level_config_vars_for_section_${section}"
- test -n "${!this_section}" ||
+ test -n "$(__git_indirect "${this_section}")" ||
printf -v "__git_second_level_config_vars_for_section_${section}" %s \
"$(echo "$__git_config_vars_all" | awk -F. "/^${section}\.</ { print \$3 }")"
}
@@ -2907,7 +2947,7 @@ __git_complete_config_variable_name ()
local section="${pfx%.*.}"
__git_compute_second_level_config_vars_for_section "${section}"
local this_section="__git_second_level_config_vars_for_section_${section}"
- __gitcomp "${!this_section}" "$pfx" "$cur_" "$sfx"
+ __gitcomp "$(__git_indirect "${this_section}")" "$pfx" "$cur_" "$sfx"
return
;;
branch.*)
@@ -2917,7 +2957,7 @@ __git_complete_config_variable_name ()
__gitcomp_direct "$(__git_heads "$pfx" "$cur_" ".")"
__git_compute_first_level_config_vars_for_section "${section}"
local this_section="__git_first_level_config_vars_for_section_${section}"
- __gitcomp_nl_append "${!this_section}" "$pfx" "$cur_" "${sfx:- }"
+ __gitcomp_nl_append "$(__git_indirect "${this_section}")" "$pfx" "$cur_" "${sfx:- }"
return
;;
pager.*)
@@ -2934,7 +2974,7 @@ __git_complete_config_variable_name ()
__gitcomp_nl "$(__git_remotes)" "$pfx" "$cur_" "."
__git_compute_first_level_config_vars_for_section "${section}"
local this_section="__git_first_level_config_vars_for_section_${section}"
- __gitcomp_nl_append "${!this_section}" "$pfx" "$cur_" "${sfx:- }"
+ __gitcomp_nl_append "$(__git_indirect "${this_section}")" "$pfx" "$cur_" "${sfx:- }"
return
;;
submodule.*)
@@ -2944,7 +2984,7 @@ __git_complete_config_variable_name ()
__gitcomp_nl "$(__git config -f "$(__git rev-parse --show-toplevel)/.gitmodules" --get-regexp 'submodule.*.path' | awk -F. '{print $2}')" "$pfx" "$cur_" "."
__git_compute_first_level_config_vars_for_section "${section}"
local this_section="__git_first_level_config_vars_for_section_${section}"
- __gitcomp_nl_append "${!this_section}" "$pfx" "$cur_" "${sfx:- }"
+ __gitcomp_nl_append "$(__git_indirect "${this_section}")" "$pfx" "$cur_" "${sfx:- }"
return
;;
*.*)
diff --git a/contrib/completion/meson.build b/contrib/completion/meson.build
new file mode 100644
index 0000000000..576125b083
--- /dev/null
+++ b/contrib/completion/meson.build
@@ -0,0 +1,34 @@
+foreach script : [
+ 'git-completion.bash',
+ 'git-completion.tcsh',
+ 'git-completion.zsh',
+ 'git-prompt.sh'
+]
+ if meson.version().version_compare('>=1.3.0')
+ test_dependencies += fs.copyfile(script)
+ else
+ configure_file(
+ input: script,
+ output: script,
+ copy: true,
+ )
+ endif
+endforeach
+
+# We have to discern between the test dependency and the installed file. Our
+# tests assume the completion scripts to have the same name as the in-tree
+# files, but the installed filenames need to match the executable's basename.
+if meson.version().version_compare('>=1.3.0')
+ fs.copyfile('git-completion.bash', 'git',
+ install: true,
+ install_dir: get_option('datadir') / 'bash-completion/completions',
+ )
+else
+ configure_file(
+ input: 'git-completion.bash',
+ output: 'git',
+ copy: true,
+ install: true,
+ install_dir: get_option('datadir') / 'bash-completion/completions',
+ )
+endif
diff --git a/contrib/contacts/Makefile b/contrib/contacts/Makefile
index a2990f0dcb..9c4ca4f3bc 100644
--- a/contrib/contacts/Makefile
+++ b/contrib/contacts/Makefile
@@ -34,7 +34,7 @@ GIT_CONTACTS := git-contacts
GIT_CONTACTS_DOC := git-contacts.1
GIT_CONTACTS_XML := git-contacts.xml
-GIT_CONTACTS_TXT := git-contacts.txt
+GIT_CONTACTS_TXT := git-contacts.adoc
GIT_CONTACTS_HTML := git-contacts.html
doc: $(GIT_CONTACTS_DOC) $(GIT_CONTACTS_HTML)
diff --git a/contrib/contacts/git-contacts.txt b/contrib/contacts/git-contacts.adoc
index dd914d1261..dd914d1261 100644
--- a/contrib/contacts/git-contacts.txt
+++ b/contrib/contacts/git-contacts.adoc
diff --git a/contrib/contacts/meson.build b/contrib/contacts/meson.build
new file mode 100644
index 0000000000..73d82dfe52
--- /dev/null
+++ b/contrib/contacts/meson.build
@@ -0,0 +1,55 @@
+custom_target(
+ input: 'git-contacts',
+ output: 'git-contacts',
+ command: generate_perl_command,
+ depends: [git_version_file],
+ install: true,
+ install_dir: get_option('libexecdir') / 'git-core',
+)
+
+if get_option('docs').contains('man')
+ contacts_xml = custom_target(
+ command: asciidoc_common_options + [
+ '--backend=' + asciidoc_docbook,
+ '--doctype=manpage',
+ '--out-file=@OUTPUT@',
+ '@INPUT@',
+ ],
+ depends: documentation_deps,
+ input: 'git-contacts.adoc',
+ output: 'git-contacts.xml',
+ )
+
+ custom_target(
+ command: [
+ xmlto,
+ '-m', '@INPUT@',
+ 'man',
+ contacts_xml,
+ '-o',
+ meson.current_build_dir(),
+ ] + xmlto_extra,
+ input: [
+ '../../Documentation/manpage-normal.xsl',
+ ],
+ output: 'git-contacts.1',
+ install: true,
+ install_dir: get_option('mandir') / 'man1',
+ )
+endif
+
+if get_option('docs').contains('html')
+ custom_target(
+ command: asciidoc_common_options + [
+ '--backend=' + asciidoc_html,
+ '--doctype=manpage',
+ '--out-file=@OUTPUT@',
+ '@INPUT@',
+ ],
+ depends: documentation_deps,
+ input: 'git-contacts.adoc',
+ output: 'git-contacts.html',
+ install: true,
+ install_dir: get_option('datadir') / 'doc/git-doc',
+ )
+endif
diff --git a/contrib/credential/libsecret/Makefile b/contrib/credential/libsecret/Makefile
index 3e67552cc5..97ce9c92fb 100644
--- a/contrib/credential/libsecret/Makefile
+++ b/contrib/credential/libsecret/Makefile
@@ -1,3 +1,6 @@
+# The default target of this Makefile is...
+all::
+
MAIN:=git-credential-libsecret
all:: $(MAIN)
diff --git a/contrib/credential/libsecret/git-credential-libsecret.c b/contrib/credential/libsecret/git-credential-libsecret.c
index 90034d0cf1..941b2afd5e 100644
--- a/contrib/credential/libsecret/git-credential-libsecret.c
+++ b/contrib/credential/libsecret/git-credential-libsecret.c
@@ -59,10 +59,10 @@ static void credential_clear(struct credential *c);
/* ----------------- Secret Service functions ----------------- */
static const SecretSchema schema = {
- "org.git.Password",
+ .name = "org.git.Password",
/* Ignore schema name during search for backwards compatibility */
- SECRET_SCHEMA_DONT_MATCH_NAME,
- {
+ .flags = SECRET_SCHEMA_DONT_MATCH_NAME,
+ .attributes = {
/*
* libsecret assumes attribute values are non-confidential and
* unchanging, so we can't include oauth_refresh_token or
@@ -168,7 +168,7 @@ static int keyring_get(struct credential *c)
g_free(c->password);
c->password = g_strdup("");
}
- for (int i = 1; i < g_strv_length(parts); i++) {
+ for (guint i = 1; i < g_strv_length(parts); i++) {
if (g_str_has_prefix(parts[i], "password_expiry_utc=")) {
g_free(c->password_expiry_utc);
c->password_expiry_utc = g_strdup(&parts[i][20]);
@@ -424,7 +424,7 @@ int main(int argc, char *argv[])
struct credential_operation const *try_op = credential_helper_ops;
struct credential cred = CREDENTIAL_INIT;
- if (!argv[1]) {
+ if (argc < 2 || !*argv[1]) {
usage(argv[0]);
exit(EXIT_FAILURE);
}
diff --git a/contrib/credential/libsecret/meson.build b/contrib/credential/libsecret/meson.build
new file mode 100644
index 0000000000..0137660fe0
--- /dev/null
+++ b/contrib/credential/libsecret/meson.build
@@ -0,0 +1,9 @@
+executable('git-credential-libsecret',
+ sources: 'git-credential-libsecret.c',
+ dependencies: [
+ dependency('glib-2.0'),
+ dependency('libsecret-1'),
+ ],
+ install: true,
+ install_dir: get_option('libexecdir') / 'git-core',
+)
diff --git a/contrib/credential/meson.build b/contrib/credential/meson.build
new file mode 100644
index 0000000000..4216296ae0
--- /dev/null
+++ b/contrib/credential/meson.build
@@ -0,0 +1,3 @@
+foreach helper : get_option('credential_helpers')
+ subdir(helper)
+endforeach
diff --git a/contrib/credential/netrc/git-credential-netrc.perl b/contrib/credential/netrc/git-credential-netrc.perl
index 9fb998ae09..3c0a532d0e 100755
--- a/contrib/credential/netrc/git-credential-netrc.perl
+++ b/contrib/credential/netrc/git-credential-netrc.perl
@@ -1,4 +1,4 @@
-#!/usr/bin/perl
+#!/usr/bin/env perl
use strict;
use warnings;
@@ -267,8 +267,16 @@ sub load_netrc {
if (!defined $nentry->{machine}) {
next;
}
- if (defined $nentry->{port} && $nentry->{port} =~ m/^\d+$/) {
- $num_port = $nentry->{port};
+ if (defined $nentry->{port}) {
+ $num_port = Git::port_num($nentry->{port});
+ unless ($num_port) {
+ printf(STDERR "ignoring invalid port `%s' " .
+ "from netrc file\n", $nentry->{port});
+ }
+ # Since we've already validated and converted
+ # the port to its numerical value, do not
+ # capture it as the `protocol' value, as used
+ # to be the case for symbolic port names.
delete $nentry->{port};
}
diff --git a/contrib/credential/netrc/meson.build b/contrib/credential/netrc/meson.build
new file mode 100644
index 0000000000..16fa69e317
--- /dev/null
+++ b/contrib/credential/netrc/meson.build
@@ -0,0 +1,22 @@
+credential_netrc = custom_target(
+ input: 'git-credential-netrc.perl',
+ output: 'git-credential-netrc',
+ command: generate_perl_command,
+ depends: [git_version_file],
+ install: true,
+ install_dir: get_option('libexecdir') / 'git-core',
+)
+
+if get_option('tests')
+ credential_netrc_testenv = test_environment
+ credential_netrc_testenv.set('CREDENTIAL_NETRC_PATH', credential_netrc.full_path())
+
+ test('t-git-credential-netrc',
+ shell,
+ args: [ meson.current_source_dir() / 't-git-credential-netrc.sh' ],
+ workdir: meson.current_source_dir(),
+ env: credential_netrc_testenv,
+ depends: test_dependencies + bin_wrappers + [credential_netrc],
+ kwargs: test_kwargs,
+ )
+endif
diff --git a/contrib/credential/netrc/t-git-credential-netrc.sh b/contrib/credential/netrc/t-git-credential-netrc.sh
index bf2777308a..1b7b8b3a9a 100755
--- a/contrib/credential/netrc/t-git-credential-netrc.sh
+++ b/contrib/credential/netrc/t-git-credential-netrc.sh
@@ -15,7 +15,7 @@
export PERL5LIB="$GITPERLLIB"
test_expect_success 'git-credential-netrc' '
- perl "$GIT_BUILD_DIR"/contrib/credential/netrc/test.pl
+ perl "$GIT_SOURCE_DIR"/contrib/credential/netrc/test.pl
'
test_done
diff --git a/contrib/credential/netrc/test.pl b/contrib/credential/netrc/test.pl
index c0fb3718b2..8a7fc2588a 100755
--- a/contrib/credential/netrc/test.pl
+++ b/contrib/credential/netrc/test.pl
@@ -15,10 +15,11 @@ BEGIN {
my @global_credential_args = @ARGV;
my $scriptDir = dirname rel2abs $0;
-my ($netrc, $netrcGpg, $gcNetrc) = map { catfile $scriptDir, $_; }
+my ($netrc, $netrcGpg) = map { catfile $scriptDir, $_; }
qw(test.netrc
- test.netrc.gpg
- git-credential-netrc);
+ test.netrc.gpg);
+my $gcNetrc = $ENV{CREDENTIAL_NETRC_PATH} || catfile $scriptDir, qw(git-credential-netrc);
+
local $ENV{PATH} = join ':'
, $scriptDir
, $ENV{PATH}
@@ -44,7 +45,7 @@ chmod 0600, $netrc;
diag "Testing with invalid data\n";
$cred = run_credential(['-f', $netrc, 'get'],
"bad data");
-ok(scalar keys %$cred == 4, "Got first found keys with bad data");
+ok(scalar keys %$cred == 3, "Got first found keys with bad data");
diag "Testing netrc file for a missing corovamilkbar entry\n";
$cred = run_credential(['-f', $netrc, 'get'],
@@ -63,12 +64,12 @@ is($cred->{username}, 'carol', "Got correct Github username");
diag "Testing netrc file for a username-specific entry\n";
$cred = run_credential(['-f', $netrc, 'get'],
- { host => 'imap', username => 'bob' });
+ { host => 'imap:993', username => 'bob' });
-ok(scalar keys %$cred == 2, "Got 2 username-specific keys");
+# Only the password field gets returned.
+ok(scalar keys %$cred == 1, "Got 1 username-specific keys");
is($cred->{password}, 'bobwillknow', "Got correct user-specific password");
-is($cred->{protocol}, 'imaps', "Got correct user-specific protocol");
diag "Testing netrc file for a host:port-specific entry\n";
$cred = run_credential(['-f', $netrc, 'get'],
diff --git a/contrib/credential/osxkeychain/Makefile b/contrib/credential/osxkeychain/Makefile
index 238f5f8c36..0948297e20 100644
--- a/contrib/credential/osxkeychain/Makefile
+++ b/contrib/credential/osxkeychain/Makefile
@@ -1,3 +1,4 @@
+# The default target of this Makefile is...
all:: git-credential-osxkeychain
CC = gcc
diff --git a/contrib/credential/osxkeychain/git-credential-osxkeychain.c b/contrib/credential/osxkeychain/git-credential-osxkeychain.c
index 1c8310d7fe..611c9798b3 100644
--- a/contrib/credential/osxkeychain/git-credential-osxkeychain.c
+++ b/contrib/credential/osxkeychain/git-credential-osxkeychain.c
@@ -422,7 +422,7 @@ int main(int argc, const char **argv)
const char *usage =
"usage: git credential-osxkeychain <get|store|erase>";
- if (!argv[1])
+ if (argc < 2 || !*argv[1])
die("%s", usage);
if (open(argv[0], O_RDONLY | O_EXLOCK) == -1)
diff --git a/contrib/credential/osxkeychain/meson.build b/contrib/credential/osxkeychain/meson.build
new file mode 100644
index 0000000000..3c7677f736
--- /dev/null
+++ b/contrib/credential/osxkeychain/meson.build
@@ -0,0 +1,9 @@
+executable('git-credential-osxkeychain',
+ sources: 'git-credential-osxkeychain.c',
+ dependencies: [
+ dependency('CoreFoundation'),
+ dependency('Security'),
+ ],
+ install: true,
+ install_dir: get_option('libexecdir') / 'git-core',
+)
diff --git a/contrib/credential/wincred/Makefile b/contrib/credential/wincred/Makefile
index 6e992c0866..5b795fc9fe 100644
--- a/contrib/credential/wincred/Makefile
+++ b/contrib/credential/wincred/Makefile
@@ -1,4 +1,5 @@
-all: git-credential-wincred.exe
+# The default target of this Makefile is...
+all:: git-credential-wincred.exe
-include ../../../config.mak.autogen
-include ../../../config.mak
diff --git a/contrib/credential/wincred/git-credential-wincred.c b/contrib/credential/wincred/git-credential-wincred.c
index 3c16b74f52..5683846b4b 100644
--- a/contrib/credential/wincred/git-credential-wincred.c
+++ b/contrib/credential/wincred/git-credential-wincred.c
@@ -12,7 +12,9 @@
#define ARRAY_SIZE(x) (sizeof(x)/sizeof(x[0]))
+#ifndef _MSC_VER
__attribute__((format (printf, 1, 2)))
+#endif
static void die(const char *err, ...)
{
char msg[4096];
diff --git a/contrib/credential/wincred/meson.build b/contrib/credential/wincred/meson.build
new file mode 100644
index 0000000000..6de23ca17d
--- /dev/null
+++ b/contrib/credential/wincred/meson.build
@@ -0,0 +1,5 @@
+executable('git-credential-wincred',
+ sources: 'git-credential-wincred.c',
+ install: true,
+ install_dir: get_option('libexecdir') / 'git-core',
+)
diff --git a/contrib/diff-highlight/DiffHighlight.pm b/contrib/diff-highlight/DiffHighlight.pm
index 636add6968..3d061bc0b7 100644
--- a/contrib/diff-highlight/DiffHighlight.pm
+++ b/contrib/diff-highlight/DiffHighlight.pm
@@ -1,6 +1,6 @@
package DiffHighlight;
-use 5.008001;
+require v5.26;
use warnings FATAL => 'all';
use strict;
diff --git a/contrib/diff-highlight/Makefile b/contrib/diff-highlight/Makefile
index f2be7cc924..33c2ccc9f7 100644
--- a/contrib/diff-highlight/Makefile
+++ b/contrib/diff-highlight/Makefile
@@ -1,4 +1,5 @@
-all: diff-highlight
+# The default target of this Makefile is...
+all:: diff-highlight
PERL_PATH = /usr/bin/perl
-include ../../config.mak
diff --git a/contrib/diff-highlight/t/Makefile b/contrib/diff-highlight/t/Makefile
index 5ff5275496..2a98541477 100644
--- a/contrib/diff-highlight/t/Makefile
+++ b/contrib/diff-highlight/t/Makefile
@@ -1,3 +1,6 @@
+# The default target of this Makefile is...
+all::
+
-include ../../../config.mak.autogen
-include ../../../config.mak
@@ -6,7 +9,7 @@ SHELL_PATH ?= $(SHELL)
SHELL_PATH_SQ = $(subst ','\'',$(SHELL_PATH))
T = $(wildcard t[0-9][0-9][0-9][0-9]-*.sh)
-all: test
+all:: test
test: $(T)
.PHONY: help clean all test $(T)
diff --git a/contrib/emacs/README b/contrib/emacs/README
deleted file mode 100644
index 977a16f1e3..0000000000
--- a/contrib/emacs/README
+++ /dev/null
@@ -1,33 +0,0 @@
-This directory used to contain various modules for Emacs support.
-
-These were added shortly after Git was first released. Since then
-Emacs's own support for Git got better than what was offered by these
-modes. There are also popular 3rd-party Git modes such as Magit which
-offer replacements for these.
-
-The following modules were available, and can be dug up from the Git
-history:
-
-* git.el:
-
- Wrapper for "git status" that provided access to other git commands.
-
- Modern alternatives to this include Magit, and VC mode that ships
- with Emacs.
-
-* git-blame.el:
-
- A wrapper for "git blame" written before Emacs's own vc-annotate
- mode learned to invoke git-blame, which can be done via C-x v g.
-
-* vc-git.el:
-
- This file used to contain the VC-mode backend for git, but it is no
- longer distributed with git. It is now maintained as part of Emacs
- and included in standard Emacs distributions starting from version
- 22.2.
-
- If you have an earlier Emacs version, upgrading to Emacs 22 is
- recommended, since the VC mode in older Emacs is not generic enough
- to be able to support git in a reasonable manner, and no attempt has
- been made to backport vc-git.el.
diff --git a/contrib/emacs/git-blame.el b/contrib/emacs/git-blame.el
deleted file mode 100644
index 6a8a2b8ff1..0000000000
--- a/contrib/emacs/git-blame.el
+++ /dev/null
@@ -1,6 +0,0 @@
-(error "git-blame.el no longer ships with git. It's recommended
-to replace its use with Emacs's own vc-annotate. See
-contrib/emacs/README in git's
-sources (https://github.com/git/git/blob/master/contrib/emacs/README)
-for more info on suggested alternatives and for why this
-happened.")
diff --git a/contrib/emacs/git.el b/contrib/emacs/git.el
deleted file mode 100644
index 03f926281f..0000000000
--- a/contrib/emacs/git.el
+++ /dev/null
@@ -1,6 +0,0 @@
-(error "git.el no longer ships with git. It's recommended to
-replace its use with Magit, or simply delete references to git.el
-in your initialization file(s). See contrib/emacs/README in git's
-sources (https://github.com/git/git/blob/master/contrib/emacs/README)
-for suggested alternatives and for why this happened. Emacs's own
-VC mode and Magit are viable alternatives.")
diff --git a/contrib/examples/README b/contrib/examples/README
deleted file mode 100644
index 18bc60b021..0000000000
--- a/contrib/examples/README
+++ /dev/null
@@ -1,20 +0,0 @@
-This directory used to contain scripted implementations of builtins
-that have since been rewritten in C.
-
-They have now been removed, but can be retrieved from an older commit
-that removed them from this directory.
-
-They're interesting for their reference value to any aspiring plumbing
-users who want to learn how pieces can be fit together, but in many
-cases have drifted enough from the actual implementations Git uses to
-be instructive.
-
-Other things that can be useful:
-
- * Some commands such as git-gc wrap other commands, and what they're
- doing behind the scenes can be seen by running them under
- GIT_TRACE=1
-
- * Doing `git log` on paths matching '*--helper.c' will show
- incremental effort in the direction of moving existing shell
- scripts to C.
diff --git a/contrib/git-resurrect.sh b/contrib/git-resurrect.sh
deleted file mode 100755
index d843df3afd..0000000000
--- a/contrib/git-resurrect.sh
+++ /dev/null
@@ -1,181 +0,0 @@
-#!/bin/sh
-
-USAGE="[-a] [-r] [-m] [-t] [-n] [-b <newname>] <name>"
-LONG_USAGE="git-resurrect attempts to find traces of a branch tip
-called <name>, and tries to resurrect it. Currently, the reflog is
-searched for checkout messages, and with -r also merge messages. With
--m and -t, the history of all refs is scanned for Merge <name> into
-other/Merge <other> into <name> (respectively) commit subjects, which
-is rather slow but allows you to resurrect other people's topic
-branches."
-
-OPTIONS_KEEPDASHDASH=
-OPTIONS_STUCKLONG=
-OPTIONS_SPEC="\
-git resurrect $USAGE
---
-b,branch= save branch as <newname> instead of <name>
-a,all same as -l -r -m -t
-k,keep-going full rev-list scan (instead of first match)
-l,reflog scan reflog for checkouts (enabled by default)
-r,reflog-merges scan for merges recorded in reflog
-m,merges scan for merges into other branches (slow)
-t,merge-targets scan for merges of other branches into <name>
-n,dry-run don't recreate the branch"
-
-. git-sh-setup
-
-search_reflog () {
- sed -ne 's~^\([^ ]*\) .* checkout: moving from '"$1"' .*~\1~p' \
- < "$GIT_DIR"/logs/HEAD
-}
-
-search_reflog_merges () {
- git rev-parse $(
- sed -ne 's~^[^ ]* \([^ ]*\) .* merge '"$1"':.*~\1^2~p' \
- < "$GIT_DIR"/logs/HEAD
- )
-}
-
-oid_pattern=$(git hash-object --stdin </dev/null | sed -e 's/./[0-9a-f]/g')
-
-search_merges () {
- git rev-list --all --grep="Merge branch '$1'" \
- --pretty=tformat:"%P %s" |
- sed -ne "/^$oid_pattern \($oid_pattern\) Merge .*/ {s//\1/p;$early_exit}"
-}
-
-search_merge_targets () {
- git rev-list --all --grep="Merge branch '[^']*' into $branch\$" \
- --pretty=tformat:"%H %s" --all |
- sed -ne "/^\($oid_pattern\) Merge .*/ {s//\1/p;$early_exit} "
-}
-
-dry_run=
-early_exit=q
-scan_reflog=t
-scan_reflog_merges=
-scan_merges=
-scan_merge_targets=
-new_name=
-
-while test "$#" != 0; do
- case "$1" in
- -b|--branch)
- shift
- new_name="$1"
- ;;
- -n|--dry-run)
- dry_run=t
- ;;
- --no-dry-run)
- dry_run=
- ;;
- -k|--keep-going)
- early_exit=
- ;;
- --no-keep-going)
- early_exit=q
- ;;
- -m|--merges)
- scan_merges=t
- ;;
- --no-merges)
- scan_merges=
- ;;
- -l|--reflog)
- scan_reflog=t
- ;;
- --no-reflog)
- scan_reflog=
- ;;
- -r|--reflog_merges)
- scan_reflog_merges=t
- ;;
- --no-reflog_merges)
- scan_reflog_merges=
- ;;
- -t|--merge-targets)
- scan_merge_targets=t
- ;;
- --no-merge-targets)
- scan_merge_targets=
- ;;
- -a|--all)
- scan_reflog=t
- scan_reflog_merges=t
- scan_merges=t
- scan_merge_targets=t
- ;;
- --)
- shift
- break
- ;;
- *)
- usage
- ;;
- esac
- shift
-done
-
-test "$#" = 1 || usage
-
-all_strategies="$scan_reflog$scan_reflog_merges$scan_merges$scan_merge_targets"
-if test -z "$all_strategies"; then
- die "must enable at least one of -lrmt"
-fi
-
-branch="$1"
-test -z "$new_name" && new_name="$branch"
-
-if test ! -z "$scan_reflog"; then
- if test -r "$GIT_DIR"/logs/HEAD; then
- candidates="$(search_reflog $branch)"
- else
- die 'reflog scanning requested, but' \
- '$GIT_DIR/logs/HEAD not readable'
- fi
-fi
-if test ! -z "$scan_reflog_merges"; then
- if test -r "$GIT_DIR"/logs/HEAD; then
- candidates="$candidates $(search_reflog_merges $branch)"
- else
- die 'reflog scanning requested, but' \
- '$GIT_DIR/logs/HEAD not readable'
- fi
-fi
-if test ! -z "$scan_merges"; then
- candidates="$candidates $(search_merges $branch)"
-fi
-if test ! -z "$scan_merge_targets"; then
- candidates="$candidates $(search_merge_targets $branch)"
-fi
-
-candidates="$(git rev-parse $candidates | sort -u)"
-
-if test -z "$candidates"; then
- hint=
- test "z$all_strategies" != "ztttt" \
- && hint=" (maybe try again with -a)"
- die "no candidates for $branch found$hint"
-fi
-
-echo "** Candidates for $branch **"
-for cmt in $candidates; do
- git --no-pager log --pretty=tformat:"%ct:%h [%cr] %s" --abbrev-commit -1 $cmt
-done \
-| sort -n | cut -d: -f2-
-
-newest="$(git rev-list -1 $candidates)"
-if test ! -z "$dry_run"; then
- printf "** Most recent: "
- git --no-pager log -1 --pretty=tformat:"%h %s" $newest
-elif ! git rev-parse --verify --quiet $new_name >/dev/null; then
- printf "** Restoring $new_name to "
- git --no-pager log -1 --pretty=tformat:"%h %s" $newest
- git branch $new_name $newest
-else
- printf "Most recent: "
- git --no-pager log -1 --pretty=tformat:"%h %s" $newest
- echo "** $new_name already exists, doing nothing"
-fi
diff --git a/contrib/hooks/multimail/README.Git b/contrib/hooks/multimail/README.Git
deleted file mode 100644
index c427efc7bd..0000000000
--- a/contrib/hooks/multimail/README.Git
+++ /dev/null
@@ -1,7 +0,0 @@
-git-multimail is developed as an independent project at the following
-website:
-
- https://github.com/git-multimail/git-multimail
-
-Please refer to that project page for information about how to report
-bugs or contribute to git-multimail.
diff --git a/contrib/hooks/post-receive-email b/contrib/hooks/post-receive-email
deleted file mode 100755
index ff565eb3d8..0000000000
--- a/contrib/hooks/post-receive-email
+++ /dev/null
@@ -1,759 +0,0 @@
-#!/bin/sh
-#
-# Copyright (c) 2007 Andy Parkins
-#
-# An example hook script to mail out commit update information.
-#
-# NOTE: This script is no longer under active development. There
-# is another script, git-multimail, which is more capable and
-# configurable and is largely backwards-compatible with this script;
-# please see "contrib/hooks/multimail/". For instructions on how to
-# migrate from post-receive-email to git-multimail, please see
-# "README.migrate-from-post-receive-email" in that directory.
-#
-# This hook sends emails listing new revisions to the repository
-# introduced by the change being reported. The rule is that (for
-# branch updates) each commit will appear on one email and one email
-# only.
-#
-# This hook is stored in the contrib/hooks directory. Your distribution
-# will have put this somewhere standard. You should make this script
-# executable then link to it in the repository you would like to use it in.
-# For example, on debian the hook is stored in
-# /usr/share/git-core/contrib/hooks/post-receive-email:
-#
-# cd /path/to/your/repository.git
-# ln -sf /usr/share/git-core/contrib/hooks/post-receive-email hooks/post-receive
-#
-# This hook script assumes it is enabled on the central repository of a
-# project, with all users pushing only to it and not between each other. It
-# will still work if you don't operate in that style, but it would become
-# possible for the email to be from someone other than the person doing the
-# push.
-#
-# To help with debugging and use on pre-v1.5.1 git servers, this script will
-# also obey the interface of hooks/update, taking its arguments on the
-# command line. Unfortunately, hooks/update is called once for each ref.
-# To avoid firing one email per ref, this script just prints its output to
-# the screen when used in this mode. The output can then be redirected if
-# wanted.
-#
-# Config
-# ------
-# hooks.mailinglist
-# This is the list that all pushes will go to; leave it blank to not send
-# emails for every ref update.
-# hooks.announcelist
-# This is the list that all pushes of annotated tags will go to. Leave it
-# blank to default to the mailinglist field. The announce emails lists
-# the short log summary of the changes since the last annotated tag.
-# hooks.envelopesender
-# If set then the -f option is passed to sendmail to allow the envelope
-# sender address to be set
-# hooks.emailprefix
-# All emails have their subjects prefixed with this prefix, or "[SCM]"
-# if emailprefix is unset, to aid filtering
-# hooks.showrev
-# The shell command used to format each revision in the email, with
-# "%s" replaced with the commit id. Defaults to "git rev-list -1
-# --pretty %s", displaying the commit id, author, date and log
-# message. To list full patches separated by a blank line, you
-# could set this to "git show -C %s; echo".
-# To list a gitweb/cgit URL *and* a full patch for each change set, use this:
-# "t=%s; printf 'http://.../?id=%%s' \$t; echo;echo; git show -C \$t; echo"
-# Be careful if "..." contains things that will be expanded by shell "eval"
-# or printf.
-# hooks.emailmaxlines
-# The maximum number of lines that should be included in the generated
-# email body. If not specified, there is no limit.
-# Lines beyond the limit are suppressed and counted, and a final
-# line is added indicating the number of suppressed lines.
-# hooks.diffopts
-# Alternate options for the git diff-tree invocation that shows changes.
-# Default is "--stat --summary --find-copies-harder". Add -p to those
-# options to include a unified diff of changes in addition to the usual
-# summary output.
-#
-# Notes
-# -----
-# All emails include the headers "X-Git-Refname", "X-Git-Oldrev",
-# "X-Git-Newrev", and "X-Git-Reftype" to enable fine tuned filtering and
-# give information for debugging.
-#
-
-# ---------------------------- Functions
-
-#
-# Function to prepare for email generation. This decides what type
-# of update this is and whether an email should even be generated.
-#
-prep_for_email()
-{
- # --- Arguments
- oldrev=$(git rev-parse $1)
- newrev=$(git rev-parse $2)
- refname="$3"
-
- # --- Interpret
- # 0000->1234 (create)
- # 1234->2345 (update)
- # 2345->0000 (delete)
- if expr "$oldrev" : '0*$' >/dev/null
- then
- change_type="create"
- else
- if expr "$newrev" : '0*$' >/dev/null
- then
- change_type="delete"
- else
- change_type="update"
- fi
- fi
-
- # --- Get the revision types
- newrev_type=$(git cat-file -t $newrev 2> /dev/null)
- oldrev_type=$(git cat-file -t "$oldrev" 2> /dev/null)
- case "$change_type" in
- create|update)
- rev="$newrev"
- rev_type="$newrev_type"
- ;;
- delete)
- rev="$oldrev"
- rev_type="$oldrev_type"
- ;;
- esac
-
- # The revision type tells us what type the commit is, combined with
- # the location of the ref we can decide between
- # - working branch
- # - tracking branch
- # - unannoted tag
- # - annotated tag
- case "$refname","$rev_type" in
- refs/tags/*,commit)
- # un-annotated tag
- refname_type="tag"
- short_refname=${refname##refs/tags/}
- ;;
- refs/tags/*,tag)
- # annotated tag
- refname_type="annotated tag"
- short_refname=${refname##refs/tags/}
- # change recipients
- if [ -n "$announcerecipients" ]; then
- recipients="$announcerecipients"
- fi
- ;;
- refs/heads/*,commit)
- # branch
- refname_type="branch"
- short_refname=${refname##refs/heads/}
- ;;
- refs/remotes/*,commit)
- # tracking branch
- refname_type="tracking branch"
- short_refname=${refname##refs/remotes/}
- echo >&2 "*** Push-update of tracking branch, $refname"
- echo >&2 "*** - no email generated."
- return 1
- ;;
- *)
- # Anything else (is there anything else?)
- echo >&2 "*** Unknown type of update to $refname ($rev_type)"
- echo >&2 "*** - no email generated"
- return 1
- ;;
- esac
-
- # Check if we've got anyone to send to
- if [ -z "$recipients" ]; then
- case "$refname_type" in
- "annotated tag")
- config_name="hooks.announcelist"
- ;;
- *)
- config_name="hooks.mailinglist"
- ;;
- esac
- echo >&2 "*** $config_name is not set so no email will be sent"
- echo >&2 "*** for $refname update $oldrev->$newrev"
- return 1
- fi
-
- return 0
-}
-
-#
-# Top level email generation function. This calls the appropriate
-# body-generation routine after outputting the common header.
-#
-# Note this function doesn't actually generate any email output, that is
-# taken care of by the functions it calls:
-# - generate_email_header
-# - generate_create_XXXX_email
-# - generate_update_XXXX_email
-# - generate_delete_XXXX_email
-# - generate_email_footer
-#
-# Note also that this function cannot 'exit' from the script; when this
-# function is running (in hook script mode), the send_mail() function
-# is already executing in another process, connected via a pipe, and
-# if this function exits without, whatever has been generated to that
-# point will be sent as an email... even if nothing has been generated.
-#
-generate_email()
-{
- # Email parameters
- # The email subject will contain the best description of the ref
- # that we can build from the parameters
- describe=$(git describe $rev 2>/dev/null)
- if [ -z "$describe" ]; then
- describe=$rev
- fi
-
- generate_email_header
-
- # Call the correct body generation function
- fn_name=general
- case "$refname_type" in
- "tracking branch"|branch)
- fn_name=branch
- ;;
- "annotated tag")
- fn_name=atag
- ;;
- esac
-
- if [ -z "$maxlines" ]; then
- generate_${change_type}_${fn_name}_email
- else
- generate_${change_type}_${fn_name}_email | limit_lines $maxlines
- fi
-
- generate_email_footer
-}
-
-generate_email_header()
-{
- # --- Email (all stdout will be the email)
- # Generate header
- cat <<-EOF
- To: $recipients
- Subject: ${emailprefix}$projectdesc $refname_type $short_refname ${change_type}d. $describe
- MIME-Version: 1.0
- Content-Type: text/plain; charset=utf-8
- Content-Transfer-Encoding: 8bit
- X-Git-Refname: $refname
- X-Git-Reftype: $refname_type
- X-Git-Oldrev: $oldrev
- X-Git-Newrev: $newrev
- Auto-Submitted: auto-generated
-
- This is an automated email from the git hooks/post-receive script. It was
- generated because a ref change was pushed to the repository containing
- the project "$projectdesc".
-
- The $refname_type, $short_refname has been ${change_type}d
- EOF
-}
-
-generate_email_footer()
-{
- SPACE=" "
- cat <<-EOF
-
-
- hooks/post-receive
- --${SPACE}
- $projectdesc
- EOF
-}
-
-# --------------- Branches
-
-#
-# Called for the creation of a branch
-#
-generate_create_branch_email()
-{
- # This is a new branch and so oldrev is not valid
- echo " at $newrev ($newrev_type)"
- echo ""
-
- echo $LOGBEGIN
- show_new_revisions
- echo $LOGEND
-}
-
-#
-# Called for the change of a pre-existing branch
-#
-generate_update_branch_email()
-{
- # Consider this:
- # 1 --- 2 --- O --- X --- 3 --- 4 --- N
- #
- # O is $oldrev for $refname
- # N is $newrev for $refname
- # X is a revision pointed to by some other ref, for which we may
- # assume that an email has already been generated.
- # In this case we want to issue an email containing only revisions
- # 3, 4, and N. Given (almost) by
- #
- # git rev-list N ^O --not --all
- #
- # The reason for the "almost", is that the "--not --all" will take
- # precedence over the "N", and effectively will translate to
- #
- # git rev-list N ^O ^X ^N
- #
- # So, we need to build up the list more carefully. git rev-parse
- # will generate a list of revs that may be fed into git rev-list.
- # We can get it to make the "--not --all" part and then filter out
- # the "^N" with:
- #
- # git rev-parse --not --all | grep -v N
- #
- # Then, using the --stdin switch to git rev-list we have effectively
- # manufactured
- #
- # git rev-list N ^O ^X
- #
- # This leaves a problem when someone else updates the repository
- # while this script is running. Their new value of the ref we're
- # working on would be included in the "--not --all" output; and as
- # our $newrev would be an ancestor of that commit, it would exclude
- # all of our commits. What we really want is to exclude the current
- # value of $refname from the --not list, rather than N itself. So:
- #
- # git rev-parse --not --all | grep -v $(git rev-parse $refname)
- #
- # Gets us to something pretty safe (apart from the small time
- # between refname being read, and git rev-parse running - for that,
- # I give up)
- #
- #
- # Next problem, consider this:
- # * --- B --- * --- O ($oldrev)
- # \
- # * --- X --- * --- N ($newrev)
- #
- # That is to say, there is no guarantee that oldrev is a strict
- # subset of newrev (it would have required a --force, but that's
- # allowed). So, we can't simply say rev-list $oldrev..$newrev.
- # Instead we find the common base of the two revs and list from
- # there.
- #
- # As above, we need to take into account the presence of X; if
- # another branch is already in the repository and points at some of
- # the revisions that we are about to output - we don't want them.
- # The solution is as before: git rev-parse output filtered.
- #
- # Finally, tags: 1 --- 2 --- O --- T --- 3 --- 4 --- N
- #
- # Tags pushed into the repository generate nice shortlog emails that
- # summarise the commits between them and the previous tag. However,
- # those emails don't include the full commit messages that we output
- # for a branch update. Therefore we still want to output revisions
- # that have been output on a tag email.
- #
- # Luckily, git rev-parse includes just the tool. Instead of using
- # "--all" we use "--branches"; this has the added benefit that
- # "remotes/" will be ignored as well.
-
- # List all of the revisions that were removed by this update, in a
- # fast-forward update, this list will be empty, because rev-list O
- # ^N is empty. For a non-fast-forward, O ^N is the list of removed
- # revisions
- fast_forward=""
- rev=""
- for rev in $(git rev-list $newrev..$oldrev)
- do
- revtype=$(git cat-file -t "$rev")
- echo " discards $rev ($revtype)"
- done
- if [ -z "$rev" ]; then
- fast_forward=1
- fi
-
- # List all the revisions from baserev to newrev in a kind of
- # "table-of-contents"; note this list can include revisions that
- # have already had notification emails and is present to show the
- # full detail of the change from rolling back the old revision to
- # the base revision and then forward to the new revision
- for rev in $(git rev-list $oldrev..$newrev)
- do
- revtype=$(git cat-file -t "$rev")
- echo " via $rev ($revtype)"
- done
-
- if [ "$fast_forward" ]; then
- echo " from $oldrev ($oldrev_type)"
- else
- # 1. Existing revisions were removed. In this case newrev
- # is a subset of oldrev - this is the reverse of a
- # fast-forward, a rewind
- # 2. New revisions were added on top of an old revision,
- # this is a rewind and addition.
-
- # (1) certainly happened, (2) possibly. When (2) hasn't
- # happened, we set a flag to indicate that no log printout
- # is required.
-
- echo ""
-
- # Find the common ancestor of the old and new revisions and
- # compare it with newrev
- baserev=$(git merge-base $oldrev $newrev)
- rewind_only=""
- if [ "$baserev" = "$newrev" ]; then
- echo "This update discarded existing revisions and left the branch pointing at"
- echo "a previous point in the repository history."
- echo ""
- echo " * -- * -- N ($newrev)"
- echo " \\"
- echo " O -- O -- O ($oldrev)"
- echo ""
- echo "The removed revisions are not necessarily gone - if another reference"
- echo "still refers to them they will stay in the repository."
- rewind_only=1
- else
- echo "This update added new revisions after undoing existing revisions. That is"
- echo "to say, the old revision is not a strict subset of the new revision. This"
- echo "situation occurs when you --force push a change and generate a repository"
- echo "containing something like this:"
- echo ""
- echo " * -- * -- B -- O -- O -- O ($oldrev)"
- echo " \\"
- echo " N -- N -- N ($newrev)"
- echo ""
- echo "When this happens we assume that you've already had alert emails for all"
- echo "of the O revisions, and so we here report only the revisions in the N"
- echo "branch from the common base, B."
- fi
- fi
-
- echo ""
- if [ -z "$rewind_only" ]; then
- echo "Those revisions listed above that are new to this repository have"
- echo "not appeared on any other notification email; so we list those"
- echo "revisions in full, below."
-
- echo ""
- echo $LOGBEGIN
- show_new_revisions
-
- # XXX: Need a way of detecting whether git rev-list actually
- # outputted anything, so that we can issue a "no new
- # revisions added by this update" message
-
- echo $LOGEND
- else
- echo "No new revisions were added by this update."
- fi
-
- # The diffstat is shown from the old revision to the new revision.
- # This is to show the truth of what happened in this change.
- # There's no point showing the stat from the base to the new
- # revision because the base is effectively a random revision at this
- # point - the user will be interested in what this revision changed
- # - including the undoing of previous revisions in the case of
- # non-fast-forward updates.
- echo ""
- echo "Summary of changes:"
- git diff-tree $diffopts $oldrev..$newrev
-}
-
-#
-# Called for the deletion of a branch
-#
-generate_delete_branch_email()
-{
- echo " was $oldrev"
- echo ""
- echo $LOGBEGIN
- git diff-tree -s --always --encoding=UTF-8 --pretty=oneline $oldrev
- echo $LOGEND
-}
-
-# --------------- Annotated tags
-
-#
-# Called for the creation of an annotated tag
-#
-generate_create_atag_email()
-{
- echo " at $newrev ($newrev_type)"
-
- generate_atag_email
-}
-
-#
-# Called for the update of an annotated tag (this is probably a rare event
-# and may not even be allowed)
-#
-generate_update_atag_email()
-{
- echo " to $newrev ($newrev_type)"
- echo " from $oldrev (which is now obsolete)"
-
- generate_atag_email
-}
-
-#
-# Called when an annotated tag is created or changed
-#
-generate_atag_email()
-{
- # Use git for-each-ref to pull out the individual fields from the
- # tag
- eval $(git for-each-ref --shell --format='
- tagobject=%(*objectname)
- tagtype=%(*objecttype)
- tagger=%(taggername)
- tagged=%(taggerdate)' $refname
- )
-
- echo " tagging $tagobject ($tagtype)"
- case "$tagtype" in
- commit)
-
- # If the tagged object is a commit, then we assume this is a
- # release, and so we calculate which tag this tag is
- # replacing
- prevtag=$(git describe --abbrev=0 $newrev^ 2>/dev/null)
-
- if [ -n "$prevtag" ]; then
- echo " replaces $prevtag"
- fi
- ;;
- *)
- echo " length $(git cat-file -s $tagobject) bytes"
- ;;
- esac
- echo " tagged by $tagger"
- echo " on $tagged"
-
- echo ""
- echo $LOGBEGIN
-
- # Show the content of the tag message; this might contain a change
- # log or release notes so is worth displaying.
- git cat-file tag $newrev | sed -e '1,/^$/d'
-
- echo ""
- case "$tagtype" in
- commit)
- # Only commit tags make sense to have rev-list operations
- # performed on them
- if [ -n "$prevtag" ]; then
- # Show changes since the previous release
- git shortlog "$prevtag..$newrev"
- else
- # No previous tag, show all the changes since time
- # began
- git shortlog $newrev
- fi
- ;;
- *)
- # XXX: Is there anything useful we can do for non-commit
- # objects?
- ;;
- esac
-
- echo $LOGEND
-}
-
-#
-# Called for the deletion of an annotated tag
-#
-generate_delete_atag_email()
-{
- echo " was $oldrev"
- echo ""
- echo $LOGBEGIN
- git diff-tree -s --always --encoding=UTF-8 --pretty=oneline $oldrev
- echo $LOGEND
-}
-
-# --------------- General references
-
-#
-# Called when any other type of reference is created (most likely a
-# non-annotated tag)
-#
-generate_create_general_email()
-{
- echo " at $newrev ($newrev_type)"
-
- generate_general_email
-}
-
-#
-# Called when any other type of reference is updated (most likely a
-# non-annotated tag)
-#
-generate_update_general_email()
-{
- echo " to $newrev ($newrev_type)"
- echo " from $oldrev"
-
- generate_general_email
-}
-
-#
-# Called for creation or update of any other type of reference
-#
-generate_general_email()
-{
- # Unannotated tags are more about marking a point than releasing a
- # version; therefore we don't do the shortlog summary that we do for
- # annotated tags above - we simply show that the point has been
- # marked, and print the log message for the marked point for
- # reference purposes
- #
- # Note this section also catches any other reference type (although
- # there aren't any) and deals with them in the same way.
-
- echo ""
- if [ "$newrev_type" = "commit" ]; then
- echo $LOGBEGIN
- git diff-tree -s --always --encoding=UTF-8 --pretty=medium $newrev
- echo $LOGEND
- else
- # What can we do here? The tag marks an object that is not
- # a commit, so there is no log for us to display. It's
- # probably not wise to output git cat-file as it could be a
- # binary blob. We'll just say how big it is
- echo "$newrev is a $newrev_type, and is $(git cat-file -s $newrev) bytes long."
- fi
-}
-
-#
-# Called for the deletion of any other type of reference
-#
-generate_delete_general_email()
-{
- echo " was $oldrev"
- echo ""
- echo $LOGBEGIN
- git diff-tree -s --always --encoding=UTF-8 --pretty=oneline $oldrev
- echo $LOGEND
-}
-
-
-# --------------- Miscellaneous utilities
-
-#
-# Show new revisions as the user would like to see them in the email.
-#
-show_new_revisions()
-{
- # This shows all log entries that are not already covered by
- # another ref - i.e. commits that are now accessible from this
- # ref that were previously not accessible
- # (see generate_update_branch_email for the explanation of this
- # command)
-
- # Revision range passed to rev-list differs for new vs. updated
- # branches.
- if [ "$change_type" = create ]
- then
- # Show all revisions exclusive to this (new) branch.
- revspec=$newrev
- else
- # Branch update; show revisions not part of $oldrev.
- revspec=$oldrev..$newrev
- fi
-
- other_branches=$(git for-each-ref --format='%(refname)' refs/heads/ |
- grep -F -v $refname)
- git rev-parse --not $other_branches |
- if [ -z "$custom_showrev" ]
- then
- git rev-list --pretty --stdin $revspec
- else
- git rev-list --stdin $revspec |
- while read onerev
- do
- eval $(printf "$custom_showrev" $onerev)
- done
- fi
-}
-
-
-limit_lines()
-{
- lines=0
- skipped=0
- while IFS="" read -r line; do
- lines=$((lines + 1))
- if [ $lines -gt $1 ]; then
- skipped=$((skipped + 1))
- else
- printf "%s\n" "$line"
- fi
- done
- if [ $skipped -ne 0 ]; then
- echo "... $skipped lines suppressed ..."
- fi
-}
-
-
-send_mail()
-{
- if [ -n "$envelopesender" ]; then
- /usr/sbin/sendmail -t -f "$envelopesender"
- else
- /usr/sbin/sendmail -t
- fi
-}
-
-# ---------------------------- main()
-
-# --- Constants
-LOGBEGIN="- Log -----------------------------------------------------------------"
-LOGEND="-----------------------------------------------------------------------"
-
-# --- Config
-# Set GIT_DIR either from the working directory, or from the environment
-# variable.
-GIT_DIR=$(git rev-parse --git-dir 2>/dev/null)
-if [ -z "$GIT_DIR" ]; then
- echo >&2 "fatal: post-receive: GIT_DIR not set"
- exit 1
-fi
-
-projectdesc=$(sed -ne '1p' "$GIT_DIR/description" 2>/dev/null)
-# Check if the description is unchanged from it's default, and shorten it to
-# a more manageable length if it is
-if expr "$projectdesc" : "Unnamed repository.*$" >/dev/null
-then
- projectdesc="UNNAMED PROJECT"
-fi
-
-recipients=$(git config hooks.mailinglist)
-announcerecipients=$(git config hooks.announcelist)
-envelopesender=$(git config hooks.envelopesender)
-emailprefix=$(git config hooks.emailprefix || echo '[SCM] ')
-custom_showrev=$(git config hooks.showrev)
-maxlines=$(git config hooks.emailmaxlines)
-diffopts=$(git config hooks.diffopts)
-: ${diffopts:="--stat --summary --find-copies-harder"}
-
-# --- Main loop
-# Allow dual mode: run from the command line just like the update hook, or
-# if no arguments are given then run as a hook script
-if [ -n "$1" -a -n "$2" -a -n "$3" ]; then
- # Output to the terminal in command line mode - if someone wanted to
- # resend an email; they could redirect the output to sendmail
- # themselves
- prep_for_email $2 $3 $1 && PAGER= generate_email
-else
- while read oldrev newrev refname
- do
- prep_for_email $oldrev $newrev $refname || continue
- generate_email $maxlines | send_mail
- done
-fi
diff --git a/contrib/hooks/pre-auto-gc-battery b/contrib/hooks/pre-auto-gc-battery
deleted file mode 100755
index 7ba78c4dff..0000000000
--- a/contrib/hooks/pre-auto-gc-battery
+++ /dev/null
@@ -1,42 +0,0 @@
-#!/bin/sh
-#
-# An example hook script to verify if you are on battery, in case you
-# are running Linux or OS X. Called by git-gc --auto with no arguments.
-# The hook should exit with non-zero status after issuing an appropriate
-# message if it wants to stop the auto repacking.
-#
-# This hook is stored in the contrib/hooks directory. Your distribution
-# may have put this somewhere else. If you want to use this hook, you
-# should make this script executable then link to it in the repository
-# you would like to use it in.
-#
-# For example, if the hook is stored in
-# /usr/share/git-core/contrib/hooks/pre-auto-gc-battery:
-#
-# cd /path/to/your/repository.git
-# ln -sf /usr/share/git-core/contrib/hooks/pre-auto-gc-battery \
-# hooks/pre-auto-gc
-
-if test -x /sbin/on_ac_power && (/sbin/on_ac_power;test $? -ne 1)
-then
- exit 0
-elif test "$(cat /sys/class/power_supply/AC/online 2>/dev/null)" = 1
-then
- exit 0
-elif grep -q 'on-line' /proc/acpi/ac_adapter/AC/state 2>/dev/null
-then
- exit 0
-elif grep -q '0x01$' /proc/apm 2>/dev/null
-then
- exit 0
-elif grep -q "AC Power \+: 1" /proc/pmu/info 2>/dev/null
-then
- exit 0
-elif test -x /usr/bin/pmset && /usr/bin/pmset -g batt |
- grep -q "drawing from 'AC Power'"
-then
- exit 0
-fi
-
-echo "Auto packing deferred; not on AC"
-exit 1
diff --git a/contrib/hooks/setgitperms.perl b/contrib/hooks/setgitperms.perl
deleted file mode 100755
index 2770a1b1d2..0000000000
--- a/contrib/hooks/setgitperms.perl
+++ /dev/null
@@ -1,214 +0,0 @@
-#!/usr/bin/perl
-#
-# Copyright (c) 2006 Josh England
-#
-# This script can be used to save/restore full permissions and ownership data
-# within a git working tree.
-#
-# To save permissions/ownership data, place this script in your .git/hooks
-# directory and enable a `pre-commit` hook with the following lines:
-# #!/bin/sh
-# SUBDIRECTORY_OK=1 . git-sh-setup
-# $GIT_DIR/hooks/setgitperms.perl -r
-#
-# To restore permissions/ownership data, place this script in your .git/hooks
-# directory and enable a `post-merge` and `post-checkout` hook with the
-# following lines:
-# #!/bin/sh
-# SUBDIRECTORY_OK=1 . git-sh-setup
-# $GIT_DIR/hooks/setgitperms.perl -w
-#
-use strict;
-use Getopt::Long;
-use File::Find;
-use File::Basename;
-
-my $usage =
-"usage: setgitperms.perl [OPTION]... <--read|--write>
-This program uses a file `.gitmeta` to store/restore permissions and uid/gid
-info for all files/dirs tracked by git in the repository.
-
----------------------------------Read Mode-------------------------------------
--r, --read Reads perms/etc from working dir into a .gitmeta file
--s, --stdout Output to stdout instead of .gitmeta
--d, --diff Show unified diff of perms file (XOR with --stdout)
-
----------------------------------Write Mode------------------------------------
--w, --write Modify perms/etc in working dir to match the .gitmeta file
--v, --verbose Be verbose
-
-\n";
-
-my ($stdout, $showdiff, $verbose, $read_mode, $write_mode);
-
-if ((@ARGV < 0) || !GetOptions(
- "stdout", \$stdout,
- "diff", \$showdiff,
- "read", \$read_mode,
- "write", \$write_mode,
- "verbose", \$verbose,
- )) { die $usage; }
-die $usage unless ($read_mode xor $write_mode);
-
-my $topdir = `git rev-parse --show-cdup` or die "\n"; chomp $topdir;
-my $gitdir = $topdir . '.git';
-my $gitmeta = $topdir . '.gitmeta';
-
-if ($write_mode) {
- # Update the working dir permissions/ownership based on data from .gitmeta
- open (IN, "<$gitmeta") or die "Could not open $gitmeta for reading: $!\n";
- while (defined ($_ = <IN>)) {
- chomp;
- if (/^(.*) mode=(\S+)\s+uid=(\d+)\s+gid=(\d+)/) {
- # Compare recorded perms to actual perms in the working dir
- my ($path, $mode, $uid, $gid) = ($1, $2, $3, $4);
- my $fullpath = $topdir . $path;
- my (undef,undef,$wmode,undef,$wuid,$wgid) = lstat($fullpath);
- $wmode = sprintf "%04o", $wmode & 07777;
- if ($mode ne $wmode) {
- $verbose && print "Updating permissions on $path: old=$wmode, new=$mode\n";
- chmod oct($mode), $fullpath;
- }
- if ($uid != $wuid || $gid != $wgid) {
- if ($verbose) {
- # Print out user/group names instead of uid/gid
- my $pwname = getpwuid($uid);
- my $grpname = getgrgid($gid);
- my $wpwname = getpwuid($wuid);
- my $wgrpname = getgrgid($wgid);
- $pwname = $uid if !defined $pwname;
- $grpname = $gid if !defined $grpname;
- $wpwname = $wuid if !defined $wpwname;
- $wgrpname = $wgid if !defined $wgrpname;
-
- print "Updating uid/gid on $path: old=$wpwname/$wgrpname, new=$pwname/$grpname\n";
- }
- chown $uid, $gid, $fullpath;
- }
- }
- else {
- warn "Invalid input format in $gitmeta:\n\t$_\n";
- }
- }
- close IN;
-}
-elsif ($read_mode) {
- # Handle merge conflicts in the .gitperms file
- if (-e "$gitdir/MERGE_MSG") {
- if (`grep ====== $gitmeta`) {
- # Conflict not resolved -- abort the commit
- print "PERMISSIONS/OWNERSHIP CONFLICT\n";
- print " Resolve the conflict in the $gitmeta file and then run\n";
- print " `.git/hooks/setgitperms.perl --write` to reconcile.\n";
- exit 1;
- }
- elsif (`grep $gitmeta $gitdir/MERGE_MSG`) {
- # A conflict in .gitmeta has been manually resolved. Verify that
- # the working dir perms matches the current .gitmeta perms for
- # each file/dir that conflicted.
- # This is here because a `setgitperms.perl --write` was not
- # performed due to a merge conflict, so permissions/ownership
- # may not be consistent with the manually merged .gitmeta file.
- my @conflict_diff = `git show \$(cat $gitdir/MERGE_HEAD)`;
- my @conflict_files;
- my $metadiff = 0;
-
- # Build a list of files that conflicted from the .gitmeta diff
- foreach my $line (@conflict_diff) {
- if ($line =~ m|^diff --git a/$gitmeta b/$gitmeta|) {
- $metadiff = 1;
- }
- elsif ($line =~ /^diff --git/) {
- $metadiff = 0;
- }
- elsif ($metadiff && $line =~ /^\+(.*) mode=/) {
- push @conflict_files, $1;
- }
- }
-
- # Verify that each conflict file now has permissions consistent
- # with the .gitmeta file
- foreach my $file (@conflict_files) {
- my $absfile = $topdir . $file;
- my $gm_entry = `grep "^$file mode=" $gitmeta`;
- if ($gm_entry =~ /mode=(\d+) uid=(\d+) gid=(\d+)/) {
- my ($gm_mode, $gm_uid, $gm_gid) = ($1, $2, $3);
- my (undef,undef,$mode,undef,$uid,$gid) = lstat("$absfile");
- $mode = sprintf("%04o", $mode & 07777);
- if (($gm_mode ne $mode) || ($gm_uid != $uid)
- || ($gm_gid != $gid)) {
- print "PERMISSIONS/OWNERSHIP CONFLICT\n";
- print " Mismatch found for file: $file\n";
- print " Run `.git/hooks/setgitperms.perl --write` to reconcile.\n";
- exit 1;
- }
- }
- else {
- print "Warning! Permissions/ownership no longer being tracked for file: $file\n";
- }
- }
- }
- }
-
- # No merge conflicts -- write out perms/ownership data to .gitmeta file
- unless ($stdout) {
- open (OUT, ">$gitmeta.tmp") or die "Could not open $gitmeta.tmp for writing: $!\n";
- }
-
- my @files = `git ls-files`;
- my %dirs;
-
- foreach my $path (@files) {
- chomp $path;
- # We have to manually add stats for parent directories
- my $parent = dirname($path);
- while (!exists $dirs{$parent}) {
- $dirs{$parent} = 1;
- next if $parent eq '.';
- printstats($parent);
- $parent = dirname($parent);
- }
- # Now the git-tracked file
- printstats($path);
- }
-
- # diff the temporary metadata file to see if anything has changed
- # If no metadata has changed, don't overwrite the real file
- # This is just so `git commit -a` doesn't try to commit a bogus update
- unless ($stdout) {
- if (! -e $gitmeta) {
- rename "$gitmeta.tmp", $gitmeta;
- }
- else {
- my $diff = `diff -U 0 $gitmeta $gitmeta.tmp`;
- if ($diff ne '') {
- rename "$gitmeta.tmp", $gitmeta;
- }
- else {
- unlink "$gitmeta.tmp";
- }
- if ($showdiff) {
- print $diff;
- }
- }
- close OUT;
- }
- # Make sure the .gitmeta file is tracked
- system("git add $gitmeta");
-}
-
-
-sub printstats {
- my $path = $_[0];
- $path =~ s/@/\@/g;
- my (undef,undef,$mode,undef,$uid,$gid) = lstat($path);
- $path =~ s/%/\%/g;
- if ($stdout) {
- print $path;
- printf " mode=%04o uid=$uid gid=$gid\n", $mode & 07777;
- }
- else {
- print OUT $path;
- printf OUT " mode=%04o uid=$uid gid=$gid\n", $mode & 07777;
- }
-}
diff --git a/contrib/hooks/update-paranoid b/contrib/hooks/update-paranoid
deleted file mode 100755
index 0092d67b8a..0000000000
--- a/contrib/hooks/update-paranoid
+++ /dev/null
@@ -1,421 +0,0 @@
-#!/usr/bin/perl
-
-use strict;
-use File::Spec;
-
-$ENV{PATH} = '/opt/git/bin';
-my $acl_git = '/vcs/acls.git';
-my $acl_branch = 'refs/heads/master';
-my $debug = 0;
-
-=doc
-Invoked as: update refname old-sha1 new-sha1
-
-This script is run by git-receive-pack once for each ref that the
-client is trying to modify. If we exit with a non-zero exit value
-then the update for that particular ref is denied, but updates for
-other refs in the same run of receive-pack may still be allowed.
-
-We are run after the objects have been uploaded, but before the
-ref is actually modified. We take advantage of that fact when we
-look for "new" commits and tags (the new objects won't show up in
-`rev-list --all`).
-
-This script loads and parses the content of the config file
-"users/$this_user.acl" from the $acl_branch commit of $acl_git ODB.
-The acl file is a git-config style file, but uses a slightly more
-restricted syntax as the Perl parser contained within this script
-is not nearly as permissive as git-config.
-
-Example:
-
- [user]
- committer = John Doe <john.doe@example.com>
- committer = John R. Doe <john.doe@example.com>
-
- [repository "acls"]
- allow = heads/master
- allow = CDUR for heads/jd/
- allow = C for ^tags/v\\d+$
-
-For all new commit or tag objects the committer (or tagger) line
-within the object must exactly match one of the user.committer
-values listed in the acl file ("HEAD:users/$this_user.acl").
-
-For a branch to be modified an allow line within the matching
-repository section must be matched for both the refname and the
-opcode.
-
-Repository sections are matched on the basename of the repository
-(after removing the .git suffix).
-
-The opcode abbreviations are:
-
- C: create new ref
- D: delete existing ref
- U: fast-forward existing ref (no commit loss)
- R: rewind/rebase existing ref (commit loss)
-
-if no opcodes are listed before the "for" keyword then "U" (for
-fast-forward update only) is assumed as this is the most common
-usage.
-
-Refnames are matched by always assuming a prefix of "refs/".
-This hook forbids pushing or deleting anything not under "refs/".
-
-Refnames that start with ^ are Perl regular expressions, and the ^
-is kept as part of the regexp. \\ is needed to get just one \, so
-\\d expands to \d in Perl. The 3rd allow line above is an example.
-
-Refnames that don't start with ^ but that end with / are prefix
-matches (2nd allow line above); all other refnames are strict
-equality matches (1st allow line).
-
-Anything pushed to "heads/" (ok, really "refs/heads/") must be
-a commit. Tags are not permitted here.
-
-Anything pushed to "tags/" (err, really "refs/tags/") must be an
-annotated tag. Commits, blobs, trees, etc. are not permitted here.
-Annotated tag signatures aren't checked, nor are they required.
-
-The special subrepository of 'info/new-commit-check' can
-be created and used to allow users to push new commits and
-tags from another local repository to this one, even if they
-aren't the committer/tagger of those objects. In a nut shell
-the info/new-commit-check directory is a Git repository whose
-objects/info/alternates file lists this repository and all other
-possible sources, and whose refs subdirectory contains symlinks
-to this repository's refs subdirectory, and to all other possible
-sources refs subdirectories. Yes, this means that you cannot
-use packed-refs in those repositories as they won't be resolved
-correctly.
-
-=cut
-
-my $git_dir = $ENV{GIT_DIR};
-my $new_commit_check = "$git_dir/info/new-commit-check";
-my $ref = $ARGV[0];
-my $old = $ARGV[1];
-my $new = $ARGV[2];
-my $new_type;
-my ($this_user) = getpwuid $<; # REAL_USER_ID
-my $repository_name;
-my %user_committer;
-my @allow_rules;
-my @path_rules;
-my %diff_cache;
-
-sub deny ($) {
- print STDERR "-Deny- $_[0]\n" if $debug;
- print STDERR "\ndenied: $_[0]\n\n";
- exit 1;
-}
-
-sub grant ($) {
- print STDERR "-Grant- $_[0]\n" if $debug;
- exit 0;
-}
-
-sub info ($) {
- print STDERR "-Info- $_[0]\n" if $debug;
-}
-
-sub git_value (@) {
- open(T,'-|','git',@_); local $_ = <T>; chop; close T; $_;
-}
-
-sub match_string ($$) {
- my ($acl_n, $ref) = @_;
- ($acl_n eq $ref)
- || ($acl_n =~ m,/$, && substr($ref,0,length $acl_n) eq $acl_n)
- || ($acl_n =~ m,^\^, && $ref =~ m:$acl_n:);
-}
-
-sub parse_config ($$$$) {
- my $data = shift;
- local $ENV{GIT_DIR} = shift;
- my $br = shift;
- my $fn = shift;
- return unless git_value('rev-list','--max-count=1',$br,'--',$fn);
- info "Loading $br:$fn";
- open(I,'-|','git','cat-file','blob',"$br:$fn");
- my $section = '';
- while (<I>) {
- chomp;
- if (/^\s*$/ || /^\s*#/) {
- } elsif (/^\[([a-z]+)\]$/i) {
- $section = lc $1;
- } elsif (/^\[([a-z]+)\s+"(.*)"\]$/i) {
- $section = join('.',lc $1,$2);
- } elsif (/^\s*([a-z][a-z0-9]+)\s*=\s*(.*?)\s*$/i) {
- push @{$data->{join('.',$section,lc $1)}}, $2;
- } else {
- deny "bad config file line $. in $br:$fn";
- }
- }
- close I;
-}
-
-sub all_new_committers () {
- local $ENV{GIT_DIR} = $git_dir;
- $ENV{GIT_DIR} = $new_commit_check if -d $new_commit_check;
-
- info "Getting committers of new commits.";
- my %used;
- open(T,'-|','git','rev-list','--pretty=raw',$new,'--not','--all');
- while (<T>) {
- next unless s/^committer //;
- chop;
- s/>.*$/>/;
- info "Found $_." unless $used{$_}++;
- }
- close T;
- info "No new commits." unless %used;
- keys %used;
-}
-
-sub all_new_taggers () {
- my %exists;
- open(T,'-|','git','for-each-ref','--format=%(objectname)','refs/tags');
- while (<T>) {
- chop;
- $exists{$_} = 1;
- }
- close T;
-
- info "Getting taggers of new tags.";
- my %used;
- my $obj = $new;
- my $obj_type = $new_type;
- while ($obj_type eq 'tag') {
- last if $exists{$obj};
- $obj_type = '';
- open(T,'-|','git','cat-file','tag',$obj);
- while (<T>) {
- chop;
- if (/^object ([a-z0-9]{40})$/) {
- $obj = $1;
- } elsif (/^type (.+)$/) {
- $obj_type = $1;
- } elsif (s/^tagger //) {
- s/>.*$/>/;
- info "Found $_." unless $used{$_}++;
- last;
- }
- }
- close T;
- }
- info "No new tags." unless %used;
- keys %used;
-}
-
-sub check_committers (@) {
- my @bad;
- foreach (@_) { push @bad, $_ unless $user_committer{$_}; }
- if (@bad) {
- print STDERR "\n";
- print STDERR "You are not $_.\n" foreach (sort @bad);
- deny "You cannot push changes not committed by you.";
- }
-}
-
-sub load_diff ($) {
- my $base = shift;
- my $d = $diff_cache{$base};
- unless ($d) {
- local $/ = "\0";
- my %this_diff;
- if ($base =~ /^0{40}$/) {
- # Don't load the diff at all; we are making the
- # branch and have no base to compare to in this
- # case. A file level ACL makes no sense in this
- # context. Having an empty diff will allow the
- # branch creation.
- #
- } else {
- open(T,'-|','git','diff-tree',
- '-r','--name-status','-z',
- $base,$new) or return undef;
- while (<T>) {
- my $op = $_;
- chop $op;
-
- my $path = <T>;
- chop $path;
-
- $this_diff{$path} = $op;
- }
- close T or return undef;
- }
- $d = \%this_diff;
- $diff_cache{$base} = $d;
- }
- return $d;
-}
-
-deny "No GIT_DIR inherited from caller" unless $git_dir;
-deny "Need a ref name" unless $ref;
-deny "Refusing funny ref $ref" unless $ref =~ s,^refs/,,;
-deny "Bad old value $old" unless $old =~ /^[a-z0-9]{40}$/;
-deny "Bad new value $new" unless $new =~ /^[a-z0-9]{40}$/;
-deny "Cannot determine who you are." unless $this_user;
-grant "No change requested." if $old eq $new;
-
-$repository_name = File::Spec->rel2abs($git_dir);
-$repository_name =~ m,/([^/]+)(?:\.git|/\.git)$,;
-$repository_name = $1;
-info "Updating in '$repository_name'.";
-
-my $op;
-if ($old =~ /^0{40}$/) { $op = 'C'; }
-elsif ($new =~ /^0{40}$/) { $op = 'D'; }
-else { $op = 'R'; }
-
-# This is really an update (fast-forward) if the
-# merge base of $old and $new is $old.
-#
-$op = 'U' if ($op eq 'R'
- && $ref =~ m,^heads/,
- && $old eq git_value('merge-base',$old,$new));
-
-# Load the user's ACL file. Expand groups (user.memberof) one level.
-{
- my %data = ('user.committer' => []);
- parse_config(\%data,$acl_git,$acl_branch,"external/$repository_name.acl");
-
- %data = (
- 'user.committer' => $data{'user.committer'},
- 'user.memberof' => [],
- );
- parse_config(\%data,$acl_git,$acl_branch,"users/$this_user.acl");
-
- %user_committer = map {$_ => $_} @{$data{'user.committer'}};
- my $rule_key = "repository.$repository_name.allow";
- my $rules = $data{$rule_key} || [];
-
- foreach my $group (@{$data{'user.memberof'}}) {
- my %g;
- parse_config(\%g,$acl_git,$acl_branch,"groups/$group.acl");
- my $group_rules = $g{$rule_key};
- push @$rules, @$group_rules if $group_rules;
- }
-
-RULE:
- foreach (@$rules) {
- while (/\${user\.([a-z][a-zA-Z0-9]+)}/) {
- my $k = lc $1;
- my $v = $data{"user.$k"};
- next RULE unless defined $v;
- next RULE if @$v != 1;
- next RULE unless defined $v->[0];
- s/\${user\.$k}/$v->[0]/g;
- }
-
- if (/^([AMD ]+)\s+of\s+([^\s]+)\s+for\s+([^\s]+)\s+diff\s+([^\s]+)$/) {
- my ($ops, $pth, $ref, $bst) = ($1, $2, $3, $4);
- $ops =~ s/ //g;
- $pth =~ s/\\\\/\\/g;
- $ref =~ s/\\\\/\\/g;
- push @path_rules, [$ops, $pth, $ref, $bst];
- } elsif (/^([AMD ]+)\s+of\s+([^\s]+)\s+for\s+([^\s]+)$/) {
- my ($ops, $pth, $ref) = ($1, $2, $3);
- $ops =~ s/ //g;
- $pth =~ s/\\\\/\\/g;
- $ref =~ s/\\\\/\\/g;
- push @path_rules, [$ops, $pth, $ref, $old];
- } elsif (/^([CDRU ]+)\s+for\s+([^\s]+)$/) {
- my $ops = $1;
- my $ref = $2;
- $ops =~ s/ //g;
- $ref =~ s/\\\\/\\/g;
- push @allow_rules, [$ops, $ref];
- } elsif (/^for\s+([^\s]+)$/) {
- # Mentioned, but nothing granted?
- } elsif (/^[^\s]+$/) {
- s/\\\\/\\/g;
- push @allow_rules, ['U', $_];
- }
- }
-}
-
-if ($op ne 'D') {
- $new_type = git_value('cat-file','-t',$new);
-
- if ($ref =~ m,^heads/,) {
- deny "$ref must be a commit." unless $new_type eq 'commit';
- } elsif ($ref =~ m,^tags/,) {
- deny "$ref must be an annotated tag." unless $new_type eq 'tag';
- }
-
- check_committers (all_new_committers);
- check_committers (all_new_taggers) if $new_type eq 'tag';
-}
-
-info "$this_user wants $op for $ref";
-foreach my $acl_entry (@allow_rules) {
- my ($acl_ops, $acl_n) = @$acl_entry;
- next unless $acl_ops =~ /^[CDRU]+$/; # Uhh.... shouldn't happen.
- next unless $acl_n;
- next unless $op =~ /^[$acl_ops]$/;
- next unless match_string $acl_n, $ref;
-
- # Don't test path rules on branch deletes.
- #
- grant "Allowed by: $acl_ops for $acl_n" if $op eq 'D';
-
- # Aggregate matching path rules; allow if there aren't
- # any matching this ref.
- #
- my %pr;
- foreach my $p_entry (@path_rules) {
- my ($p_ops, $p_n, $p_ref, $p_bst) = @$p_entry;
- next unless $p_ref;
- push @{$pr{$p_bst}}, $p_entry if match_string $p_ref, $ref;
- }
- grant "Allowed by: $acl_ops for $acl_n" unless %pr;
-
- # Allow only if all changes against a single base are
- # allowed by file path rules.
- #
- my @bad;
- foreach my $p_bst (keys %pr) {
- my $diff_ref = load_diff $p_bst;
- deny "Cannot difference trees." unless ref $diff_ref;
-
- my %fd = %$diff_ref;
- foreach my $p_entry (@{$pr{$p_bst}}) {
- my ($p_ops, $p_n, $p_ref, $p_bst) = @$p_entry;
- next unless $p_ops =~ /^[AMD]+$/;
- next unless $p_n;
-
- foreach my $f_n (keys %fd) {
- my $f_op = $fd{$f_n};
- next unless $f_op;
- next unless $f_op =~ /^[$p_ops]$/;
- delete $fd{$f_n} if match_string $p_n, $f_n;
- }
- last unless %fd;
- }
-
- if (%fd) {
- push @bad, [$p_bst, \%fd];
- } else {
- # All changes relative to $p_bst were allowed.
- #
- grant "Allowed by: $acl_ops for $acl_n diff $p_bst";
- }
- }
-
- foreach my $bad_ref (@bad) {
- my ($p_bst, $fd) = @$bad_ref;
- print STDERR "\n";
- print STDERR "Not allowed to make the following changes:\n";
- print STDERR "(base: $p_bst)\n";
- foreach my $f_n (sort keys %$fd) {
- print STDERR " $fd->{$f_n} $f_n\n";
- }
- }
- deny "You are not permitted to $op $ref";
-}
-close A;
-deny "You are not permitted to $op $ref";
diff --git a/contrib/libgit-rs/Cargo.lock b/contrib/libgit-rs/Cargo.lock
new file mode 100644
index 0000000000..a30c7c8d33
--- /dev/null
+++ b/contrib/libgit-rs/Cargo.lock
@@ -0,0 +1,77 @@
+# This file is automatically @generated by Cargo.
+# It is not intended for manual editing.
+version = 3
+
+[[package]]
+name = "autocfg"
+version = "1.4.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "ace50bade8e6234aa140d9a2f552bbee1db4d353f69b8217bc503490fc1a9f26"
+
+[[package]]
+name = "cc"
+version = "1.1.15"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "57b6a275aa2903740dc87da01c62040406b8812552e97129a63ea8850a17c6e6"
+dependencies = [
+ "shlex",
+]
+
+[[package]]
+name = "libc"
+version = "0.2.158"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "d8adc4bb1803a324070e64a98ae98f38934d91957a99cfb3a43dcbc01bc56439"
+
+[[package]]
+name = "libgit"
+version = "0.1.0"
+dependencies = [
+ "autocfg",
+ "libgit-sys",
+]
+
+[[package]]
+name = "libgit-sys"
+version = "0.1.0"
+dependencies = [
+ "autocfg",
+ "libz-sys",
+ "make-cmd",
+]
+
+[[package]]
+name = "libz-sys"
+version = "1.1.20"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "d2d16453e800a8cf6dd2fc3eb4bc99b786a9b90c663b8559a5b1a041bf89e472"
+dependencies = [
+ "cc",
+ "libc",
+ "pkg-config",
+ "vcpkg",
+]
+
+[[package]]
+name = "make-cmd"
+version = "0.1.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "a8ca8afbe8af1785e09636acb5a41e08a765f5f0340568716c18a8700ba3c0d3"
+
+[[package]]
+name = "pkg-config"
+version = "0.3.30"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "d231b230927b5e4ad203db57bbcbee2802f6bce620b1e4a9024a07d94e2907ec"
+
+[[package]]
+name = "shlex"
+version = "1.3.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64"
+
+[[package]]
+name = "vcpkg"
+version = "0.2.15"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426"
diff --git a/contrib/libgit-rs/Cargo.toml b/contrib/libgit-rs/Cargo.toml
new file mode 100644
index 0000000000..c3289e69db
--- /dev/null
+++ b/contrib/libgit-rs/Cargo.toml
@@ -0,0 +1,17 @@
+[package]
+name = "libgit"
+version = "0.1.0"
+edition = "2021"
+build = "build.rs"
+rust-version = "1.63" # TODO: Once we hit 1.84 or newer, we may want to remove Cargo.lock from
+ # version control. See https://lore.kernel.org/git/Z47jgK-oMjFRSslr@tapette.crustytoothpaste.net/
+
+
+[lib]
+path = "src/lib.rs"
+
+[dependencies]
+libgit-sys = { version = "0.1.0", path = "../libgit-sys" }
+
+[build-dependencies]
+autocfg = "1.4.0"
diff --git a/contrib/libgit-rs/README.md b/contrib/libgit-rs/README.md
new file mode 100644
index 0000000000..ff945e1ce2
--- /dev/null
+++ b/contrib/libgit-rs/README.md
@@ -0,0 +1,13 @@
+# libgit-rs
+
+Proof-of-concept Git bindings for Rust.
+
+```toml
+[dependencies]
+libgit = "0.1.0"
+```
+
+## Rust version requirements
+
+libgit-rs should support Rust versions at least as old as the version included
+in Debian stable (currently 1.63).
diff --git a/contrib/libgit-rs/build.rs b/contrib/libgit-rs/build.rs
new file mode 100644
index 0000000000..f8bd01a690
--- /dev/null
+++ b/contrib/libgit-rs/build.rs
@@ -0,0 +1,4 @@
+pub fn main() {
+ let ac = autocfg::new();
+ ac.emit_has_path("std::ffi::c_char");
+}
diff --git a/contrib/libgit-rs/src/config.rs b/contrib/libgit-rs/src/config.rs
new file mode 100644
index 0000000000..6bf04845c8
--- /dev/null
+++ b/contrib/libgit-rs/src/config.rs
@@ -0,0 +1,106 @@
+use std::ffi::{c_void, CStr, CString};
+use std::path::Path;
+
+#[cfg(has_std__ffi__c_char)]
+use std::ffi::{c_char, c_int};
+
+#[cfg(not(has_std__ffi__c_char))]
+#[allow(non_camel_case_types)]
+type c_char = i8;
+
+#[cfg(not(has_std__ffi__c_char))]
+#[allow(non_camel_case_types)]
+type c_int = i32;
+
+use libgit_sys::*;
+
+/// A ConfigSet is an in-memory cache for config-like files such as `.gitmodules` or `.gitconfig`.
+/// It does not support all config directives; notably, it will not process `include` or
+/// `includeIf` directives (but it will store them so that callers can choose whether and how to
+/// handle them).
+pub struct ConfigSet(*mut libgit_config_set);
+impl ConfigSet {
+ /// Allocate a new ConfigSet
+ pub fn new() -> Self {
+ unsafe { ConfigSet(libgit_configset_alloc()) }
+ }
+
+ /// Load the given files into the ConfigSet; conflicting directives in later files will
+ /// override those given in earlier files.
+ pub fn add_files(&mut self, files: &[&Path]) {
+ for file in files {
+ let pstr = file.to_str().expect("Invalid UTF-8");
+ let rs = CString::new(pstr).expect("Couldn't convert to CString");
+ unsafe {
+ libgit_configset_add_file(self.0, rs.as_ptr());
+ }
+ }
+ }
+
+ /// Load the value for the given key and attempt to parse it as an i32. Dies with a fatal error
+ /// if the value cannot be parsed. Returns None if the key is not present.
+ pub fn get_int(&mut self, key: &str) -> Option<i32> {
+ let key = CString::new(key).expect("Couldn't convert to CString");
+ let mut val: c_int = 0;
+ unsafe {
+ if libgit_configset_get_int(self.0, key.as_ptr(), &mut val as *mut c_int) != 0 {
+ return None;
+ }
+ }
+
+ Some(val.into())
+ }
+
+ /// Clones the value for the given key. Dies with a fatal error if the value cannot be
+ /// converted to a String. Returns None if the key is not present.
+ pub fn get_string(&mut self, key: &str) -> Option<String> {
+ let key = CString::new(key).expect("Couldn't convert key to CString");
+ let mut val: *mut c_char = std::ptr::null_mut();
+ unsafe {
+ if libgit_configset_get_string(self.0, key.as_ptr(), &mut val as *mut *mut c_char) != 0
+ {
+ return None;
+ }
+ let borrowed_str = CStr::from_ptr(val);
+ let owned_str =
+ String::from(borrowed_str.to_str().expect("Couldn't convert val to str"));
+ free(val as *mut c_void); // Free the xstrdup()ed pointer from the C side
+ Some(owned_str)
+ }
+ }
+}
+
+impl Default for ConfigSet {
+ fn default() -> Self {
+ Self::new()
+ }
+}
+
+impl Drop for ConfigSet {
+ fn drop(&mut self) {
+ unsafe {
+ libgit_configset_free(self.0);
+ }
+ }
+}
+
+#[cfg(test)]
+mod tests {
+ use super::*;
+
+ #[test]
+ fn load_configs_via_configset() {
+ let mut cs = ConfigSet::new();
+ cs.add_files(&[
+ Path::new("testdata/config1"),
+ Path::new("testdata/config2"),
+ Path::new("testdata/config3"),
+ ]);
+ // ConfigSet retrieves correct value
+ assert_eq!(cs.get_int("trace2.eventTarget"), Some(1));
+ // ConfigSet respects last config value set
+ assert_eq!(cs.get_int("trace2.eventNesting"), Some(3));
+ // ConfigSet returns None for missing key
+ assert_eq!(cs.get_string("foo.bar"), None);
+ }
+}
diff --git a/contrib/libgit-rs/src/lib.rs b/contrib/libgit-rs/src/lib.rs
new file mode 100644
index 0000000000..ef68c36943
--- /dev/null
+++ b/contrib/libgit-rs/src/lib.rs
@@ -0,0 +1 @@
+pub mod config;
diff --git a/contrib/libgit-rs/testdata/config1 b/contrib/libgit-rs/testdata/config1
new file mode 100644
index 0000000000..4e9a9d25d1
--- /dev/null
+++ b/contrib/libgit-rs/testdata/config1
@@ -0,0 +1,2 @@
+[trace2]
+ eventNesting = 1
diff --git a/contrib/libgit-rs/testdata/config2 b/contrib/libgit-rs/testdata/config2
new file mode 100644
index 0000000000..b8d1eca423
--- /dev/null
+++ b/contrib/libgit-rs/testdata/config2
@@ -0,0 +1,2 @@
+[trace2]
+ eventTarget = 1
diff --git a/contrib/libgit-rs/testdata/config3 b/contrib/libgit-rs/testdata/config3
new file mode 100644
index 0000000000..ca7b9a7c38
--- /dev/null
+++ b/contrib/libgit-rs/testdata/config3
@@ -0,0 +1,2 @@
+[trace2]
+ eventNesting = 3
diff --git a/contrib/libgit-sys/Cargo.lock b/contrib/libgit-sys/Cargo.lock
new file mode 100644
index 0000000000..427a4c66b7
--- /dev/null
+++ b/contrib/libgit-sys/Cargo.lock
@@ -0,0 +1,69 @@
+# This file is automatically @generated by Cargo.
+# It is not intended for manual editing.
+version = 3
+
+[[package]]
+name = "autocfg"
+version = "1.4.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "ace50bade8e6234aa140d9a2f552bbee1db4d353f69b8217bc503490fc1a9f26"
+
+[[package]]
+name = "cc"
+version = "1.1.15"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "57b6a275aa2903740dc87da01c62040406b8812552e97129a63ea8850a17c6e6"
+dependencies = [
+ "shlex",
+]
+
+[[package]]
+name = "libc"
+version = "0.2.158"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "d8adc4bb1803a324070e64a98ae98f38934d91957a99cfb3a43dcbc01bc56439"
+
+[[package]]
+name = "libgit-sys"
+version = "0.1.0"
+dependencies = [
+ "autocfg",
+ "libz-sys",
+ "make-cmd",
+]
+
+[[package]]
+name = "libz-sys"
+version = "1.1.20"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "d2d16453e800a8cf6dd2fc3eb4bc99b786a9b90c663b8559a5b1a041bf89e472"
+dependencies = [
+ "cc",
+ "libc",
+ "pkg-config",
+ "vcpkg",
+]
+
+[[package]]
+name = "make-cmd"
+version = "0.1.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "a8ca8afbe8af1785e09636acb5a41e08a765f5f0340568716c18a8700ba3c0d3"
+
+[[package]]
+name = "pkg-config"
+version = "0.3.30"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "d231b230927b5e4ad203db57bbcbee2802f6bce620b1e4a9024a07d94e2907ec"
+
+[[package]]
+name = "shlex"
+version = "1.3.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64"
+
+[[package]]
+name = "vcpkg"
+version = "0.2.15"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426"
diff --git a/contrib/libgit-sys/Cargo.toml b/contrib/libgit-sys/Cargo.toml
new file mode 100644
index 0000000000..e0623022c3
--- /dev/null
+++ b/contrib/libgit-sys/Cargo.toml
@@ -0,0 +1,19 @@
+[package]
+name = "libgit-sys"
+version = "0.1.0"
+edition = "2021"
+build = "build.rs"
+links = "gitpub"
+rust-version = "1.63" # TODO: Once we hit 1.84 or newer, we may want to remove Cargo.lock from
+ # version control. See https://lore.kernel.org/git/Z47jgK-oMjFRSslr@tapette.crustytoothpaste.net/
+description = "Native bindings to a portion of libgit"
+
+[lib]
+path = "src/lib.rs"
+
+[dependencies]
+libz-sys = "1.1.19"
+
+[build-dependencies]
+autocfg = "1.4.0"
+make-cmd = "0.1.0"
diff --git a/contrib/libgit-sys/README.md b/contrib/libgit-sys/README.md
new file mode 100644
index 0000000000..c061cfcaf5
--- /dev/null
+++ b/contrib/libgit-sys/README.md
@@ -0,0 +1,4 @@
+# libgit-sys
+
+A small proof-of-concept crate showing how to provide a Rust FFI to Git
+internals.
diff --git a/contrib/libgit-sys/build.rs b/contrib/libgit-sys/build.rs
new file mode 100644
index 0000000000..3ffd80ad91
--- /dev/null
+++ b/contrib/libgit-sys/build.rs
@@ -0,0 +1,35 @@
+use std::env;
+use std::path::PathBuf;
+
+pub fn main() -> std::io::Result<()> {
+ let ac = autocfg::new();
+ ac.emit_has_path("std::ffi::c_char");
+
+ let crate_root = PathBuf::from(env::var_os("CARGO_MANIFEST_DIR").unwrap());
+ let git_root = crate_root.join("../..");
+ let dst = PathBuf::from(env::var_os("OUT_DIR").unwrap());
+
+ let make_output = make_cmd::gnu_make()
+ .env("DEVELOPER", "1")
+ .env_remove("PROFILE")
+ .current_dir(git_root.clone())
+ .args([
+ "INCLUDE_LIBGIT_RS=YesPlease",
+ "contrib/libgit-sys/libgitpub.a",
+ ])
+ .output()
+ .expect("Make failed to run");
+ if !make_output.status.success() {
+ panic!(
+ "Make failed:\n stdout = {}\n stderr = {}\n",
+ String::from_utf8(make_output.stdout).unwrap(),
+ String::from_utf8(make_output.stderr).unwrap()
+ );
+ }
+ std::fs::copy(crate_root.join("libgitpub.a"), dst.join("libgitpub.a"))?;
+ println!("cargo:rustc-link-search=native={}", dst.display());
+ println!("cargo:rustc-link-lib=gitpub");
+ println!("cargo:rerun-if-changed={}", git_root.display());
+
+ Ok(())
+}
diff --git a/contrib/libgit-sys/public_symbol_export.c b/contrib/libgit-sys/public_symbol_export.c
new file mode 100644
index 0000000000..dfbb257115
--- /dev/null
+++ b/contrib/libgit-sys/public_symbol_export.c
@@ -0,0 +1,59 @@
+/*
+ * Shim to publicly export Git symbols. These must be renamed so that the
+ * original symbols can be hidden. Renaming these with a "libgit_" prefix also
+ * avoids conflicts with other libraries such as libgit2.
+ */
+
+#include "git-compat-util.h"
+#include "config.h"
+#include "contrib/libgit-sys/public_symbol_export.h"
+#include "version.h"
+
+#pragma GCC visibility push(default)
+
+struct libgit_config_set {
+ struct config_set cs;
+};
+
+struct libgit_config_set *libgit_configset_alloc(void)
+{
+ struct libgit_config_set *cs =
+ xmalloc(sizeof(struct libgit_config_set));
+ git_configset_init(&cs->cs);
+ return cs;
+}
+
+void libgit_configset_free(struct libgit_config_set *cs)
+{
+ git_configset_clear(&cs->cs);
+ free(cs);
+}
+
+int libgit_configset_add_file(struct libgit_config_set *cs, const char *filename)
+{
+ return git_configset_add_file(&cs->cs, filename);
+}
+
+int libgit_configset_get_int(struct libgit_config_set *cs, const char *key,
+ int *dest)
+{
+ return git_configset_get_int(&cs->cs, key, dest);
+}
+
+int libgit_configset_get_string(struct libgit_config_set *cs, const char *key,
+ char **dest)
+{
+ return git_configset_get_string(&cs->cs, key, dest);
+}
+
+const char *libgit_user_agent(void)
+{
+ return git_user_agent();
+}
+
+const char *libgit_user_agent_sanitized(void)
+{
+ return git_user_agent_sanitized();
+}
+
+#pragma GCC visibility pop
diff --git a/contrib/libgit-sys/public_symbol_export.h b/contrib/libgit-sys/public_symbol_export.h
new file mode 100644
index 0000000000..701db92d53
--- /dev/null
+++ b/contrib/libgit-sys/public_symbol_export.h
@@ -0,0 +1,18 @@
+#ifndef PUBLIC_SYMBOL_EXPORT_H
+#define PUBLIC_SYMBOL_EXPORT_H
+
+struct libgit_config_set *libgit_configset_alloc(void);
+
+void libgit_configset_free(struct libgit_config_set *cs);
+
+int libgit_configset_add_file(struct libgit_config_set *cs, const char *filename);
+
+int libgit_configset_get_int(struct libgit_config_set *cs, const char *key, int *dest);
+
+int libgit_configset_get_string(struct libgit_config_set *cs, const char *key, char **dest);
+
+const char *libgit_user_agent(void);
+
+const char *libgit_user_agent_sanitized(void);
+
+#endif /* PUBLIC_SYMBOL_EXPORT_H */
diff --git a/contrib/libgit-sys/src/lib.rs b/contrib/libgit-sys/src/lib.rs
new file mode 100644
index 0000000000..4bfc650450
--- /dev/null
+++ b/contrib/libgit-sys/src/lib.rs
@@ -0,0 +1,79 @@
+use std::ffi::c_void;
+
+#[cfg(has_std__ffi__c_char)]
+use std::ffi::{c_char, c_int};
+
+#[cfg(not(has_std__ffi__c_char))]
+#[allow(non_camel_case_types)]
+pub type c_char = i8;
+
+#[cfg(not(has_std__ffi__c_char))]
+#[allow(non_camel_case_types)]
+pub type c_int = i32;
+
+extern crate libz_sys;
+
+#[allow(non_camel_case_types)]
+#[repr(C)]
+pub struct libgit_config_set {
+ _data: [u8; 0],
+ _marker: core::marker::PhantomData<(*mut u8, core::marker::PhantomPinned)>,
+}
+
+extern "C" {
+ pub fn free(ptr: *mut c_void);
+
+ pub fn libgit_user_agent() -> *const c_char;
+ pub fn libgit_user_agent_sanitized() -> *const c_char;
+
+ pub fn libgit_configset_alloc() -> *mut libgit_config_set;
+ pub fn libgit_configset_free(cs: *mut libgit_config_set);
+
+ pub fn libgit_configset_add_file(cs: *mut libgit_config_set, filename: *const c_char) -> c_int;
+
+ pub fn libgit_configset_get_int(
+ cs: *mut libgit_config_set,
+ key: *const c_char,
+ int: *mut c_int,
+ ) -> c_int;
+
+ pub fn libgit_configset_get_string(
+ cs: *mut libgit_config_set,
+ key: *const c_char,
+ dest: *mut *mut c_char,
+ ) -> c_int;
+
+}
+
+#[cfg(test)]
+mod tests {
+ use std::ffi::CStr;
+
+ use super::*;
+
+ #[test]
+ fn user_agent_starts_with_git() {
+ let c_str = unsafe { CStr::from_ptr(libgit_user_agent()) };
+ let agent = c_str
+ .to_str()
+ .expect("User agent contains invalid UTF-8 data");
+ assert!(
+ agent.starts_with("git/"),
+ r#"Expected user agent to start with "git/", got: {}"#,
+ agent
+ );
+ }
+
+ #[test]
+ fn sanitized_user_agent_starts_with_git() {
+ let c_str = unsafe { CStr::from_ptr(libgit_user_agent_sanitized()) };
+ let agent = c_str
+ .to_str()
+ .expect("Sanitized user agent contains invalid UTF-8 data");
+ assert!(
+ agent.starts_with("git/"),
+ r#"Expected user agent to start with "git/", got: {}"#,
+ agent
+ );
+ }
+}
diff --git a/contrib/long-running-filter/example.pl b/contrib/long-running-filter/example.pl
index a677569ddd..4b83e4c5e8 100755
--- a/contrib/long-running-filter/example.pl
+++ b/contrib/long-running-filter/example.pl
@@ -1,7 +1,7 @@
#!/usr/bin/perl
#
# Example implementation for the Git filter protocol version 2
-# See Documentation/gitattributes.txt, section "Filter Protocol"
+# See Documentation/gitattributes.adoc, section "Filter Protocol"
#
# Please note, this pass-thru filter is a minimal skeleton. No proper
# error handling was implemented.
diff --git a/contrib/meson.build b/contrib/meson.build
new file mode 100644
index 0000000000..a88c5dfe09
--- /dev/null
+++ b/contrib/meson.build
@@ -0,0 +1,6 @@
+foreach feature : get_option('contrib')
+ subdir(feature)
+endforeach
+
+subdir('coccinelle')
+subdir('credential')
diff --git a/contrib/mw-to-git/.gitignore b/contrib/mw-to-git/.gitignore
deleted file mode 100644
index ae545b013d..0000000000
--- a/contrib/mw-to-git/.gitignore
+++ /dev/null
@@ -1,2 +0,0 @@
-git-remote-mediawiki
-git-mw
diff --git a/contrib/mw-to-git/.perlcriticrc b/contrib/mw-to-git/.perlcriticrc
deleted file mode 100644
index b7333267ad..0000000000
--- a/contrib/mw-to-git/.perlcriticrc
+++ /dev/null
@@ -1,28 +0,0 @@
-# These 3 rules demand to add the s, m and x flag to *every* regexp. This is
-# overkill and would be harmful for readability.
-[-RegularExpressions::RequireExtendedFormatting]
-[-RegularExpressions::RequireDotMatchAnything]
-[-RegularExpressions::RequireLineBoundaryMatching]
-
-# This rule says that builtin functions should not be called with parentheses
-# e.g.: (taken from CPAN's documentation)
-# open($handle, '>', $filename); #not ok
-# open $handle, '>', $filename; #ok
-# Applying such a rule would mean modifying a huge number of lines for a
-# question of style.
-[-CodeLayout::ProhibitParensWithBuiltins]
-
-# This rule states that each system call should have its return value checked
-# The problem is that it includes the print call. Checking every print call's
-# return value would be harmful to the code readability.
-# This configuration keeps all default function but print.
-[InputOutput::RequireCheckedSyscalls]
-functions = open say close
-
-# This rule demands to add a dependency for the Readonly module. This is not
-# wished.
-[-ValuesAndExpressions::ProhibitConstantPragma]
-
-# This rule is not really useful (rather a question of style) and produces many
-# warnings among the code.
-[-ValuesAndExpressions::ProhibitNoisyQuotes]
diff --git a/contrib/mw-to-git/Git/Mediawiki.pm b/contrib/mw-to-git/Git/Mediawiki.pm
deleted file mode 100644
index ff7811225e..0000000000
--- a/contrib/mw-to-git/Git/Mediawiki.pm
+++ /dev/null
@@ -1,101 +0,0 @@
-package Git::Mediawiki;
-
-use 5.008001;
-use strict;
-use POSIX;
-use Git;
-
-BEGIN {
-
-our ($VERSION, @ISA, @EXPORT, @EXPORT_OK);
-
-# Totally unstable API.
-$VERSION = '0.01';
-
-require Exporter;
-
-@ISA = qw(Exporter);
-
-@EXPORT = ();
-
-# Methods which can be called as standalone functions as well:
-@EXPORT_OK = qw(clean_filename smudge_filename connect_maybe
- EMPTY HTTP_CODE_OK HTTP_CODE_PAGE_NOT_FOUND);
-}
-
-# Mediawiki filenames can contain forward slashes. This variable decides by which pattern they should be replaced
-use constant SLASH_REPLACEMENT => '%2F';
-
-# Used to test for empty strings
-use constant EMPTY => q{};
-
-# HTTP codes
-use constant HTTP_CODE_OK => 200;
-use constant HTTP_CODE_PAGE_NOT_FOUND => 404;
-
-sub clean_filename {
- my $filename = shift;
- $filename =~ s{@{[SLASH_REPLACEMENT]}}{/}g;
- # [, ], |, {, and } are forbidden by MediaWiki, even URL-encoded.
- # Do a variant of URL-encoding, i.e. looks like URL-encoding,
- # but with _ added to prevent MediaWiki from thinking this is
- # an actual special character.
- $filename =~ s/[\[\]\{\}\|]/sprintf("_%%_%x", ord($&))/ge;
- # If we use the uri escape before
- # we should unescape here, before anything
-
- return $filename;
-}
-
-sub smudge_filename {
- my $filename = shift;
- $filename =~ s{/}{@{[SLASH_REPLACEMENT]}}g;
- $filename =~ s/ /_/g;
- # Decode forbidden characters encoded in clean_filename
- $filename =~ s/_%_([0-9a-fA-F][0-9a-fA-F])/sprintf('%c', hex($1))/ge;
- return substr($filename, 0, NAME_MAX-length('.mw'));
-}
-
-sub connect_maybe {
- my $wiki = shift;
- if ($wiki) {
- return $wiki;
- }
-
- my $remote_name = shift;
- my $remote_url = shift;
- my ($wiki_login, $wiki_password, $wiki_domain);
-
- $wiki_login = Git::config("remote.${remote_name}.mwLogin");
- $wiki_password = Git::config("remote.${remote_name}.mwPassword");
- $wiki_domain = Git::config("remote.${remote_name}.mwDomain");
-
- $wiki = MediaWiki::API->new;
- $wiki->{config}->{api_url} = "${remote_url}/api.php";
- if ($wiki_login) {
- my %credential = (
- 'url' => $remote_url,
- 'username' => $wiki_login,
- 'password' => $wiki_password
- );
- Git::credential(\%credential);
- my $request = {lgname => $credential{username},
- lgpassword => $credential{password},
- lgdomain => $wiki_domain};
- if ($wiki->login($request)) {
- Git::credential(\%credential, 'approve');
- print {*STDERR} qq(Logged in mediawiki user "$credential{username}".\n);
- } else {
- print {*STDERR} qq(Failed to log in mediawiki user "$credential{username}" on ${remote_url}\n);
- print {*STDERR} ' (error ' .
- $wiki->{error}->{code} . ': ' .
- $wiki->{error}->{details} . ")\n";
- Git::credential(\%credential, 'reject');
- exit 1;
- }
- }
-
- return $wiki;
-}
-
-1; # Famous last words
diff --git a/contrib/mw-to-git/Makefile b/contrib/mw-to-git/Makefile
deleted file mode 100644
index 4e603512a3..0000000000
--- a/contrib/mw-to-git/Makefile
+++ /dev/null
@@ -1,58 +0,0 @@
-#
-# Copyright (C) 2013
-# Matthieu Moy <Matthieu.Moy@imag.fr>
-#
-# To build and test:
-#
-# make
-# bin-wrapper/git mw preview Some_page.mw
-# bin-wrapper/git clone mediawiki::http://example.com/wiki/
-#
-# To install, run Git's toplevel 'make install' then run:
-#
-# make install
-
-GIT_MEDIAWIKI_PM=Git/Mediawiki.pm
-SCRIPT_PERL=git-remote-mediawiki.perl
-SCRIPT_PERL+=git-mw.perl
-GIT_ROOT_DIR=../..
-HERE=contrib/mw-to-git/
-
-INSTALL = install
-
-SCRIPT_PERL_FULL=$(patsubst %,$(HERE)/%,$(SCRIPT_PERL))
-INSTLIBDIR=$(shell $(MAKE) -C $(GIT_ROOT_DIR)/ \
- -s --no-print-directory prefix=$(prefix) \
- perllibdir=$(perllibdir) perllibdir)
-DESTDIR_SQ = $(subst ','\'',$(DESTDIR))
-INSTLIBDIR_SQ = $(subst ','\'',$(INSTLIBDIR))
-
-all: build
-
-test: all
- $(MAKE) -C t
-
-check: perlcritic test
-
-install_pm:
- $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(INSTLIBDIR_SQ)/Git'
- $(INSTALL) -m 644 $(GIT_MEDIAWIKI_PM) \
- '$(DESTDIR_SQ)$(INSTLIBDIR_SQ)/$(GIT_MEDIAWIKI_PM)'
-
-build:
- $(MAKE) -C $(GIT_ROOT_DIR) SCRIPT_PERL="$(SCRIPT_PERL_FULL)" \
- build-perl-script
-
-install: install_pm
- $(MAKE) -C $(GIT_ROOT_DIR) SCRIPT_PERL="$(SCRIPT_PERL_FULL)" \
- install-perl-script
-
-clean:
- $(MAKE) -C $(GIT_ROOT_DIR) SCRIPT_PERL="$(SCRIPT_PERL_FULL)" \
- clean-perl-script
-
-perlcritic:
- perlcritic -5 $(SCRIPT_PERL)
- -perlcritic -2 $(SCRIPT_PERL)
-
-.PHONY: all test check install_pm install clean perlcritic
diff --git a/contrib/mw-to-git/bin-wrapper/git b/contrib/mw-to-git/bin-wrapper/git
deleted file mode 100755
index 6663ae57e8..0000000000
--- a/contrib/mw-to-git/bin-wrapper/git
+++ /dev/null
@@ -1,14 +0,0 @@
-#!/bin/sh
-
-# git executable wrapper script for Git-Mediawiki to run tests without
-# installing all the scripts and perl packages.
-
-GIT_ROOT_DIR=../../..
-GIT_EXEC_PATH=$(cd "$(dirname "$0")" && cd ${GIT_ROOT_DIR} && pwd)
-
-GITPERLLIB="$GIT_EXEC_PATH"'/contrib/mw-to-git'"${GITPERLLIB:+:$GITPERLLIB}"
-PATH="$GIT_EXEC_PATH"'/contrib/mw-to-git:'"$PATH"
-
-export GITPERLLIB PATH
-
-exec "${GIT_EXEC_PATH}/bin-wrappers/git" "$@"
diff --git a/contrib/mw-to-git/git-mw.perl b/contrib/mw-to-git/git-mw.perl
deleted file mode 100755
index eb52a53d32..0000000000
--- a/contrib/mw-to-git/git-mw.perl
+++ /dev/null
@@ -1,368 +0,0 @@
-#!/usr/bin/perl
-
-# Copyright (C) 2013
-# Benoit Person <benoit.person@ensimag.imag.fr>
-# Celestin Matte <celestin.matte@ensimag.imag.fr>
-# License: GPL v2 or later
-
-# Set of tools for git repo with a mediawiki remote.
-# Documentation & bugtracker: https://github.com/Git-Mediawiki/Git-Mediawiki
-
-use strict;
-use warnings;
-
-use Getopt::Long;
-use URI::URL qw(url);
-use LWP::UserAgent;
-use HTML::TreeBuilder;
-
-use Git;
-use MediaWiki::API;
-use Git::Mediawiki qw(clean_filename connect_maybe
- EMPTY HTTP_CODE_PAGE_NOT_FOUND);
-
-# By default, use UTF-8 to communicate with Git and the user
-binmode STDERR, ':encoding(UTF-8)';
-binmode STDOUT, ':encoding(UTF-8)';
-
-# Global parameters
-my $verbose = 0;
-sub v_print {
- if ($verbose) {
- return print {*STDERR} @_;
- }
- return;
-}
-
-# Preview parameters
-my $file_name = EMPTY;
-my $remote_name = EMPTY;
-my $preview_file_name = EMPTY;
-my $autoload = 0;
-sub file {
- $file_name = shift;
- return $file_name;
-}
-
-my %commands = (
- 'help' =>
- [\&help, {}, \&help],
- 'preview' =>
- [\&preview, {
- '<>' => \&file,
- 'output|o=s' => \$preview_file_name,
- 'remote|r=s' => \$remote_name,
- 'autoload|a' => \$autoload
- }, \&preview_help]
-);
-
-# Search for sub-command
-my $cmd = $commands{'help'};
-for (0..@ARGV-1) {
- if (defined $commands{$ARGV[$_]}) {
- $cmd = $commands{$ARGV[$_]};
- splice @ARGV, $_, 1;
- last;
- }
-};
-GetOptions( %{$cmd->[1]},
- 'help|h' => \&{$cmd->[2]},
- 'verbose|v' => \$verbose);
-
-# Launch command
-&{$cmd->[0]};
-
-############################# Preview Functions ################################
-
-sub preview_help {
- print {*STDOUT} <<'END';
-USAGE: git mw preview [--remote|-r <remote name>] [--autoload|-a]
- [--output|-o <output filename>] [--verbose|-v]
- <blob> | <filename>
-
-DESCRIPTION:
-Preview is an utiliy to preview local content of a mediawiki repo as if it was
-pushed on the remote.
-
-For that, preview searches for the remote name of the current branch's
-upstream if --remote is not set. If that remote is not found or if it
-is not a mediawiki, it lists all mediawiki remotes configured and asks
-you to replay your command with the --remote option set properly.
-
-Then, it searches for a file named 'filename'. If it's not found in
-the current dir, it will assume it's a blob.
-
-The content retrieved in the file (or in the blob) will then be parsed
-by the remote mediawiki and combined with a template retrieved from
-the mediawiki.
-
-Finally, preview will save the HTML result in a file. and autoload it
-in your default web browser if the option --autoload is present.
-
-OPTIONS:
- -r <remote name>, --remote <remote name>
- If the remote is a mediawiki, the template and the parse engine
- used for the preview will be those of that remote.
- If not, a list of valid remotes will be shown.
-
- -a, --autoload
- Try to load the HTML output in a new tab (or new window) of your
- default web browser.
-
- -o <output filename>, --output <output filename>
- Change the HTML output filename. Default filename is based on the
- input filename with its extension replaced by '.html'.
-
- -v, --verbose
- Show more information on what's going on under the hood.
-END
- exit;
-}
-
-sub preview {
- my $wiki;
- my ($remote_url, $wiki_page_name);
- my ($new_content, $template);
- my $file_content;
-
- if ($file_name eq EMPTY) {
- die "Missing file argument, see `git mw help`\n";
- }
-
- v_print("### Selecting remote\n");
- if ($remote_name eq EMPTY) {
- $remote_name = find_upstream_remote_name();
- if ($remote_name) {
- $remote_url = mediawiki_remote_url_maybe($remote_name);
- }
-
- if (! $remote_url) {
- my @valid_remotes = find_mediawiki_remotes();
-
- if ($#valid_remotes == 0) {
- print {*STDERR} "No mediawiki remote in this repo. \n";
- exit 1;
- } else {
- my $remotes_list = join("\n\t", @valid_remotes);
- print {*STDERR} <<"MESSAGE";
-There are multiple mediawiki remotes, which of:
- ${remotes_list}
-do you want ? Use the -r option to specify the remote.
-MESSAGE
- }
-
- exit 1;
- }
- } else {
- if (!is_valid_remote($remote_name)) {
- die "${remote_name} is not a remote\n";
- }
-
- $remote_url = mediawiki_remote_url_maybe($remote_name);
- if (! $remote_url) {
- die "${remote_name} is not a mediawiki remote\n";
- }
- }
- v_print("selected remote:\n\tname: ${remote_name}\n\turl: ${remote_url}\n");
-
- $wiki = connect_maybe($wiki, $remote_name, $remote_url);
-
- # Read file content
- if (! -e $file_name) {
- $file_content = git_cmd_try {
- Git::command('cat-file', 'blob', $file_name); }
- "%s failed w/ code %d";
-
- if ($file_name =~ /(.+):(.+)/) {
- $file_name = $2;
- }
- } else {
- open my $read_fh, "<", $file_name
- or die "could not open ${file_name}: $!\n";
- $file_content = do { local $/ = undef; <$read_fh> };
- close $read_fh
- or die "unable to close: $!\n";
- }
-
- v_print("### Retrieving template\n");
- ($wiki_page_name = clean_filename($file_name)) =~ s/\.[^.]+$//;
- $template = get_template($remote_url, $wiki_page_name);
-
- v_print("### Parsing local content\n");
- $new_content = $wiki->api({
- action => 'parse',
- text => $file_content,
- title => $wiki_page_name
- }, {
- skip_encoding => 1
- }) or die "No response from remote mediawiki\n";
- $new_content = $new_content->{'parse'}->{'text'}->{'*'};
-
- v_print("### Merging contents\n");
- if ($preview_file_name eq EMPTY) {
- ($preview_file_name = $file_name) =~ s/\.[^.]+$/.html/;
- }
- open(my $save_fh, '>:encoding(UTF-8)', $preview_file_name)
- or die "Could not open: $!\n";
- print {$save_fh} merge_contents($template, $new_content, $remote_url);
- close($save_fh)
- or die "Could not close: $!\n";
-
- v_print("### Results\n");
- if ($autoload) {
- v_print("Launching browser w/ file: ${preview_file_name}");
- system('git', 'web--browse', $preview_file_name);
- } else {
- print {*STDERR} "Preview file saved as: ${preview_file_name}\n";
- }
-
- exit;
-}
-
-# uses global scope variable: $remote_name
-sub merge_contents {
- my $template = shift;
- my $content = shift;
- my $remote_url = shift;
- my ($content_tree, $html_tree, $mw_content_text);
- my $template_content_id = 'bodyContent';
-
- $html_tree = HTML::TreeBuilder->new;
- $html_tree->parse($template);
-
- $content_tree = HTML::TreeBuilder->new;
- $content_tree->parse($content);
-
- $template_content_id = Git::config("remote.${remote_name}.mwIDcontent")
- || $template_content_id;
- v_print("Using '${template_content_id}' as the content ID\n");
-
- $mw_content_text = $html_tree->look_down('id', $template_content_id);
- if (!defined $mw_content_text) {
- print {*STDERR} <<"CONFIG";
-Could not combine the new content with the template. You might want to
-configure `mediawiki.IDContent` in your config:
- git config --add remote.${remote_name}.mwIDcontent <id>
-and re-run the command afterward.
-CONFIG
- exit 1;
- }
- $mw_content_text->delete_content();
- $mw_content_text->push_content($content_tree);
-
- make_links_absolute($html_tree, $remote_url);
-
- return $html_tree->as_HTML;
-}
-
-sub make_links_absolute {
- my $html_tree = shift;
- my $remote_url = shift;
- for (@{ $html_tree->extract_links() }) {
- my ($link, $element, $attr) = @{ $_ };
- my $url = url($link)->canonical;
- if ($url !~ /#/) {
- $element->attr($attr, URI->new_abs($url, $remote_url));
- }
- }
- return $html_tree;
-}
-
-sub is_valid_remote {
- my $remote = shift;
- my @remotes = git_cmd_try {
- Git::command('remote') }
- "%s failed w/ code %d";
- my $found_remote = 0;
- foreach my $remote (@remotes) {
- if ($remote eq $remote) {
- $found_remote = 1;
- last;
- }
- }
- return $found_remote;
-}
-
-sub find_mediawiki_remotes {
- my @remotes = git_cmd_try {
- Git::command('remote'); }
- "%s failed w/ code %d";
- my $remote_url;
- my @valid_remotes = ();
- foreach my $remote (@remotes) {
- $remote_url = mediawiki_remote_url_maybe($remote);
- if ($remote_url) {
- push(@valid_remotes, $remote);
- }
- }
- return @valid_remotes;
-}
-
-sub find_upstream_remote_name {
- my $current_branch = git_cmd_try {
- Git::command_oneline('symbolic-ref', '--short', 'HEAD') }
- "%s failed w/ code %d";
- return Git::config("branch.${current_branch}.remote");
-}
-
-sub mediawiki_remote_url_maybe {
- my $remote = shift;
-
- # Find remote url
- my $remote_url = Git::config("remote.${remote}.url");
- if ($remote_url =~ s/mediawiki::(.*)/$1/) {
- return url($remote_url)->canonical;
- }
-
- return;
-}
-
-sub get_template {
- my $url = shift;
- my $page_name = shift;
- my ($req, $res, $code, $url_after);
-
- $req = LWP::UserAgent->new;
- if ($verbose) {
- $req->show_progress(1);
- }
-
- $res = $req->get("${url}/index.php?title=${page_name}");
- if (!$res->is_success) {
- $code = $res->code;
- $url_after = $res->request()->uri(); # resolve all redirections
- if ($code == HTTP_CODE_PAGE_NOT_FOUND) {
- if ($verbose) {
- print {*STDERR} <<"WARNING";
-Warning: Failed to retrieve '$page_name'. Create it on the mediawiki if you want
-all the links to work properly.
-Trying to use the mediawiki homepage as a fallback template ...
-WARNING
- }
-
- # LWP automatically redirects GET request
- $res = $req->get("${url}/index.php");
- if (!$res->is_success) {
- $url_after = $res->request()->uri(); # resolve all redirections
- die "Failed to get homepage @ ${url_after} w/ code ${code}\n";
- }
- } else {
- die "Failed to get '${page_name}' @ ${url_after} w/ code ${code}\n";
- }
- }
-
- return $res->decoded_content;
-}
-
-############################## Help Functions ##################################
-
-sub help {
- print {*STDOUT} <<'END';
-usage: git mw <command> <args>
-
-git mw commands are:
- help Display help information about git mw
- preview Parse and render local file into HTML
-END
- exit;
-}
diff --git a/contrib/mw-to-git/git-remote-mediawiki.perl b/contrib/mw-to-git/git-remote-mediawiki.perl
deleted file mode 100755
index a5624413dc..0000000000
--- a/contrib/mw-to-git/git-remote-mediawiki.perl
+++ /dev/null
@@ -1,1390 +0,0 @@
-#! /usr/bin/perl
-
-# Copyright (C) 2011
-# Jérémie Nikaes <jeremie.nikaes@ensimag.imag.fr>
-# Arnaud Lacurie <arnaud.lacurie@ensimag.imag.fr>
-# Claire Fousse <claire.fousse@ensimag.imag.fr>
-# David Amouyal <david.amouyal@ensimag.imag.fr>
-# Matthieu Moy <matthieu.moy@grenoble-inp.fr>
-# License: GPL v2 or later
-
-# Gateway between Git and MediaWiki.
-# Documentation & bugtracker: https://github.com/Git-Mediawiki/Git-Mediawiki
-
-use strict;
-use MediaWiki::API;
-use Git;
-use Git::Mediawiki qw(clean_filename smudge_filename connect_maybe
- EMPTY HTTP_CODE_OK);
-use DateTime::Format::ISO8601;
-use warnings;
-
-# By default, use UTF-8 to communicate with Git and the user
-binmode STDERR, ':encoding(UTF-8)';
-binmode STDOUT, ':encoding(UTF-8)';
-
-use URI::Escape;
-
-# It's not always possible to delete pages (may require some
-# privileges). Deleted pages are replaced with this content.
-use constant DELETED_CONTENT => "[[Category:Deleted]]\n";
-
-# It's not possible to create empty pages. New empty files in Git are
-# sent with this content instead.
-use constant EMPTY_CONTENT => "<!-- empty page -->\n";
-
-# used to reflect file creation or deletion in diff.
-use constant NULL_SHA1 => '0000000000000000000000000000000000000000';
-
-# Used on Git's side to reflect empty edit messages on the wiki
-use constant EMPTY_MESSAGE => '*Empty MediaWiki Message*';
-
-# Number of pages taken into account at once in submodule get_mw_page_list
-use constant SLICE_SIZE => 50;
-
-# Number of linked mediafile to get at once in get_linked_mediafiles
-# The query is split in small batches because of the MW API limit of
-# the number of links to be returned (500 links max).
-use constant BATCH_SIZE => 10;
-
-if (@ARGV != 2) {
- exit_error_usage();
-}
-
-my $remotename = $ARGV[0];
-my $url = $ARGV[1];
-
-# Accept both space-separated and multiple keys in config file.
-# Spaces should be written as _ anyway because we'll use chomp.
-my @tracked_pages = split(/[ \n]/, run_git_quoted(["config", "--get-all", "remote.${remotename}.pages"]));
-chomp(@tracked_pages);
-
-# Just like @tracked_pages, but for MediaWiki categories.
-my @tracked_categories = split(/[ \n]/, run_git_quoted(["config", "--get-all", "remote.${remotename}.categories"]));
-chomp(@tracked_categories);
-
-# Just like @tracked_categories, but for MediaWiki namespaces.
-my @tracked_namespaces = split(/[ \n]/, run_git_quoted(["config", "--get-all", "remote.${remotename}.namespaces"]));
-for (@tracked_namespaces) { s/_/ /g; }
-chomp(@tracked_namespaces);
-
-# Import media files on pull
-my $import_media = run_git_quoted(["config", "--get", "--bool", "remote.${remotename}.mediaimport"]);
-chomp($import_media);
-$import_media = ($import_media eq 'true');
-
-# Export media files on push
-my $export_media = run_git_quoted(["config", "--get", "--bool", "remote.${remotename}.mediaexport"]);
-chomp($export_media);
-$export_media = !($export_media eq 'false');
-
-my $wiki_login = run_git_quoted(["config", "--get", "remote.${remotename}.mwLogin"]);
-# Note: mwPassword is discouraged. Use the credential system instead.
-my $wiki_passwd = run_git_quoted(["config", "--get", "remote.${remotename}.mwPassword"]);
-my $wiki_domain = run_git_quoted(["config", "--get", "remote.${remotename}.mwDomain"]);
-chomp($wiki_login);
-chomp($wiki_passwd);
-chomp($wiki_domain);
-
-# Import only last revisions (both for clone and fetch)
-my $shallow_import = run_git_quoted(["config", "--get", "--bool", "remote.${remotename}.shallow"]);
-chomp($shallow_import);
-$shallow_import = ($shallow_import eq 'true');
-
-# Fetch (clone and pull) by revisions instead of by pages. This behavior
-# is more efficient when we have a wiki with lots of pages and we fetch
-# the revisions quite often so that they concern only few pages.
-# Possible values:
-# - by_rev: perform one query per new revision on the remote wiki
-# - by_page: query each tracked page for new revision
-my $fetch_strategy = run_git_quoted(["config", "--get", "remote.${remotename}.fetchStrategy"]);
-if (!$fetch_strategy) {
- $fetch_strategy = run_git_quoted(["config", "--get", "mediawiki.fetchStrategy"]);
-}
-chomp($fetch_strategy);
-if (!$fetch_strategy) {
- $fetch_strategy = 'by_page';
-}
-
-# Remember the timestamp corresponding to a revision id.
-my %basetimestamps;
-
-# Dumb push: don't update notes and mediawiki ref to reflect the last push.
-#
-# Configurable with mediawiki.dumbPush, or per-remote with
-# remote.<remotename>.dumbPush.
-#
-# This means the user will have to re-import the just-pushed
-# revisions. On the other hand, this means that the Git revisions
-# corresponding to MediaWiki revisions are all imported from the wiki,
-# regardless of whether they were initially created in Git or from the
-# web interface, hence all users will get the same history (i.e. if
-# the push from Git to MediaWiki loses some information, everybody
-# will get the history with information lost). If the import is
-# deterministic, this means everybody gets the same sha1 for each
-# MediaWiki revision.
-my $dumb_push = run_git_quoted(["config", "--get", "--bool", "remote.${remotename}.dumbPush"]);
-if (!$dumb_push) {
- $dumb_push = run_git_quoted(["config", "--get", "--bool", "mediawiki.dumbPush"]);
-}
-chomp($dumb_push);
-$dumb_push = ($dumb_push eq 'true');
-
-my $wiki_name = $url;
-$wiki_name =~ s{[^/]*://}{};
-# If URL is like http://user:password@example.com/, we clearly don't
-# want the password in $wiki_name. While we're there, also remove user
-# and '@' sign, to avoid author like MWUser@HTTPUser@host.com
-$wiki_name =~ s/^.*@//;
-
-# Commands parser
-while (<STDIN>) {
- chomp;
-
- if (!parse_command($_)) {
- last;
- }
-
- BEGIN { $| = 1 } # flush STDOUT, to make sure the previous
- # command is fully processed.
-}
-
-########################## Functions ##############################
-
-## error handling
-sub exit_error_usage {
- die "ERROR: git-remote-mediawiki module was not called with a correct number of\n" .
- "parameters\n" .
- "You may obtain this error because you attempted to run the git-remote-mediawiki\n" .
- "module directly.\n" .
- "This module can be used the following way:\n" .
- "\tgit clone mediawiki://<address of a mediawiki>\n" .
- "Then, use git commit, push and pull as with every normal git repository.\n";
-}
-
-sub parse_command {
- my ($line) = @_;
- my @cmd = split(/ /, $line);
- if (!defined $cmd[0]) {
- return 0;
- }
- if ($cmd[0] eq 'capabilities') {
- die("Too many arguments for capabilities\n")
- if (defined($cmd[1]));
- mw_capabilities();
- } elsif ($cmd[0] eq 'list') {
- die("Too many arguments for list\n") if (defined($cmd[2]));
- mw_list($cmd[1]);
- } elsif ($cmd[0] eq 'import') {
- die("Invalid argument for import\n")
- if ($cmd[1] eq EMPTY);
- die("Too many arguments for import\n")
- if (defined($cmd[2]));
- mw_import($cmd[1]);
- } elsif ($cmd[0] eq 'option') {
- die("Invalid arguments for option\n")
- if ($cmd[1] eq EMPTY || $cmd[2] eq EMPTY);
- die("Too many arguments for option\n")
- if (defined($cmd[3]));
- mw_option($cmd[1],$cmd[2]);
- } elsif ($cmd[0] eq 'push') {
- mw_push($cmd[1]);
- } else {
- print {*STDERR} "Unknown command. Aborting...\n";
- return 0;
- }
- return 1;
-}
-
-# MediaWiki API instance, created lazily.
-my $mediawiki;
-
-sub fatal_mw_error {
- my $action = shift;
- print STDERR "fatal: could not $action.\n";
- print STDERR "fatal: '$url' does not appear to be a mediawiki\n";
- if ($url =~ /^https/) {
- print STDERR "fatal: make sure '$url/api.php' is a valid page\n";
- print STDERR "fatal: and the SSL certificate is correct.\n";
- } else {
- print STDERR "fatal: make sure '$url/api.php' is a valid page.\n";
- }
- print STDERR "fatal: (error " .
- $mediawiki->{error}->{code} . ': ' .
- $mediawiki->{error}->{details} . ")\n";
- exit 1;
-}
-
-## Functions for listing pages on the remote wiki
-sub get_mw_tracked_pages {
- my $pages = shift;
- get_mw_page_list(\@tracked_pages, $pages);
- return;
-}
-
-sub get_mw_page_list {
- my $page_list = shift;
- my $pages = shift;
- my @some_pages = @{$page_list};
- while (@some_pages) {
- my $last_page = SLICE_SIZE;
- if ($#some_pages < $last_page) {
- $last_page = $#some_pages;
- }
- my @slice = @some_pages[0..$last_page];
- get_mw_first_pages(\@slice, $pages);
- @some_pages = @some_pages[(SLICE_SIZE + 1)..$#some_pages];
- }
- return;
-}
-
-sub get_mw_tracked_categories {
- my $pages = shift;
- foreach my $category (@tracked_categories) {
- if (index($category, ':') < 0) {
- # Mediawiki requires the Category
- # prefix, but let's not force the user
- # to specify it.
- $category = "Category:${category}";
- }
- my $mw_pages = $mediawiki->list( {
- action => 'query',
- list => 'categorymembers',
- cmtitle => $category,
- cmlimit => 'max' } )
- || die $mediawiki->{error}->{code} . ': '
- . $mediawiki->{error}->{details} . "\n";
- foreach my $page (@{$mw_pages}) {
- $pages->{$page->{title}} = $page;
- }
- }
- return;
-}
-
-sub get_mw_tracked_namespaces {
- my $pages = shift;
- foreach my $local_namespace (sort @tracked_namespaces) {
- my $namespace_id;
- if ($local_namespace eq "(Main)") {
- $namespace_id = 0;
- } else {
- $namespace_id = get_mw_namespace_id($local_namespace);
- }
- # virtual namespaces don't support allpages
- next if !defined($namespace_id) || $namespace_id < 0;
- my $mw_pages = $mediawiki->list( {
- action => 'query',
- list => 'allpages',
- apnamespace => $namespace_id,
- aplimit => 'max' } )
- || die $mediawiki->{error}->{code} . ': '
- . $mediawiki->{error}->{details} . "\n";
- print {*STDERR} "$#{$mw_pages} found in namespace $local_namespace ($namespace_id)\n";
- foreach my $page (@{$mw_pages}) {
- $pages->{$page->{title}} = $page;
- }
- }
- return;
-}
-
-sub get_mw_all_pages {
- my $pages = shift;
- # No user-provided list, get the list of pages from the API.
- my $mw_pages = $mediawiki->list({
- action => 'query',
- list => 'allpages',
- aplimit => 'max'
- });
- if (!defined($mw_pages)) {
- fatal_mw_error("get the list of wiki pages");
- }
- foreach my $page (@{$mw_pages}) {
- $pages->{$page->{title}} = $page;
- }
- return;
-}
-
-# queries the wiki for a set of pages. Meant to be used within a loop
-# querying the wiki for slices of page list.
-sub get_mw_first_pages {
- my $some_pages = shift;
- my @some_pages = @{$some_pages};
-
- my $pages = shift;
-
- # pattern 'page1|page2|...' required by the API
- my $titles = join('|', @some_pages);
-
- my $mw_pages = $mediawiki->api({
- action => 'query',
- titles => $titles,
- });
- if (!defined($mw_pages)) {
- fatal_mw_error("query the list of wiki pages");
- }
- while (my ($id, $page) = each(%{$mw_pages->{query}->{pages}})) {
- if ($id < 0) {
- print {*STDERR} "Warning: page $page->{title} not found on wiki\n";
- } else {
- $pages->{$page->{title}} = $page;
- }
- }
- return;
-}
-
-# Get the list of pages to be fetched according to configuration.
-sub get_mw_pages {
- $mediawiki = connect_maybe($mediawiki, $remotename, $url);
-
- print {*STDERR} "Listing pages on remote wiki...\n";
-
- my %pages; # hash on page titles to avoid duplicates
- my $user_defined;
- if (@tracked_pages) {
- $user_defined = 1;
- # The user provided a list of pages titles, but we
- # still need to query the API to get the page IDs.
- get_mw_tracked_pages(\%pages);
- }
- if (@tracked_categories) {
- $user_defined = 1;
- get_mw_tracked_categories(\%pages);
- }
- if (@tracked_namespaces) {
- $user_defined = 1;
- get_mw_tracked_namespaces(\%pages);
- }
- if (!$user_defined) {
- get_mw_all_pages(\%pages);
- }
- if ($import_media) {
- print {*STDERR} "Getting media files for selected pages...\n";
- if ($user_defined) {
- get_linked_mediafiles(\%pages);
- } else {
- get_all_mediafiles(\%pages);
- }
- }
- print {*STDERR} (scalar keys %pages) . " pages found.\n";
- return %pages;
-}
-
-# usage: $out = run_git_quoted(["command", "args", ...]);
-# $out = run_git_quoted(["command", "args", ...], "raw"); # don't interpret output as UTF-8.
-# $out = run_git_quoted_nostderr(["command", "args", ...]); # discard stderr
-# $out = run_git_quoted_nostderr(["command", "args", ...], "raw"); # ditto but raw instead of UTF-8 as above
-sub _run_git {
- my $args = shift;
- my $encoding = (shift || 'encoding(UTF-8)');
- open(my $git, "-|:${encoding}", @$args)
- or die "Unable to fork: $!\n";
- my $res = do {
- local $/ = undef;
- <$git>
- };
- close($git);
-
- return $res;
-}
-
-sub run_git_quoted {
- _run_git(["git", @{$_[0]}], $_[1]);
-}
-
-sub run_git_quoted_nostderr {
- _run_git(['sh', '-c', 'git "$@" 2>/dev/null', '--', @{$_[0]}], $_[1]);
-}
-
-sub get_all_mediafiles {
- my $pages = shift;
- # Attach list of all pages for media files from the API,
- # they are in a different namespace, only one namespace
- # can be queried at the same moment
- my $mw_pages = $mediawiki->list({
- action => 'query',
- list => 'allpages',
- apnamespace => get_mw_namespace_id('File'),
- aplimit => 'max'
- });
- if (!defined($mw_pages)) {
- print {*STDERR} "fatal: could not get the list of pages for media files.\n";
- print {*STDERR} "fatal: '$url' does not appear to be a mediawiki\n";
- print {*STDERR} "fatal: make sure '$url/api.php' is a valid page.\n";
- exit 1;
- }
- foreach my $page (@{$mw_pages}) {
- $pages->{$page->{title}} = $page;
- }
- return;
-}
-
-sub get_linked_mediafiles {
- my $pages = shift;
- my @titles = map { $_->{title} } values(%{$pages});
-
- my $batch = BATCH_SIZE;
- while (@titles) {
- if ($#titles < $batch) {
- $batch = $#titles;
- }
- my @slice = @titles[0..$batch];
-
- # pattern 'page1|page2|...' required by the API
- my $mw_titles = join('|', @slice);
-
- # Media files could be included or linked from
- # a page, get all related
- my $query = {
- action => 'query',
- prop => 'links|images',
- titles => $mw_titles,
- plnamespace => get_mw_namespace_id('File'),
- pllimit => 'max'
- };
- my $result = $mediawiki->api($query);
-
- while (my ($id, $page) = each(%{$result->{query}->{pages}})) {
- my @media_titles;
- if (defined($page->{links})) {
- my @link_titles
- = map { $_->{title} } @{$page->{links}};
- push(@media_titles, @link_titles);
- }
- if (defined($page->{images})) {
- my @image_titles
- = map { $_->{title} } @{$page->{images}};
- push(@media_titles, @image_titles);
- }
- if (@media_titles) {
- get_mw_page_list(\@media_titles, $pages);
- }
- }
-
- @titles = @titles[($batch+1)..$#titles];
- }
- return;
-}
-
-sub get_mw_mediafile_for_page_revision {
- # Name of the file on Wiki, with the prefix.
- my $filename = shift;
- my $timestamp = shift;
- my %mediafile;
-
- # Search if on a media file with given timestamp exists on
- # MediaWiki. In that case download the file.
- my $query = {
- action => 'query',
- prop => 'imageinfo',
- titles => "File:${filename}",
- iistart => $timestamp,
- iiend => $timestamp,
- iiprop => 'timestamp|archivename|url',
- iilimit => 1
- };
- my $result = $mediawiki->api($query);
-
- my ($fileid, $file) = each( %{$result->{query}->{pages}} );
- # If not defined it means there is no revision of the file for
- # given timestamp.
- if (defined($file->{imageinfo})) {
- $mediafile{title} = $filename;
-
- my $fileinfo = pop(@{$file->{imageinfo}});
- $mediafile{timestamp} = $fileinfo->{timestamp};
- # Mediawiki::API's download function doesn't support https URLs
- # and can't download old versions of files.
- print {*STDERR} "\tDownloading file $mediafile{title}, version $mediafile{timestamp}\n";
- $mediafile{content} = download_mw_mediafile($fileinfo->{url});
- }
- return %mediafile;
-}
-
-sub download_mw_mediafile {
- my $download_url = shift;
-
- my $response = $mediawiki->{ua}->get($download_url);
- if ($response->code == HTTP_CODE_OK) {
- # It is tempting to return
- # $response->decoded_content({charset => "none"}), but
- # when doing so, utf8::downgrade($content) fails with
- # "Wide character in subroutine entry".
- $response->decode();
- return $response->content();
- } else {
- print {*STDERR} "Error downloading mediafile from :\n";
- print {*STDERR} "URL: ${download_url}\n";
- print {*STDERR} 'Server response: ' . $response->code . q{ } . $response->message . "\n";
- exit 1;
- }
-}
-
-sub get_last_local_revision {
- # Get note regarding last mediawiki revision.
- my $note = run_git_quoted_nostderr(["notes", "--ref=${remotename}/mediawiki",
- "show", "refs/mediawiki/${remotename}/master"]);
- my @note_info = split(/ /, $note);
-
- my $lastrevision_number;
- if (!(defined($note_info[0]) && $note_info[0] eq 'mediawiki_revision:')) {
- print {*STDERR} 'No previous mediawiki revision found';
- $lastrevision_number = 0;
- } else {
- # Notes are formatted : mediawiki_revision: #number
- $lastrevision_number = $note_info[1];
- chomp($lastrevision_number);
- print {*STDERR} "Last local mediawiki revision found is ${lastrevision_number}";
- }
- return $lastrevision_number;
-}
-
-# Get the last remote revision without taking in account which pages are
-# tracked or not. This function makes a single request to the wiki thus
-# avoid a loop onto all tracked pages. This is useful for the fetch-by-rev
-# option.
-sub get_last_global_remote_rev {
- $mediawiki = connect_maybe($mediawiki, $remotename, $url);
-
- my $query = {
- action => 'query',
- list => 'recentchanges',
- prop => 'revisions',
- rclimit => '1',
- rcdir => 'older',
- };
- my $result = $mediawiki->api($query);
- return $result->{query}->{recentchanges}[0]->{revid};
-}
-
-# Get the last remote revision concerning the tracked pages and the tracked
-# categories.
-sub get_last_remote_revision {
- $mediawiki = connect_maybe($mediawiki, $remotename, $url);
-
- my %pages_hash = get_mw_pages();
- my @pages = values(%pages_hash);
-
- my $max_rev_num = 0;
-
- print {*STDERR} "Getting last revision id on tracked pages...\n";
-
- foreach my $page (@pages) {
- my $id = $page->{pageid};
-
- my $query = {
- action => 'query',
- prop => 'revisions',
- rvprop => 'ids|timestamp',
- pageids => $id,
- };
-
- my $result = $mediawiki->api($query);
-
- my $lastrev = pop(@{$result->{query}->{pages}->{$id}->{revisions}});
-
- $basetimestamps{$lastrev->{revid}} = $lastrev->{timestamp};
-
- $max_rev_num = ($lastrev->{revid} > $max_rev_num ? $lastrev->{revid} : $max_rev_num);
- }
-
- print {*STDERR} "Last remote revision found is $max_rev_num.\n";
- return $max_rev_num;
-}
-
-# Clean content before sending it to MediaWiki
-sub mediawiki_clean {
- my $string = shift;
- my $page_created = shift;
- # Mediawiki does not allow blank space at the end of a page and ends with a single \n.
- # This function right trims a string and adds a \n at the end to follow this rule
- $string =~ s/\s+$//;
- if ($string eq EMPTY && $page_created) {
- # Creating empty pages is forbidden.
- $string = EMPTY_CONTENT;
- }
- return $string."\n";
-}
-
-# Filter applied on MediaWiki data before adding them to Git
-sub mediawiki_smudge {
- my $string = shift;
- if ($string eq EMPTY_CONTENT) {
- $string = EMPTY;
- }
- # This \n is important. This is due to mediawiki's way to handle end of files.
- return "${string}\n";
-}
-
-sub literal_data {
- my ($content) = @_;
- print {*STDOUT} 'data ', bytes::length($content), "\n", $content;
- return;
-}
-
-sub literal_data_raw {
- # Output possibly binary content.
- my ($content) = @_;
- # Avoid confusion between size in bytes and in characters
- utf8::downgrade($content);
- binmode STDOUT, ':raw';
- print {*STDOUT} 'data ', bytes::length($content), "\n", $content;
- binmode STDOUT, ':encoding(UTF-8)';
- return;
-}
-
-sub mw_capabilities {
- # Revisions are imported to the private namespace
- # refs/mediawiki/$remotename/ by the helper and fetched into
- # refs/remotes/$remotename later by fetch.
- print {*STDOUT} "refspec refs/heads/*:refs/mediawiki/${remotename}/*\n";
- print {*STDOUT} "import\n";
- print {*STDOUT} "list\n";
- print {*STDOUT} "push\n";
- if ($dumb_push) {
- print {*STDOUT} "no-private-update\n";
- }
- print {*STDOUT} "\n";
- return;
-}
-
-sub mw_list {
- # MediaWiki do not have branches, we consider one branch arbitrarily
- # called master, and HEAD pointing to it.
- print {*STDOUT} "? refs/heads/master\n";
- print {*STDOUT} "\@refs/heads/master HEAD\n";
- print {*STDOUT} "\n";
- return;
-}
-
-sub mw_option {
- print {*STDERR} "remote-helper command 'option $_[0]' not yet implemented\n";
- print {*STDOUT} "unsupported\n";
- return;
-}
-
-sub fetch_mw_revisions_for_page {
- my $page = shift;
- my $id = shift;
- my $fetch_from = shift;
- my @page_revs = ();
- my $query = {
- action => 'query',
- prop => 'revisions',
- rvprop => 'ids',
- rvdir => 'newer',
- rvstartid => $fetch_from,
- rvlimit => 500,
- pageids => $id,
-
- # Let MediaWiki know that we support the latest API.
- continue => '',
- };
-
- my $revnum = 0;
- # Get 500 revisions at a time due to the mediawiki api limit
- while (1) {
- my $result = $mediawiki->api($query);
-
- # Parse each of those 500 revisions
- foreach my $revision (@{$result->{query}->{pages}->{$id}->{revisions}}) {
- my $page_rev_ids;
- $page_rev_ids->{pageid} = $page->{pageid};
- $page_rev_ids->{revid} = $revision->{revid};
- push(@page_revs, $page_rev_ids);
- $revnum++;
- }
-
- if ($result->{'query-continue'}) { # For legacy APIs
- $query->{rvstartid} = $result->{'query-continue'}->{revisions}->{rvstartid};
- } elsif ($result->{continue}) { # For newer APIs
- $query->{rvstartid} = $result->{continue}->{rvcontinue};
- $query->{continue} = $result->{continue}->{continue};
- } else {
- last;
- }
- }
- if ($shallow_import && @page_revs) {
- print {*STDERR} " Found 1 revision (shallow import).\n";
- @page_revs = sort {$b->{revid} <=> $a->{revid}} (@page_revs);
- return $page_revs[0];
- }
- print {*STDERR} " Found ${revnum} revision(s).\n";
- return @page_revs;
-}
-
-sub fetch_mw_revisions {
- my $pages = shift; my @pages = @{$pages};
- my $fetch_from = shift;
-
- my @revisions = ();
- my $n = 1;
- foreach my $page (@pages) {
- my $id = $page->{pageid};
- print {*STDERR} "page ${n}/", scalar(@pages), ': ', $page->{title}, "\n";
- $n++;
- my @page_revs = fetch_mw_revisions_for_page($page, $id, $fetch_from);
- @revisions = (@page_revs, @revisions);
- }
-
- return ($n, @revisions);
-}
-
-sub fe_escape_path {
- my $path = shift;
- $path =~ s/\\/\\\\/g;
- $path =~ s/"/\\"/g;
- $path =~ s/\n/\\n/g;
- return qq("${path}");
-}
-
-sub import_file_revision {
- my $commit = shift;
- my %commit = %{$commit};
- my $full_import = shift;
- my $n = shift;
- my $mediafile = shift;
- my %mediafile;
- if ($mediafile) {
- %mediafile = %{$mediafile};
- }
-
- my $title = $commit{title};
- my $comment = $commit{comment};
- my $content = $commit{content};
- my $author = $commit{author};
- my $date = $commit{date};
-
- print {*STDOUT} "commit refs/mediawiki/${remotename}/master\n";
- print {*STDOUT} "mark :${n}\n";
- print {*STDOUT} "committer ${author} <${author}\@${wiki_name}> " . $date->epoch . " +0000\n";
- literal_data($comment);
-
- # If it's not a clone, we need to know where to start from
- if (!$full_import && $n == 1) {
- print {*STDOUT} "from refs/mediawiki/${remotename}/master^0\n";
- }
- if ($content ne DELETED_CONTENT) {
- print {*STDOUT} 'M 644 inline ' .
- fe_escape_path("${title}.mw") . "\n";
- literal_data($content);
- if (%mediafile) {
- print {*STDOUT} 'M 644 inline '
- . fe_escape_path($mediafile{title}) . "\n";
- literal_data_raw($mediafile{content});
- }
- print {*STDOUT} "\n\n";
- } else {
- print {*STDOUT} 'D ' . fe_escape_path("${title}.mw") . "\n";
- }
-
- # mediawiki revision number in the git note
- if ($full_import && $n == 1) {
- print {*STDOUT} "reset refs/notes/${remotename}/mediawiki\n";
- }
- print {*STDOUT} "commit refs/notes/${remotename}/mediawiki\n";
- print {*STDOUT} "committer ${author} <${author}\@${wiki_name}> " . $date->epoch . " +0000\n";
- literal_data('Note added by git-mediawiki during import');
- if (!$full_import && $n == 1) {
- print {*STDOUT} "from refs/notes/${remotename}/mediawiki^0\n";
- }
- print {*STDOUT} "N inline :${n}\n";
- literal_data("mediawiki_revision: $commit{mw_revision}");
- print {*STDOUT} "\n\n";
- return;
-}
-
-# parse a sequence of
-# <cmd> <arg1>
-# <cmd> <arg2>
-# \n
-# (like batch sequence of import and sequence of push statements)
-sub get_more_refs {
- my $cmd = shift;
- my @refs;
- while (1) {
- my $line = <STDIN>;
- if ($line =~ /^$cmd (.*)$/) {
- push(@refs, $1);
- } elsif ($line eq "\n") {
- return @refs;
- } else {
- die("Invalid command in a '$cmd' batch: $_\n");
- }
- }
- return;
-}
-
-sub mw_import {
- # multiple import commands can follow each other.
- my @refs = (shift, get_more_refs('import'));
- my $processedRefs;
- foreach my $ref (@refs) {
- next if $processedRefs->{$ref}; # skip duplicates: "import refs/heads/master" being issued twice; TODO: why?
- $processedRefs->{$ref} = 1;
- mw_import_ref($ref);
- }
- print {*STDOUT} "done\n";
- return;
-}
-
-sub mw_import_ref {
- my $ref = shift;
- # The remote helper will call "import HEAD" and
- # "import refs/heads/master".
- # Since HEAD is a symbolic ref to master (by convention,
- # followed by the output of the command "list" that we gave),
- # we don't need to do anything in this case.
- if ($ref eq 'HEAD') {
- return;
- }
-
- $mediawiki = connect_maybe($mediawiki, $remotename, $url);
-
- print {*STDERR} "Searching revisions...\n";
- my $last_local = get_last_local_revision();
- my $fetch_from = $last_local + 1;
- if ($fetch_from == 1) {
- print {*STDERR} ", fetching from beginning.\n";
- } else {
- print {*STDERR} ", fetching from here.\n";
- }
-
- my $n = 0;
- if ($fetch_strategy eq 'by_rev') {
- print {*STDERR} "Fetching & writing export data by revs...\n";
- $n = mw_import_ref_by_revs($fetch_from);
- } elsif ($fetch_strategy eq 'by_page') {
- print {*STDERR} "Fetching & writing export data by pages...\n";
- $n = mw_import_ref_by_pages($fetch_from);
- } else {
- print {*STDERR} qq(fatal: invalid fetch strategy "${fetch_strategy}".\n);
- print {*STDERR} "Check your configuration variables remote.${remotename}.fetchStrategy and mediawiki.fetchStrategy\n";
- exit 1;
- }
-
- if ($fetch_from == 1 && $n == 0) {
- print {*STDERR} "You appear to have cloned an empty MediaWiki.\n";
- # Something has to be done remote-helper side. If nothing is done, an error is
- # thrown saying that HEAD is referring to unknown object 0000000000000000000
- # and the clone fails.
- }
- return;
-}
-
-sub mw_import_ref_by_pages {
-
- my $fetch_from = shift;
- my %pages_hash = get_mw_pages();
- my @pages = values(%pages_hash);
-
- my ($n, @revisions) = fetch_mw_revisions(\@pages, $fetch_from);
-
- @revisions = sort {$a->{revid} <=> $b->{revid}} @revisions;
- my @revision_ids = map { $_->{revid} } @revisions;
-
- return mw_import_revids($fetch_from, \@revision_ids, \%pages_hash);
-}
-
-sub mw_import_ref_by_revs {
-
- my $fetch_from = shift;
- my %pages_hash = get_mw_pages();
-
- my $last_remote = get_last_global_remote_rev();
- my @revision_ids = $fetch_from..$last_remote;
- return mw_import_revids($fetch_from, \@revision_ids, \%pages_hash);
-}
-
-# Import revisions given in second argument (array of integers).
-# Only pages appearing in the third argument (hash indexed by page titles)
-# will be imported.
-sub mw_import_revids {
- my $fetch_from = shift;
- my $revision_ids = shift;
- my $pages = shift;
-
- my $n = 0;
- my $n_actual = 0;
- my $last_timestamp = 0; # Placeholder in case $rev->timestamp is undefined
-
- foreach my $pagerevid (@{$revision_ids}) {
- # Count page even if we skip it, since we display
- # $n/$total and $total includes skipped pages.
- $n++;
-
- # fetch the content of the pages
- my $query = {
- action => 'query',
- prop => 'revisions',
- rvprop => 'content|timestamp|comment|user|ids',
- revids => $pagerevid,
- };
-
- my $result = $mediawiki->api($query);
-
- if (!$result) {
- die "Failed to retrieve modified page for revision $pagerevid\n";
- }
-
- if (defined($result->{query}->{badrevids}->{$pagerevid})) {
- # The revision id does not exist on the remote wiki.
- next;
- }
-
- if (!defined($result->{query}->{pages})) {
- die "Invalid revision ${pagerevid}.\n";
- }
-
- my @result_pages = values(%{$result->{query}->{pages}});
- my $result_page = $result_pages[0];
- my $rev = $result_pages[0]->{revisions}->[0];
-
- my $page_title = $result_page->{title};
-
- if (!exists($pages->{$page_title})) {
- print {*STDERR} "${n}/", scalar(@{$revision_ids}),
- ": Skipping revision #$rev->{revid} of ${page_title}\n";
- next;
- }
-
- $n_actual++;
-
- my %commit;
- $commit{author} = $rev->{user} || 'Anonymous';
- $commit{comment} = $rev->{comment} || EMPTY_MESSAGE;
- $commit{title} = smudge_filename($page_title);
- $commit{mw_revision} = $rev->{revid};
- $commit{content} = mediawiki_smudge($rev->{'*'});
-
- if (!defined($rev->{timestamp})) {
- $last_timestamp++;
- } else {
- $last_timestamp = $rev->{timestamp};
- }
- $commit{date} = DateTime::Format::ISO8601->parse_datetime($last_timestamp);
-
- # Differentiates classic pages and media files.
- my ($namespace, $filename) = $page_title =~ /^([^:]*):(.*)$/;
- my %mediafile;
- if ($namespace) {
- my $id = get_mw_namespace_id($namespace);
- if ($id && $id == get_mw_namespace_id('File')) {
- %mediafile = get_mw_mediafile_for_page_revision($filename, $rev->{timestamp});
- }
- }
- # If this is a revision of the media page for new version
- # of a file do one common commit for both file and media page.
- # Else do commit only for that page.
- print {*STDERR} "${n}/", scalar(@{$revision_ids}), ": Revision #$rev->{revid} of $commit{title}\n";
- import_file_revision(\%commit, ($fetch_from == 1), $n_actual, \%mediafile);
- }
-
- return $n_actual;
-}
-
-sub error_non_fast_forward {
- my $advice = run_git_quoted(["config", "--bool", "advice.pushNonFastForward"]);
- chomp($advice);
- if ($advice ne 'false') {
- # Native git-push would show this after the summary.
- # We can't ask it to display it cleanly, so print it
- # ourselves before.
- print {*STDERR} "To prevent you from losing history, non-fast-forward updates were rejected\n";
- print {*STDERR} "Merge the remote changes (e.g. 'git pull') before pushing again. See the\n";
- print {*STDERR} "'Note about fast-forwards' section of 'git push --help' for details.\n";
- }
- print {*STDOUT} qq(error $_[0] "non-fast-forward"\n);
- return 0;
-}
-
-sub mw_upload_file {
- my $complete_file_name = shift;
- my $new_sha1 = shift;
- my $extension = shift;
- my $file_deleted = shift;
- my $summary = shift;
- my $newrevid;
- my $path = "File:${complete_file_name}";
- my %hashFiles = get_allowed_file_extensions();
- if (!exists($hashFiles{$extension})) {
- print {*STDERR} "${complete_file_name} is not a permitted file on this wiki.\n";
- print {*STDERR} "Check the configuration of file uploads in your mediawiki.\n";
- return $newrevid;
- }
- # Deleting and uploading a file requires a privileged user
- if ($file_deleted) {
- $mediawiki = connect_maybe($mediawiki, $remotename, $url);
- my $query = {
- action => 'delete',
- title => $path,
- reason => $summary
- };
- if (!$mediawiki->edit($query)) {
- print {*STDERR} "Failed to delete file on remote wiki\n";
- print {*STDERR} "Check your permissions on the remote site. Error code:\n";
- print {*STDERR} $mediawiki->{error}->{code} . ':' . $mediawiki->{error}->{details};
- exit 1;
- }
- } else {
- # Don't let perl try to interpret file content as UTF-8 => use "raw"
- my $content = run_git_quoted(["cat-file", "blob", $new_sha1], 'raw');
- if ($content ne EMPTY) {
- $mediawiki = connect_maybe($mediawiki, $remotename, $url);
- $mediawiki->{config}->{upload_url} =
- "${url}/index.php/Special:Upload";
- $mediawiki->edit({
- action => 'upload',
- filename => $complete_file_name,
- comment => $summary,
- file => [undef,
- $complete_file_name,
- Content => $content],
- ignorewarnings => 1,
- }, {
- skip_encoding => 1
- } ) || die $mediawiki->{error}->{code} . ':'
- . $mediawiki->{error}->{details} . "\n";
- my $last_file_page = $mediawiki->get_page({title => $path});
- $newrevid = $last_file_page->{revid};
- print {*STDERR} "Pushed file: ${new_sha1} - ${complete_file_name}.\n";
- } else {
- print {*STDERR} "Empty file ${complete_file_name} not pushed.\n";
- }
- }
- return $newrevid;
-}
-
-sub mw_push_file {
- my $diff_info = shift;
- # $diff_info contains a string in this format:
- # 100644 100644 <sha1_of_blob_before_commit> <sha1_of_blob_now> <status>
- my @diff_info_split = split(/[ \t]/, $diff_info);
-
- # Filename, including .mw extension
- my $complete_file_name = shift;
- # Commit message
- my $summary = shift;
- # MediaWiki revision number. Keep the previous one by default,
- # in case there's no edit to perform.
- my $oldrevid = shift;
- my $newrevid;
-
- if ($summary eq EMPTY_MESSAGE) {
- $summary = EMPTY;
- }
-
- my $new_sha1 = $diff_info_split[3];
- my $old_sha1 = $diff_info_split[2];
- my $page_created = ($old_sha1 eq NULL_SHA1);
- my $page_deleted = ($new_sha1 eq NULL_SHA1);
- $complete_file_name = clean_filename($complete_file_name);
-
- my ($title, $extension) = $complete_file_name =~ /^(.*)\.([^\.]*)$/;
- if (!defined($extension)) {
- $extension = EMPTY;
- }
- if ($extension eq 'mw') {
- my $ns = get_mw_namespace_id_for_page($complete_file_name);
- if ($ns && $ns == get_mw_namespace_id('File') && (!$export_media)) {
- print {*STDERR} "Ignoring media file related page: ${complete_file_name}\n";
- return ($oldrevid, 'ok');
- }
- my $file_content;
- if ($page_deleted) {
- # Deleting a page usually requires
- # special privileges. A common
- # convention is to replace the page
- # with this content instead:
- $file_content = DELETED_CONTENT;
- } else {
- $file_content = run_git_quoted(["cat-file", "blob", $new_sha1]);
- }
-
- $mediawiki = connect_maybe($mediawiki, $remotename, $url);
-
- my $result = $mediawiki->edit( {
- action => 'edit',
- summary => $summary,
- title => $title,
- basetimestamp => $basetimestamps{$oldrevid},
- text => mediawiki_clean($file_content, $page_created),
- }, {
- skip_encoding => 1 # Helps with names with accentuated characters
- });
- if (!$result) {
- if ($mediawiki->{error}->{code} == 3) {
- # edit conflicts, considered as non-fast-forward
- print {*STDERR} 'Warning: Error ' .
- $mediawiki->{error}->{code} .
- ' from mediawiki: ' . $mediawiki->{error}->{details} .
- ".\n";
- return ($oldrevid, 'non-fast-forward');
- } else {
- # Other errors. Shouldn't happen => just die()
- die 'Fatal: Error ' .
- $mediawiki->{error}->{code} .
- ' from mediawiki: ' . $mediawiki->{error}->{details} . "\n";
- }
- }
- $newrevid = $result->{edit}->{newrevid};
- print {*STDERR} "Pushed file: ${new_sha1} - ${title}\n";
- } elsif ($export_media) {
- $newrevid = mw_upload_file($complete_file_name, $new_sha1,
- $extension, $page_deleted,
- $summary);
- } else {
- print {*STDERR} "Ignoring media file ${title}\n";
- }
- $newrevid = ($newrevid or $oldrevid);
- return ($newrevid, 'ok');
-}
-
-sub mw_push {
- # multiple push statements can follow each other
- my @refsspecs = (shift, get_more_refs('push'));
- my $pushed;
- for my $refspec (@refsspecs) {
- my ($force, $local, $remote) = $refspec =~ /^(\+)?([^:]*):([^:]*)$/
- or die("Invalid refspec for push. Expected <src>:<dst> or +<src>:<dst>\n");
- if ($force) {
- print {*STDERR} "Warning: forced push not allowed on a MediaWiki.\n";
- }
- if ($local eq EMPTY) {
- print {*STDERR} "Cannot delete remote branch on a MediaWiki\n";
- print {*STDOUT} "error ${remote} cannot delete\n";
- next;
- }
- if ($remote ne 'refs/heads/master') {
- print {*STDERR} "Only push to the branch 'master' is supported on a MediaWiki\n";
- print {*STDOUT} "error ${remote} only master allowed\n";
- next;
- }
- if (mw_push_revision($local, $remote)) {
- $pushed = 1;
- }
- }
-
- # Notify Git that the push is done
- print {*STDOUT} "\n";
-
- if ($pushed && $dumb_push) {
- print {*STDERR} "Just pushed some revisions to MediaWiki.\n";
- print {*STDERR} "The pushed revisions now have to be re-imported, and your current branch\n";
- print {*STDERR} "needs to be updated with these re-imported commits. You can do this with\n";
- print {*STDERR} "\n";
- print {*STDERR} " git pull --rebase\n";
- print {*STDERR} "\n";
- }
- return;
-}
-
-sub mw_push_revision {
- my $local = shift;
- my $remote = shift; # actually, this has to be "refs/heads/master" at this point.
- my $last_local_revid = get_last_local_revision();
- print {*STDERR} ".\n"; # Finish sentence started by get_last_local_revision()
- my $last_remote_revid = get_last_remote_revision();
- my $mw_revision = $last_remote_revid;
-
- # Get sha1 of commit pointed by local HEAD
- my $HEAD_sha1 = run_git_quoted_nostderr(["rev-parse", $local]);
- chomp($HEAD_sha1);
- # Get sha1 of commit pointed by remotes/$remotename/master
- my $remoteorigin_sha1 = run_git_quoted_nostderr(["rev-parse", "refs/remotes/${remotename}/master"]);
- chomp($remoteorigin_sha1);
-
- if ($last_local_revid > 0 &&
- $last_local_revid < $last_remote_revid) {
- return error_non_fast_forward($remote);
- }
-
- if ($HEAD_sha1 eq $remoteorigin_sha1) {
- # nothing to push
- return 0;
- }
-
- # Get every commit in between HEAD and refs/remotes/origin/master,
- # including HEAD and refs/remotes/origin/master
- my @commit_pairs = ();
- if ($last_local_revid > 0) {
- my $parsed_sha1 = $remoteorigin_sha1;
- # Find a path from last MediaWiki commit to pushed commit
- print {*STDERR} "Computing path from local to remote ...\n";
- my @local_ancestry = split(/\n/, run_git_quoted(["rev-list", "--boundary", "--parents", $local, "^${parsed_sha1}"]));
- my %local_ancestry;
- foreach my $line (@local_ancestry) {
- if (my ($child, $parents) = $line =~ /^-?([a-f0-9]+) ([a-f0-9 ]+)/) {
- foreach my $parent (split(/ /, $parents)) {
- $local_ancestry{$parent} = $child;
- }
- } elsif (!$line =~ /^([a-f0-9]+)/) {
- die "Unexpected output from git rev-list: ${line}\n";
- }
- }
- while ($parsed_sha1 ne $HEAD_sha1) {
- my $child = $local_ancestry{$parsed_sha1};
- if (!$child) {
- print {*STDERR} "Cannot find a path in history from remote commit to last commit\n";
- return error_non_fast_forward($remote);
- }
- push(@commit_pairs, [$parsed_sha1, $child]);
- $parsed_sha1 = $child;
- }
- } else {
- # No remote mediawiki revision. Export the whole
- # history (linearized with --first-parent)
- print {*STDERR} "Warning: no common ancestor, pushing complete history\n";
- my $history = run_git_quoted(["rev-list", "--first-parent", "--children", $local]);
- my @history = split(/\n/, $history);
- @history = @history[1..$#history];
- foreach my $line (reverse @history) {
- my @commit_info_split = split(/[ \n]/, $line);
- push(@commit_pairs, \@commit_info_split);
- }
- }
-
- foreach my $commit_info_split (@commit_pairs) {
- my $sha1_child = @{$commit_info_split}[0];
- my $sha1_commit = @{$commit_info_split}[1];
- my $diff_infos = run_git_quoted(["diff-tree", "-r", "--raw", "-z", $sha1_child, $sha1_commit]);
- # TODO: we could detect rename, and encode them with a #redirect on the wiki.
- # TODO: for now, it's just a delete+add
- my @diff_info_list = split(/\0/, $diff_infos);
- # Keep the subject line of the commit message as mediawiki comment for the revision
- my $commit_msg = run_git_quoted(["log", "--no-walk", '--format="%s"', $sha1_commit]);
- chomp($commit_msg);
- # Push every blob
- while (@diff_info_list) {
- my $status;
- # git diff-tree -z gives an output like
- # <metadata>\0<filename1>\0
- # <metadata>\0<filename2>\0
- # and we've split on \0.
- my $info = shift(@diff_info_list);
- my $file = shift(@diff_info_list);
- ($mw_revision, $status) = mw_push_file($info, $file, $commit_msg, $mw_revision);
- if ($status eq 'non-fast-forward') {
- # we may already have sent part of the
- # commit to MediaWiki, but it's too
- # late to cancel it. Stop the push in
- # the middle, but still give an
- # accurate error message.
- return error_non_fast_forward($remote);
- }
- if ($status ne 'ok') {
- die("Unknown error from mw_push_file()\n");
- }
- }
- if (!$dumb_push) {
- run_git_quoted(["notes", "--ref=${remotename}/mediawiki",
- "add", "-f", "-m",
- "mediawiki_revision: ${mw_revision}",
- $sha1_commit]);
- }
- }
-
- print {*STDOUT} "ok ${remote}\n";
- return 1;
-}
-
-sub get_allowed_file_extensions {
- $mediawiki = connect_maybe($mediawiki, $remotename, $url);
-
- my $query = {
- action => 'query',
- meta => 'siteinfo',
- siprop => 'fileextensions'
- };
- my $result = $mediawiki->api($query);
- my @file_extensions = map { $_->{ext}} @{$result->{query}->{fileextensions}};
- my %hashFile = map { $_ => 1 } @file_extensions;
-
- return %hashFile;
-}
-
-# In memory cache for MediaWiki namespace ids.
-my %namespace_id;
-
-# Namespaces whose id is cached in the configuration file
-# (to avoid duplicates)
-my %cached_mw_namespace_id;
-
-# Return MediaWiki id for a canonical namespace name.
-# Ex.: "File", "Project".
-sub get_mw_namespace_id {
- $mediawiki = connect_maybe($mediawiki, $remotename, $url);
- my $name = shift;
-
- if (!exists $namespace_id{$name}) {
- # Look at configuration file, if the record for that namespace is
- # already cached. Namespaces are stored in form:
- # "Name_of_namespace:Id_namespace", ex.: "File:6".
- my @temp = split(/\n/,
- run_git_quoted(["config", "--get-all", "remote.${remotename}.namespaceCache"]));
- chomp(@temp);
- foreach my $ns (@temp) {
- my ($n, $id) = split(/:/, $ns);
- if ($id eq 'notANameSpace') {
- $namespace_id{$n} = {is_namespace => 0};
- } else {
- $namespace_id{$n} = {is_namespace => 1, id => $id};
- }
- $cached_mw_namespace_id{$n} = 1;
- }
- }
-
- if (!exists $namespace_id{$name}) {
- print {*STDERR} "Namespace ${name} not found in cache, querying the wiki ...\n";
- # NS not found => get namespace id from MW and store it in
- # configuration file.
- my $query = {
- action => 'query',
- meta => 'siteinfo',
- siprop => 'namespaces'
- };
- my $result = $mediawiki->api($query);
-
- while (my ($id, $ns) = each(%{$result->{query}->{namespaces}})) {
- if (defined($ns->{id}) && defined($ns->{canonical})) {
- $namespace_id{$ns->{canonical}} = {is_namespace => 1, id => $ns->{id}};
- if ($ns->{'*'}) {
- # alias (e.g. french Fichier: as alias for canonical File:)
- $namespace_id{$ns->{'*'}} = {is_namespace => 1, id => $ns->{id}};
- }
- }
- }
- }
-
- my $ns = $namespace_id{$name};
- my $id;
-
- if (!defined $ns) {
- my @namespaces = map { s/ /_/g; $_; } sort keys %namespace_id;
- print {*STDERR} "No such namespace ${name} on MediaWiki, known namespaces: @namespaces\n";
- $ns = {is_namespace => 0};
- $namespace_id{$name} = $ns;
- }
-
- if ($ns->{is_namespace}) {
- $id = $ns->{id};
- }
-
- # Store "notANameSpace" as special value for inexisting namespaces
- my $store_id = ($id || 'notANameSpace');
-
- # Store explicitly requested namespaces on disk
- if (!exists $cached_mw_namespace_id{$name}) {
- run_git_quoted(["config", "--add", "remote.${remotename}.namespaceCache", "${name}:${store_id}"]);
- $cached_mw_namespace_id{$name} = 1;
- }
- return $id;
-}
-
-sub get_mw_namespace_id_for_page {
- my $namespace = shift;
- if ($namespace =~ /^([^:]*):/) {
- return get_mw_namespace_id($namespace);
- } else {
- return;
- }
-}
diff --git a/contrib/mw-to-git/git-remote-mediawiki.txt b/contrib/mw-to-git/git-remote-mediawiki.txt
deleted file mode 100644
index 5da825f61e..0000000000
--- a/contrib/mw-to-git/git-remote-mediawiki.txt
+++ /dev/null
@@ -1,7 +0,0 @@
-Git-Mediawiki is a project which aims the creation of a gate
-between git and mediawiki, allowing git users to push and pull
-objects from mediawiki just as one would do with a classic git
-repository thanks to remote-helpers.
-
-For more information, visit the wiki at
-https://github.com/Git-Mediawiki/Git-Mediawiki
diff --git a/contrib/mw-to-git/t/.gitignore b/contrib/mw-to-git/t/.gitignore
deleted file mode 100644
index 2b8dc30c6d..0000000000
--- a/contrib/mw-to-git/t/.gitignore
+++ /dev/null
@@ -1,4 +0,0 @@
-WEB/
-mediawiki/
-trash directory.t*/
-test-results/
diff --git a/contrib/mw-to-git/t/Makefile b/contrib/mw-to-git/t/Makefile
deleted file mode 100644
index f422203fa0..0000000000
--- a/contrib/mw-to-git/t/Makefile
+++ /dev/null
@@ -1,31 +0,0 @@
-#
-# Copyright (C) 2012
-# Charles Roussel <charles.roussel@ensimag.imag.fr>
-# Simon Cathebras <simon.cathebras@ensimag.imag.fr>
-# Julien Khayat <julien.khayat@ensimag.imag.fr>
-# Guillaume Sasdy <guillaume.sasdy@ensimag.imag.fr>
-# Simon Perrat <simon.perrat@ensimag.imag.fr>
-#
-## Test git-remote-mediawiki
-
-all: test
-
--include ../../../config.mak.autogen
--include ../../../config.mak
-
-T = $(wildcard t[0-9][0-9][0-9][0-9]-*.sh)
-
-.PHONY: help test clean all
-
-help:
- @echo 'Run "$(MAKE) test" to launch test scripts'
- @echo 'Run "$(MAKE) clean" to remove trash folders'
-
-test:
- @for t in $(T); do \
- echo "$$t"; \
- "./$$t" || exit 1; \
- done
-
-clean:
- $(RM) -r 'trash directory'.*
diff --git a/contrib/mw-to-git/t/README b/contrib/mw-to-git/t/README
deleted file mode 100644
index 72c4889db7..0000000000
--- a/contrib/mw-to-git/t/README
+++ /dev/null
@@ -1,124 +0,0 @@
-Tests for Mediawiki-to-Git
-==========================
-
-Introduction
-------------
-This manual describes how to install the git-remote-mediawiki test
-environment on a machine with git installed on it.
-
-Prerequisite
-------------
-
-In order to run this test environment correctly, you will need to
-install the following packages (Debian/Ubuntu names, may need to be
-adapted for another distribution):
-
-* lighttpd
-* php
-* php-cgi
-* php-cli
-* php-curl
-* php-sqlite
-
-Principles and Technical Choices
---------------------------------
-
-The test environment makes it easy to install and manipulate one or
-several MediaWiki instances. To allow developers to run the testsuite
-easily, the environment does not require root privilege (except to
-install the required packages if needed). It starts a webserver
-instance on the user's account (using lighttpd greatly helps for
-that), and does not need a separate database daemon (thanks to the use
-of sqlite).
-
-Run the test environment
-------------------------
-
-Install a new wiki
-~~~~~~~~~~~~~~~~~~
-
-Once you have all the prerequisite, you need to install a MediaWiki
-instance on your machine. If you already have one, it is still
-strongly recommended to install one with the script provided. Here's
-how to work it:
-
-a. change directory to contrib/mw-to-git/t/
-b. if needed, edit test.config to choose your installation parameters
-c. run `./install-wiki.sh install`
-d. check on your favourite web browser if your wiki is correctly
- installed.
-
-Remove an existing wiki
-~~~~~~~~~~~~~~~~~~~~~~~
-
-Edit the file test.config to fit the wiki you want to delete, and then
-execute the command `./install-wiki.sh delete` from the
-contrib/mw-to-git/t directory.
-
-Run the existing tests
-~~~~~~~~~~~~~~~~~~~~~~
-
-The provided tests are currently in the `contrib/mw-to-git/t` directory.
-The files are all the t936[0-9]-*.sh shell scripts.
-
-a. Run all tests:
-To do so, run "make test" from the contrib/mw-to-git/ directory.
-
-b. Run a specific test:
-To run a given test <test_name>, run ./<test_name> from the
-contrib/mw-to-git/t directory.
-
-How to create new tests
------------------------
-
-Available functions
-~~~~~~~~~~~~~~~~~~~
-
-The test environment of git-remote-mediawiki provides some functions
-useful to test its behaviour. for more details about the functions'
-parameters, please refer to the `test-gitmw-lib.sh` and
-`test-gitmw.pl` files.
-
-** `test_check_wiki_precond`:
-Check if the tests must be skipped or not. Please use this function
-at the beginning of each new test file.
-
-** `wiki_getpage`:
-Fetch a given page from the wiki and puts its content in the
-directory in parameter.
-
-** `wiki_delete_page`:
-Delete a given page from the wiki.
-
-** `wiki_edit_page`:
-Create or modify a given page in the wiki. You can specify several
-parameters like a summary for the page edition, or add the page to a
-given category.
-See test-gitmw.pl for more details.
-
-** `wiki_getallpage`:
-Fetch all pages from the wiki into a given directory. The directory
-is created if it does not exists.
-
-** `test_diff_directories`:
-Compare the content of two directories. The content must be the same.
-Use this function to compare the content of a git directory and a wiki
-one created by wiki_getallpage.
-
-** `test_contains_N_files`:
-Check if the given directory contains a given number of file.
-
-** `wiki_page_exists`:
-Tests if a given page exists on the wiki.
-
-** `wiki_reset`:
-Reset the wiki, i.e. flush the database. Use this function at the
-beginning of each new test, except if the test re-uses the same wiki
-(and history) as the previous test.
-
-How to write a new test
-~~~~~~~~~~~~~~~~~~~~~~~
-
-Please, follow the standards given by git. See git/t/README.
-New file should be named as t936[0-9]-*.sh.
-Be sure to reset your wiki regularly with the function `wiki_reset`.
diff --git a/contrib/mw-to-git/t/install-wiki.sh b/contrib/mw-to-git/t/install-wiki.sh
deleted file mode 100755
index c215213c4b..0000000000
--- a/contrib/mw-to-git/t/install-wiki.sh
+++ /dev/null
@@ -1,55 +0,0 @@
-#!/bin/sh
-
-# This script installs or deletes a MediaWiki on your computer.
-# It requires a web server with PHP and SQLite running. In addition, if you
-# do not have MediaWiki sources on your computer, the option 'install'
-# downloads them for you.
-# Please set the CONFIGURATION VARIABLES in ./test-gitmw-lib.sh
-
-WIKI_TEST_DIR=$(cd "$(dirname "$0")" && pwd)
-
-if test -z "$WIKI_TEST_DIR"
-then
- WIKI_TEST_DIR=.
-fi
-
-. "$WIKI_TEST_DIR"/test-gitmw-lib.sh
-usage () {
- echo "usage: "
- echo " ./install-wiki.sh <install | delete | --help>"
- echo " install | -i : Install a wiki on your computer."
- echo " delete | -d : Delete the wiki and all its pages and "
- echo " content."
- echo " start | -s : Start the previously configured lighttpd daemon"
- echo " stop : Stop lighttpd daemon."
-}
-
-
-# Argument: install, delete, --help | -h
-case "$1" in
- "install" | "-i")
- wiki_install
- exit 0
- ;;
- "delete" | "-d")
- wiki_delete
- exit 0
- ;;
- "start" | "-s")
- start_lighttpd
- exit
- ;;
- "stop")
- stop_lighttpd
- exit
- ;;
- "--help" | "-h")
- usage
- exit 0
- ;;
- *)
- echo "Invalid argument: $1"
- usage
- exit 1
- ;;
-esac
diff --git a/contrib/mw-to-git/t/push-pull-tests.sh b/contrib/mw-to-git/t/push-pull-tests.sh
deleted file mode 100644
index 9da2dc5ff0..0000000000
--- a/contrib/mw-to-git/t/push-pull-tests.sh
+++ /dev/null
@@ -1,144 +0,0 @@
-test_push_pull () {
-
- test_expect_success 'Git pull works after adding a new wiki page' '
- wiki_reset &&
-
- git clone mediawiki::'"$WIKI_URL"' mw_dir_1 &&
- wiki_editpage Foo "page created after the git clone" false &&
-
- (
- cd mw_dir_1 &&
- git pull
- ) &&
-
- wiki_getallpage ref_page_1 &&
- test_diff_directories mw_dir_1 ref_page_1
- '
-
- test_expect_success 'Git pull works after editing a wiki page' '
- wiki_reset &&
-
- wiki_editpage Foo "page created before the git clone" false &&
- git clone mediawiki::'"$WIKI_URL"' mw_dir_2 &&
- wiki_editpage Foo "new line added on the wiki" true &&
-
- (
- cd mw_dir_2 &&
- git pull
- ) &&
-
- wiki_getallpage ref_page_2 &&
- test_diff_directories mw_dir_2 ref_page_2
- '
-
- test_expect_success 'git pull works on conflict handled by auto-merge' '
- wiki_reset &&
-
- wiki_editpage Foo "1 init
-3
-5
- " false &&
- git clone mediawiki::'"$WIKI_URL"' mw_dir_3 &&
-
- wiki_editpage Foo "1 init
-2 content added on wiki after clone
-3
-5
- " false &&
-
- (
- cd mw_dir_3 &&
- echo "1 init
-3
-4 content added on git after clone
-5
-" >Foo.mw &&
- git commit -am "conflicting change on foo" &&
- git pull &&
- git push
- )
- '
-
- test_expect_success 'Git push works after adding a file .mw' '
- wiki_reset &&
- git clone mediawiki::'"$WIKI_URL"' mw_dir_4 &&
- wiki_getallpage ref_page_4 &&
- (
- cd mw_dir_4 &&
- test_path_is_missing Foo.mw &&
- touch Foo.mw &&
- echo "hello world" >>Foo.mw &&
- git add Foo.mw &&
- git commit -m "Foo" &&
- git push
- ) &&
- wiki_getallpage ref_page_4 &&
- test_diff_directories mw_dir_4 ref_page_4
- '
-
- test_expect_success 'Git push works after editing a file .mw' '
- wiki_reset &&
- wiki_editpage "Foo" "page created before the git clone" false &&
- git clone mediawiki::'"$WIKI_URL"' mw_dir_5 &&
-
- (
- cd mw_dir_5 &&
- echo "new line added in the file Foo.mw" >>Foo.mw &&
- git commit -am "edit file Foo.mw" &&
- git push
- ) &&
-
- wiki_getallpage ref_page_5 &&
- test_diff_directories mw_dir_5 ref_page_5
- '
-
- test_expect_failure 'Git push works after deleting a file' '
- wiki_reset &&
- wiki_editpage Foo "wiki page added before git clone" false &&
- git clone mediawiki::'"$WIKI_URL"' mw_dir_6 &&
-
- (
- cd mw_dir_6 &&
- git rm Foo.mw &&
- git commit -am "page Foo.mw deleted" &&
- git push
- ) &&
-
- test_must_fail wiki_page_exist Foo
- '
-
- test_expect_success 'Merge conflict expected and solving it' '
- wiki_reset &&
-
- git clone mediawiki::'"$WIKI_URL"' mw_dir_7 &&
- wiki_editpage Foo "1 conflict
-3 wiki
-4" false &&
-
- (
- cd mw_dir_7 &&
- echo "1 conflict
-2 git
-4" >Foo.mw &&
- git add Foo.mw &&
- git commit -m "conflict created" &&
- test_must_fail git pull &&
- "$PERL_PATH" -pi -e "s/[<=>].*//g" Foo.mw &&
- git commit -am "merge conflict solved" &&
- git push
- )
- '
-
- test_expect_failure 'git pull works after deleting a wiki page' '
- wiki_reset &&
- wiki_editpage Foo "wiki page added before the git clone" false &&
- git clone mediawiki::'"$WIKI_URL"' mw_dir_8 &&
-
- wiki_delete_page Foo &&
- (
- cd mw_dir_8 &&
- git pull &&
- test_path_is_missing Foo.mw
- )
- '
-}
diff --git a/contrib/mw-to-git/t/t9360-mw-to-git-clone.sh b/contrib/mw-to-git/t/t9360-mw-to-git-clone.sh
deleted file mode 100755
index f08890d9e7..0000000000
--- a/contrib/mw-to-git/t/t9360-mw-to-git-clone.sh
+++ /dev/null
@@ -1,257 +0,0 @@
-#!/bin/sh
-#
-# Copyright (C) 2012
-# Charles Roussel <charles.roussel@ensimag.imag.fr>
-# Simon Cathebras <simon.cathebras@ensimag.imag.fr>
-# Julien Khayat <julien.khayat@ensimag.imag.fr>
-# Guillaume Sasdy <guillaume.sasdy@ensimag.imag.fr>
-# Simon Perrat <simon.perrat@ensimag.imag.fr>
-#
-# License: GPL v2 or later
-
-
-test_description='Test the Git Mediawiki remote helper: git clone'
-
-. ./test-gitmw-lib.sh
-. $TEST_DIRECTORY/test-lib.sh
-
-
-test_check_precond
-
-
-test_expect_success 'Git clone creates the expected git log with one file' '
- wiki_reset &&
- wiki_editpage foo "this is not important" false -c cat -s "this must be the same" &&
- git clone mediawiki::'"$WIKI_URL"' mw_dir_1 &&
- (
- cd mw_dir_1 &&
- git log --format=%s HEAD^..HEAD >log.tmp
- ) &&
- echo "this must be the same" >msg.tmp &&
- test_cmp msg.tmp mw_dir_1/log.tmp
-'
-
-
-test_expect_success 'Git clone creates the expected git log with multiple files' '
- wiki_reset &&
- wiki_editpage daddy "this is not important" false -s="this must be the same" &&
- wiki_editpage daddy "neither is this" true -s="this must also be the same" &&
- wiki_editpage daddy "neither is this" true -s="same same same" &&
- wiki_editpage dj "dont care" false -s="identical" &&
- wiki_editpage dj "dont care either" true -s="identical too" &&
- git clone mediawiki::'"$WIKI_URL"' mw_dir_2 &&
- (
- cd mw_dir_2 &&
- git log --format=%s Daddy.mw >logDaddy.tmp &&
- git log --format=%s Dj.mw >logDj.tmp
- ) &&
- echo "same same same" >msgDaddy.tmp &&
- echo "this must also be the same" >>msgDaddy.tmp &&
- echo "this must be the same" >>msgDaddy.tmp &&
- echo "identical too" >msgDj.tmp &&
- echo "identical" >>msgDj.tmp &&
- test_cmp msgDaddy.tmp mw_dir_2/logDaddy.tmp &&
- test_cmp msgDj.tmp mw_dir_2/logDj.tmp
-'
-
-
-test_expect_success 'Git clone creates only Main_Page.mw with an empty wiki' '
- wiki_reset &&
- git clone mediawiki::'"$WIKI_URL"' mw_dir_3 &&
- test_contains_N_files mw_dir_3 1 &&
- test_path_is_file mw_dir_3/Main_Page.mw
-'
-
-test_expect_success 'Git clone does not fetch a deleted page' '
- wiki_reset &&
- wiki_editpage foo "this page must be deleted before the clone" false &&
- wiki_delete_page foo &&
- git clone mediawiki::'"$WIKI_URL"' mw_dir_4 &&
- test_contains_N_files mw_dir_4 1 &&
- test_path_is_file mw_dir_4/Main_Page.mw &&
- test_path_is_missing mw_dir_4/Foo.mw
-'
-
-test_expect_success 'Git clone works with page added' '
- wiki_reset &&
- wiki_editpage foo " I will be cloned" false &&
- wiki_editpage bar "I will be cloned" false &&
- git clone mediawiki::'"$WIKI_URL"' mw_dir_5 &&
- wiki_getallpage ref_page_5 &&
- test_diff_directories mw_dir_5 ref_page_5 &&
- wiki_delete_page foo &&
- wiki_delete_page bar
-'
-
-test_expect_success 'Git clone works with an edited page ' '
- wiki_reset &&
- wiki_editpage foo "this page will be edited" \
- false -s "first edition of page foo" &&
- wiki_editpage foo "this page has been edited and must be on the clone " true &&
- git clone mediawiki::'"$WIKI_URL"' mw_dir_6 &&
- test_path_is_file mw_dir_6/Foo.mw &&
- test_path_is_file mw_dir_6/Main_Page.mw &&
- wiki_getallpage mw_dir_6/page_ref_6 &&
- test_diff_directories mw_dir_6 mw_dir_6/page_ref_6 &&
- (
- cd mw_dir_6 &&
- git log --format=%s HEAD^ Foo.mw > ../Foo.log
- ) &&
- echo "first edition of page foo" > FooExpect.log &&
- diff FooExpect.log Foo.log
-'
-
-
-test_expect_success 'Git clone works with several pages and some deleted ' '
- wiki_reset &&
- wiki_editpage foo "this page will not be deleted" false &&
- wiki_editpage bar "I must not be erased" false &&
- wiki_editpage namnam "I will not be there at the end" false &&
- wiki_editpage nyancat "nyan nyan nyan delete me" false &&
- wiki_delete_page namnam &&
- wiki_delete_page nyancat &&
- git clone mediawiki::'"$WIKI_URL"' mw_dir_7 &&
- test_path_is_file mw_dir_7/Foo.mw &&
- test_path_is_file mw_dir_7/Bar.mw &&
- test_path_is_missing mw_dir_7/Namnam.mw &&
- test_path_is_missing mw_dir_7/Nyancat.mw &&
- wiki_getallpage mw_dir_7/page_ref_7 &&
- test_diff_directories mw_dir_7 mw_dir_7/page_ref_7
-'
-
-
-test_expect_success 'Git clone works with one specific page cloned ' '
- wiki_reset &&
- wiki_editpage foo "I will not be cloned" false &&
- wiki_editpage bar "Do not clone me" false &&
- wiki_editpage namnam "I will be cloned :)" false -s="this log must stay" &&
- wiki_editpage nyancat "nyan nyan nyan you cant clone me" false &&
- git clone -c remote.origin.pages=namnam \
- mediawiki::'"$WIKI_URL"' mw_dir_8 &&
- test_contains_N_files mw_dir_8 1 &&
- test_path_is_file mw_dir_8/Namnam.mw &&
- test_path_is_missing mw_dir_8/Main_Page.mw &&
- (
- cd mw_dir_8 &&
- echo "this log must stay" >msg.tmp &&
- git log --format=%s >log.tmp &&
- test_cmp msg.tmp log.tmp
- ) &&
- wiki_check_content mw_dir_8/Namnam.mw Namnam
-'
-
-test_expect_success 'Git clone works with multiple specific page cloned ' '
- wiki_reset &&
- wiki_editpage foo "I will be there" false &&
- wiki_editpage bar "I will not disappear" false &&
- wiki_editpage namnam "I be erased" false &&
- wiki_editpage nyancat "nyan nyan nyan you will not erase me" false &&
- wiki_delete_page namnam &&
- git clone -c remote.origin.pages="foo bar nyancat namnam" \
- mediawiki::'"$WIKI_URL"' mw_dir_9 &&
- test_contains_N_files mw_dir_9 3 &&
- test_path_is_missing mw_dir_9/Namnam.mw &&
- test_path_is_file mw_dir_9/Foo.mw &&
- test_path_is_file mw_dir_9/Nyancat.mw &&
- test_path_is_file mw_dir_9/Bar.mw &&
- wiki_check_content mw_dir_9/Foo.mw Foo &&
- wiki_check_content mw_dir_9/Bar.mw Bar &&
- wiki_check_content mw_dir_9/Nyancat.mw Nyancat
-'
-
-test_expect_success 'Mediawiki-clone of several specific pages on wiki' '
- wiki_reset &&
- wiki_editpage foo "foo 1" false &&
- wiki_editpage bar "bar 1" false &&
- wiki_editpage dummy "dummy 1" false &&
- wiki_editpage cloned_1 "cloned_1 1" false &&
- wiki_editpage cloned_2 "cloned_2 2" false &&
- wiki_editpage cloned_3 "cloned_3 3" false &&
- mkdir -p ref_page_10 &&
- wiki_getpage cloned_1 ref_page_10 &&
- wiki_getpage cloned_2 ref_page_10 &&
- wiki_getpage cloned_3 ref_page_10 &&
- git clone -c remote.origin.pages="cloned_1 cloned_2 cloned_3" \
- mediawiki::'"$WIKI_URL"' mw_dir_10 &&
- test_diff_directories mw_dir_10 ref_page_10
-'
-
-test_expect_success 'Git clone works with the shallow option' '
- wiki_reset &&
- wiki_editpage foo "1st revision, should be cloned" false &&
- wiki_editpage bar "1st revision, should be cloned" false &&
- wiki_editpage nyan "1st revision, should not be cloned" false &&
- wiki_editpage nyan "2nd revision, should be cloned" false &&
- git -c remote.origin.shallow=true clone \
- mediawiki::'"$WIKI_URL"' mw_dir_11 &&
- test_contains_N_files mw_dir_11 4 &&
- test_path_is_file mw_dir_11/Nyan.mw &&
- test_path_is_file mw_dir_11/Foo.mw &&
- test_path_is_file mw_dir_11/Bar.mw &&
- test_path_is_file mw_dir_11/Main_Page.mw &&
- (
- cd mw_dir_11 &&
- test $(git log --oneline Nyan.mw | wc -l) -eq 1 &&
- test $(git log --oneline Foo.mw | wc -l) -eq 1 &&
- test $(git log --oneline Bar.mw | wc -l) -eq 1 &&
- test $(git log --oneline Main_Page.mw | wc -l ) -eq 1
- ) &&
- wiki_check_content mw_dir_11/Nyan.mw Nyan &&
- wiki_check_content mw_dir_11/Foo.mw Foo &&
- wiki_check_content mw_dir_11/Bar.mw Bar &&
- wiki_check_content mw_dir_11/Main_Page.mw Main_Page
-'
-
-test_expect_success 'Git clone works with the shallow option with a delete page' '
- wiki_reset &&
- wiki_editpage foo "1st revision, will be deleted" false &&
- wiki_editpage bar "1st revision, should be cloned" false &&
- wiki_editpage nyan "1st revision, should not be cloned" false &&
- wiki_editpage nyan "2nd revision, should be cloned" false &&
- wiki_delete_page foo &&
- git -c remote.origin.shallow=true clone \
- mediawiki::'"$WIKI_URL"' mw_dir_12 &&
- test_contains_N_files mw_dir_12 3 &&
- test_path_is_file mw_dir_12/Nyan.mw &&
- test_path_is_missing mw_dir_12/Foo.mw &&
- test_path_is_file mw_dir_12/Bar.mw &&
- test_path_is_file mw_dir_12/Main_Page.mw &&
- (
- cd mw_dir_12 &&
- test $(git log --oneline Nyan.mw | wc -l) -eq 1 &&
- test $(git log --oneline Bar.mw | wc -l) -eq 1 &&
- test $(git log --oneline Main_Page.mw | wc -l ) -eq 1
- ) &&
- wiki_check_content mw_dir_12/Nyan.mw Nyan &&
- wiki_check_content mw_dir_12/Bar.mw Bar &&
- wiki_check_content mw_dir_12/Main_Page.mw Main_Page
-'
-
-test_expect_success 'Test of fetching a category' '
- wiki_reset &&
- wiki_editpage Foo "I will be cloned" false -c=Category &&
- wiki_editpage Bar "Meet me on the repository" false -c=Category &&
- wiki_editpage Dummy "I will not come" false &&
- wiki_editpage BarWrong "I will stay online only" false -c=NotCategory &&
- git clone -c remote.origin.categories="Category" \
- mediawiki::'"$WIKI_URL"' mw_dir_13 &&
- wiki_getallpage ref_page_13 Category &&
- test_diff_directories mw_dir_13 ref_page_13
-'
-
-test_expect_success 'Test of resistance to modification of category on wiki for clone' '
- wiki_reset &&
- wiki_editpage Tobedeleted "this page will be deleted" false -c=Catone &&
- wiki_editpage Tobeedited "this page will be modified" false -c=Catone &&
- wiki_editpage Normalone "this page wont be modified and will be on git" false -c=Catone &&
- wiki_editpage Notconsidered "this page will not appear on local" false &&
- wiki_editpage Othercategory "this page will not appear on local" false -c=Cattwo &&
- wiki_editpage Tobeedited "this page have been modified" true -c=Catone &&
- wiki_delete_page Tobedeleted &&
- git clone -c remote.origin.categories="Catone" \
- mediawiki::'"$WIKI_URL"' mw_dir_14 &&
- wiki_getallpage ref_page_14 Catone &&
- test_diff_directories mw_dir_14 ref_page_14
-'
-
-test_done
diff --git a/contrib/mw-to-git/t/t9361-mw-to-git-push-pull.sh b/contrib/mw-to-git/t/t9361-mw-to-git-push-pull.sh
deleted file mode 100755
index 9ea201459b..0000000000
--- a/contrib/mw-to-git/t/t9361-mw-to-git-push-pull.sh
+++ /dev/null
@@ -1,24 +0,0 @@
-#!/bin/sh
-#
-# Copyright (C) 2012
-# Charles Roussel <charles.roussel@ensimag.imag.fr>
-# Simon Cathebras <simon.cathebras@ensimag.imag.fr>
-# Julien Khayat <julien.khayat@ensimag.imag.fr>
-# Guillaume Sasdy <guillaume.sasdy@ensimag.imag.fr>
-# Simon Perrat <simon.perrat@ensimag.imag.fr>
-#
-# License: GPL v2 or later
-
-# tests for git-remote-mediawiki
-
-test_description='Test the Git Mediawiki remote helper: git push and git pull simple test cases'
-
-. ./test-gitmw-lib.sh
-. ./push-pull-tests.sh
-. $TEST_DIRECTORY/test-lib.sh
-
-test_check_precond
-
-test_push_pull
-
-test_done
diff --git a/contrib/mw-to-git/t/t9362-mw-to-git-utf8.sh b/contrib/mw-to-git/t/t9362-mw-to-git-utf8.sh
deleted file mode 100755
index 526d92850f..0000000000
--- a/contrib/mw-to-git/t/t9362-mw-to-git-utf8.sh
+++ /dev/null
@@ -1,347 +0,0 @@
-#!/bin/sh
-#
-# Copyright (C) 2012
-# Charles Roussel <charles.roussel@ensimag.imag.fr>
-# Simon Cathebras <simon.cathebras@ensimag.imag.fr>
-# Julien Khayat <julien.khayat@ensimag.imag.fr>
-# Guillaume Sasdy <guillaume.sasdy@ensimag.imag.fr>
-# Simon Perrat <simon.perrat@ensimag.imag.fr>
-#
-# License: GPL v2 or later
-
-# tests for git-remote-mediawiki
-
-test_description='Test git-mediawiki with special characters in filenames'
-
-. ./test-gitmw-lib.sh
-. $TEST_DIRECTORY/test-lib.sh
-
-
-test_check_precond
-
-
-test_expect_success 'Git clone works for a wiki with accents in the page names' '
- wiki_reset &&
- wiki_editpage féé "This page must be délétéd before clone" false &&
- wiki_editpage kèè "This page must be deleted before clone" false &&
- wiki_editpage hàà "This page must be deleted before clone" false &&
- wiki_editpage kîî "This page must be deleted before clone" false &&
- wiki_editpage foo "This page must be deleted before clone" false &&
- git clone mediawiki::'"$WIKI_URL"' mw_dir_1 &&
- wiki_getallpage ref_page_1 &&
- test_diff_directories mw_dir_1 ref_page_1
-'
-
-
-test_expect_success 'Git pull works with a wiki with accents in the pages names' '
- wiki_reset &&
- wiki_editpage kîî "this page must be cloned" false &&
- wiki_editpage foo "this page must be cloned" false &&
- git clone mediawiki::'"$WIKI_URL"' mw_dir_2 &&
- wiki_editpage éàîôû "This page must be pulled" false &&
- (
- cd mw_dir_2 &&
- git pull
- ) &&
- wiki_getallpage ref_page_2 &&
- test_diff_directories mw_dir_2 ref_page_2
-'
-
-
-test_expect_success 'Cloning a chosen page works with accents' '
- wiki_reset &&
- wiki_editpage kîî "this page must be cloned" false &&
- git clone -c remote.origin.pages=kîî \
- mediawiki::'"$WIKI_URL"' mw_dir_3 &&
- wiki_check_content mw_dir_3/Kîî.mw Kîî &&
- test_path_is_file mw_dir_3/Kîî.mw &&
- rm -rf mw_dir_3
-'
-
-
-test_expect_success 'The shallow option works with accents' '
- wiki_reset &&
- wiki_editpage néoà "1st revision, should not be cloned" false &&
- wiki_editpage néoà "2nd revision, should be cloned" false &&
- git -c remote.origin.shallow=true clone \
- mediawiki::'"$WIKI_URL"' mw_dir_4 &&
- test_contains_N_files mw_dir_4 2 &&
- test_path_is_file mw_dir_4/Néoà.mw &&
- test_path_is_file mw_dir_4/Main_Page.mw &&
- (
- cd mw_dir_4 &&
- test $(git log --oneline Néoà.mw | wc -l) -eq 1 &&
- test $(git log --oneline Main_Page.mw | wc -l ) -eq 1
- ) &&
- wiki_check_content mw_dir_4/Néoà.mw Néoà &&
- wiki_check_content mw_dir_4/Main_Page.mw Main_Page
-'
-
-
-test_expect_success 'Cloning works when page name first letter has an accent' '
- wiki_reset &&
- wiki_editpage îî "this page must be cloned" false &&
- git clone -c remote.origin.pages=îî \
- mediawiki::'"$WIKI_URL"' mw_dir_5 &&
- test_path_is_file mw_dir_5/Îî.mw &&
- wiki_check_content mw_dir_5/Îî.mw Îî
-'
-
-
-test_expect_success 'Git push works with a wiki with accents' '
- wiki_reset &&
- wiki_editpage féé "lots of accents : éèàÖ" false &&
- wiki_editpage foo "this page must be cloned" false &&
- git clone mediawiki::'"$WIKI_URL"' mw_dir_6 &&
- (
- cd mw_dir_6 &&
- echo "A wild Pîkächû appears on the wiki" >Pîkächû.mw &&
- git add Pîkächû.mw &&
- git commit -m "A new page appears" &&
- git push
- ) &&
- wiki_getallpage ref_page_6 &&
- test_diff_directories mw_dir_6 ref_page_6
-'
-
-test_expect_success 'Git clone works with accentsand spaces' '
- wiki_reset &&
- wiki_editpage "é à î" "this page must be délété before the clone" false &&
- git clone mediawiki::'"$WIKI_URL"' mw_dir_7 &&
- wiki_getallpage ref_page_7 &&
- test_diff_directories mw_dir_7 ref_page_7
-'
-
-test_expect_success 'character $ in page name (mw -> git)' '
- wiki_reset &&
- wiki_editpage file_\$_foo "expect to be called file_$_foo" false &&
- git clone mediawiki::'"$WIKI_URL"' mw_dir_8 &&
- test_path_is_file mw_dir_8/File_\$_foo.mw &&
- wiki_getallpage ref_page_8 &&
- test_diff_directories mw_dir_8 ref_page_8
-'
-
-
-
-test_expect_success 'character $ in file name (git -> mw) ' '
- wiki_reset &&
- git clone mediawiki::'"$WIKI_URL"' mw_dir_9 &&
- (
- cd mw_dir_9 &&
- echo "this file is called File_\$_foo.mw" >File_\$_foo.mw &&
- git add . &&
- git commit -am "file File_\$_foo.mw" &&
- git pull &&
- git push
- ) &&
- wiki_getallpage ref_page_9 &&
- test_diff_directories mw_dir_9 ref_page_9
-'
-
-
-test_expect_failure 'capital at the beginning of file names' '
- wiki_reset &&
- git clone mediawiki::'"$WIKI_URL"' mw_dir_10 &&
- (
- cd mw_dir_10 &&
- echo "my new file foo" >foo.mw &&
- echo "my new file Foo... Finger crossed" >Foo.mw &&
- git add . &&
- git commit -am "file foo.mw" &&
- git pull &&
- git push
- ) &&
- wiki_getallpage ref_page_10 &&
- test_diff_directories mw_dir_10 ref_page_10
-'
-
-
-test_expect_failure 'special character at the beginning of file name from mw to git' '
- wiki_reset &&
- git clone mediawiki::'"$WIKI_URL"' mw_dir_11 &&
- wiki_editpage {char_1 "expect to be renamed {char_1" false &&
- wiki_editpage [char_2 "expect to be renamed [char_2" false &&
- (
- cd mw_dir_11 &&
- git pull
- ) &&
- test_path_is_file mw_dir_11/{char_1 &&
- test_path_is_file mw_dir_11/[char_2
-'
-
-test_expect_success 'Pull page with title containing ":" other than namespace separator' '
- wiki_editpage Foo:Bar content false &&
- (
- cd mw_dir_11 &&
- git pull
- ) &&
- test_path_is_file mw_dir_11/Foo:Bar.mw
-'
-
-test_expect_success 'Push page with title containing ":" other than namespace separator' '
- (
- cd mw_dir_11 &&
- echo content >NotANameSpace:Page.mw &&
- git add NotANameSpace:Page.mw &&
- git commit -m "add page with colon" &&
- git push
- ) &&
- wiki_page_exist NotANameSpace:Page
-'
-
-test_expect_success 'test of correct formatting for file name from mw to git' '
- wiki_reset &&
- git clone mediawiki::'"$WIKI_URL"' mw_dir_12 &&
- wiki_editpage char_%_7b_1 "expect to be renamed char{_1" false &&
- wiki_editpage char_%_5b_2 "expect to be renamed char{_2" false &&
- (
- cd mw_dir_12 &&
- git pull
- ) &&
- test_path_is_file mw_dir_12/Char\{_1.mw &&
- test_path_is_file mw_dir_12/Char\[_2.mw &&
- wiki_getallpage ref_page_12 &&
- mv ref_page_12/Char_%_7b_1.mw ref_page_12/Char\{_1.mw &&
- mv ref_page_12/Char_%_5b_2.mw ref_page_12/Char\[_2.mw &&
- test_diff_directories mw_dir_12 ref_page_12
-'
-
-
-test_expect_failure 'test of correct formatting for file name beginning with special character' '
- wiki_reset &&
- git clone mediawiki::'"$WIKI_URL"' mw_dir_13 &&
- (
- cd mw_dir_13 &&
- echo "my new file {char_1" >\{char_1.mw &&
- echo "my new file [char_2" >\[char_2.mw &&
- git add . &&
- git commit -am "committing some exotic file name..." &&
- git push &&
- git pull
- ) &&
- wiki_getallpage ref_page_13 &&
- test_path_is_file ref_page_13/{char_1.mw &&
- test_path_is_file ref_page_13/[char_2.mw &&
- test_diff_directories mw_dir_13 ref_page_13
-'
-
-
-test_expect_success 'test of correct formatting for file name from git to mw' '
- wiki_reset &&
- git clone mediawiki::'"$WIKI_URL"' mw_dir_14 &&
- (
- cd mw_dir_14 &&
- echo "my new file char{_1" >Char\{_1.mw &&
- echo "my new file char[_2" >Char\[_2.mw &&
- git add . &&
- git commit -m "committing some exotic file name..." &&
- git push
- ) &&
- wiki_getallpage ref_page_14 &&
- mv mw_dir_14/Char\{_1.mw mw_dir_14/Char_%_7b_1.mw &&
- mv mw_dir_14/Char\[_2.mw mw_dir_14/Char_%_5b_2.mw &&
- test_diff_directories mw_dir_14 ref_page_14
-'
-
-
-test_expect_success 'git clone with /' '
- wiki_reset &&
- wiki_editpage \/fo\/o "this is not important" false -c=Deleted &&
- git clone mediawiki::'"$WIKI_URL"' mw_dir_15 &&
- test_path_is_file mw_dir_15/%2Ffo%2Fo.mw &&
- wiki_check_content mw_dir_15/%2Ffo%2Fo.mw \/fo\/o
-'
-
-
-test_expect_success 'git push with /' '
- wiki_reset &&
- git clone mediawiki::'"$WIKI_URL"' mw_dir_16 &&
- echo "I will be on the wiki" >mw_dir_16/%2Ffo%2Fo.mw &&
- (
- cd mw_dir_16 &&
- git add %2Ffo%2Fo.mw &&
- git commit -m " %2Ffo%2Fo added" &&
- git push
- ) &&
- wiki_page_exist \/fo\/o &&
- wiki_check_content mw_dir_16/%2Ffo%2Fo.mw \/fo\/o
-
-'
-
-
-test_expect_success 'git clone with \' '
- wiki_reset &&
- wiki_editpage \\ko\\o "this is not important" false -c=Deleted &&
- git clone mediawiki::'"$WIKI_URL"' mw_dir_17 &&
- test_path_is_file mw_dir_17/\\ko\\o.mw &&
- wiki_check_content mw_dir_17/\\ko\\o.mw \\ko\\o
-'
-
-
-test_expect_success 'git push with \' '
- wiki_reset &&
- git clone mediawiki::'"$WIKI_URL"' mw_dir_18 &&
- echo "I will be on the wiki" >mw_dir_18/\\ko\\o.mw &&
- (
- cd mw_dir_18 &&
- git add \\ko\\o.mw &&
- git commit -m " \\ko\\o added" &&
- git push
- ) &&
- wiki_page_exist \\ko\\o &&
- wiki_check_content mw_dir_18/\\ko\\o.mw \\ko\\o
-
-'
-
-test_expect_success 'git clone with \ in format control' '
- wiki_reset &&
- wiki_editpage \\no\\o "this is not important" false &&
- git clone mediawiki::'"$WIKI_URL"' mw_dir_19 &&
- test_path_is_file mw_dir_19/\\no\\o.mw &&
- wiki_check_content mw_dir_19/\\no\\o.mw \\no\\o
-'
-
-
-test_expect_success 'git push with \ in format control' '
- wiki_reset &&
- git clone mediawiki::'"$WIKI_URL"' mw_dir_20 &&
- echo "I will be on the wiki" >mw_dir_20/\\fo\\o.mw &&
- (
- cd mw_dir_20 &&
- git add \\fo\\o.mw &&
- git commit -m " \\fo\\o added" &&
- git push
- ) &&
- wiki_page_exist \\fo\\o &&
- wiki_check_content mw_dir_20/\\fo\\o.mw \\fo\\o
-
-'
-
-
-test_expect_success 'fast-import meta-characters in page name (mw -> git)' '
- wiki_reset &&
- wiki_editpage \"file\"_\\_foo "expect to be called \"file\"_\\_foo" false &&
- git clone mediawiki::'"$WIKI_URL"' mw_dir_21 &&
- test_path_is_file mw_dir_21/\"file\"_\\_foo.mw &&
- wiki_getallpage ref_page_21 &&
- test_diff_directories mw_dir_21 ref_page_21
-'
-
-
-test_expect_success 'fast-import meta-characters in page name (git -> mw) ' '
- wiki_reset &&
- git clone mediawiki::'"$WIKI_URL"' mw_dir_22 &&
- (
- cd mw_dir_22 &&
- echo "this file is called \"file\"_\\_foo.mw" >\"file\"_\\_foo &&
- git add . &&
- git commit -am "file \"file\"_\\_foo" &&
- git pull &&
- git push
- ) &&
- wiki_getallpage ref_page_22 &&
- test_diff_directories mw_dir_22 ref_page_22
-'
-
-
-test_done
diff --git a/contrib/mw-to-git/t/t9363-mw-to-git-export-import.sh b/contrib/mw-to-git/t/t9363-mw-to-git-export-import.sh
deleted file mode 100755
index 7139995a40..0000000000
--- a/contrib/mw-to-git/t/t9363-mw-to-git-export-import.sh
+++ /dev/null
@@ -1,218 +0,0 @@
-#!/bin/sh
-#
-# Copyright (C) 2012
-# Charles Roussel <charles.roussel@ensimag.imag.fr>
-# Simon Cathebras <simon.cathebras@ensimag.imag.fr>
-# Julien Khayat <julien.khayat@ensimag.imag.fr>
-# Guillaume Sasdy <guillaume.sasdy@ensimag.imag.fr>
-# Simon Perrat <simon.perrat@ensimag.imag.fr>
-#
-# License: GPL v2 or later
-
-# tests for git-remote-mediawiki
-
-test_description='Test the Git Mediawiki remote helper: git push and git pull simple test cases'
-
-. ./test-gitmw-lib.sh
-. $TEST_DIRECTORY/test-lib.sh
-
-
-test_check_precond
-
-
-test_git_reimport () {
- git -c remote.origin.dumbPush=true push &&
- git -c remote.origin.mediaImport=true pull --rebase
-}
-
-# Don't bother with permissions, be administrator by default
-test_expect_success 'setup config' '
- git config --global remote.origin.mwLogin "$WIKI_ADMIN" &&
- git config --global remote.origin.mwPassword "$WIKI_PASSW" &&
- test_might_fail git config --global --unset remote.origin.mediaImport
-'
-
-test_expect_failure 'git push can upload media (File:) files' '
- wiki_reset &&
- git clone mediawiki::'"$WIKI_URL"' mw_dir &&
- (
- cd mw_dir &&
- echo "hello world" >Foo.txt &&
- git add Foo.txt &&
- git commit -m "add a text file" &&
- git push &&
- "$PERL_PATH" -e "print STDOUT \"binary content: \".chr(255);" >Foo.txt &&
- git add Foo.txt &&
- git commit -m "add a text file with binary content" &&
- git push
- )
-'
-
-test_expect_failure 'git clone works on previously created wiki with media files' '
- test_when_finished "rm -rf mw_dir mw_dir_clone" &&
- git clone -c remote.origin.mediaimport=true \
- mediawiki::'"$WIKI_URL"' mw_dir_clone &&
- test_cmp mw_dir_clone/Foo.txt mw_dir/Foo.txt &&
- (cd mw_dir_clone && git checkout HEAD^) &&
- (cd mw_dir && git checkout HEAD^) &&
- test_path_is_file mw_dir_clone/Foo.txt &&
- test_cmp mw_dir_clone/Foo.txt mw_dir/Foo.txt
-'
-
-test_expect_success 'git push can upload media (File:) files containing valid UTF-8' '
- wiki_reset &&
- git clone mediawiki::'"$WIKI_URL"' mw_dir &&
- (
- cd mw_dir &&
- "$PERL_PATH" -e "print STDOUT \"UTF-8 content: éèàéê€.\";" >Bar.txt &&
- git add Bar.txt &&
- git commit -m "add a text file with UTF-8 content" &&
- git push
- )
-'
-
-test_expect_success 'git clone works on previously created wiki with media files containing valid UTF-8' '
- test_when_finished "rm -rf mw_dir mw_dir_clone" &&
- git clone -c remote.origin.mediaimport=true \
- mediawiki::'"$WIKI_URL"' mw_dir_clone &&
- test_cmp mw_dir_clone/Bar.txt mw_dir/Bar.txt
-'
-
-test_expect_success 'git push & pull work with locally renamed media files' '
- wiki_reset &&
- git clone mediawiki::'"$WIKI_URL"' mw_dir &&
- test_when_finished "rm -fr mw_dir" &&
- (
- cd mw_dir &&
- echo "A File" >Foo.txt &&
- git add Foo.txt &&
- git commit -m "add a file" &&
- git mv Foo.txt Bar.txt &&
- git commit -m "Rename a file" &&
- test_git_reimport &&
- echo "A File" >expect &&
- test_cmp expect Bar.txt &&
- test_path_is_missing Foo.txt
- )
-'
-
-test_expect_success 'git push can propagate local page deletion' '
- wiki_reset &&
- git clone mediawiki::'"$WIKI_URL"' mw_dir &&
- test_when_finished "rm -fr mw_dir" &&
- (
- cd mw_dir &&
- test_path_is_missing Foo.mw &&
- echo "hello world" >Foo.mw &&
- git add Foo.mw &&
- git commit -m "Add the page Foo" &&
- git push &&
- rm -f Foo.mw &&
- git commit -am "Delete the page Foo" &&
- test_git_reimport &&
- test_path_is_missing Foo.mw
- )
-'
-
-test_expect_success 'git push can propagate local media file deletion' '
- wiki_reset &&
- git clone mediawiki::'"$WIKI_URL"' mw_dir &&
- test_when_finished "rm -fr mw_dir" &&
- (
- cd mw_dir &&
- echo "hello world" >Foo.txt &&
- git add Foo.txt &&
- git commit -m "Add the text file Foo" &&
- git rm Foo.txt &&
- git commit -m "Delete the file Foo" &&
- test_git_reimport &&
- test_path_is_missing Foo.txt
- )
-'
-
-# test failure: the file is correctly uploaded, and then deleted but
-# as no page link to it, the import (which looks at page revisions)
-# doesn't notice the file deletion on the wiki. We fetch the list of
-# files from the wiki, but as the file is deleted, it doesn't appear.
-test_expect_failure 'git pull correctly imports media file deletion when no page link to it' '
- wiki_reset &&
- git clone mediawiki::'"$WIKI_URL"' mw_dir &&
- test_when_finished "rm -fr mw_dir" &&
- (
- cd mw_dir &&
- echo "hello world" >Foo.txt &&
- git add Foo.txt &&
- git commit -m "Add the text file Foo" &&
- git push &&
- git rm Foo.txt &&
- git commit -m "Delete the file Foo" &&
- test_git_reimport &&
- test_path_is_missing Foo.txt
- )
-'
-
-test_expect_success 'git push properly warns about insufficient permissions' '
- wiki_reset &&
- git clone mediawiki::'"$WIKI_URL"' mw_dir &&
- test_when_finished "rm -fr mw_dir" &&
- (
- cd mw_dir &&
- echo "A File" >foo.forbidden &&
- git add foo.forbidden &&
- git commit -m "add a file" &&
- git push 2>actual &&
- test_grep "foo.forbidden is not a permitted file" actual
- )
-'
-
-test_expect_success 'setup a repository with media files' '
- wiki_reset &&
- wiki_editpage testpage "I am linking a file [[File:File.txt]]" false &&
- echo "File content" >File.txt &&
- wiki_upload_file File.txt &&
- echo "Another file content" >AnotherFile.txt &&
- wiki_upload_file AnotherFile.txt
-'
-
-test_expect_success 'git clone works with one specific page cloned and mediaimport=true' '
- git clone -c remote.origin.pages=testpage \
- -c remote.origin.mediaimport=true \
- mediawiki::'"$WIKI_URL"' mw_dir_15 &&
- test_when_finished "rm -rf mw_dir_15" &&
- test_contains_N_files mw_dir_15 3 &&
- test_path_is_file mw_dir_15/Testpage.mw &&
- test_path_is_file mw_dir_15/File:File.txt.mw &&
- test_path_is_file mw_dir_15/File.txt &&
- test_path_is_missing mw_dir_15/Main_Page.mw &&
- test_path_is_missing mw_dir_15/File:AnotherFile.txt.mw &&
- test_path_is_missing mw_dir_15/AnothetFile.txt &&
- wiki_check_content mw_dir_15/Testpage.mw Testpage &&
- test_cmp mw_dir_15/File.txt File.txt
-'
-
-test_expect_success 'git clone works with one specific page cloned and mediaimport=false' '
- test_when_finished "rm -rf mw_dir_16" &&
- git clone -c remote.origin.pages=testpage \
- mediawiki::'"$WIKI_URL"' mw_dir_16 &&
- test_contains_N_files mw_dir_16 1 &&
- test_path_is_file mw_dir_16/Testpage.mw &&
- test_path_is_missing mw_dir_16/File:File.txt.mw &&
- test_path_is_missing mw_dir_16/File.txt &&
- test_path_is_missing mw_dir_16/Main_Page.mw &&
- wiki_check_content mw_dir_16/Testpage.mw Testpage
-'
-
-# should behave like mediaimport=false
-test_expect_success 'git clone works with one specific page cloned and mediaimport unset' '
- test_when_finished "rm -fr mw_dir_17" &&
- git clone -c remote.origin.pages=testpage \
- mediawiki::'"$WIKI_URL"' mw_dir_17 &&
- test_contains_N_files mw_dir_17 1 &&
- test_path_is_file mw_dir_17/Testpage.mw &&
- test_path_is_missing mw_dir_17/File:File.txt.mw &&
- test_path_is_missing mw_dir_17/File.txt &&
- test_path_is_missing mw_dir_17/Main_Page.mw &&
- wiki_check_content mw_dir_17/Testpage.mw Testpage
-'
-
-test_done
diff --git a/contrib/mw-to-git/t/t9364-pull-by-rev.sh b/contrib/mw-to-git/t/t9364-pull-by-rev.sh
deleted file mode 100755
index 5c22457a0b..0000000000
--- a/contrib/mw-to-git/t/t9364-pull-by-rev.sh
+++ /dev/null
@@ -1,17 +0,0 @@
-#!/bin/sh
-
-test_description='Test the Git Mediawiki remote helper: git pull by revision'
-
-. ./test-gitmw-lib.sh
-. ./push-pull-tests.sh
-. $TEST_DIRECTORY/test-lib.sh
-
-test_check_precond
-
-test_expect_success 'configuration' '
- git config --global mediawiki.fetchStrategy by_rev
-'
-
-test_push_pull
-
-test_done
diff --git a/contrib/mw-to-git/t/t9365-continuing-queries.sh b/contrib/mw-to-git/t/t9365-continuing-queries.sh
deleted file mode 100755
index d3e7312659..0000000000
--- a/contrib/mw-to-git/t/t9365-continuing-queries.sh
+++ /dev/null
@@ -1,23 +0,0 @@
-#!/bin/sh
-
-test_description='Test the Git Mediawiki remote helper: queries w/ more than 500 results'
-
-. ./test-gitmw-lib.sh
-. $TEST_DIRECTORY/test-lib.sh
-
-test_check_precond
-
-test_expect_success 'creating page w/ >500 revisions' '
- wiki_reset &&
- for i in $(test_seq 501)
- do
- echo "creating revision $i" &&
- wiki_editpage foo "revision $i<br/>" true || return 1
- done
-'
-
-test_expect_success 'cloning page w/ >500 revisions' '
- git clone mediawiki::'"$WIKI_URL"' mw_dir
-'
-
-test_done
diff --git a/contrib/mw-to-git/t/test-gitmw-lib.sh b/contrib/mw-to-git/t/test-gitmw-lib.sh
deleted file mode 100755
index 64e46c1671..0000000000
--- a/contrib/mw-to-git/t/test-gitmw-lib.sh
+++ /dev/null
@@ -1,432 +0,0 @@
-# Copyright (C) 2012
-# Charles Roussel <charles.roussel@ensimag.imag.fr>
-# Simon Cathebras <simon.cathebras@ensimag.imag.fr>
-# Julien Khayat <julien.khayat@ensimag.imag.fr>
-# Guillaume Sasdy <guillaume.sasdy@ensimag.imag.fr>
-# Simon Perrat <simon.perrat@ensimag.imag.fr>
-# License: GPL v2 or later
-
-#
-# CONFIGURATION VARIABLES
-# You might want to change these ones
-#
-
-. ./test.config
-
-WIKI_BASE_URL=http://$SERVER_ADDR:$PORT
-WIKI_URL=$WIKI_BASE_URL/$WIKI_DIR_NAME
-CURR_DIR=$(pwd)
-TEST_OUTPUT_DIRECTORY=$(pwd)
-TEST_DIRECTORY="$CURR_DIR"/../../../t
-
-export TEST_OUTPUT_DIRECTORY TEST_DIRECTORY CURR_DIR
-
-if test "$LIGHTTPD" = "false" ; then
- PORT=80
-else
- WIKI_DIR_INST="$CURR_DIR/$WEB_WWW"
-fi
-
-wiki_upload_file () {
- "$CURR_DIR"/test-gitmw.pl upload_file "$@"
-}
-
-wiki_getpage () {
- "$CURR_DIR"/test-gitmw.pl get_page "$@"
-}
-
-wiki_delete_page () {
- "$CURR_DIR"/test-gitmw.pl delete_page "$@"
-}
-
-wiki_editpage () {
- "$CURR_DIR"/test-gitmw.pl edit_page "$@"
-}
-
-die () {
- die_with_status 1 "$@"
-}
-
-die_with_status () {
- status=$1
- shift
- echo >&2 "$*"
- exit "$status"
-}
-
-
-# Check the preconditions to run git-remote-mediawiki's tests
-test_check_precond () {
- if ! test_have_prereq PERL
- then
- skip_all='skipping gateway git-mw tests, perl not available'
- test_done
- fi
-
- GIT_EXEC_PATH=$(cd "$(dirname "$0")" && cd "../.." && pwd)
- PATH="$GIT_EXEC_PATH"'/bin-wrapper:'"$PATH"
-
- if ! test -d "$WIKI_DIR_INST/$WIKI_DIR_NAME"
- then
- skip_all='skipping gateway git-mw tests, no mediawiki found'
- test_done
- fi
-}
-
-# test_diff_directories <dir_git> <dir_wiki>
-#
-# Compare the contents of directories <dir_git> and <dir_wiki> with diff
-# and errors if they do not match. The program will
-# not look into .git in the process.
-# Warning: the first argument MUST be the directory containing the git data
-test_diff_directories () {
- rm -rf "$1_tmp"
- mkdir -p "$1_tmp"
- cp "$1"/*.mw "$1_tmp"
- diff -r -b "$1_tmp" "$2"
-}
-
-# $1=<dir>
-# $2=<N>
-#
-# Check that <dir> contains exactly <N> files
-test_contains_N_files () {
- if test $(ls -- "$1" | wc -l) -ne "$2"; then
- echo "directory $1 should contain $2 files"
- echo "it contains these files:"
- ls "$1"
- false
- fi
-}
-
-
-# wiki_check_content <file_name> <page_name>
-#
-# Compares the contents of the file <file_name> and the wiki page
-# <page_name> and exits with error 1 if they do not match.
-wiki_check_content () {
- mkdir -p wiki_tmp
- wiki_getpage "$2" wiki_tmp
- # replacement of forbidden character in file name
- page_name=$(printf "%s\n" "$2" | sed -e "s/\//%2F/g")
-
- diff -b "$1" wiki_tmp/"$page_name".mw
- if test $? -ne 0
- then
- rm -rf wiki_tmp
- error "ERROR: file $2 not found on wiki"
- fi
- rm -rf wiki_tmp
-}
-
-# wiki_page_exist <page_name>
-#
-# Check the existence of the page <page_name> on the wiki and exits
-# with error if it is absent from it.
-wiki_page_exist () {
- mkdir -p wiki_tmp
- wiki_getpage "$1" wiki_tmp
- page_name=$(printf "%s\n" "$1" | sed "s/\//%2F/g")
- if test -f wiki_tmp/"$page_name".mw ; then
- rm -rf wiki_tmp
- else
- rm -rf wiki_tmp
- error "test failed: file $1 not found on wiki"
- fi
-}
-
-# wiki_getallpagename
-#
-# Fetch the name of each page on the wiki.
-wiki_getallpagename () {
- "$CURR_DIR"/test-gitmw.pl getallpagename
-}
-
-# wiki_getallpagecategory <category>
-#
-# Fetch the name of each page belonging to <category> on the wiki.
-wiki_getallpagecategory () {
- "$CURR_DIR"/test-gitmw.pl getallpagename "$@"
-}
-
-# wiki_getallpage <dest_dir> [<category>]
-#
-# Fetch all the pages from the wiki and place them in the directory
-# <dest_dir>.
-# If <category> is define, then wiki_getallpage fetch the pages included
-# in <category>.
-wiki_getallpage () {
- if test -z "$2";
- then
- wiki_getallpagename
- else
- wiki_getallpagecategory "$2"
- fi
- mkdir -p "$1"
- while read -r line; do
- wiki_getpage "$line" $1;
- done < all.txt
-}
-
-# ================= Install part =================
-
-error () {
- echo "$@" >&2
- exit 1
-}
-
-# config_lighttpd
-#
-# Create the configuration files and the folders necessary to start lighttpd.
-# Overwrite any existing file.
-config_lighttpd () {
- mkdir -p $WEB
- mkdir -p $WEB_TMP
- mkdir -p $WEB_WWW
- cat > $WEB/lighttpd.conf <<EOF
- server.document-root = "$CURR_DIR/$WEB_WWW"
- server.port = $PORT
- server.pid-file = "$CURR_DIR/$WEB_TMP/pid"
-
- server.modules = (
- "mod_rewrite",
- "mod_redirect",
- "mod_access",
- "mod_accesslog",
- "mod_fastcgi"
- )
-
- index-file.names = ("index.php" , "index.html")
-
- mimetype.assign = (
- ".pdf" => "application/pdf",
- ".sig" => "application/pgp-signature",
- ".spl" => "application/futuresplash",
- ".class" => "application/octet-stream",
- ".ps" => "application/postscript",
- ".torrent" => "application/x-bittorrent",
- ".dvi" => "application/x-dvi",
- ".gz" => "application/x-gzip",
- ".pac" => "application/x-ns-proxy-autoconfig",
- ".swf" => "application/x-shockwave-flash",
- ".tar.gz" => "application/x-tgz",
- ".tgz" => "application/x-tgz",
- ".tar" => "application/x-tar",
- ".zip" => "application/zip",
- ".mp3" => "audio/mpeg",
- ".m3u" => "audio/x-mpegurl",
- ".wma" => "audio/x-ms-wma",
- ".wax" => "audio/x-ms-wax",
- ".ogg" => "application/ogg",
- ".wav" => "audio/x-wav",
- ".gif" => "image/gif",
- ".jpg" => "image/jpeg",
- ".jpeg" => "image/jpeg",
- ".png" => "image/png",
- ".xbm" => "image/x-xbitmap",
- ".xpm" => "image/x-xpixmap",
- ".xwd" => "image/x-xwindowdump",
- ".css" => "text/css",
- ".html" => "text/html",
- ".htm" => "text/html",
- ".js" => "text/javascript",
- ".asc" => "text/plain",
- ".c" => "text/plain",
- ".cpp" => "text/plain",
- ".log" => "text/plain",
- ".conf" => "text/plain",
- ".text" => "text/plain",
- ".txt" => "text/plain",
- ".dtd" => "text/xml",
- ".xml" => "text/xml",
- ".mpeg" => "video/mpeg",
- ".mpg" => "video/mpeg",
- ".mov" => "video/quicktime",
- ".qt" => "video/quicktime",
- ".avi" => "video/x-msvideo",
- ".asf" => "video/x-ms-asf",
- ".asx" => "video/x-ms-asf",
- ".wmv" => "video/x-ms-wmv",
- ".bz2" => "application/x-bzip",
- ".tbz" => "application/x-bzip-compressed-tar",
- ".tar.bz2" => "application/x-bzip-compressed-tar",
- "" => "text/plain"
- )
-
- fastcgi.server = ( ".php" =>
- ("localhost" =>
- ( "socket" => "$CURR_DIR/$WEB_TMP/php.socket",
- "bin-path" => "$PHP_DIR/php-cgi -c $CURR_DIR/$WEB/php.ini"
-
- )
- )
- )
-EOF
-
- cat > $WEB/php.ini <<EOF
- session.save_path ='$CURR_DIR/$WEB_TMP'
-EOF
-}
-
-# start_lighttpd
-#
-# Start or restart daemon lighttpd. If restart, rewrite configuration files.
-start_lighttpd () {
- if test -f "$WEB_TMP/pid"; then
- echo "Instance already running. Restarting..."
- stop_lighttpd
- fi
- config_lighttpd
- "$LIGHTTPD_DIR"/lighttpd -f "$WEB"/lighttpd.conf
-
- if test $? -ne 0 ; then
- echo "Could not execute http daemon lighttpd"
- exit 1
- fi
-}
-
-# stop_lighttpd
-#
-# Kill daemon lighttpd and removes files and folders associated.
-stop_lighttpd () {
- test -f "$WEB_TMP/pid" && kill $(cat "$WEB_TMP/pid")
-}
-
-wiki_delete_db () {
- rm -rf \
- "$FILES_FOLDER_DB"/* || error "Couldn't delete $FILES_FOLDER_DB/"
-}
-
-wiki_delete_db_backup () {
- rm -rf \
- "$FILES_FOLDER_POST_INSTALL_DB"/* || error "Couldn't delete $FILES_FOLDER_POST_INSTALL_DB/"
-}
-
-# Install MediaWiki using its install.php script. If the database file
-# already exists, it will be deleted.
-install_mediawiki () {
-
- localsettings="$WIKI_DIR_INST/$WIKI_DIR_NAME/LocalSettings.php"
- if test -f "$localsettings"
- then
- error "We already installed the wiki, since $localsettings exists" \
- "perhaps you wanted to run 'delete' first?"
- fi
-
- wiki_delete_db
- wiki_delete_db_backup
- mkdir \
- "$FILES_FOLDER_DB/" \
- "$FILES_FOLDER_POST_INSTALL_DB/"
-
- install_script="$WIKI_DIR_INST/$WIKI_DIR_NAME/maintenance/install.php"
- echo "Installing MediaWiki using $install_script. This may take some time ..."
-
- php "$WIKI_DIR_INST/$WIKI_DIR_NAME/maintenance/install.php" \
- --server $WIKI_BASE_URL \
- --scriptpath /wiki \
- --lang en \
- --dbtype sqlite \
- --dbpath $PWD/$FILES_FOLDER_DB/ \
- --pass "$WIKI_PASSW" \
- Git-MediaWiki-Test \
- "$WIKI_ADMIN" ||
- error "Couldn't run $install_script, see errors above. Try to run ./install-wiki.sh delete first."
- cat <<-'EOF' >>$localsettings
-# Custom settings added by test-gitmw-lib.sh
-#
-# Uploading text files is needed for
-# t9363-mw-to-git-export-import.sh
-$wgEnableUploads = true;
-$wgFileExtensions[] = 'txt';
-EOF
-
- # Copy the initially generated database file into our backup
- # folder
- cp -R "$FILES_FOLDER_DB/"* "$FILES_FOLDER_POST_INSTALL_DB/" ||
- error "Unable to copy $FILES_FOLDER_DB/* to $FILES_FOLDER_POST_INSTALL_DB/*"
-}
-
-# Install a wiki in your web server directory.
-wiki_install () {
- if test $LIGHTTPD = "true" ; then
- start_lighttpd
- fi
-
- # In this part, we change directory to $TMP in order to download,
- # unpack and copy the files of MediaWiki
- (
- mkdir -p "$WIKI_DIR_INST/$WIKI_DIR_NAME"
- if ! test -d "$WIKI_DIR_INST/$WIKI_DIR_NAME"
- then
- error "Folder $WIKI_DIR_INST/$WIKI_DIR_NAME doesn't exist.
- Please create it and launch the script again."
- fi
-
- # Fetch MediaWiki's archive if not already present in the
- # download directory
- mkdir -p "$FILES_FOLDER_DOWNLOAD"
- MW_FILENAME="mediawiki-$MW_VERSION_MAJOR.$MW_VERSION_MINOR.tar.gz"
- cd "$FILES_FOLDER_DOWNLOAD"
- if ! test -f $MW_FILENAME
- then
- echo "Downloading $MW_VERSION_MAJOR.$MW_VERSION_MINOR sources ..."
- wget "http://download.wikimedia.org/mediawiki/$MW_VERSION_MAJOR/$MW_FILENAME" ||
- error "Unable to download "\
- "http://download.wikimedia.org/mediawiki/$MW_VERSION_MAJOR/"\
- "$MW_FILENAME. "\
- "Please fix your connection and launch the script again."
- echo "$MW_FILENAME downloaded in $(pwd)/;" \
- "you can delete it later if you want."
- else
- echo "Reusing existing $MW_FILENAME downloaded in $(pwd)/"
- fi
- archive_abs_path=$(pwd)/$MW_FILENAME
- cd "$WIKI_DIR_INST/$WIKI_DIR_NAME/" ||
- error "can't cd to $WIKI_DIR_INST/$WIKI_DIR_NAME/"
- tar xzf "$archive_abs_path" --strip-components=1 ||
- error "Unable to extract WikiMedia's files from $archive_abs_path to "\
- "$WIKI_DIR_INST/$WIKI_DIR_NAME"
- ) || exit 1
- echo Extracted in "$WIKI_DIR_INST/$WIKI_DIR_NAME"
-
- install_mediawiki
-
- echo "Your wiki has been installed. You can check it at
- $WIKI_URL"
-}
-
-# Reset the database of the wiki and the password of the admin
-#
-# Warning: This function must be called only in a subdirectory of t/ directory
-wiki_reset () {
- # Copy initial database of the wiki
- if ! test -d "../$FILES_FOLDER_DB"
- then
- error "No wiki database at ../$FILES_FOLDER_DB, not installed yet?"
- fi
- if ! test -d "../$FILES_FOLDER_POST_INSTALL_DB"
- then
- error "No wiki backup database at ../$FILES_FOLDER_POST_INSTALL_DB, failed installation?"
- fi
- wiki_delete_db
- cp -R "../$FILES_FOLDER_POST_INSTALL_DB/"* "../$FILES_FOLDER_DB/" ||
- error "Can't copy ../$FILES_FOLDER_POST_INSTALL_DB/* to ../$FILES_FOLDER_DB/*"
- echo "File $FILES_FOLDER_DB/* has been reset"
-}
-
-# Delete the wiki created in the web server's directory and all its content
-# saved in the database.
-wiki_delete () {
- if test $LIGHTTPD = "true"; then
- stop_lighttpd
- rm -fr "$WEB"
- else
- # Delete the wiki's directory.
- rm -rf "$WIKI_DIR_INST/$WIKI_DIR_NAME" ||
- error "Wiki's directory $WIKI_DIR_INST/" \
- "$WIKI_DIR_NAME could not be deleted"
- fi
- wiki_delete_db
- wiki_delete_db_backup
-}
diff --git a/contrib/mw-to-git/t/test-gitmw.pl b/contrib/mw-to-git/t/test-gitmw.pl
deleted file mode 100755
index c5d687f078..0000000000
--- a/contrib/mw-to-git/t/test-gitmw.pl
+++ /dev/null
@@ -1,223 +0,0 @@
-#!/usr/bin/perl -w -s
-# Copyright (C) 2012
-# Charles Roussel <charles.roussel@ensimag.imag.fr>
-# Simon Cathebras <simon.cathebras@ensimag.imag.fr>
-# Julien Khayat <julien.khayat@ensimag.imag.fr>
-# Guillaume Sasdy <guillaume.sasdy@ensimag.imag.fr>
-# Simon Perrat <simon.perrat@ensimag.imag.fr>
-# License: GPL v2 or later
-
-# Usage:
-# ./test-gitmw.pl <command> [argument]*
-# Execute in terminal using the name of the function to call as first
-# parameter, and the function's arguments as following parameters
-#
-# Example:
-# ./test-gitmw.pl "get_page" foo .
-# will call <wiki_getpage> with arguments <foo> and <.>
-#
-# Available functions are:
-# "get_page"
-# "delete_page"
-# "edit_page"
-# "getallpagename"
-
-use MediaWiki::API;
-use Getopt::Long;
-use DateTime::Format::ISO8601;
-use constant SLASH_REPLACEMENT => "%2F";
-
-#Parsing of the config file
-
-my $configfile = "$ENV{'CURR_DIR'}/test.config";
-my %config;
-open my $CONFIG, "<", $configfile or die "can't open $configfile: $!";
-while (<$CONFIG>)
-{
- chomp;
- s/#.*//;
- s/^\s+//;
- s/\s+$//;
- next unless length;
- my ($key, $value) = split (/\s*=\s*/,$_, 2);
- $config{$key} = $value;
- last if ($key eq 'LIGHTTPD' and $value eq 'false');
- last if ($key eq 'PORT');
-}
-close $CONFIG or die "can't close $configfile: $!";
-
-my $wiki_address = "http://$config{'SERVER_ADDR'}".":"."$config{'PORT'}";
-my $wiki_url = "$wiki_address/$config{'WIKI_DIR_NAME'}/api.php";
-my $wiki_admin = "$config{'WIKI_ADMIN'}";
-my $wiki_admin_pass = "$config{'WIKI_PASSW'}";
-my $mw = MediaWiki::API->new;
-$mw->{config}->{api_url} = $wiki_url;
-
-
-# wiki_login <name> <password>
-#
-# Logs the user with <name> and <password> in the global variable
-# of the mediawiki $mw
-sub wiki_login {
- $mw->login( { lgname => "$_[0]",lgpassword => "$_[1]" } )
- || die "getpage: login failed";
-}
-
-# wiki_getpage <wiki_page> <dest_path>
-#
-# fetch a page <wiki_page> from the wiki referenced in the global variable
-# $mw and copies its content in directory dest_path
-sub wiki_getpage {
- my $pagename = $_[0];
- my $destdir = $_[1];
-
- my $page = $mw->get_page( { title => $pagename } );
- if (!defined($page)) {
- die "getpage: wiki does not exist";
- }
-
- my $content = $page->{'*'};
- if (!defined($content)) {
- die "getpage: page does not exist";
- }
-
- $pagename=$page->{'title'};
- # Replace spaces by underscore in the page name
- $pagename =~ s/ /_/g;
- $pagename =~ s/\//%2F/g;
- open(my $file, ">:encoding(UTF-8)", "$destdir/$pagename.mw");
- print $file "$content";
- close ($file);
-
-}
-
-# wiki_delete_page <page_name>
-#
-# delete the page with name <page_name> from the wiki referenced
-# in the global variable $mw
-sub wiki_delete_page {
- my $pagename = $_[0];
-
- my $exist=$mw->get_page({title => $pagename});
-
- if (defined($exist->{'*'})){
- $mw->edit({ action => 'delete',
- title => $pagename})
- || die $mw->{error}->{code} . ": " . $mw->{error}->{details};
- } else {
- die "no page with such name found: $pagename\n";
- }
-}
-
-# wiki_editpage <wiki_page> <wiki_content> <wiki_append> [-c=<category>] [-s=<summary>]
-#
-# Edit a page named <wiki_page> with content <wiki_content> on the wiki
-# referenced with the global variable $mw
-# If <wiki_append> == true : append <wiki_content> at the end of the actual
-# content of the page <wiki_page>
-# If <wik_page> doesn't exist, that page is created with the <wiki_content>
-sub wiki_editpage {
- my $wiki_page = $_[0];
- my $wiki_content = $_[1];
- my $wiki_append = $_[2];
- my $summary = "";
- my ($summ, $cat) = ();
- GetOptions('s=s' => \$summ, 'c=s' => \$cat);
-
- my $append = 0;
- if (defined($wiki_append) && $wiki_append eq 'true') {
- $append=1;
- }
-
- my $previous_text ="";
-
- if ($append) {
- my $ref = $mw->get_page( { title => $wiki_page } );
- $previous_text = $ref->{'*'};
- }
-
- my $text = $wiki_content;
- if (defined($previous_text)) {
- $text="$previous_text$text";
- }
-
- # Eventually, add this page to a category.
- if (defined($cat)) {
- my $category_name="[[Category:$cat]]";
- $text="$text\n $category_name";
- }
- if(defined($summ)){
- $summary=$summ;
- }
-
- $mw->edit( { action => 'edit', title => $wiki_page, summary => $summary, text => "$text"} );
-}
-
-# wiki_getallpagename [<category>]
-#
-# Fetch all pages of the wiki referenced by the global variable $mw
-# and print the names of each one in the file all.txt with a new line
-# ("\n") between these.
-# If the argument <category> is defined, then this function get only the pages
-# belonging to <category>.
-sub wiki_getallpagename {
- # fetch the pages of the wiki
- if (defined($_[0])) {
- my $mw_pages = $mw->list ( { action => 'query',
- list => 'categorymembers',
- cmtitle => "Category:$_[0]",
- cmnamespace => 0,
- cmlimit => 500 },
- )
- || die $mw->{error}->{code}.": ".$mw->{error}->{details};
- open(my $file, ">:encoding(UTF-8)", "all.txt");
- foreach my $page (@{$mw_pages}) {
- print $file "$page->{title}\n";
- }
- close ($file);
-
- } else {
- my $mw_pages = $mw->list({
- action => 'query',
- list => 'allpages',
- aplimit => 500,
- })
- || die $mw->{error}->{code}.": ".$mw->{error}->{details};
- open(my $file, ">:encoding(UTF-8)", "all.txt");
- foreach my $page (@{$mw_pages}) {
- print $file "$page->{title}\n";
- }
- close ($file);
- }
-}
-
-sub wiki_upload_file {
- my $file_name = $_[0];
- my $resultat = $mw->edit ( {
- action => 'upload',
- filename => $file_name,
- comment => 'upload a file',
- file => [ $file_name ],
- ignorewarnings=>1,
- }, {
- skip_encoding => 1
- } ) || die $mw->{error}->{code} . ' : ' . $mw->{error}->{details};
-}
-
-
-
-# Main part of this script: parse the command line arguments
-# and select which function to execute
-my $fct_to_call = shift;
-
-wiki_login($wiki_admin, $wiki_admin_pass);
-
-my %functions_to_call = (
- upload_file => \&wiki_upload_file,
- get_page => \&wiki_getpage,
- delete_page => \&wiki_delete_page,
- edit_page => \&wiki_editpage,
- getallpagename => \&wiki_getallpagename,
-);
-die "$0 ERROR: wrong argument" unless exists $functions_to_call{$fct_to_call};
-$functions_to_call{$fct_to_call}->(map { utf8::decode($_); $_ } @ARGV);
diff --git a/contrib/mw-to-git/t/test.config b/contrib/mw-to-git/t/test.config
deleted file mode 100644
index ed10b3e4a4..0000000000
--- a/contrib/mw-to-git/t/test.config
+++ /dev/null
@@ -1,40 +0,0 @@
-# Name of the web server's directory dedicated to the wiki is WIKI_DIR_NAME
-WIKI_DIR_NAME=wiki
-
-# Login and password of the wiki's admin
-WIKI_ADMIN=WikiAdmin
-WIKI_PASSW=AdminPass1
-
-# Address of the web server
-SERVER_ADDR=localhost
-
-# If LIGHTTPD is not set to true, the script will use the default
-# web server running in WIKI_DIR_INST.
-WIKI_DIR_INST=/var/www
-
-# If LIGHTTPD is set to true, the script will use Lighttpd to run
-# the wiki.
-LIGHTTPD=true
-
-# The variables below are useful only if LIGHTTPD is set to true.
-PORT=1234
-PHP_DIR=/usr/bin
-LIGHTTPD_DIR=/usr/sbin
-WEB=WEB
-WEB_TMP=$WEB/tmp
-WEB_WWW=$WEB/www
-
-# Where our configuration for the wiki is located
-FILES_FOLDER=mediawiki
-FILES_FOLDER_DOWNLOAD=$FILES_FOLDER/download
-FILES_FOLDER_DB=$FILES_FOLDER/db
-FILES_FOLDER_POST_INSTALL_DB=$FILES_FOLDER/post-install-db
-
-# The variables below are used by the script to install a wiki.
-# You should not modify these unless you are modifying the script itself.
-# tested versions: 1.19.X -> 1.21.1 -> 1.34.2
-#
-# See https://www.mediawiki.org/wiki/Download for what the latest
-# version is.
-MW_VERSION_MAJOR=1.34
-MW_VERSION_MINOR=2
diff --git a/contrib/persistent-https/LICENSE b/contrib/persistent-https/LICENSE
deleted file mode 100644
index d645695673..0000000000
--- a/contrib/persistent-https/LICENSE
+++ /dev/null
@@ -1,202 +0,0 @@
-
- Apache License
- Version 2.0, January 2004
- http://www.apache.org/licenses/
-
- TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
-
- 1. Definitions.
-
- "License" shall mean the terms and conditions for use, reproduction,
- and distribution as defined by Sections 1 through 9 of this document.
-
- "Licensor" shall mean the copyright owner or entity authorized by
- the copyright owner that is granting the License.
-
- "Legal Entity" shall mean the union of the acting entity and all
- other entities that control, are controlled by, or are under common
- control with that entity. For the purposes of this definition,
- "control" means (i) the power, direct or indirect, to cause the
- direction or management of such entity, whether by contract or
- otherwise, or (ii) ownership of fifty percent (50%) or more of the
- outstanding shares, or (iii) beneficial ownership of such entity.
-
- "You" (or "Your") shall mean an individual or Legal Entity
- exercising permissions granted by this License.
-
- "Source" form shall mean the preferred form for making modifications,
- including but not limited to software source code, documentation
- source, and configuration files.
-
- "Object" form shall mean any form resulting from mechanical
- transformation or translation of a Source form, including but
- not limited to compiled object code, generated documentation,
- and conversions to other media types.
-
- "Work" shall mean the work of authorship, whether in Source or
- Object form, made available under the License, as indicated by a
- copyright notice that is included in or attached to the work
- (an example is provided in the Appendix below).
-
- "Derivative Works" shall mean any work, whether in Source or Object
- form, that is based on (or derived from) the Work and for which the
- editorial revisions, annotations, elaborations, or other modifications
- represent, as a whole, an original work of authorship. For the purposes
- of this License, Derivative Works shall not include works that remain
- separable from, or merely link (or bind by name) to the interfaces of,
- the Work and Derivative Works thereof.
-
- "Contribution" shall mean any work of authorship, including
- the original version of the Work and any modifications or additions
- to that Work or Derivative Works thereof, that is intentionally
- submitted to Licensor for inclusion in the Work by the copyright owner
- or by an individual or Legal Entity authorized to submit on behalf of
- the copyright owner. For the purposes of this definition, "submitted"
- means any form of electronic, verbal, or written communication sent
- to the Licensor or its representatives, including but not limited to
- communication on electronic mailing lists, source code control systems,
- and issue tracking systems that are managed by, or on behalf of, the
- Licensor for the purpose of discussing and improving the Work, but
- excluding communication that is conspicuously marked or otherwise
- designated in writing by the copyright owner as "Not a Contribution."
-
- "Contributor" shall mean Licensor and any individual or Legal Entity
- on behalf of whom a Contribution has been received by Licensor and
- subsequently incorporated within the Work.
-
- 2. Grant of Copyright License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- copyright license to reproduce, prepare Derivative Works of,
- publicly display, publicly perform, sublicense, and distribute the
- Work and such Derivative Works in Source or Object form.
-
- 3. Grant of Patent License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- (except as stated in this section) patent license to make, have made,
- use, offer to sell, sell, import, and otherwise transfer the Work,
- where such license applies only to those patent claims licensable
- by such Contributor that are necessarily infringed by their
- Contribution(s) alone or by combination of their Contribution(s)
- with the Work to which such Contribution(s) was submitted. If You
- institute patent litigation against any entity (including a
- cross-claim or counterclaim in a lawsuit) alleging that the Work
- or a Contribution incorporated within the Work constitutes direct
- or contributory patent infringement, then any patent licenses
- granted to You under this License for that Work shall terminate
- as of the date such litigation is filed.
-
- 4. Redistribution. You may reproduce and distribute copies of the
- Work or Derivative Works thereof in any medium, with or without
- modifications, and in Source or Object form, provided that You
- meet the following conditions:
-
- (a) You must give any other recipients of the Work or
- Derivative Works a copy of this License; and
-
- (b) You must cause any modified files to carry prominent notices
- stating that You changed the files; and
-
- (c) You must retain, in the Source form of any Derivative Works
- that You distribute, all copyright, patent, trademark, and
- attribution notices from the Source form of the Work,
- excluding those notices that do not pertain to any part of
- the Derivative Works; and
-
- (d) If the Work includes a "NOTICE" text file as part of its
- distribution, then any Derivative Works that You distribute must
- include a readable copy of the attribution notices contained
- within such NOTICE file, excluding those notices that do not
- pertain to any part of the Derivative Works, in at least one
- of the following places: within a NOTICE text file distributed
- as part of the Derivative Works; within the Source form or
- documentation, if provided along with the Derivative Works; or,
- within a display generated by the Derivative Works, if and
- wherever such third-party notices normally appear. The contents
- of the NOTICE file are for informational purposes only and
- do not modify the License. You may add Your own attribution
- notices within Derivative Works that You distribute, alongside
- or as an addendum to the NOTICE text from the Work, provided
- that such additional attribution notices cannot be construed
- as modifying the License.
-
- You may add Your own copyright statement to Your modifications and
- may provide additional or different license terms and conditions
- for use, reproduction, or distribution of Your modifications, or
- for any such Derivative Works as a whole, provided Your use,
- reproduction, and distribution of the Work otherwise complies with
- the conditions stated in this License.
-
- 5. Submission of Contributions. Unless You explicitly state otherwise,
- any Contribution intentionally submitted for inclusion in the Work
- by You to the Licensor shall be under the terms and conditions of
- this License, without any additional terms or conditions.
- Notwithstanding the above, nothing herein shall supersede or modify
- the terms of any separate license agreement you may have executed
- with Licensor regarding such Contributions.
-
- 6. Trademarks. This License does not grant permission to use the trade
- names, trademarks, service marks, or product names of the Licensor,
- except as required for reasonable and customary use in describing the
- origin of the Work and reproducing the content of the NOTICE file.
-
- 7. Disclaimer of Warranty. Unless required by applicable law or
- agreed to in writing, Licensor provides the Work (and each
- Contributor provides its Contributions) on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- implied, including, without limitation, any warranties or conditions
- of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
- PARTICULAR PURPOSE. You are solely responsible for determining the
- appropriateness of using or redistributing the Work and assume any
- risks associated with Your exercise of permissions under this License.
-
- 8. Limitation of Liability. In no event and under no legal theory,
- whether in tort (including negligence), contract, or otherwise,
- unless required by applicable law (such as deliberate and grossly
- negligent acts) or agreed to in writing, shall any Contributor be
- liable to You for damages, including any direct, indirect, special,
- incidental, or consequential damages of any character arising as a
- result of this License or out of the use or inability to use the
- Work (including but not limited to damages for loss of goodwill,
- work stoppage, computer failure or malfunction, or any and all
- other commercial damages or losses), even if such Contributor
- has been advised of the possibility of such damages.
-
- 9. Accepting Warranty or Additional Liability. While redistributing
- the Work or Derivative Works thereof, You may choose to offer,
- and charge a fee for, acceptance of support, warranty, indemnity,
- or other liability obligations and/or rights consistent with this
- License. However, in accepting such obligations, You may act only
- on Your own behalf and on Your sole responsibility, not on behalf
- of any other Contributor, and only if You agree to indemnify,
- defend, and hold each Contributor harmless for any liability
- incurred by, or claims asserted against, such Contributor by reason
- of your accepting any such warranty or additional liability.
-
- END OF TERMS AND CONDITIONS
-
- APPENDIX: How to apply the Apache License to your work.
-
- To apply the Apache License to your work, attach the following
- boilerplate notice, with the fields enclosed by brackets "[]"
- replaced with your own identifying information. (Don't include
- the brackets!) The text should be enclosed in the appropriate
- comment syntax for the file format. We also recommend that a
- file or class name and description of purpose be included on the
- same "printed page" as the copyright notice for easier
- identification within third-party archives.
-
- Copyright [yyyy] [name of copyright owner]
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
diff --git a/contrib/persistent-https/Makefile b/contrib/persistent-https/Makefile
deleted file mode 100644
index 52b84ba3d4..0000000000
--- a/contrib/persistent-https/Makefile
+++ /dev/null
@@ -1,40 +0,0 @@
-# Copyright 2012 Google Inc. All Rights Reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-BUILD_LABEL=$(shell cut -d" " -f3 ../../GIT-VERSION-FILE)
-TAR_OUT=$(shell go env GOOS)_$(shell go env GOARCH).tar.gz
-
-all: git-remote-persistent-https git-remote-persistent-https--proxy \
- git-remote-persistent-http
-
-git-remote-persistent-https--proxy: git-remote-persistent-https
- ln -f -s git-remote-persistent-https git-remote-persistent-https--proxy
-
-git-remote-persistent-http: git-remote-persistent-https
- ln -f -s git-remote-persistent-https git-remote-persistent-http
-
-git-remote-persistent-https:
- case $$(go version) in \
- "go version go"1.[0-5].*) EQ=" " ;; *) EQ="=" ;; esac && \
- go build -o git-remote-persistent-https \
- -ldflags "-X main._BUILD_EMBED_LABEL$${EQ}$(BUILD_LABEL)"
-
-clean:
- rm -f git-remote-persistent-http* *.tar.gz
-
-tar: clean all
- @chmod 555 git-remote-persistent-https
- @tar -czf $(TAR_OUT) git-remote-persistent-http* README LICENSE
- @echo
- @echo "Created $(TAR_OUT)"
diff --git a/contrib/persistent-https/README b/contrib/persistent-https/README
deleted file mode 100644
index 7c4cd8d257..0000000000
--- a/contrib/persistent-https/README
+++ /dev/null
@@ -1,72 +0,0 @@
-git-remote-persistent-https
-
-The git-remote-persistent-https binary speeds up SSL operations
-by running a daemon job (git-remote-persistent-https--proxy) that
-keeps a connection open to a server.
-
-
-PRE-BUILT BINARIES
-
-Darwin amd64:
-https://commondatastorage.googleapis.com/git-remote-persistent-https/darwin_amd64.tar.gz
-
-Linux amd64:
-https://commondatastorage.googleapis.com/git-remote-persistent-https/linux_amd64.tar.gz
-
-
-INSTALLING
-
-Move all of the git-remote-persistent-http* binaries to a directory
-in PATH.
-
-
-USAGE
-
-HTTPS requests can be delegated to the proxy by using the
-"persistent-https" scheme, e.g.
-
-git clone persistent-https://kernel.googlesource.com/pub/scm/git/git
-
-Likewise, .gitconfig can be updated as follows to rewrite https urls
-to use persistent-https:
-
-[url "persistent-https"]
- insteadof = https
-[url "persistent-http"]
- insteadof = http
-
-You may also want to allow the use of the persistent-https helper for
-submodule URLs (since any https URLs pointing to submodules will be
-rewritten, and Git's out-of-the-box defaults forbid submodules from
-using unknown remote helpers):
-
-[protocol "persistent-https"]
- allow = always
-[protocol "persistent-http"]
- allow = always
-
-
-#####################################################################
-# BUILDING FROM SOURCE
-#####################################################################
-
-LOCATION
-
-The source is available in the contrib/persistent-https directory of
-the Git source repository. The Git source repository is available at
-git://git.kernel.org/pub/scm/git/git.git/
-https://kernel.googlesource.com/pub/scm/git/git
-
-
-PREREQUISITES
-
-The code is written in Go (http://golang.org/) and the Go compiler is
-required. Currently, the compiler must be built and installed from tip
-of source, in order to include a fix in the reverse http proxy:
-http://code.google.com/p/go/source/detail?r=a615b796570a2cd8591884767a7d67ede74f6648
-
-
-BUILDING
-
-Run "make" to build the binaries. See the section on
-INSTALLING above.
diff --git a/contrib/persistent-https/client.go b/contrib/persistent-https/client.go
deleted file mode 100644
index 71125b5832..0000000000
--- a/contrib/persistent-https/client.go
+++ /dev/null
@@ -1,189 +0,0 @@
-// Copyright 2012 Google Inc. All Rights Reserved.
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package main
-
-import (
- "bufio"
- "errors"
- "fmt"
- "net"
- "net/url"
- "os"
- "os/exec"
- "strings"
- "syscall"
- "time"
-)
-
-type Client struct {
- ProxyBin string
- Args []string
-
- insecure bool
-}
-
-func (c *Client) Run() error {
- if err := c.resolveArgs(); err != nil {
- return fmt.Errorf("resolveArgs() got error: %v", err)
- }
-
- // Connect to the proxy.
- uconn, hconn, addr, err := c.connect()
- if err != nil {
- return fmt.Errorf("connect() got error: %v", err)
- }
- // Keep the unix socket connection open for the duration of the request.
- defer uconn.Close()
- // Keep a connection to the HTTP server open, so no other user can
- // bind on the same address so long as the process is running.
- defer hconn.Close()
-
- // Start the git-remote-http subprocess.
- cargs := []string{"-c", fmt.Sprintf("http.proxy=%v", addr), "remote-http"}
- cargs = append(cargs, c.Args...)
- cmd := exec.Command("git", cargs...)
-
- for _, v := range os.Environ() {
- if !strings.HasPrefix(v, "GIT_PERSISTENT_HTTPS_SECURE=") {
- cmd.Env = append(cmd.Env, v)
- }
- }
- // Set the GIT_PERSISTENT_HTTPS_SECURE environment variable when
- // the proxy is using a SSL connection. This allows credential helpers
- // to identify secure proxy connections, despite being passed an HTTP
- // scheme.
- if !c.insecure {
- cmd.Env = append(cmd.Env, "GIT_PERSISTENT_HTTPS_SECURE=1")
- }
-
- cmd.Stdin = os.Stdin
- cmd.Stdout = os.Stdout
- cmd.Stderr = os.Stderr
- if err := cmd.Run(); err != nil {
- if eerr, ok := err.(*exec.ExitError); ok {
- if stat, ok := eerr.ProcessState.Sys().(syscall.WaitStatus); ok && stat.ExitStatus() != 0 {
- os.Exit(stat.ExitStatus())
- }
- }
- return fmt.Errorf("git-remote-http subprocess got error: %v", err)
- }
- return nil
-}
-
-func (c *Client) connect() (uconn net.Conn, hconn net.Conn, addr string, err error) {
- uconn, err = DefaultSocket.Dial()
- if err != nil {
- if e, ok := err.(*net.OpError); ok && (os.IsNotExist(e.Err) || e.Err == syscall.ECONNREFUSED) {
- if err = c.startProxy(); err == nil {
- uconn, err = DefaultSocket.Dial()
- }
- }
- if err != nil {
- return
- }
- }
-
- if addr, err = c.readAddr(uconn); err != nil {
- return
- }
-
- // Open a tcp connection to the proxy.
- if hconn, err = net.Dial("tcp", addr); err != nil {
- return
- }
-
- // Verify the address hasn't changed ownership.
- var addr2 string
- if addr2, err = c.readAddr(uconn); err != nil {
- return
- } else if addr != addr2 {
- err = fmt.Errorf("address changed after connect. got %q, want %q", addr2, addr)
- return
- }
- return
-}
-
-func (c *Client) readAddr(conn net.Conn) (string, error) {
- conn.SetDeadline(time.Now().Add(5 * time.Second))
- data := make([]byte, 100)
- n, err := conn.Read(data)
- if err != nil {
- return "", fmt.Errorf("error reading unix socket: %v", err)
- } else if n == 0 {
- return "", errors.New("empty data response")
- }
- conn.Write([]byte{1}) // Ack
-
- var addr string
- if addrs := strings.Split(string(data[:n]), "\n"); len(addrs) != 2 {
- return "", fmt.Errorf("got %q, wanted 2 addresses", data[:n])
- } else if c.insecure {
- addr = addrs[1]
- } else {
- addr = addrs[0]
- }
- return addr, nil
-}
-
-func (c *Client) startProxy() error {
- cmd := exec.Command(c.ProxyBin)
- cmd.SysProcAttr = &syscall.SysProcAttr{Setpgid: true}
- stdout, err := cmd.StdoutPipe()
- if err != nil {
- return err
- }
- defer stdout.Close()
- if err := cmd.Start(); err != nil {
- return err
- }
- result := make(chan error)
- go func() {
- bytes, _, err := bufio.NewReader(stdout).ReadLine()
- if line := string(bytes); err == nil && line != "OK" {
- err = fmt.Errorf("proxy returned %q, want \"OK\"", line)
- }
- result <- err
- }()
- select {
- case err := <-result:
- return err
- case <-time.After(5 * time.Second):
- return errors.New("timeout waiting for proxy to start")
- }
- panic("not reachable")
-}
-
-func (c *Client) resolveArgs() error {
- if nargs := len(c.Args); nargs == 0 {
- return errors.New("remote needed")
- } else if nargs > 2 {
- return fmt.Errorf("want at most 2 args, got %v", c.Args)
- }
-
- // Rewrite the url scheme to be http.
- idx := len(c.Args) - 1
- rawurl := c.Args[idx]
- rurl, err := url.Parse(rawurl)
- if err != nil {
- return fmt.Errorf("invalid remote: %v", err)
- }
- c.insecure = rurl.Scheme == "persistent-http"
- rurl.Scheme = "http"
- c.Args[idx] = rurl.String()
- if idx != 0 && c.Args[0] == rawurl {
- c.Args[0] = c.Args[idx]
- }
- return nil
-}
diff --git a/contrib/persistent-https/main.go b/contrib/persistent-https/main.go
deleted file mode 100644
index fd1b107743..0000000000
--- a/contrib/persistent-https/main.go
+++ /dev/null
@@ -1,82 +0,0 @@
-// Copyright 2012 Google Inc. All Rights Reserved.
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-// The git-remote-persistent-https binary speeds up SSL operations by running
-// a daemon job that keeps a connection open to a Git server. This ensures the
-// git-remote-persistent-https--proxy is running and delegating execution
-// to the git-remote-http binary with the http_proxy set to the daemon job.
-// A unix socket is used to authenticate the proxy and discover the
-// HTTP address. Note, both the client and proxy are included in the same
-// binary.
-package main
-
-import (
- "flag"
- "fmt"
- "log"
- "os"
- "strings"
- "time"
-)
-
-var (
- forceProxy = flag.Bool("proxy", false, "Whether to start the binary in proxy mode")
- proxyBin = flag.String("proxy_bin", "git-remote-persistent-https--proxy", "Path to the proxy binary")
- printLabel = flag.Bool("print_label", false, "Prints the build label for the binary")
-
- // Variable that should be defined through the -X linker flag.
- _BUILD_EMBED_LABEL string
-)
-
-const (
- defaultMaxIdleDuration = 24 * time.Hour
- defaultPollUpdateInterval = 15 * time.Minute
-)
-
-func main() {
- flag.Parse()
- if *printLabel {
- // Short circuit execution to print the build label
- fmt.Println(buildLabel())
- return
- }
-
- var err error
- if *forceProxy || strings.HasSuffix(os.Args[0], "--proxy") {
- log.SetPrefix("git-remote-persistent-https--proxy: ")
- proxy := &Proxy{
- BuildLabel: buildLabel(),
- MaxIdleDuration: defaultMaxIdleDuration,
- PollUpdateInterval: defaultPollUpdateInterval,
- }
- err = proxy.Run()
- } else {
- log.SetPrefix("git-remote-persistent-https: ")
- client := &Client{
- ProxyBin: *proxyBin,
- Args: flag.Args(),
- }
- err = client.Run()
- }
- if err != nil {
- log.Fatalln(err)
- }
-}
-
-func buildLabel() string {
- if _BUILD_EMBED_LABEL == "" {
- log.Println(`unlabeled build; build with "make" to label`)
- }
- return _BUILD_EMBED_LABEL
-}
diff --git a/contrib/persistent-https/proxy.go b/contrib/persistent-https/proxy.go
deleted file mode 100644
index bb0cdba386..0000000000
--- a/contrib/persistent-https/proxy.go
+++ /dev/null
@@ -1,190 +0,0 @@
-// Copyright 2012 Google Inc. All Rights Reserved.
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package main
-
-import (
- "fmt"
- "log"
- "net"
- "net/http"
- "net/http/httputil"
- "os"
- "os/exec"
- "os/signal"
- "sync"
- "syscall"
- "time"
-)
-
-type Proxy struct {
- BuildLabel string
- MaxIdleDuration time.Duration
- PollUpdateInterval time.Duration
-
- ul net.Listener
- httpAddr string
- httpsAddr string
-}
-
-func (p *Proxy) Run() error {
- hl, err := net.Listen("tcp", "127.0.0.1:0")
- if err != nil {
- return fmt.Errorf("http listen failed: %v", err)
- }
- defer hl.Close()
-
- hsl, err := net.Listen("tcp", "127.0.0.1:0")
- if err != nil {
- return fmt.Errorf("https listen failed: %v", err)
- }
- defer hsl.Close()
-
- p.ul, err = DefaultSocket.Listen()
- if err != nil {
- c, derr := DefaultSocket.Dial()
- if derr == nil {
- c.Close()
- fmt.Println("OK\nA proxy is already running... exiting")
- return nil
- } else if e, ok := derr.(*net.OpError); ok && e.Err == syscall.ECONNREFUSED {
- // Nothing is listening on the socket, unlink it and try again.
- syscall.Unlink(DefaultSocket.Path())
- p.ul, err = DefaultSocket.Listen()
- }
- if err != nil {
- return fmt.Errorf("unix listen failed on %v: %v", DefaultSocket.Path(), err)
- }
- }
- defer p.ul.Close()
- go p.closeOnSignal()
- go p.closeOnUpdate()
-
- p.httpAddr = hl.Addr().String()
- p.httpsAddr = hsl.Addr().String()
- fmt.Printf("OK\nListening on unix socket=%v http=%v https=%v\n",
- p.ul.Addr(), p.httpAddr, p.httpsAddr)
-
- result := make(chan error, 2)
- go p.serveUnix(result)
- go func() {
- result <- http.Serve(hl, &httputil.ReverseProxy{
- FlushInterval: 500 * time.Millisecond,
- Director: func(r *http.Request) {},
- })
- }()
- go func() {
- result <- http.Serve(hsl, &httputil.ReverseProxy{
- FlushInterval: 500 * time.Millisecond,
- Director: func(r *http.Request) {
- r.URL.Scheme = "https"
- },
- })
- }()
- return <-result
-}
-
-type socketContext struct {
- sync.WaitGroup
- mutex sync.Mutex
- last time.Time
-}
-
-func (sc *socketContext) Done() {
- sc.mutex.Lock()
- defer sc.mutex.Unlock()
- sc.last = time.Now()
- sc.WaitGroup.Done()
-}
-
-func (p *Proxy) serveUnix(result chan<- error) {
- sockCtx := &socketContext{}
- go p.closeOnIdle(sockCtx)
-
- var err error
- for {
- var uconn net.Conn
- uconn, err = p.ul.Accept()
- if err != nil {
- err = fmt.Errorf("accept failed: %v", err)
- break
- }
- sockCtx.Add(1)
- go p.handleUnixConn(sockCtx, uconn)
- }
- sockCtx.Wait()
- result <- err
-}
-
-func (p *Proxy) handleUnixConn(sockCtx *socketContext, uconn net.Conn) {
- defer sockCtx.Done()
- defer uconn.Close()
- data := []byte(fmt.Sprintf("%v\n%v", p.httpsAddr, p.httpAddr))
- uconn.SetDeadline(time.Now().Add(5 * time.Second))
- for i := 0; i < 2; i++ {
- if n, err := uconn.Write(data); err != nil {
- log.Printf("error sending http addresses: %+v\n", err)
- return
- } else if n != len(data) {
- log.Printf("sent %d data bytes, wanted %d\n", n, len(data))
- return
- }
- if _, err := uconn.Read([]byte{0, 0, 0, 0}); err != nil {
- log.Printf("error waiting for Ack: %+v\n", err)
- return
- }
- }
- // Wait without a deadline for the client to finish via EOF
- uconn.SetDeadline(time.Time{})
- uconn.Read([]byte{0, 0, 0, 0})
-}
-
-func (p *Proxy) closeOnIdle(sockCtx *socketContext) {
- for d := p.MaxIdleDuration; d > 0; {
- time.Sleep(d)
- sockCtx.Wait()
- sockCtx.mutex.Lock()
- if d = sockCtx.last.Add(p.MaxIdleDuration).Sub(time.Now()); d <= 0 {
- log.Println("graceful shutdown from idle timeout")
- p.ul.Close()
- }
- sockCtx.mutex.Unlock()
- }
-}
-
-func (p *Proxy) closeOnUpdate() {
- for {
- time.Sleep(p.PollUpdateInterval)
- if out, err := exec.Command(os.Args[0], "--print_label").Output(); err != nil {
- log.Printf("error polling for updated binary: %v\n", err)
- } else if s := string(out[:len(out)-1]); p.BuildLabel != s {
- log.Printf("graceful shutdown from updated binary: %q --> %q\n", p.BuildLabel, s)
- p.ul.Close()
- break
- }
- }
-}
-
-func (p *Proxy) closeOnSignal() {
- ch := make(chan os.Signal, 10)
- signal.Notify(ch, os.Interrupt, os.Kill, os.Signal(syscall.SIGTERM), os.Signal(syscall.SIGHUP))
- sig := <-ch
- p.ul.Close()
- switch sig {
- case os.Signal(syscall.SIGHUP):
- log.Printf("graceful shutdown from signal: %v\n", sig)
- default:
- log.Fatalf("exiting from signal: %v\n", sig)
- }
-}
diff --git a/contrib/persistent-https/socket.go b/contrib/persistent-https/socket.go
deleted file mode 100644
index 193b911dd1..0000000000
--- a/contrib/persistent-https/socket.go
+++ /dev/null
@@ -1,97 +0,0 @@
-// Copyright 2012 Google Inc. All Rights Reserved.
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package main
-
-import (
- "fmt"
- "log"
- "net"
- "os"
- "path/filepath"
- "syscall"
-)
-
-// A Socket is a wrapper around a Unix socket that verifies directory
-// permissions.
-type Socket struct {
- Dir string
-}
-
-func defaultDir() string {
- sockPath := ".git-credential-cache"
- if home := os.Getenv("HOME"); home != "" {
- return filepath.Join(home, sockPath)
- }
- log.Printf("socket: cannot find HOME path. using relative directory %q for socket", sockPath)
- return sockPath
-}
-
-// DefaultSocket is a Socket in the $HOME/.git-credential-cache directory.
-var DefaultSocket = Socket{Dir: defaultDir()}
-
-// Listen announces the local network address of the unix socket. The
-// permissions on the socket directory are verified before attempting
-// the actual listen.
-func (s Socket) Listen() (net.Listener, error) {
- network, addr := "unix", s.Path()
- if err := s.mkdir(); err != nil {
- return nil, &net.OpError{Op: "listen", Net: network, Addr: &net.UnixAddr{Name: addr, Net: network}, Err: err}
- }
- return net.Listen(network, addr)
-}
-
-// Dial connects to the unix socket. The permissions on the socket directory
-// are verified before attempting the actual dial.
-func (s Socket) Dial() (net.Conn, error) {
- network, addr := "unix", s.Path()
- if err := s.checkPermissions(); err != nil {
- return nil, &net.OpError{Op: "dial", Net: network, Addr: &net.UnixAddr{Name: addr, Net: network}, Err: err}
- }
- return net.Dial(network, addr)
-}
-
-// Path returns the fully specified file name of the unix socket.
-func (s Socket) Path() string {
- return filepath.Join(s.Dir, "persistent-https-proxy-socket")
-}
-
-func (s Socket) mkdir() error {
- if err := s.checkPermissions(); err == nil {
- return nil
- } else if !os.IsNotExist(err) {
- return err
- }
- if err := os.MkdirAll(s.Dir, 0700); err != nil {
- return err
- }
- return s.checkPermissions()
-}
-
-func (s Socket) checkPermissions() error {
- fi, err := os.Stat(s.Dir)
- if err != nil {
- return err
- }
- if !fi.IsDir() {
- return fmt.Errorf("socket: got file, want directory for %q", s.Dir)
- }
- if fi.Mode().Perm() != 0700 {
- return fmt.Errorf("socket: got perm %o, want 700 for %q", fi.Mode().Perm(), s.Dir)
- }
- if st := fi.Sys().(*syscall.Stat_t); int(st.Uid) != os.Getuid() {
- return fmt.Errorf("socket: got uid %d, want %d for %q", st.Uid, os.Getuid(), s.Dir)
- }
- return nil
-}
diff --git a/contrib/remote-helpers/README b/contrib/remote-helpers/README
deleted file mode 100644
index ac72332517..0000000000
--- a/contrib/remote-helpers/README
+++ /dev/null
@@ -1,15 +0,0 @@
-The remote-helper bridges to access data stored in Mercurial and
-Bazaar are maintained outside the git.git tree in the repositories
-of their primary author:
-
- https://github.com/felipec/git-remote-hg (for Mercurial)
- https://github.com/felipec/git-remote-bzr (for Bazaar)
-
-You can pick a directory on your $PATH and download them from these
-repositories, e.g.:
-
- $ wget -O $HOME/bin/git-remote-hg \
- https://raw.github.com/felipec/git-remote-hg/master/git-remote-hg
- $ wget -O $HOME/bin/git-remote-bzr \
- https://raw.github.com/felipec/git-remote-bzr/master/git-remote-bzr
- $ chmod +x $HOME/bin/git-remote-hg $HOME/bin/git-remote-bzr
diff --git a/contrib/remote-helpers/git-remote-bzr b/contrib/remote-helpers/git-remote-bzr
deleted file mode 100755
index 1c3d87f861..0000000000
--- a/contrib/remote-helpers/git-remote-bzr
+++ /dev/null
@@ -1,11 +0,0 @@
-#!/bin/sh
-
-cat >&2 <<'EOT'
-WARNING: git-remote-bzr is now maintained independently.
-WARNING: For more information visit https://github.com/felipec/git-remote-bzr
-WARNING:
-WARNING: You can pick a directory on your $PATH and download it, e.g.:
-WARNING: $ wget -O $HOME/bin/git-remote-bzr \
-WARNING: https://raw.github.com/felipec/git-remote-bzr/master/git-remote-bzr
-WARNING: $ chmod +x $HOME/bin/git-remote-bzr
-EOT
diff --git a/contrib/remote-helpers/git-remote-hg b/contrib/remote-helpers/git-remote-hg
deleted file mode 100755
index 8e9188364c..0000000000
--- a/contrib/remote-helpers/git-remote-hg
+++ /dev/null
@@ -1,11 +0,0 @@
-#!/bin/sh
-
-cat >&2 <<'EOT'
-WARNING: git-remote-hg is now maintained independently.
-WARNING: For more information visit https://github.com/felipec/git-remote-hg
-WARNING:
-WARNING: You can pick a directory on your $PATH and download it, e.g.:
-WARNING: $ wget -O $HOME/bin/git-remote-hg \
-WARNING: https://raw.github.com/felipec/git-remote-hg/master/git-remote-hg
-WARNING: $ chmod +x $HOME/bin/git-remote-hg
-EOT
diff --git a/contrib/remotes2config.sh b/contrib/remotes2config.sh
deleted file mode 100755
index 1cda19f66a..0000000000
--- a/contrib/remotes2config.sh
+++ /dev/null
@@ -1,33 +0,0 @@
-#!/bin/sh
-
-# Use this tool to rewrite your .git/remotes/ files into the config.
-
-. git-sh-setup
-
-if [ -d "$GIT_DIR"/remotes ]; then
- echo "Rewriting $GIT_DIR/remotes" >&2
- error=0
- # rewrite into config
- {
- cd "$GIT_DIR"/remotes
- ls | while read f; do
- name=$(printf "$f" | tr -c "A-Za-z0-9-" ".")
- sed -n \
- -e "s/^URL:[ ]*\(.*\)$/remote.$name.url \1 ./p" \
- -e "s/^Pull:[ ]*\(.*\)$/remote.$name.fetch \1 ^$ /p" \
- -e "s/^Push:[ ]*\(.*\)$/remote.$name.push \1 ^$ /p" \
- < "$f"
- done
- echo done
- } | while read key value regex; do
- case $key in
- done)
- if [ $error = 0 ]; then
- mv "$GIT_DIR"/remotes "$GIT_DIR"/remotes.old
- fi ;;
- *)
- echo "git config $key "$value" $regex"
- git config $key "$value" $regex || error=1 ;;
- esac
- done
-fi
diff --git a/contrib/stats/git-common-hash b/contrib/stats/git-common-hash
deleted file mode 100755
index e27fd088be..0000000000
--- a/contrib/stats/git-common-hash
+++ /dev/null
@@ -1,26 +0,0 @@
-#!/bin/sh
-
-# This script displays the distribution of longest common hash prefixes.
-# This can be used to determine the minimum prefix length to use
-# for object names to be unique.
-
-git rev-list --objects --all | sort | perl -lne '
- substr($_, 40) = "";
- # uncomment next line for a distribution of bits instead of hex chars
- # $_ = unpack("B*",pack("H*",$_));
- if (defined $p) {
- ($p ^ $_) =~ /^(\0*)/;
- $common = length $1;
- if (defined $pcommon) {
- $count[$pcommon > $common ? $pcommon : $common]++;
- } else {
- $count[$common]++; # first item
- }
- }
- $p = $_;
- $pcommon = $common;
- END {
- $count[$common]++; # last item
- print "$_: $count[$_]" for 0..$#count;
- }
-'
diff --git a/contrib/stats/mailmap.pl b/contrib/stats/mailmap.pl
deleted file mode 100755
index 9513f5e35b..0000000000
--- a/contrib/stats/mailmap.pl
+++ /dev/null
@@ -1,70 +0,0 @@
-#!/usr/bin/perl
-
-use warnings 'all';
-use strict;
-use Getopt::Long;
-
-my $match_emails;
-my $match_names;
-my $order_by = 'count';
-Getopt::Long::Configure(qw(bundling));
-GetOptions(
- 'emails|e!' => \$match_emails,
- 'names|n!' => \$match_names,
- 'count|c' => sub { $order_by = 'count' },
- 'time|t' => sub { $order_by = 'stamp' },
-) or exit 1;
-$match_emails = 1 unless $match_names;
-
-my $email = {};
-my $name = {};
-
-open(my $fh, '-|', "git log --format='%at <%aE> %aN'");
-while(<$fh>) {
- my ($t, $e, $n) = /(\S+) <(\S+)> (.*)/;
- mark($email, $e, $n, $t);
- mark($name, $n, $e, $t);
-}
-close($fh);
-
-if ($match_emails) {
- foreach my $e (dups($email)) {
- foreach my $n (vals($email->{$e})) {
- show($n, $e, $email->{$e}->{$n});
- }
- print "\n";
- }
-}
-if ($match_names) {
- foreach my $n (dups($name)) {
- foreach my $e (vals($name->{$n})) {
- show($n, $e, $name->{$n}->{$e});
- }
- print "\n";
- }
-}
-exit 0;
-
-sub mark {
- my ($h, $k, $v, $t) = @_;
- my $e = $h->{$k}->{$v} ||= { count => 0, stamp => 0 };
- $e->{count}++;
- $e->{stamp} = $t unless $t < $e->{stamp};
-}
-
-sub dups {
- my $h = shift;
- return grep { keys($h->{$_}) > 1 } keys($h);
-}
-
-sub vals {
- my $h = shift;
- return sort {
- $h->{$b}->{$order_by} <=> $h->{$a}->{$order_by}
- } keys($h);
-}
-
-sub show {
- my ($n, $e, $h) = @_;
- print "$n <$e> ($h->{$order_by})\n";
-}
diff --git a/contrib/subtree/.gitignore b/contrib/subtree/.gitignore
index 0b9381abca..6deaf177c7 100644
--- a/contrib/subtree/.gitignore
+++ b/contrib/subtree/.gitignore
@@ -1,4 +1,6 @@
*~
+asciidoc.conf
+asciidoctor-extensions.rb
git-subtree
git-subtree.1
git-subtree.html
diff --git a/contrib/subtree/Makefile b/contrib/subtree/Makefile
index 6fa7496bfd..c0c9f21cb7 100644
--- a/contrib/subtree/Makefile
+++ b/contrib/subtree/Makefile
@@ -1,6 +1,7 @@
# The default target of this Makefile is...
all::
+-include ../../shared.mak
-include ../../config.mak.autogen
-include ../../config.mak
@@ -13,17 +14,16 @@ htmldir ?= $(prefix)/share/doc/git-doc
../../GIT-VERSION-FILE: FORCE
$(MAKE) -C ../../ GIT-VERSION-FILE
--include ../../GIT-VERSION-FILE
-
# this should be set to a 'standard' bsd-type install program
INSTALL ?= install
RM ?= rm -f
ASCIIDOC = asciidoc
-ASCIIDOC_CONF = -f ../../Documentation/asciidoc.conf
+ASCIIDOC_CONF = -f asciidoc.conf
ASCIIDOC_HTML = xhtml11
ASCIIDOC_DOCBOOK = docbook
ASCIIDOC_EXTRA =
+ASCIIDOC_DEPS = asciidoc.conf
XMLTO = xmlto
XMLTO_EXTRA =
@@ -32,8 +32,9 @@ ASCIIDOC = asciidoctor
ASCIIDOC_CONF =
ASCIIDOC_HTML = xhtml5
ASCIIDOC_DOCBOOK = docbook
-ASCIIDOC_EXTRA += -I../../Documentation -rasciidoctor-extensions
+ASCIIDOC_EXTRA += -I. -rasciidoctor-extensions
ASCIIDOC_EXTRA += -alitdd='&\#x2d;&\#x2d;'
+ASCIIDOC_DEPS = asciidoctor-extensions.rb
XMLTO_EXTRA += --skip-validation
endif
@@ -49,7 +50,7 @@ GIT_SUBTREE := git-subtree
GIT_SUBTREE_DOC := git-subtree.1
GIT_SUBTREE_XML := git-subtree.xml
-GIT_SUBTREE_TXT := git-subtree.txt
+GIT_SUBTREE_TXT := git-subtree.adoc
GIT_SUBTREE_HTML := git-subtree.html
GIT_SUBTREE_TEST := ../../git-subtree
@@ -82,13 +83,13 @@ install-html: $(GIT_SUBTREE_HTML)
$(GIT_SUBTREE_DOC): $(GIT_SUBTREE_XML)
$(XMLTO) -m $(MANPAGE_XSL) $(XMLTO_EXTRA) man $^
-$(GIT_SUBTREE_XML): $(GIT_SUBTREE_TXT)
+$(GIT_SUBTREE_XML): $(GIT_SUBTREE_TXT) $(ASCIIDOC_DEPS)
$(ASCIIDOC) -b $(ASCIIDOC_DOCBOOK) -d manpage $(ASCIIDOC_CONF) \
- -agit_version=$(GIT_VERSION) $(ASCIIDOC_EXTRA) $^
+ $(ASCIIDOC_EXTRA) $<
-$(GIT_SUBTREE_HTML): $(GIT_SUBTREE_TXT)
+$(GIT_SUBTREE_HTML): $(GIT_SUBTREE_TXT) $(ASCIIDOC_DEPS)
$(ASCIIDOC) -b $(ASCIIDOC_HTML) -d manpage $(ASCIIDOC_CONF) \
- -agit_version=$(GIT_VERSION) $(ASCIIDOC_EXTRA) $^
+ $(ASCIIDOC_EXTRA) $<
$(GIT_SUBTREE_TEST): $(GIT_SUBTREE)
cp $< $@
@@ -98,6 +99,12 @@ test: $(GIT_SUBTREE_TEST)
clean:
$(RM) $(GIT_SUBTREE)
+ $(RM) asciidoc.conf asciidoctor-extensions.rb
$(RM) *.xml *.html *.1
+asciidoc.conf: ../../Documentation/asciidoc.conf.in ../../GIT-VERSION-FILE
+ $(QUIET_GEN)$(call version_gen,"$(shell pwd)/../..",$<,$@)
+asciidoctor-extensions.rb: ../../Documentation/asciidoctor-extensions.rb.in ../../GIT-VERSION-FILE
+ $(QUIET_GEN)$(call version_gen,"$(shell pwd)/../..",$<,$@)
+
.PHONY: FORCE
diff --git a/contrib/subtree/README b/contrib/subtree/README
index c686b4a69b..65d167b678 100644
--- a/contrib/subtree/README
+++ b/contrib/subtree/README
@@ -1,5 +1,5 @@
-Please read git-subtree.txt for documentation.
+Please read git-subtree.adoc for documentation.
Please don't contact me using github mail; it's slow, ugly, and worst of
all, redundant. Email me instead at apenwarr@gmail.com and I'll be happy to
diff --git a/contrib/subtree/git-subtree.txt b/contrib/subtree/git-subtree.adoc
index 004abf415b..b2bcbcad0d 100644
--- a/contrib/subtree/git-subtree.txt
+++ b/contrib/subtree/git-subtree.adoc
@@ -9,14 +9,14 @@ git-subtree - Merge subtrees together and split repository into subtrees
SYNOPSIS
--------
[verse]
-'git subtree' [<options>] -P <prefix> add <local-commit>
-'git subtree' [<options>] -P <prefix> add <repository> <remote-ref>
-'git subtree' [<options>] -P <prefix> merge <local-commit> [<repository>]
-'git subtree' [<options>] -P <prefix> split [<local-commit>]
+'git subtree' [<options>] -P <prefix> [-S[<keyid>]] add <local-commit>
+'git subtree' [<options>] -P <prefix> [-S[<keyid>]] add <repository> <remote-ref>
+'git subtree' [<options>] -P <prefix> [-S[<keyid>]] merge <local-commit> [<repository>]
+'git subtree' [<options>] -P <prefix> [-S[<keyid>]] split [<local-commit>]
[verse]
-'git subtree' [<options>] -P <prefix> pull <repository> <remote-ref>
-'git subtree' [<options>] -P <prefix> push <repository> <refspec>
+'git subtree' [<options>] -P <prefix> [-S[<keyid>]] pull <repository> <remote-ref>
+'git subtree' [<options>] -P <prefix> [-S[<keyid>]] push <repository> <refspec>
DESCRIPTION
-----------
@@ -149,6 +149,13 @@ OPTIONS FOR ALL COMMANDS
want to manipulate. This option is mandatory
for all commands.
+-S[<keyid>]::
+--gpg-sign[=<keyid>]::
+--no-gpg-sign::
+ GPG-sign commits. The `keyid` argument is optional and
+ defaults to the committer identity; `--no-gpg-sign` is useful to
+ countermand a `--gpg-sign` option given earlier on the command line.
+
OPTIONS FOR 'add' AND 'merge' (ALSO: 'pull', 'split --rejoin', AND 'push --rejoin')
-----------------------------------------------------------------------------------
These options for 'add' and 'merge' may also be given to 'pull' (which
diff --git a/contrib/subtree/git-subtree.sh b/contrib/subtree/git-subtree.sh
index 15ae86db1b..3fddba797c 100755
--- a/contrib/subtree/git-subtree.sh
+++ b/contrib/subtree/git-subtree.sh
@@ -26,12 +26,12 @@ then
fi
OPTS_SPEC="\
-git subtree add --prefix=<prefix> <commit>
-git subtree add --prefix=<prefix> <repository> <ref>
-git subtree merge --prefix=<prefix> <commit>
-git subtree split --prefix=<prefix> [<commit>]
-git subtree pull --prefix=<prefix> <repository> <ref>
-git subtree push --prefix=<prefix> <repository> <refspec>
+git subtree add --prefix=<prefix> [-S[=<key-id>]] <commit>
+git subtree add --prefix=<prefix> [-S[=<key-id>]] <repository> <ref>
+git subtree merge --prefix=<prefix> [-S[=<key-id>]] <commit>
+git subtree split --prefix=<prefix> [-S[=<key-id>]] [<commit>]
+git subtree pull --prefix=<prefix> [-S[=<key-id>]] <repository> <ref>
+git subtree push --prefix=<prefix> [-S[=<key-id>]] <repository> <refspec>
--
h,help! show the help
q,quiet! quiet
@@ -46,6 +46,7 @@ rejoin merge the new branch back into HEAD
options for 'add' and 'merge' (also: 'pull', 'split --rejoin', and 'push --rejoin')
squash merge subtree changes as a single commit
m,message!= use the given message as the commit message for the merge commit
+S,gpg-sign?key-id GPG-sign commits. The keyid argument is optional and defaults to the committer identity
"
indent=0
@@ -115,7 +116,7 @@ main () {
then
set -- -h
fi
- set_args="$(echo "$OPTS_SPEC" | git rev-parse --parseopt -- "$@" || echo exit $?)"
+ set_args="$(echo "$OPTS_SPEC" | git rev-parse --parseopt --stuck-long -- "$@" || echo exit $?)"
eval "$set_args"
. git-sh-setup
require_work_tree
@@ -131,9 +132,6 @@ main () {
opt="$1"
shift
case "$opt" in
- --annotate|-b|-P|-m|--onto)
- shift
- ;;
--rejoin)
arg_split_rejoin=1
;;
@@ -171,48 +169,44 @@ main () {
arg_split_annotate=
arg_addmerge_squash=
arg_addmerge_message=
+ arg_gpg_sign=
while test $# -gt 0
do
opt="$1"
shift
case "$opt" in
- -q)
+ --quiet)
arg_quiet=1
;;
- -d)
+ --debug)
arg_debug=1
;;
- --annotate)
+ --annotate=*)
test -n "$allow_split" || die_incompatible_opt "$opt" "$arg_command"
- arg_split_annotate="$1"
- shift
+ arg_split_annotate="${opt#*=}"
;;
--no-annotate)
test -n "$allow_split" || die_incompatible_opt "$opt" "$arg_command"
arg_split_annotate=
;;
- -b)
+ --branch=*)
test -n "$allow_split" || die_incompatible_opt "$opt" "$arg_command"
- arg_split_branch="$1"
- shift
+ arg_split_branch="${opt#*=}"
;;
- -P)
- arg_prefix="${1%/}"
- shift
+ --prefix=*)
+ arg_prefix="${opt#*=}"
;;
- -m)
+ --message=*)
test -n "$allow_addmerge" || die_incompatible_opt "$opt" "$arg_command"
- arg_addmerge_message="$1"
- shift
+ arg_addmerge_message="${opt#*=}"
;;
--no-prefix)
arg_prefix=
;;
- --onto)
+ --onto=*)
test -n "$allow_split" || die_incompatible_opt "$opt" "$arg_command"
- arg_split_onto="$1"
- shift
+ arg_split_onto="${opt#*=}"
;;
--no-onto)
test -n "$allow_split" || die_incompatible_opt "$opt" "$arg_command"
@@ -240,6 +234,9 @@ main () {
test -n "$allow_addmerge" || die_incompatible_opt "$opt" "$arg_command"
arg_addmerge_squash=
;;
+ --gpg-sign=* | --gpg-sign | --no-gpg-sign)
+ arg_gpg_sign="$opt"
+ ;;
--)
break
;;
@@ -272,6 +269,7 @@ main () {
debug "quiet: {$arg_quiet}"
debug "dir: {$dir}"
debug "opts: {$*}"
+ debug "gpg-sign: {$arg_gpg_sign}"
debug
"cmd_$arg_command" "$@"
@@ -537,7 +535,7 @@ copy_commit () {
printf "%s" "$arg_split_annotate"
cat
) |
- git commit-tree "$2" $3 # reads the rest of stdin
+ git commit-tree $arg_gpg_sign "$2" $3 # reads the rest of stdin
) || die "fatal: can't copy commit $1"
}
@@ -683,10 +681,10 @@ new_squash_commit () {
if test -n "$old"
then
squash_msg "$dir" "$oldsub" "$newsub" |
- git commit-tree "$tree" -p "$old" || exit $?
+ git commit-tree $arg_gpg_sign "$tree" -p "$old" || exit $?
else
squash_msg "$dir" "" "$newsub" |
- git commit-tree "$tree" || exit $?
+ git commit-tree $arg_gpg_sign "$tree" || exit $?
fi
}
@@ -925,11 +923,11 @@ cmd_add_commit () {
then
rev=$(new_squash_commit "" "" "$rev") || exit $?
commit=$(add_squashed_msg "$rev" "$dir" |
- git commit-tree "$tree" $headp -p "$rev") || exit $?
+ git commit-tree $arg_gpg_sign "$tree" $headp -p "$rev") || exit $?
else
revp=$(peel_committish "$rev") || exit $?
commit=$(add_msg "$dir" $headrev "$rev" |
- git commit-tree "$tree" $headp -p "$revp") || exit $?
+ git commit-tree $arg_gpg_sign "$tree" $headp -p "$revp") || exit $?
fi
git reset "$commit" || exit $?
@@ -1080,9 +1078,9 @@ cmd_merge () {
if test -n "$arg_addmerge_message"
then
git merge --no-ff -Xsubtree="$arg_prefix" \
- --message="$arg_addmerge_message" "$rev"
+ --message="$arg_addmerge_message" $arg_gpg_sign "$rev"
else
- git merge --no-ff -Xsubtree="$arg_prefix" $rev
+ git merge --no-ff -Xsubtree="$arg_prefix" $arg_gpg_sign $rev
fi
}
diff --git a/contrib/subtree/meson.build b/contrib/subtree/meson.build
new file mode 100644
index 0000000000..98dd8e0c8e
--- /dev/null
+++ b/contrib/subtree/meson.build
@@ -0,0 +1,73 @@
+git_subtree = custom_target(
+ input: 'git-subtree.sh',
+ output: 'git-subtree',
+ command: [
+ shell,
+ meson.project_source_root() / 'generate-script.sh',
+ '@INPUT@',
+ '@OUTPUT@',
+ meson.project_build_root() / 'GIT-BUILD-OPTIONS',
+ ],
+ install: true,
+ install_dir: get_option('libexecdir') / 'git-core',
+)
+
+if get_option('tests')
+ subtree_test_environment = test_environment
+ subtree_test_environment.prepend('PATH', meson.current_build_dir())
+
+ test('t7900-subtree', shell,
+ args: [ 't7900-subtree.sh' ],
+ env: subtree_test_environment,
+ workdir: meson.current_source_dir() / 't',
+ depends: test_dependencies + bin_wrappers + [ git_subtree ],
+ kwargs: test_kwargs,
+ )
+endif
+
+if get_option('docs').contains('man')
+ subtree_xml = custom_target(
+ command: asciidoc_common_options + [
+ '--backend=' + asciidoc_docbook,
+ '--doctype=manpage',
+ '--out-file=@OUTPUT@',
+ '@INPUT@',
+ ],
+ depends: documentation_deps,
+ input: 'git-subtree.adoc',
+ output: 'git-subtree.xml',
+ )
+
+ custom_target(
+ command: [
+ xmlto,
+ '-m', '@INPUT@',
+ 'man',
+ subtree_xml,
+ '-o',
+ meson.current_build_dir(),
+ ] + xmlto_extra,
+ input: [
+ '../../Documentation/manpage-normal.xsl',
+ ],
+ output: 'git-subtree.1',
+ install: true,
+ install_dir: get_option('mandir') / 'man1',
+ )
+endif
+
+if get_option('docs').contains('html')
+ custom_target(
+ command: asciidoc_common_options + [
+ '--backend=' + asciidoc_html,
+ '--doctype=manpage',
+ '--out-file=@OUTPUT@',
+ '@INPUT@',
+ ],
+ depends: documentation_deps,
+ input: 'git-subtree.adoc',
+ output: 'git-subtree.html',
+ install: true,
+ install_dir: get_option('datadir') / 'doc/git-doc',
+ )
+endif
diff --git a/contrib/subtree/t/Makefile b/contrib/subtree/t/Makefile
index 093399c788..2a85f5ee84 100644
--- a/contrib/subtree/t/Makefile
+++ b/contrib/subtree/t/Makefile
@@ -3,6 +3,9 @@
# Copyright (c) 2005 Junio C Hamano
#
+# The default target of this Makefile is...
+all::
+
-include ../../../config.mak.autogen
-include ../../../config.mak
@@ -31,7 +34,7 @@ TSVN = $(sort $(wildcard t91[0-9][0-9]-*.sh))
TGITWEB = $(sort $(wildcard t95[0-9][0-9]-*.sh))
THELPERS = $(sort $(filter-out $(T),$(wildcard *.sh)))
-all: $(DEFAULT_TEST_TARGET)
+all:: $(DEFAULT_TEST_TARGET)
test: pre-clean $(TEST_LINT)
$(MAKE) aggregate-results-and-cleanup
diff --git a/contrib/subtree/t/t7900-subtree.sh b/contrib/subtree/t/t7900-subtree.sh
index 3c6103f6d2..3edbb33af4 100755
--- a/contrib/subtree/t/t7900-subtree.sh
+++ b/contrib/subtree/t/t7900-subtree.sh
@@ -11,6 +11,7 @@ and push subcommands of git subtree.
TEST_DIRECTORY=$(pwd)/../../../t
. "$TEST_DIRECTORY"/test-lib.sh
+. "$TEST_DIRECTORY"/lib-gpg.sh
# Use our own wrapper around test-lib.sh's test_create_repo, in order
# to set log.date=relative. `git subtree` parses the output of `git
@@ -1563,4 +1564,116 @@ test_expect_success 'subtree descendant check' '
)
'
+test_expect_success GPG 'add subproj with GPG signing using -S flag' '
+ subtree_test_create_repo "$test_count" &&
+ subtree_test_create_repo "$test_count/sub proj" &&
+ test_create_commit "$test_count" main1 &&
+ test_create_commit "$test_count/sub proj" sub1 &&
+ (
+ cd "$test_count" &&
+ git fetch ./"sub proj" HEAD &&
+ git subtree add --prefix="sub dir" -S FETCH_HEAD &&
+ git verify-commit HEAD &&
+ test "$(last_commit_subject)" = "Add '\''sub dir/'\'' from commit '\''$(git rev-parse FETCH_HEAD)'\''"
+ )
+'
+
+test_expect_success GPG 'add subproj with GPG signing using --gpg-sign flag' '
+ subtree_test_create_repo "$test_count" &&
+ subtree_test_create_repo "$test_count/sub proj" &&
+ test_create_commit "$test_count" main1 &&
+ test_create_commit "$test_count/sub proj" sub1 &&
+ (
+ cd "$test_count" &&
+ git fetch ./"sub proj" HEAD &&
+ git subtree add --prefix="sub dir" --gpg-sign FETCH_HEAD &&
+ git verify-commit HEAD &&
+ test "$(last_commit_subject)" = "Add '\''sub dir/'\'' from commit '\''$(git rev-parse FETCH_HEAD)'\''"
+ )
+'
+
+test_expect_success GPG 'add subproj with GPG signing using specific key ID' '
+ subtree_test_create_repo "$test_count" &&
+ subtree_test_create_repo "$test_count/sub proj" &&
+ test_create_commit "$test_count" main1 &&
+ test_create_commit "$test_count/sub proj" sub1 &&
+ (
+ cd "$test_count" &&
+ git fetch ./"sub proj" HEAD &&
+ git subtree add --prefix="sub dir" -S"$GIT_COMMITTER_EMAIL" FETCH_HEAD &&
+ git verify-commit HEAD &&
+ test "$(last_commit_subject)" = "Add '\''sub dir/'\'' from commit '\''$(git rev-parse FETCH_HEAD)'\''"
+ )
+'
+
+test_expect_success GPG 'merge with GPG signing' '
+ subtree_test_create_repo "$test_count" &&
+ subtree_test_create_repo "$test_count/sub proj" &&
+ test_create_commit "$test_count" main1 &&
+ test_create_commit "$test_count/sub proj" sub1 &&
+ (
+ cd "$test_count" &&
+ git fetch ./"sub proj" HEAD &&
+ git subtree add --prefix="sub dir" FETCH_HEAD
+ ) &&
+ test_create_commit "$test_count/sub proj" sub2 &&
+ (
+ cd "$test_count" &&
+ git fetch ./"sub proj" HEAD &&
+ git subtree merge --prefix="sub dir" -S FETCH_HEAD &&
+ git verify-commit HEAD
+ )
+'
+
+test_expect_success GPG 'split with GPG signing and --rejoin' '
+ subtree_test_create_repo "$test_count" &&
+ subtree_test_create_repo "$test_count/sub proj" &&
+ test_create_commit "$test_count" main1 &&
+ test_create_commit "$test_count/sub proj" sub1 &&
+ (
+ cd "$test_count" &&
+ git fetch ./"sub proj" HEAD &&
+ git subtree add --prefix="sub dir" FETCH_HEAD
+ ) &&
+ test_create_commit "$test_count" "sub dir/main-sub1" &&
+ (
+ cd "$test_count" &&
+ git subtree split --prefix="sub dir" --rejoin -S &&
+ git verify-commit HEAD
+ )
+'
+
+test_expect_success GPG 'add with --squash and GPG signing' '
+ subtree_test_create_repo "$test_count" &&
+ subtree_test_create_repo "$test_count/sub proj" &&
+ test_create_commit "$test_count" main1 &&
+ test_create_commit "$test_count/sub proj" sub1 &&
+ (
+ cd "$test_count" &&
+ git fetch ./"sub proj" HEAD &&
+ git subtree add --prefix="sub dir" --squash -S FETCH_HEAD &&
+ git verify-commit HEAD &&
+ # With --squash, the commit subject should reference the squash commit (first parent of merge)
+ squash_commit=$(git rev-parse HEAD^2) &&
+ test "$(last_commit_subject)" = "Merge commit '\''$squash_commit'\'' as '\''sub dir'\''"
+ )
+'
+
+test_expect_success GPG 'pull with GPG signing' '
+ subtree_test_create_repo "$test_count" &&
+ subtree_test_create_repo "$test_count/sub proj" &&
+ test_create_commit "$test_count" main1 &&
+ test_create_commit "$test_count/sub proj" sub1 &&
+ (
+ cd "$test_count" &&
+ git subtree add --prefix="sub dir" ./"sub proj" HEAD
+ ) &&
+ test_create_commit "$test_count/sub proj" sub2 &&
+ (
+ cd "$test_count" &&
+ git subtree pull --prefix="sub dir" -S ./"sub proj" HEAD &&
+ git verify-commit HEAD
+ )
+'
+
test_done
diff --git a/contrib/thunderbird-patch-inline/README b/contrib/thunderbird-patch-inline/README
deleted file mode 100644
index 000147bbe4..0000000000
--- a/contrib/thunderbird-patch-inline/README
+++ /dev/null
@@ -1,20 +0,0 @@
-appp.sh is a script that is supposed to be used together with ExternalEditor
-for Mozilla Thunderbird. It will let you include patches inline in e-mails
-in an easy way.
-
-Usage:
-- Generate the patch with git format-patch.
-- Start writing a new e-mail in Thunderbird.
-- Press the external editor button (or Ctrl-E) to run appp.sh
-- Select the previously generated patch file.
-- Finish editing the e-mail.
-
-Any text that is entered into the message editor before appp.sh is called
-will be moved to the section between the --- and the diffstat.
-
-All S-O-B:s and Cc:s in the patch will be added to the CC list.
-
-To set it up, just install External Editor and tell it to use appp.sh as the
-editor.
-
-Zenity is a required dependency.
diff --git a/contrib/thunderbird-patch-inline/appp.sh b/contrib/thunderbird-patch-inline/appp.sh
deleted file mode 100755
index 1053872eea..0000000000
--- a/contrib/thunderbird-patch-inline/appp.sh
+++ /dev/null
@@ -1,55 +0,0 @@
-#!/bin/sh
-# Copyright 2008 Lukas Sandström <luksan@gmail.com>
-#
-# AppendPatch - A script to be used together with ExternalEditor
-# for Mozilla Thunderbird to properly include patches inline in e-mails.
-
-# ExternalEditor can be downloaded at http://globs.org/articles.php?lng=en&pg=2
-
-CONFFILE=~/.appprc
-
-SEP="-=-=-=-=-=-=-=-=-=# Don't remove this line #=-=-=-=-=-=-=-=-=-"
-if [ -e "$CONFFILE" ] ; then
- LAST_DIR=$(grep -m 1 "^LAST_DIR=" "${CONFFILE}"|sed -e 's/^LAST_DIR=//')
- cd "${LAST_DIR}"
-else
- cd > /dev/null
-fi
-
-PATCH=$(zenity --file-selection)
-
-if [ "$?" != "0" ] ; then
- #zenity --error --text "No patchfile given."
- exit 1
-fi
-
-cd - > /dev/null
-
-SUBJECT=$(sed -n -e '/^Subject: /p' "${PATCH}")
-HEADERS=$(sed -e '/^'"${SEP}"'$/,$d' $1)
-BODY=$(sed -e "1,/${SEP}/d" $1)
-CMT_MSG=$(sed -e '1,/^$/d' -e '/^---$/,$d' "${PATCH}")
-DIFF=$(sed -e '1,/^---$/d' "${PATCH}")
-
-CCS=$(echo -e "$CMT_MSG\n$HEADERS" | sed -n -e 's/^Cc: \(.*\)$/\1,/gp' \
- -e 's/^Signed-off-by: \(.*\)/\1,/gp')
-
-echo "$SUBJECT" > $1
-echo "Cc: $CCS" >> $1
-echo "$HEADERS" | sed -e '/^Subject: /d' -e '/^Cc: /d' >> $1
-echo "$SEP" >> $1
-
-echo "$CMT_MSG" >> $1
-echo "---" >> $1
-if [ "x${BODY}x" != "xx" ] ; then
- echo >> $1
- echo "$BODY" >> $1
- echo >> $1
-fi
-echo "$DIFF" >> $1
-
-LAST_DIR=$(dirname "${PATCH}")
-
-grep -v "^LAST_DIR=" "${CONFFILE}" > "${CONFFILE}_"
-echo "LAST_DIR=${LAST_DIR}" >> "${CONFFILE}_"
-mv "${CONFFILE}_" "${CONFFILE}"
diff --git a/contrib/workdir/.gitattributes b/contrib/workdir/.gitattributes
deleted file mode 100644
index 1f78c5d1bd..0000000000
--- a/contrib/workdir/.gitattributes
+++ /dev/null
@@ -1 +0,0 @@
-/git-new-workdir eol=lf
diff --git a/contrib/workdir/git-new-workdir b/contrib/workdir/git-new-workdir
deleted file mode 100755
index 989197aace..0000000000
--- a/contrib/workdir/git-new-workdir
+++ /dev/null
@@ -1,105 +0,0 @@
-#!/bin/sh
-
-usage () {
- echo "usage:" $@
- exit 127
-}
-
-die () {
- echo $@
- exit 128
-}
-
-failed () {
- die "unable to create new workdir '$new_workdir'!"
-}
-
-if test $# -lt 2 || test $# -gt 3
-then
- usage "$0 <repository> <new_workdir> [<branch>]"
-fi
-
-orig_git=$1
-new_workdir=$2
-branch=$3
-
-# want to make sure that what is pointed to has a .git directory ...
-git_dir=$(cd "$orig_git" 2>/dev/null &&
- git rev-parse --git-dir 2>/dev/null) ||
- die "Not a git repository: \"$orig_git\""
-
-case "$git_dir" in
-.git)
- git_dir="$orig_git/.git"
- ;;
-.)
- git_dir=$orig_git
- ;;
-esac
-
-# don't link to a configured bare repository
-isbare=$(git --git-dir="$git_dir" config --bool --get core.bare)
-if test ztrue = "z$isbare"
-then
- die "\"$git_dir\" has core.bare set to true," \
- " remove from \"$git_dir/config\" to use $0"
-fi
-
-# don't link to a workdir
-if test -h "$git_dir/config"
-then
- die "\"$orig_git\" is a working directory only, please specify" \
- "a complete repository."
-fi
-
-# make sure the links in the workdir have full paths to the original repo
-git_dir=$(cd "$git_dir" && pwd) || exit 1
-
-# don't recreate a workdir over an existing directory, unless it's empty
-if test -d "$new_workdir"
-then
- if test $(ls -a1 "$new_workdir/." | wc -l) -ne 2
- then
- die "destination directory '$new_workdir' is not empty."
- fi
- cleandir="$new_workdir/.git"
-else
- cleandir="$new_workdir"
-fi
-
-mkdir -p "$new_workdir/.git" || failed
-cleandir=$(cd "$cleandir" && pwd) || failed
-
-cleanup () {
- rm -rf "$cleandir"
-}
-siglist="0 1 2 15"
-trap cleanup $siglist
-
-# create the links to the original repo. explicitly exclude index, HEAD and
-# logs/HEAD from the list since they are purely related to the current working
-# directory, and should not be shared.
-for x in config refs logs/refs objects info hooks packed-refs remotes rr-cache svn reftable
-do
- # create a containing directory if needed
- case $x in
- */*)
- mkdir -p "$new_workdir/.git/${x%/*}"
- ;;
- esac
-
- ln -s "$git_dir/$x" "$new_workdir/.git/$x" || failed
-done
-
-# commands below this are run in the context of the new workdir
-cd "$new_workdir" || failed
-
-# copy the HEAD from the original repository as a default branch
-cp "$git_dir/HEAD" .git/HEAD || failed
-
-# the workdir is set up. if the checkout fails, the user can fix it.
-trap - $siglist
-
-# checkout the branch (either the same as HEAD from the original repository,
-# or the one that was asked for)
-git checkout -f $branch