From 43b1791ec601732ac31195df96781a848360a9ac Mon Sep 17 00:00:00 2001 From: Vincent Ambo Date: Tue, 21 Sep 2021 13:03:01 +0300 Subject: chore(3p/git): Unvendor git and track patches instead This was vendored a long time ago under the expectation that keeping it in sync with cgit would be easier this way, but it has proven not to be a big issue. On the other hand, a vendored copy of git is an annoying maintenance burden. It is much easier to rebase the single (dottime) patch that we have. This removes the vendored copy of git and instead passes the git source code to cgit via `pkgs.srcOnly`, which includes the applied patch so that cgit can continue rendering dottime. Change-Id: If31f62dea7ce688fd1b9050204e9378019775f2b --- third_party/git/contrib/README | 43 - .../git/contrib/buildsystems/CMakeLists.txt | 988 ----- third_party/git/contrib/buildsystems/Generators.pm | 42 - .../git/contrib/buildsystems/Generators/QMake.pm | 189 - .../git/contrib/buildsystems/Generators/Vcproj.pm | 579 --- .../git/contrib/buildsystems/Generators/Vcxproj.pm | 393 -- third_party/git/contrib/buildsystems/engine.pl | 394 -- third_party/git/contrib/buildsystems/generate | 29 - third_party/git/contrib/buildsystems/parse.pl | 228 - third_party/git/contrib/coccinelle/.gitignore | 1 - third_party/git/contrib/coccinelle/README | 43 - third_party/git/contrib/coccinelle/array.cocci | 90 - third_party/git/contrib/coccinelle/commit.cocci | 52 - .../git/contrib/coccinelle/flex_alloc.cocci | 13 - third_party/git/contrib/coccinelle/free.cocci | 18 - third_party/git/contrib/coccinelle/hashmap.cocci | 16 - third_party/git/contrib/coccinelle/object_id.cocci | 87 - third_party/git/contrib/coccinelle/preincr.cocci | 5 - third_party/git/contrib/coccinelle/qsort.cocci | 37 - third_party/git/contrib/coccinelle/strbuf.cocci | 62 - third_party/git/contrib/coccinelle/swap.cocci | 28 - .../coccinelle/the_repository.pending.cocci | 144 - .../git/contrib/coccinelle/xstrdup_or_null.cocci | 13 - third_party/git/contrib/completion/.gitattributes | 1 - .../git/contrib/completion/git-completion.bash | 3585 ---------------- .../git/contrib/completion/git-completion.tcsh | 126 - .../git/contrib/completion/git-completion.zsh | 246 -- third_party/git/contrib/completion/git-prompt.sh | 582 --- third_party/git/contrib/contacts/.gitignore | 3 - third_party/git/contrib/contacts/Makefile | 71 - third_party/git/contrib/contacts/git-contacts | 203 - third_party/git/contrib/contacts/git-contacts.txt | 94 - third_party/git/contrib/coverage-diff.sh | 108 - .../contrib/credential/gnome-keyring/.gitignore | 1 - .../git/contrib/credential/gnome-keyring/Makefile | 25 - .../gnome-keyring/git-credential-gnome-keyring.c | 470 --- .../git/contrib/credential/libsecret/Makefile | 25 - .../libsecret/git-credential-libsecret.c | 369 -- .../git/contrib/credential/netrc/.gitignore | 1 - third_party/git/contrib/credential/netrc/Makefile | 30 - .../credential/netrc/git-credential-netrc.perl | 440 -- .../credential/netrc/t-git-credential-netrc.sh | 32 - .../credential/netrc/test.command-option-gpg | 2 - .../contrib/credential/netrc/test.git-config-gpg | 2 - .../git/contrib/credential/netrc/test.netrc | 13 - .../git/contrib/credential/netrc/test.netrc.gpg | 0 third_party/git/contrib/credential/netrc/test.pl | 139 - .../git/contrib/credential/osxkeychain/.gitignore | 1 - .../git/contrib/credential/osxkeychain/Makefile | 17 - .../osxkeychain/git-credential-osxkeychain.c | 183 - .../git/contrib/credential/wincred/Makefile | 22 - .../credential/wincred/git-credential-wincred.c | 327 -- third_party/git/contrib/diff-highlight/.gitignore | 2 - .../git/contrib/diff-highlight/DiffHighlight.pm | 285 -- third_party/git/contrib/diff-highlight/Makefile | 23 - third_party/git/contrib/diff-highlight/README | 223 - .../git/contrib/diff-highlight/diff-highlight.perl | 8 - .../git/contrib/diff-highlight/t/.gitignore | 2 - third_party/git/contrib/diff-highlight/t/Makefile | 22 - .../diff-highlight/t/t9400-diff-highlight.sh | 341 -- third_party/git/contrib/emacs/README | 33 - third_party/git/contrib/emacs/git-blame.el | 6 - third_party/git/contrib/emacs/git.el | 6 - third_party/git/contrib/examples/README | 20 - .../git/contrib/fast-import/git-import.perl | 64 - third_party/git/contrib/fast-import/git-import.sh | 38 - third_party/git/contrib/fast-import/git-p4.README | 12 - .../contrib/fast-import/import-directories.perl | 416 -- .../git/contrib/fast-import/import-tars.perl | 227 - third_party/git/contrib/fast-import/import-zips.py | 78 - third_party/git/contrib/git-jump/README | 112 - third_party/git/contrib/git-jump/git-jump | 78 - third_party/git/contrib/git-resurrect.sh | 182 - third_party/git/contrib/git-shell-commands/README | 18 - third_party/git/contrib/git-shell-commands/help | 18 - third_party/git/contrib/git-shell-commands/list | 10 - third_party/git/contrib/hg-to-git/hg-to-git.py | 254 -- third_party/git/contrib/hg-to-git/hg-to-git.txt | 21 - third_party/git/contrib/hooks/multimail/CHANGES | 285 -- .../git/contrib/hooks/multimail/CONTRIBUTING.rst | 60 - third_party/git/contrib/hooks/multimail/README.Git | 15 - .../README.migrate-from-post-receive-email | 145 - third_party/git/contrib/hooks/multimail/README.rst | 774 ---- .../hooks/multimail/doc/customizing-emails.rst | 56 - .../git/contrib/hooks/multimail/doc/gerrit.rst | 56 - .../git/contrib/hooks/multimail/doc/gitolite.rst | 118 - .../hooks/multimail/doc/troubleshooting.rst | 78 - .../git/contrib/hooks/multimail/git_multimail.py | 4346 -------------------- .../hooks/multimail/migrate-mailhook-config | 274 -- .../contrib/hooks/multimail/post-receive.example | 101 - third_party/git/contrib/hooks/post-receive-email | 759 ---- third_party/git/contrib/hooks/pre-auto-gc-battery | 42 - third_party/git/contrib/hooks/setgitperms.perl | 214 - third_party/git/contrib/hooks/update-paranoid | 421 -- .../git/contrib/long-running-filter/example.pl | 132 - third_party/git/contrib/mw-to-git/.gitignore | 2 - third_party/git/contrib/mw-to-git/.perlcriticrc | 28 - third_party/git/contrib/mw-to-git/Git/Mediawiki.pm | 101 - third_party/git/contrib/mw-to-git/Makefile | 58 - third_party/git/contrib/mw-to-git/bin-wrapper/git | 14 - third_party/git/contrib/mw-to-git/git-mw.perl | 368 -- .../contrib/mw-to-git/git-remote-mediawiki.perl | 1390 ------- .../git/contrib/mw-to-git/git-remote-mediawiki.txt | 7 - third_party/git/contrib/mw-to-git/t/.gitignore | 4 - third_party/git/contrib/mw-to-git/t/Makefile | 31 - third_party/git/contrib/mw-to-git/t/README | 124 - .../git/contrib/mw-to-git/t/install-wiki.sh | 55 - .../git/contrib/mw-to-git/t/push-pull-tests.sh | 144 - .../contrib/mw-to-git/t/t9360-mw-to-git-clone.sh | 257 -- .../mw-to-git/t/t9361-mw-to-git-push-pull.sh | 24 - .../contrib/mw-to-git/t/t9362-mw-to-git-utf8.sh | 347 -- .../mw-to-git/t/t9363-mw-to-git-export-import.sh | 218 - .../git/contrib/mw-to-git/t/t9364-pull-by-rev.sh | 17 - .../mw-to-git/t/t9365-continuing-queries.sh | 23 - .../git/contrib/mw-to-git/t/test-gitmw-lib.sh | 432 -- third_party/git/contrib/mw-to-git/t/test-gitmw.pl | 223 - third_party/git/contrib/mw-to-git/t/test.config | 40 - third_party/git/contrib/persistent-https/LICENSE | 202 - third_party/git/contrib/persistent-https/Makefile | 40 - third_party/git/contrib/persistent-https/README | 72 - third_party/git/contrib/persistent-https/client.go | 189 - third_party/git/contrib/persistent-https/main.go | 82 - third_party/git/contrib/persistent-https/proxy.go | 190 - third_party/git/contrib/persistent-https/socket.go | 97 - third_party/git/contrib/remote-helpers/README | 15 - .../git/contrib/remote-helpers/git-remote-bzr | 11 - .../git/contrib/remote-helpers/git-remote-hg | 11 - third_party/git/contrib/remotes2config.sh | 33 - third_party/git/contrib/rerere-train.sh | 102 - third_party/git/contrib/stats/git-common-hash | 26 - third_party/git/contrib/stats/mailmap.pl | 70 - third_party/git/contrib/stats/packinfo.pl | 212 - third_party/git/contrib/subtree/.gitignore | 7 - third_party/git/contrib/subtree/COPYING | 339 -- third_party/git/contrib/subtree/INSTALL | 28 - third_party/git/contrib/subtree/Makefile | 103 - third_party/git/contrib/subtree/README | 8 - third_party/git/contrib/subtree/git-subtree.sh | 901 ---- third_party/git/contrib/subtree/git-subtree.txt | 351 -- third_party/git/contrib/subtree/t/Makefile | 86 - third_party/git/contrib/subtree/t/t7900-subtree.sh | 1034 ----- third_party/git/contrib/subtree/todo | 48 - .../git/contrib/thunderbird-patch-inline/README | 20 - .../git/contrib/thunderbird-patch-inline/appp.sh | 55 - third_party/git/contrib/update-unicode/.gitignore | 3 - third_party/git/contrib/update-unicode/README | 20 - .../git/contrib/update-unicode/update_unicode.sh | 33 - third_party/git/contrib/vscode/.gitattributes | 1 - third_party/git/contrib/vscode/README.md | 14 - third_party/git/contrib/vscode/init.sh | 375 -- third_party/git/contrib/workdir/.gitattributes | 1 - third_party/git/contrib/workdir/git-new-workdir | 105 - 152 files changed, 29778 deletions(-) delete mode 100644 third_party/git/contrib/README delete mode 100644 third_party/git/contrib/buildsystems/CMakeLists.txt delete mode 100644 third_party/git/contrib/buildsystems/Generators.pm delete mode 100644 third_party/git/contrib/buildsystems/Generators/QMake.pm delete mode 100644 third_party/git/contrib/buildsystems/Generators/Vcproj.pm delete mode 100644 third_party/git/contrib/buildsystems/Generators/Vcxproj.pm delete mode 100755 third_party/git/contrib/buildsystems/engine.pl delete mode 100755 third_party/git/contrib/buildsystems/generate delete mode 100755 third_party/git/contrib/buildsystems/parse.pl delete mode 100644 third_party/git/contrib/coccinelle/.gitignore delete mode 100644 third_party/git/contrib/coccinelle/README delete mode 100644 third_party/git/contrib/coccinelle/array.cocci delete mode 100644 third_party/git/contrib/coccinelle/commit.cocci delete mode 100644 third_party/git/contrib/coccinelle/flex_alloc.cocci delete mode 100644 third_party/git/contrib/coccinelle/free.cocci delete mode 100644 third_party/git/contrib/coccinelle/hashmap.cocci delete mode 100644 third_party/git/contrib/coccinelle/object_id.cocci delete mode 100644 third_party/git/contrib/coccinelle/preincr.cocci delete mode 100644 third_party/git/contrib/coccinelle/qsort.cocci delete mode 100644 third_party/git/contrib/coccinelle/strbuf.cocci delete mode 100644 third_party/git/contrib/coccinelle/swap.cocci delete mode 100644 third_party/git/contrib/coccinelle/the_repository.pending.cocci delete mode 100644 third_party/git/contrib/coccinelle/xstrdup_or_null.cocci delete mode 100644 third_party/git/contrib/completion/.gitattributes delete mode 100644 third_party/git/contrib/completion/git-completion.bash delete mode 100644 third_party/git/contrib/completion/git-completion.tcsh delete mode 100644 third_party/git/contrib/completion/git-completion.zsh delete mode 100644 third_party/git/contrib/completion/git-prompt.sh delete mode 100644 third_party/git/contrib/contacts/.gitignore delete mode 100644 third_party/git/contrib/contacts/Makefile delete mode 100755 third_party/git/contrib/contacts/git-contacts delete mode 100644 third_party/git/contrib/contacts/git-contacts.txt delete mode 100755 third_party/git/contrib/coverage-diff.sh delete mode 100644 third_party/git/contrib/credential/gnome-keyring/.gitignore delete mode 100644 third_party/git/contrib/credential/gnome-keyring/Makefile delete mode 100644 third_party/git/contrib/credential/gnome-keyring/git-credential-gnome-keyring.c delete mode 100644 third_party/git/contrib/credential/libsecret/Makefile delete mode 100644 third_party/git/contrib/credential/libsecret/git-credential-libsecret.c delete mode 100644 third_party/git/contrib/credential/netrc/.gitignore delete mode 100644 third_party/git/contrib/credential/netrc/Makefile delete mode 100755 third_party/git/contrib/credential/netrc/git-credential-netrc.perl delete mode 100755 third_party/git/contrib/credential/netrc/t-git-credential-netrc.sh delete mode 100755 third_party/git/contrib/credential/netrc/test.command-option-gpg delete mode 100755 third_party/git/contrib/credential/netrc/test.git-config-gpg delete mode 100644 third_party/git/contrib/credential/netrc/test.netrc delete mode 100644 third_party/git/contrib/credential/netrc/test.netrc.gpg delete mode 100755 third_party/git/contrib/credential/netrc/test.pl delete mode 100644 third_party/git/contrib/credential/osxkeychain/.gitignore delete mode 100644 third_party/git/contrib/credential/osxkeychain/Makefile delete mode 100644 third_party/git/contrib/credential/osxkeychain/git-credential-osxkeychain.c delete mode 100644 third_party/git/contrib/credential/wincred/Makefile delete mode 100644 third_party/git/contrib/credential/wincred/git-credential-wincred.c delete mode 100644 third_party/git/contrib/diff-highlight/.gitignore delete mode 100644 third_party/git/contrib/diff-highlight/DiffHighlight.pm delete mode 100644 third_party/git/contrib/diff-highlight/Makefile delete mode 100644 third_party/git/contrib/diff-highlight/README delete mode 100644 third_party/git/contrib/diff-highlight/diff-highlight.perl delete mode 100644 third_party/git/contrib/diff-highlight/t/.gitignore delete mode 100644 third_party/git/contrib/diff-highlight/t/Makefile delete mode 100755 third_party/git/contrib/diff-highlight/t/t9400-diff-highlight.sh delete mode 100644 third_party/git/contrib/emacs/README delete mode 100644 third_party/git/contrib/emacs/git-blame.el delete mode 100644 third_party/git/contrib/emacs/git.el delete mode 100644 third_party/git/contrib/examples/README delete mode 100755 third_party/git/contrib/fast-import/git-import.perl delete mode 100755 third_party/git/contrib/fast-import/git-import.sh delete mode 100644 third_party/git/contrib/fast-import/git-p4.README delete mode 100755 third_party/git/contrib/fast-import/import-directories.perl delete mode 100755 third_party/git/contrib/fast-import/import-tars.perl delete mode 100755 third_party/git/contrib/fast-import/import-zips.py delete mode 100644 third_party/git/contrib/git-jump/README delete mode 100755 third_party/git/contrib/git-jump/git-jump delete mode 100755 third_party/git/contrib/git-resurrect.sh delete mode 100644 third_party/git/contrib/git-shell-commands/README delete mode 100755 third_party/git/contrib/git-shell-commands/help delete mode 100755 third_party/git/contrib/git-shell-commands/list delete mode 100755 third_party/git/contrib/hg-to-git/hg-to-git.py delete mode 100644 third_party/git/contrib/hg-to-git/hg-to-git.txt delete mode 100644 third_party/git/contrib/hooks/multimail/CHANGES delete mode 100644 third_party/git/contrib/hooks/multimail/CONTRIBUTING.rst delete mode 100644 third_party/git/contrib/hooks/multimail/README.Git delete mode 100644 third_party/git/contrib/hooks/multimail/README.migrate-from-post-receive-email delete mode 100644 third_party/git/contrib/hooks/multimail/README.rst delete mode 100644 third_party/git/contrib/hooks/multimail/doc/customizing-emails.rst delete mode 100644 third_party/git/contrib/hooks/multimail/doc/gerrit.rst delete mode 100644 third_party/git/contrib/hooks/multimail/doc/gitolite.rst delete mode 100644 third_party/git/contrib/hooks/multimail/doc/troubleshooting.rst delete mode 100755 third_party/git/contrib/hooks/multimail/git_multimail.py delete mode 100755 third_party/git/contrib/hooks/multimail/migrate-mailhook-config delete mode 100755 third_party/git/contrib/hooks/multimail/post-receive.example delete mode 100755 third_party/git/contrib/hooks/post-receive-email delete mode 100755 third_party/git/contrib/hooks/pre-auto-gc-battery delete mode 100755 third_party/git/contrib/hooks/setgitperms.perl delete mode 100755 third_party/git/contrib/hooks/update-paranoid delete mode 100755 third_party/git/contrib/long-running-filter/example.pl delete mode 100644 third_party/git/contrib/mw-to-git/.gitignore delete mode 100644 third_party/git/contrib/mw-to-git/.perlcriticrc delete mode 100644 third_party/git/contrib/mw-to-git/Git/Mediawiki.pm delete mode 100644 third_party/git/contrib/mw-to-git/Makefile delete mode 100755 third_party/git/contrib/mw-to-git/bin-wrapper/git delete mode 100755 third_party/git/contrib/mw-to-git/git-mw.perl delete mode 100755 third_party/git/contrib/mw-to-git/git-remote-mediawiki.perl delete mode 100644 third_party/git/contrib/mw-to-git/git-remote-mediawiki.txt delete mode 100644 third_party/git/contrib/mw-to-git/t/.gitignore delete mode 100644 third_party/git/contrib/mw-to-git/t/Makefile delete mode 100644 third_party/git/contrib/mw-to-git/t/README delete mode 100755 third_party/git/contrib/mw-to-git/t/install-wiki.sh delete mode 100644 third_party/git/contrib/mw-to-git/t/push-pull-tests.sh delete mode 100755 third_party/git/contrib/mw-to-git/t/t9360-mw-to-git-clone.sh delete mode 100755 third_party/git/contrib/mw-to-git/t/t9361-mw-to-git-push-pull.sh delete mode 100755 third_party/git/contrib/mw-to-git/t/t9362-mw-to-git-utf8.sh delete mode 100755 third_party/git/contrib/mw-to-git/t/t9363-mw-to-git-export-import.sh delete mode 100755 third_party/git/contrib/mw-to-git/t/t9364-pull-by-rev.sh delete mode 100755 third_party/git/contrib/mw-to-git/t/t9365-continuing-queries.sh delete mode 100755 third_party/git/contrib/mw-to-git/t/test-gitmw-lib.sh delete mode 100755 third_party/git/contrib/mw-to-git/t/test-gitmw.pl delete mode 100644 third_party/git/contrib/mw-to-git/t/test.config delete mode 100644 third_party/git/contrib/persistent-https/LICENSE delete mode 100644 third_party/git/contrib/persistent-https/Makefile delete mode 100644 third_party/git/contrib/persistent-https/README delete mode 100644 third_party/git/contrib/persistent-https/client.go delete mode 100644 third_party/git/contrib/persistent-https/main.go delete mode 100644 third_party/git/contrib/persistent-https/proxy.go delete mode 100644 third_party/git/contrib/persistent-https/socket.go delete mode 100644 third_party/git/contrib/remote-helpers/README delete mode 100755 third_party/git/contrib/remote-helpers/git-remote-bzr delete mode 100755 third_party/git/contrib/remote-helpers/git-remote-hg delete mode 100755 third_party/git/contrib/remotes2config.sh delete mode 100755 third_party/git/contrib/rerere-train.sh delete mode 100755 third_party/git/contrib/stats/git-common-hash delete mode 100755 third_party/git/contrib/stats/mailmap.pl delete mode 100755 third_party/git/contrib/stats/packinfo.pl delete mode 100644 third_party/git/contrib/subtree/.gitignore delete mode 100644 third_party/git/contrib/subtree/COPYING delete mode 100644 third_party/git/contrib/subtree/INSTALL delete mode 100644 third_party/git/contrib/subtree/Makefile delete mode 100644 third_party/git/contrib/subtree/README delete mode 100755 third_party/git/contrib/subtree/git-subtree.sh delete mode 100644 third_party/git/contrib/subtree/git-subtree.txt delete mode 100644 third_party/git/contrib/subtree/t/Makefile delete mode 100755 third_party/git/contrib/subtree/t/t7900-subtree.sh delete mode 100644 third_party/git/contrib/subtree/todo delete mode 100644 third_party/git/contrib/thunderbird-patch-inline/README delete mode 100755 third_party/git/contrib/thunderbird-patch-inline/appp.sh delete mode 100644 third_party/git/contrib/update-unicode/.gitignore delete mode 100644 third_party/git/contrib/update-unicode/README delete mode 100755 third_party/git/contrib/update-unicode/update_unicode.sh delete mode 100644 third_party/git/contrib/vscode/.gitattributes delete mode 100644 third_party/git/contrib/vscode/README.md delete mode 100755 third_party/git/contrib/vscode/init.sh delete mode 100644 third_party/git/contrib/workdir/.gitattributes delete mode 100755 third_party/git/contrib/workdir/git-new-workdir (limited to 'third_party/git/contrib') diff --git a/third_party/git/contrib/README b/third_party/git/contrib/README deleted file mode 100644 index 05f291c1f1d3..000000000000 --- a/third_party/git/contrib/README +++ /dev/null @@ -1,43 +0,0 @@ -Contributed Software - -Although these pieces are available as part of the official git -source tree, they are in somewhat different status. The -intention is to keep interesting tools around git here, maybe -even experimental ones, to give users an easier access to them, -and to give tools wider exposure, so that they can be improved -faster. - -I am not expecting to touch these myself that much. As far as -my day-to-day operation is concerned, these subdirectories are -owned by their respective primary authors. I am willing to help -if users of these components and the contrib/ subtree "owners" -have technical/design issues to resolve, but the initiative to -fix and/or enhance things _must_ be on the side of the subtree -owners. IOW, I won't be actively looking for bugs and rooms for -enhancements in them as the git maintainer -- I may only do so -just as one of the users when I want to scratch my own itch. If -you have patches to things in contrib/ area, the patch should be -first sent to the primary author, and then the primary author -should ack and forward it to me (git pull request is nicer). -This is the same way as how I have been treating gitk, and to a -lesser degree various foreign SCM interfaces, so you know the -drill. - -I expect that things that start their life in the contrib/ area -to graduate out of contrib/ once they mature, either by becoming -projects on their own, or moving to the toplevel directory. On -the other hand, I expect I'll be proposing removal of disused -and inactive ones from time to time. - -If you have new things to add to this area, please first propose -it on the git mailing list, and after a list discussion proves -there are some general interests (it does not have to be a -list-wide consensus for a tool targeted to a relatively narrow -audience -- for example I do not work with projects whose -upstream is svn, so I have no use for git-svn myself, but it is -of general interest for people who need to interoperate with SVN -repositories in a way git-svn works better than git-svnimport), -submit a patch to create a subdirectory of contrib/ and put your -stuff there. - --jc diff --git a/third_party/git/contrib/buildsystems/CMakeLists.txt b/third_party/git/contrib/buildsystems/CMakeLists.txt deleted file mode 100644 index df539a44fa0a..000000000000 --- a/third_party/git/contrib/buildsystems/CMakeLists.txt +++ /dev/null @@ -1,988 +0,0 @@ -# -# Copyright (c) 2020 Sibi Siddharthan -# - -#[[ - -Instructions how to use this in Visual Studio: - -Open the worktree as a folder. Visual Studio 2019 and later will detect -the CMake configuration automatically and set everything up for you, -ready to build. You can then run the tests in `t/` via a regular Git Bash. - -Note: Visual Studio also has the option of opening `CMakeLists.txt` -directly; Using this option, Visual Studio will not find the source code, -though, therefore the `File>Open>Folder...` option is preferred. - -Instructions to run CMake manually: - - mkdir -p contrib/buildsystems/out - cd contrib/buildsystems/out - cmake ../ -DCMAKE_BUILD_TYPE=Release - -This will build the git binaries in contrib/buildsystems/out -directory (our top-level .gitignore file knows to ignore contents of -this directory). - -Possible build configurations(-DCMAKE_BUILD_TYPE) with corresponding -compiler flags -Debug : -g -Release: -O3 -RelWithDebInfo : -O2 -g -MinSizeRel : -Os -empty(default) : - -NOTE: -DCMAKE_BUILD_TYPE is optional. For multi-config generators like Visual Studio -this option is ignored - -This process generates a Makefile(Linux/*BSD/MacOS) , Visual Studio solution(Windows) by default. -Run `make` to build Git on Linux/*BSD/MacOS. -Open git.sln on Windows and build Git. - -NOTE: By default CMake uses Makefile as the build tool on Linux and Visual Studio in Windows, -to use another tool say `ninja` add this to the command line when configuring. -`-G Ninja` - -]] -cmake_minimum_required(VERSION 3.14) - -#set the source directory to root of git -set(CMAKE_SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}/../..) -if(WIN32) - set(VCPKG_DIR "${CMAKE_SOURCE_DIR}/compat/vcbuild/vcpkg") - if(MSVC AND NOT EXISTS ${VCPKG_DIR}) - message("Initializing vcpkg and building the Git's dependencies (this will take a while...)") - execute_process(COMMAND ${CMAKE_SOURCE_DIR}/compat/vcbuild/vcpkg_install.bat) - endif() - list(APPEND CMAKE_PREFIX_PATH "${VCPKG_DIR}/installed/x64-windows") - - # In the vcpkg edition, we need this to be able to link to libcurl - set(CURL_NO_CURL_CMAKE ON) -endif() - -find_program(SH_EXE sh PATHS "C:/Program Files/Git/bin") -if(NOT SH_EXE) - message(FATAL_ERROR "sh: shell interpreter was not found in your path, please install one." - "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() - -project(git - VERSION ${git_version} - LANGUAGES C) - - -#TODO gitk git-gui gitweb -#TODO Enable NLS on windows natively -#TODO Add pcre support - -#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} \\+=(.*)") - 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 - string(REPLACE ".o" ".c;" ${list_var} ${${list_var}}) #change .o to .c, ; is for converting the string into a list - list(TRANSFORM ${list_var} STRIP) #remove trailing/leading whitespaces for each element in list - list(REMOVE_ITEM ${list_var} "") #remove empty list elements -endmacro() - -macro(parse_makefile_for_scripts list_var regex lang) - file(STRINGS ${CMAKE_SOURCE_DIR}/Makefile ${list_var} REGEX "^${regex} \\+=(.*)") - string(REPLACE "${regex} +=" "" ${list_var} ${${list_var}}) - string(STRIP ${${list_var}} ${list_var}) #remove trailing/leading whitespaces - string(REPLACE " " ";" ${list_var} ${${list_var}}) #convert string to a list - if(NOT ${lang}) #exclude for SCRIPT_LIB - list(TRANSFORM ${list_var} REPLACE "${lang}" "") #do the replacement - endif() -endmacro() - -include(CheckTypeSize) -include(CheckCSourceRuns) -include(CheckCSourceCompiles) -include(CheckIncludeFile) -include(CheckFunctionExists) -include(CheckSymbolExists) -include(CheckStructHasMember) -include(CTest) - -find_package(ZLIB REQUIRED) -find_package(CURL) -find_package(EXPAT) -find_package(Iconv) - -#Don't use libintl on Windows Visual Studio and Clang builds -if(NOT (WIN32 AND (CMAKE_C_COMPILER_ID STREQUAL "MSVC" OR CMAKE_C_COMPILER_ID STREQUAL "Clang"))) - find_package(Intl) -endif() - -if(NOT Intl_FOUND) - add_compile_definitions(NO_GETTEXT) - if(NOT Iconv_FOUND) - add_compile_definitions(NO_ICONV) - endif() -endif() - -include_directories(SYSTEM ${ZLIB_INCLUDE_DIRS}) -if(CURL_FOUND) - include_directories(SYSTEM ${CURL_INCLUDE_DIRS}) -endif() -if(EXPAT_FOUND) - include_directories(SYSTEM ${EXPAT_INCLUDE_DIRS}) -endif() -if(Iconv_FOUND) - include_directories(SYSTEM ${Iconv_INCLUDE_DIRS}) -endif() -if(Intl_FOUND) - include_directories(SYSTEM ${Intl_INCLUDE_DIRS}) -endif() - - -if(WIN32 AND NOT MSVC)#not required for visual studio builds - find_program(WINDRES_EXE windres) - if(NOT WINDRES_EXE) - message(FATAL_ERROR "Install windres on Windows for resource files") - endif() -endif() - -find_program(MSGFMT_EXE msgfmt) -if(NOT MSGFMT_EXE) - set(MSGFMT_EXE ${CMAKE_SOURCE_DIR}/compat/vcbuild/vcpkg/downloads/tools/msys2/msys64/usr/bin/msgfmt.exe) - if(NOT EXISTS ${MSGFMT_EXE}) - message(WARNING "Text Translations won't be built") - unset(MSGFMT_EXE) - endif() -endif() - -#Force all visual studio outputs to CMAKE_BINARY_DIR -if(CMAKE_C_COMPILER_ID STREQUAL "MSVC") - set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG ${CMAKE_BINARY_DIR}) - set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE ${CMAKE_BINARY_DIR}) - add_compile_options(/MP) -endif() - -#default behaviour -include_directories(${CMAKE_SOURCE_DIR}) -add_compile_definitions(GIT_HOST_CPU="${CMAKE_SYSTEM_PROCESSOR}") -add_compile_definitions(SHA256_BLK INTERNAL_QSORT RUNTIME_PREFIX) -add_compile_definitions(NO_OPENSSL SHA1_DC SHA1DC_NO_STANDARD_INCLUDES - SHA1DC_INIT_SAFE_HASH_DEFAULT=0 - SHA1DC_CUSTOM_INCLUDE_SHA1_C="cache.h" - SHA1DC_CUSTOM_INCLUDE_UBC_CHECK_C="git-compat-util.h" ) -list(APPEND compat_SOURCES sha1dc_git.c sha1dc/sha1.c sha1dc/ubc_check.c block-sha1/sha1.c sha256/block/sha256.c compat/qsort_s.c) - - -add_compile_definitions(PAGER_ENV="LESS=FRX LV=-c" - ETC_GITATTRIBUTES="etc/gitattributes" - ETC_GITCONFIG="etc/gitconfig" - GIT_EXEC_PATH="libexec/git-core" - GIT_LOCALE_PATH="share/locale" - GIT_MAN_PATH="share/man" - GIT_INFO_PATH="share/info" - 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="") - -if(WIN32) - set(FALLBACK_RUNTIME_PREFIX /mingw64) - add_compile_definitions(FALLBACK_RUNTIME_PREFIX="${FALLBACK_RUNTIME_PREFIX}") -else() - set(FALLBACK_RUNTIME_PREFIX /home/$ENV{USER}) - add_compile_definitions(FALLBACK_RUNTIME_PREFIX="${FALLBACK_RUNTIME_PREFIX}") -endif() - - -#Platform Specific -if(CMAKE_SYSTEM_NAME STREQUAL "Windows") - if(CMAKE_C_COMPILER_ID STREQUAL "MSVC" OR CMAKE_C_COMPILER_ID STREQUAL "Clang") - include_directories(${CMAKE_SOURCE_DIR}/compat/vcbuild/include) - add_compile_definitions(_CRT_SECURE_NO_WARNINGS _CRT_NONSTDC_NO_DEPRECATE) - endif() - include_directories(${CMAKE_SOURCE_DIR}/compat/win32) - add_compile_definitions(HAVE_ALLOCA_H NO_POSIX_GOODIES NATIVE_CRLF NO_UNIX_SOCKETS WIN32 - _CONSOLE DETECT_MSYS_TTY STRIP_EXTENSION=".exe" NO_SYMLINK_HEAD UNRELIABLE_FSTAT - NOGDI OBJECT_CREATION_MODE=1 __USE_MINGW_ANSI_STDIO=0 - USE_NED_ALLOCATOR OVERRIDE_STRDUP MMAP_PREVENTS_DELETE USE_WIN32_MMAP - UNICODE _UNICODE HAVE_WPGMPTR ENSURE_MSYSTEM_IS_SET) - list(APPEND compat_SOURCES compat/mingw.c compat/winansi.c compat/win32/path-utils.c - compat/win32/pthread.c compat/win32mmap.c compat/win32/syslog.c - compat/win32/trace2_win32_process_info.c compat/win32/dirent.c - compat/nedmalloc/nedmalloc.c compat/strdup.c) - set(NO_UNIX_SOCKETS 1) - -elseif(CMAKE_SYSTEM_NAME STREQUAL "Linux") - add_compile_definitions(PROCFS_EXECUTABLE_PATH="/proc/self/exe" HAVE_DEV_TTY ) - list(APPEND compat_SOURCES unix-socket.c) -endif() - -set(EXE_EXTENSION ${CMAKE_EXECUTABLE_SUFFIX}) - -#header checks -check_include_file(libgen.h HAVE_LIBGEN_H) -if(NOT HAVE_LIBGEN_H) - add_compile_definitions(NO_LIBGEN_H) - list(APPEND compat_SOURCES compat/basename.c) -endif() - -check_include_file(sys/sysinfo.h HAVE_SYSINFO) -if(HAVE_SYSINFO) - add_compile_definitions(HAVE_SYSINFO) -endif() - -check_c_source_compiles(" -#include - -int main(void) -{ - char *p = (char *) alloca(2 * sizeof(int)); - - if (p) - return 0; - return 0; -}" -HAVE_ALLOCA_H) -if(HAVE_ALLOCA_H) - add_compile_definitions(HAVE_ALLOCA_H) -endif() - -check_include_file(strings.h HAVE_STRINGS_H) -if(HAVE_STRINGS_H) - add_compile_definitions(HAVE_STRINGS_H) -endif() - -check_include_file(sys/select.h HAVE_SYS_SELECT_H) -if(NOT HAVE_SYS_SELECT_H) - add_compile_definitions(NO_SYS_SELECT_H) -endif() - -check_include_file(sys/poll.h HAVE_SYS_POLL_H) -if(NOT HAVE_SYS_POLL_H) - add_compile_definitions(NO_SYS_POLL_H) -endif() - -check_include_file(poll.h HAVE_POLL_H) -if(NOT HAVE_POLL_H) - add_compile_definitions(NO_POLL_H) -endif() - -check_include_file(inttypes.h HAVE_INTTYPES_H) -if(NOT HAVE_INTTYPES_H) - add_compile_definitions(NO_INTTYPES_H) -endif() - -check_include_file(paths.h HAVE_PATHS_H) -if(HAVE_PATHS_H) - add_compile_definitions(HAVE_PATHS_H) -endif() - -#function checks -set(function_checks - strcasestr memmem strlcpy strtoimax strtoumax strtoull - setenv mkdtemp poll pread memmem) - -#unsetenv,hstrerror are incompatible with windows build -if(NOT WIN32) - list(APPEND function_checks unsetenv hstrerror) -endif() - -foreach(f ${function_checks}) - string(TOUPPER ${f} uf) - check_function_exists(${f} HAVE_${uf}) - if(NOT HAVE_${uf}) - add_compile_definitions(NO_${uf}) - endif() -endforeach() - -if(NOT HAVE_POLL_H OR NOT HAVE_SYS_POLL_H OR NOT HAVE_POLL) - include_directories(${CMAKE_SOURCE_DIR}/compat/poll) - add_compile_definitions(NO_POLL) - list(APPEND compat_SOURCES compat/poll/poll.c) -endif() - -if(NOT HAVE_STRCASESTR) - list(APPEND compat_SOURCES compat/strcasestr.c) -endif() - -if(NOT HAVE_STRLCPY) - list(APPEND compat_SOURCES compat/strlcpy.c) -endif() - -if(NOT HAVE_STRTOUMAX) - list(APPEND compat_SOURCES compat/strtoumax.c compat/strtoimax.c) -endif() - -if(NOT HAVE_SETENV) - list(APPEND compat_SOURCES compat/setenv.c) -endif() - -if(NOT HAVE_MKDTEMP) - list(APPEND compat_SOURCES compat/mkdtemp.c) -endif() - -if(NOT HAVE_PREAD) - list(APPEND compat_SOURCES compat/pread.c) -endif() - -if(NOT HAVE_MEMMEM) - list(APPEND compat_SOURCES compat/memmem.c) -endif() - -if(NOT WIN32) - if(NOT HAVE_UNSETENV) - list(APPEND compat_SOURCES compat/unsetenv.c) - endif() - - if(NOT HAVE_HSTRERROR) - list(APPEND compat_SOURCES compat/hstrerror.c) - endif() -endif() - -check_function_exists(getdelim HAVE_GETDELIM) -if(HAVE_GETDELIM) - add_compile_definitions(HAVE_GETDELIM) -endif() - -check_function_exists(clock_gettime HAVE_CLOCK_GETTIME) -check_symbol_exists(CLOCK_MONOTONIC "time.h" HAVE_CLOCK_MONOTONIC) -if(HAVE_CLOCK_GETTIME) - add_compile_definitions(HAVE_CLOCK_GETTIME) -endif() -if(HAVE_CLOCK_MONOTONIC) - add_compile_definitions(HAVE_CLOCK_MONOTONIC) -endif() - -#check for st_blocks in struct stat -check_struct_has_member("struct stat" st_blocks "sys/stat.h" STRUCT_STAT_HAS_ST_BLOCKS) -if(NOT STRUCT_STAT_HAS_ST_BLOCKS) - add_compile_definitions(NO_ST_BLOCKS_IN_STRUCT_STAT) -endif() - -#compile checks -check_c_source_runs(" -#include -#include -#include -#include - -int test_vsnprintf(char *str, size_t maxsize, const char *format, ...) -{ - int ret; - va_list ap; - - va_start(ap, format); - ret = vsnprintf(str, maxsize, format, ap); - va_end(ap); - return ret; -} - -int main(void) -{ - char buf[6]; - - if (test_vsnprintf(buf, 3, \"%s\", \"12345\") != 5 - || strcmp(buf, \"12\")) - return 1; - if (snprintf(buf, 3, \"%s\", \"12345\") != 5 - || strcmp(buf, \"12\")) - return 1; - return 0; -}" -SNPRINTF_OK) -if(NOT SNPRINTF_OK) - add_compile_definitions(SNPRINTF_RETURNS_BOGUS) - list(APPEND compat_SOURCES compat/snprintf.c) -endif() - -check_c_source_runs(" -#include - -int main(void) -{ - FILE *f = fopen(\".\", \"r\"); - - return f != NULL; -}" -FREAD_READS_DIRECTORIES_NO) -if(NOT FREAD_READS_DIRECTORIES_NO) - add_compile_definitions(FREAD_READS_DIRECTORIES) - list(APPEND compat_SOURCES compat/fopen.c) -endif() - -check_c_source_compiles(" -#include -#ifndef REG_STARTEND -#error oops we dont have it -#endif - -int main(void) -{ - return 0; -}" -HAVE_REGEX) -if(NOT HAVE_REGEX) - include_directories(${CMAKE_SOURCE_DIR}/compat/regex) - list(APPEND compat_SOURCES compat/regex/regex.c ) - add_compile_definitions(NO_REGEX NO_MBSUPPORT GAWK) -endif() - - -check_c_source_compiles(" -#include -#include -#include - -int main(void) -{ - int val, mib[2]; - size_t len; - - mib[0] = CTL_HW; - mib[1] = 1; - len = sizeof(val); - return sysctl(mib, 2, &val, &len, NULL, 0) ? 1 : 0; -}" -HAVE_BSD_SYSCTL) -if(HAVE_BSD_SYSCTL) - add_compile_definitions(HAVE_BSD_SYSCTL) -endif() - -set(CMAKE_REQUIRED_LIBRARIES ${Iconv_LIBRARIES}) -set(CMAKE_REQUIRED_INCLUDES ${Iconv_INCLUDE_DIRS}) - -check_c_source_compiles(" -#include - -extern size_t iconv(iconv_t cd, - char **inbuf, size_t *inbytesleft, - char **outbuf, size_t *outbytesleft); - -int main(void) -{ - return 0; -}" -HAVE_NEW_ICONV) -if(HAVE_NEW_ICONV) - set(HAVE_OLD_ICONV 0) -else() - set(HAVE_OLD_ICONV 1) -endif() - -check_c_source_runs(" -#include -#if ${HAVE_OLD_ICONV} -typedef const char *iconv_ibp; -#else -typedef char *iconv_ibp; -#endif - -int main(void) -{ - int v; - iconv_t conv; - char in[] = \"a\"; - iconv_ibp pin = in; - char out[20] = \"\"; - char *pout = out; - size_t isz = sizeof(in); - size_t osz = sizeof(out); - - conv = iconv_open(\"UTF-16\", \"UTF-8\"); - iconv(conv, &pin, &isz, &pout, &osz); - iconv_close(conv); - v = (unsigned char)(out[0]) + (unsigned char)(out[1]); - return v != 0xfe + 0xff; -}" -ICONV_DOESNOT_OMIT_BOM) -if(NOT ICONV_DOESNOT_OMIT_BOM) - add_compile_definitions(ICONV_OMITS_BOM) -endif() - -unset(CMAKE_REQUIRED_LIBRARIES) -unset(CMAKE_REQUIRED_INCLUDES) - - -#programs -set(PROGRAMS_BUILT - git git-daemon git-http-backend git-sh-i18n--envsubst - git-shell) - -if(NOT CURL_FOUND) - list(APPEND excluded_progs git-http-fetch git-http-push) - add_compile_definitions(NO_CURL) - message(WARNING "git-http-push and git-http-fetch will not be built") -else() - list(APPEND PROGRAMS_BUILT git-http-fetch git-http-push git-imap-send git-remote-http) - if(CURL_VERSION_STRING VERSION_GREATER_EQUAL 7.34.0) - add_compile_definitions(USE_CURL_FOR_IMAP_SEND) - endif() -endif() - -if(NOT EXPAT_FOUND) - list(APPEND excluded_progs git-http-push) - add_compile_definitions(NO_EXPAT) -else() - list(APPEND PROGRAMS_BUILT git-http-push) - if(EXPAT_VERSION_STRING VERSION_LESS_EQUAL 1.2) - add_compile_definitions(EXPAT_NEEDS_XMLPARSE_H) - endif() -endif() - -list(REMOVE_DUPLICATES excluded_progs) -list(REMOVE_DUPLICATES PROGRAMS_BUILT) - - -foreach(p ${excluded_progs}) - list(APPEND EXCLUSION_PROGS --exclude-program ${p} ) -endforeach() - -#for comparing null values -list(APPEND EXCLUSION_PROGS empty) -set(EXCLUSION_PROGS_CACHE ${EXCLUSION_PROGS} CACHE STRING "Programs not built" FORCE) - -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) -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) -endif() - -include_directories(${CMAKE_BINARY_DIR}) - -#build -#libgit -parse_makefile_for_sources(libgit_SOURCES "LIB_OBJS") - -list(TRANSFORM libgit_SOURCES PREPEND "${CMAKE_SOURCE_DIR}/") -list(TRANSFORM compat_SOURCES PREPEND "${CMAKE_SOURCE_DIR}/") -add_library(libgit ${libgit_SOURCES} ${compat_SOURCES}) - -#libxdiff -parse_makefile_for_sources(libxdiff_SOURCES "XDIFF_OBJS") - -list(TRANSFORM libxdiff_SOURCES PREPEND "${CMAKE_SOURCE_DIR}/") -add_library(xdiff STATIC ${libxdiff_SOURCES}) - -if(WIN32) - 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 - 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 - WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} - VERBATIM) - endif() - add_custom_target(git-rc DEPENDS ${CMAKE_BINARY_DIR}/git.res) -endif() - -#link all required libraries to common-main -add_library(common-main OBJECT ${CMAKE_SOURCE_DIR}/common-main.c) - -target_link_libraries(common-main libgit xdiff ${ZLIB_LIBRARIES}) -if(Intl_FOUND) - target_link_libraries(common-main ${Intl_LIBRARIES}) -endif() -if(Iconv_FOUND) - target_link_libraries(common-main ${Iconv_LIBRARIES}) -endif() -if(WIN32) - target_link_libraries(common-main ws2_32 ntdll ${CMAKE_BINARY_DIR}/git.res) - add_dependencies(common-main git-rc) - if(CMAKE_C_COMPILER_ID STREQUAL "GNU") - target_link_options(common-main PUBLIC -municode -Wl,--nxcompat -Wl,--dynamicbase -Wl,--pic-executable,-e,mainCRTStartup) - elseif(CMAKE_C_COMPILER_ID STREQUAL "Clang") - target_link_options(common-main PUBLIC -municode -Wl,-nxcompat -Wl,-dynamicbase -Wl,-entry:wmainCRTStartup -Wl,invalidcontinue.obj) - elseif(CMAKE_C_COMPILER_ID STREQUAL "MSVC") - target_link_options(common-main PUBLIC /IGNORE:4217 /IGNORE:4049 /NOLOGO /ENTRY:wmainCRTStartup /SUBSYSTEM:CONSOLE invalidcontinue.obj) - else() - message(FATAL_ERROR "Unhandled compiler: ${CMAKE_C_COMPILER_ID}") - endif() -elseif(UNIX) - target_link_libraries(common-main pthread rt) -endif() - -#git -parse_makefile_for_sources(git_SOURCES "BUILTIN_OBJS") - -list(TRANSFORM git_SOURCES PREPEND "${CMAKE_SOURCE_DIR}/") -add_executable(git ${CMAKE_SOURCE_DIR}/git.c ${git_SOURCES}) -target_link_libraries(git common-main) - -add_executable(git-daemon ${CMAKE_SOURCE_DIR}/daemon.c) -target_link_libraries(git-daemon common-main) - -add_executable(git-http-backend ${CMAKE_SOURCE_DIR}/http-backend.c) -target_link_libraries(git-http-backend common-main) - -add_executable(git-sh-i18n--envsubst ${CMAKE_SOURCE_DIR}/sh-i18n--envsubst.c) -target_link_libraries(git-sh-i18n--envsubst common-main) - -add_executable(git-shell ${CMAKE_SOURCE_DIR}/shell.c) -target_link_libraries(git-shell common-main) - -if(CURL_FOUND) - add_library(http_obj OBJECT ${CMAKE_SOURCE_DIR}/http.c) - - add_executable(git-imap-send ${CMAKE_SOURCE_DIR}/imap-send.c) - target_link_libraries(git-imap-send http_obj common-main ${CURL_LIBRARIES}) - - add_executable(git-http-fetch ${CMAKE_SOURCE_DIR}/http-walker.c ${CMAKE_SOURCE_DIR}/http-fetch.c) - target_link_libraries(git-http-fetch http_obj common-main ${CURL_LIBRARIES}) - - add_executable(git-remote-http ${CMAKE_SOURCE_DIR}/http-walker.c ${CMAKE_SOURCE_DIR}/remote-curl.c) - target_link_libraries(git-remote-http http_obj common-main ${CURL_LIBRARIES} ) - - if(EXPAT_FOUND) - add_executable(git-http-push ${CMAKE_SOURCE_DIR}/http-push.c) - target_link_libraries(git-http-push http_obj common-main ${CURL_LIBRARIES} ${EXPAT_LIBRARIES}) - endif() -endif() - -set(git_builtin_extra - cherry cherry-pick format-patch fsck-objects - init merge-subtree restore show - stage status switch whatchanged) - -#Creating hardlinks -foreach(s ${git_SOURCES} ${git_builtin_extra}) - string(REPLACE "${CMAKE_SOURCE_DIR}/builtin/" "" s ${s}) - string(REPLACE ".c" "" s ${s}) - file(APPEND ${CMAKE_BINARY_DIR}/CreateLinks.cmake "file(CREATE_LINK git${EXE_EXTENSION} git-${s}${EXE_EXTENSION})\n") - list(APPEND git_links ${CMAKE_BINARY_DIR}/git-${s}${EXE_EXTENSION}) -endforeach() - -if(CURL_FOUND) - set(remote_exes - git-remote-https git-remote-ftp git-remote-ftps) - foreach(s ${remote_exes}) - file(APPEND ${CMAKE_BINARY_DIR}/CreateLinks.cmake "file(CREATE_LINK git-remote-http${EXE_EXTENSION} ${s}${EXE_EXTENSION})\n") - list(APPEND git_http_links ${CMAKE_BINARY_DIR}/${s}${EXE_EXTENSION}) - endforeach() -endif() - -add_custom_command(OUTPUT ${git_links} ${git_http_links} - COMMAND ${CMAKE_COMMAND} -P ${CMAKE_BINARY_DIR}/CreateLinks.cmake - DEPENDS git git-remote-http) -add_custom_target(git-links ALL DEPENDS ${git_links} ${git_http_links}) - - -#creating required scripts -set(SHELL_PATH /bin/sh) -set(PERL_PATH /usr/bin/perl) -set(LOCALEDIR ${FALLBACK_RUNTIME_PREFIX}/share/locale) -set(GITWEBDIR ${FALLBACK_RUNTIME_PREFIX}/share/locale) -set(INSTLIBDIR ${FALLBACK_RUNTIME_PREFIX}/share/perl5) - -#shell scripts -parse_makefile_for_scripts(git_sh_scripts "SCRIPT_SH" ".sh") -parse_makefile_for_scripts(git_shlib_scripts "SCRIPT_LIB" "") -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 "@@SANE_TEXT_GREP@@" "-a" 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") - -#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}) -endforeach() - -#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 modules -file(GLOB_RECURSE perl_modules "${CMAKE_SOURCE_DIR}/perl/*.pm") - -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 -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 - -#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) -endforeach() - - -#translations -if(MSGFMT_EXE) - file(GLOB po_files "${CMAKE_SOURCE_DIR}/po/*.po") - list(TRANSFORM po_files REPLACE "${CMAKE_SOURCE_DIR}/po/" "") - list(TRANSFORM po_files REPLACE ".po" "") - foreach(po ${po_files}) - file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/po/build/locale/${po}/LC_MESSAGES) - add_custom_command(OUTPUT ${CMAKE_BINARY_DIR}/po/build/locale/${po}/LC_MESSAGES/git.mo - COMMAND ${MSGFMT_EXE} --check --statistics -o ${CMAKE_BINARY_DIR}/po/build/locale/${po}/LC_MESSAGES/git.mo ${CMAKE_SOURCE_DIR}/po/${po}.po) - list(APPEND po_gen ${CMAKE_BINARY_DIR}/po/build/locale/${po}/LC_MESSAGES/git.mo) - endforeach() - add_custom_target(po-gen ALL DEPENDS ${po_gen}) -endif() - - -#to help with the install -list(TRANSFORM git_shell_scripts PREPEND "${CMAKE_BINARY_DIR}/") -list(TRANSFORM git_perl_scripts PREPEND "${CMAKE_BINARY_DIR}/") - -#install -install(TARGETS git git-shell - RUNTIME DESTINATION bin) -install(PROGRAMS ${CMAKE_BINARY_DIR}/git-cvsserver - DESTINATION bin) - -list(REMOVE_ITEM PROGRAMS_BUILT git git-shell) -install(TARGETS ${PROGRAMS_BUILT} - RUNTIME DESTINATION libexec/git-core) - -set(bin_links - git-receive-pack git-upload-archive git-upload-pack) - -foreach(b ${bin_links}) -install(CODE "file(CREATE_LINK ${CMAKE_INSTALL_PREFIX}/bin/git${EXE_EXTENSION} ${CMAKE_INSTALL_PREFIX}/bin/${b}${EXE_EXTENSION})") -endforeach() - -install(CODE "file(CREATE_LINK ${CMAKE_INSTALL_PREFIX}/bin/git${EXE_EXTENSION} ${CMAKE_INSTALL_PREFIX}/libexec/git-core/git${EXE_EXTENSION})") -install(CODE "file(CREATE_LINK ${CMAKE_INSTALL_PREFIX}/bin/git-shell${EXE_EXTENSION} ${CMAKE_INSTALL_PREFIX}/libexec/git-core/git-shell${EXE_EXTENSION})") - -foreach(b ${git_links}) - string(REPLACE "${CMAKE_BINARY_DIR}" "" b ${b}) - install(CODE "file(CREATE_LINK ${CMAKE_INSTALL_PREFIX}/bin/git${EXE_EXTENSION} ${CMAKE_INSTALL_PREFIX}/libexec/git-core/${b}${EXE_EXTENSION})") -endforeach() - -foreach(b ${git_http_links}) - string(REPLACE "${CMAKE_BINARY_DIR}" "" b ${b}) - install(CODE "file(CREATE_LINK ${CMAKE_INSTALL_PREFIX}/libexec/git-core/git-remote-http${EXE_EXTENSION} ${CMAKE_INSTALL_PREFIX}/libexec/git-core/${b}${EXE_EXTENSION})") -endforeach() - -install(PROGRAMS ${git_shell_scripts} ${git_perl_scripts} ${CMAKE_BINARY_DIR}/git-p4 - DESTINATION libexec/git-core) - -install(DIRECTORY ${CMAKE_SOURCE_DIR}/mergetools DESTINATION libexec/git-core) -install(DIRECTORY ${CMAKE_BINARY_DIR}/perl/build/lib/ DESTINATION share/perl5 - FILES_MATCHING PATTERN "*.pm") -install(DIRECTORY ${CMAKE_BINARY_DIR}/templates/blt/ DESTINATION share/git-core/templates) - -if(MSGFMT_EXE) - install(DIRECTORY ${CMAKE_BINARY_DIR}/po/build/locale DESTINATION share) -endif() - - -if(BUILD_TESTING) - -#tests-helpers -add_executable(test-fake-ssh ${CMAKE_SOURCE_DIR}/t/helper/test-fake-ssh.c) -target_link_libraries(test-fake-ssh common-main) - -#test-tool -parse_makefile_for_sources(test-tool_SOURCES "TEST_BUILTINS_OBJS") - -list(TRANSFORM test-tool_SOURCES PREPEND "${CMAKE_SOURCE_DIR}/t/helper/") -add_executable(test-tool ${CMAKE_SOURCE_DIR}/t/helper/test-tool.c ${test-tool_SOURCES}) -target_link_libraries(test-tool common-main) - -set_target_properties(test-fake-ssh test-tool - PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/t/helper) - -if(MSVC) - set_target_properties(test-fake-ssh test-tool - PROPERTIES RUNTIME_OUTPUT_DIRECTORY_DEBUG ${CMAKE_BINARY_DIR}/t/helper) - set_target_properties(test-fake-ssh test-tool - PROPERTIES RUNTIME_OUTPUT_DIRECTORY_RELEASE ${CMAKE_BINARY_DIR}/t/helper) -endif() - -#wrapper scripts -set(wrapper_scripts - git git-upload-pack git-receive-pack git-upload-archive git-shell git-remote-ext) - -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(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(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(WRITE ${CMAKE_BINARY_DIR}/bin-wrappers/git-cvsserver ${content}) - -#options for configuring test options -option(PERL_TESTS "Perform tests that use perl" ON) -option(PYTHON_TESTS "Perform tests that use python" ON) - -#GIT-BUILD-OPTIONS -set(TEST_SHELL_PATH ${SHELL_PATH}) -set(DIFF diff) -set(PYTHON_PATH /usr/bin/python) -set(TAR tar) -set(NO_CURL ) -set(NO_EXPAT ) -set(USE_LIBPCRE1 ) -set(USE_LIBPCRE2 ) -set(NO_LIBPCRE1_JIT ) -set(NO_PERL ) -set(NO_PTHREADS ) -set(NO_PYTHON ) -set(PAGER_ENV "LESS=FRX LV=-c") -set(DC_SHA1 YesPlease) -set(RUNTIME_PREFIX true) -set(NO_GETTEXT ) - -if(NOT CURL_FOUND) - set(NO_CURL 1) -endif() - -if(NOT EXPAT_FOUND) - set(NO_EXPAT 1) -endif() - -if(NOT Intl_FOUND) - set(NO_GETTEXT 1) -endif() - -if(NOT PERL_TESTS) - set(NO_PERL 1) -endif() - -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 "USE_LIBPCRE1='${USE_LIBPCRE1}'\n") -file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "NO_LIBPCRE1_JIT='${NO_LIBPCRE1_JIT}'\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 "DC_SHA1='${DC_SHA1}'\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") -if(WIN32) - file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "PATH=\"$PATH:$TEST_DIRECTORY/../compat/vcbuild/vcpkg/installed/x64-windows/bin\"\n") -endif() - -#Make the tests work when building out of the source tree -get_filename_component(CACHE_PATH ${CMAKE_CURRENT_LIST_DIR}/../../CMakeCache.txt ABSOLUTE) -if(NOT ${CMAKE_BINARY_DIR}/CMakeCache.txt STREQUAL ${CACHE_PATH}) - file(RELATIVE_PATH BUILD_DIR_RELATIVE ${CMAKE_SOURCE_DIR} ${CMAKE_BINARY_DIR}/CMakeCache.txt) - string(REPLACE "/CMakeCache.txt" "" BUILD_DIR_RELATIVE ${BUILD_DIR_RELATIVE}) - #Setting the build directory in test-lib.sh before running tests - file(WRITE ${CMAKE_BINARY_DIR}/CTestCustom.cmake - "file(STRINGS ${CMAKE_SOURCE_DIR}/t/test-lib.sh GIT_BUILD_DIR_REPL REGEX \"GIT_BUILD_DIR=(.*)\")\n" - "file(STRINGS ${CMAKE_SOURCE_DIR}/t/test-lib.sh content NEWLINE_CONSUME)\n" - "string(REPLACE \"\${GIT_BUILD_DIR_REPL}\" \"GIT_BUILD_DIR=\\\"$TEST_DIRECTORY/../${BUILD_DIR_RELATIVE}\\\"\" content \"\${content}\")\n" - "file(WRITE ${CMAKE_SOURCE_DIR}/t/test-lib.sh \${content})") - #misc copies - file(COPY ${CMAKE_SOURCE_DIR}/t/chainlint.sed DESTINATION ${CMAKE_BINARY_DIR}/t/) - file(COPY ${CMAKE_SOURCE_DIR}/po/is.po DESTINATION ${CMAKE_BINARY_DIR}/po/) - file(COPY ${CMAKE_SOURCE_DIR}/mergetools/tkdiff DESTINATION ${CMAKE_BINARY_DIR}/mergetools/) - file(COPY ${CMAKE_SOURCE_DIR}/contrib/completion/git-prompt.sh DESTINATION ${CMAKE_BINARY_DIR}/contrib/completion/) - file(COPY ${CMAKE_SOURCE_DIR}/contrib/completion/git-completion.bash DESTINATION ${CMAKE_BINARY_DIR}/contrib/completion/) -endif() - -file(GLOB test_scipts "${CMAKE_SOURCE_DIR}/t/t[0-9]*.sh") - -#test -foreach(tsh ${test_scipts}) - add_test(NAME ${tsh} - COMMAND ${SH_EXE} ${tsh} - WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/t) -endforeach() - -endif()#BUILD_TESTING diff --git a/third_party/git/contrib/buildsystems/Generators.pm b/third_party/git/contrib/buildsystems/Generators.pm deleted file mode 100644 index aa4cbaa2adac..000000000000 --- a/third_party/git/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/third_party/git/contrib/buildsystems/Generators/QMake.pm b/third_party/git/contrib/buildsystems/Generators/QMake.pm deleted file mode 100644 index ff3b657e6105..000000000000 --- a/third_party/git/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/third_party/git/contrib/buildsystems/Generators/Vcproj.pm b/third_party/git/contrib/buildsystems/Generators/Vcproj.pm deleted file mode 100644 index 737647e76afd..000000000000 --- a/third_party/git/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(""$rel_dir\\$_"", @{$$build_structure{"LIBS_${libname}_INCLUDES"}}))); - my $cflags = join(" ", sort(@{$$build_structure{"LIBS_${libname}_CFLAGS"}})); - $cflags =~ s/\"/"/g; - $cflags =~ s//>/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/\"/\\"/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"; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -EOM - foreach(@sources) { - print F << "EOM"; - -EOM - } - print F << "EOM"; - - - - - -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(""$rel_dir\\$_"", @{$$build_structure{"APPS_${appname}_INCLUDES"}}))); - my $cflags = join(" ", sort(@{$$build_structure{"APPS_${appname}_CFLAGS"}})); - $cflags =~ s/\"/"/g; - $cflags =~ s//>/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/\"/\\"/g; - $defines =~ s//>/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"; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -EOM - foreach(@sources) { - print F << "EOM"; - -EOM - } - print F << "EOM"; - - - - - -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/third_party/git/contrib/buildsystems/Generators/Vcxproj.pm b/third_party/git/contrib/buildsystems/Generators/Vcxproj.pm deleted file mode 100644 index d2584450ba17..000000000000 --- a/third_party/git/contrib/buildsystems/Generators/Vcxproj.pm +++ /dev/null @@ -1,393 +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//>/g; - - my $libs_release = "\n "; - my $libs_debug = "\n "; - if (!$static_library) { - $libs_release = join(";", sort(grep /^(?!libgit\.lib|xdiff\/lib\.lib|vcs-svn\/lib\.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//>/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"; - - - - - Debug - Win32 - - - Release - Win32 - - - Debug - x64 - - - Release - x64 - - - - $uuid - Win32Proj - x86-windows - x64-windows - $cdup\\compat\\vcbuild\\vcpkg\\installed\\\$(VCPKGArch) - \$(VCPKGArchDirectory)\\debug\\bin - \$(VCPKGArchDirectory)\\debug\\lib - \$(VCPKGArchDirectory)\\bin - \$(VCPKGArchDirectory)\\lib - \$(VCPKGArchDirectory)\\include - $libs_debug - $libs_release - - - - true - true - - - false - true - - - $config_type - v140 - - ..\\ - - - - - - - - - - - - - false - true - - - - $cflags %(AdditionalOptions) - $cdup;$cdup\\compat;$cdup\\compat\\regex;$cdup\\compat\\win32;$cdup\\compat\\poll;$cdup\\compat\\vcbuild\\include;\$(VCPKGIncludeDirectory);%(AdditionalIncludeDirectories) - - OnlyExplicitInline - - ProgramDatabase - - - true - - - \$(VCPKGLibDirectory);%(AdditionalLibraryDirectories) - \$(VCPKGLibs);\$(AdditionalDependencies) - invalidcontinue.obj %(AdditionalOptions) - wmainCRTStartup - $cdup\\compat\\win32\\git.manifest - Console - -EOM - if ($target eq 'libgit') { - print F << "EOM"; - - Initialize VCPKG - del "$cdup\\compat\\vcbuild\\vcpkg" - call "$cdup\\compat\\vcbuild\\vcpkg_install.bat" - -EOM - } - print F << "EOM"; - - - - MachineX86 - - - - - Disabled - WIN32;_DEBUG;$defines;%(PreprocessorDefinitions) - MultiThreadedDebugDLL - - - true - - - - - MaxSpeed - true - WIN32;NDEBUG;$defines;%(PreprocessorDefinitions) - MultiThreadedDLL - true - Speed - - - true - true - true - - - -EOM - foreach(@sources) { - print F << "EOM"; - -EOM - } - print F << "EOM"; - -EOM - if (!$static_library || $target =~ 'vcs-svn' || $target =~ 'xdiff') { - my $uuid_libgit = $$build_structure{"LIBS_libgit_GUID"}; - my $uuid_xdiff_lib = $$build_structure{"LIBS_xdiff/lib_GUID"}; - - print F << "EOM"; - - - $uuid_libgit - false - -EOM - if (!($name =~ 'xdiff')) { - print F << "EOM"; - - $uuid_xdiff_lib - false - -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"; - - $uuid_vcs_svn_lib - false - -EOM - } - print F << "EOM"; - -EOM - } - print F << "EOM"; - -EOM - if (!$static_library) { - print F << "EOM"; - - - - - - - -EOM - } - if ($target eq 'git') { - print F " \n"; - } - if ($target eq 'git-remote-http') { - print F " \n"; - } - print F << "EOM"; - -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/third_party/git/contrib/buildsystems/engine.pl b/third_party/git/contrib/buildsystems/engine.pl deleted file mode 100755 index 2ff962045964..000000000000 --- a/third_party/git/contrib/buildsystems/engine.pl +++ /dev/null @@ -1,394 +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 -###################################################################### -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 --gen Specify the buildsystem generator (default: $gen) - Available: $genlist - -o --out Specify output directory generation (default: .) - --make-out Write the output of GNU Make into a file - -i --in 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 = ; - 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, "libiconv.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/\.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/third_party/git/contrib/buildsystems/generate b/third_party/git/contrib/buildsystems/generate deleted file mode 100755 index bc10f25ff24a..000000000000 --- a/third_party/git/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 -###################################################################### -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/third_party/git/contrib/buildsystems/parse.pl b/third_party/git/contrib/buildsystems/parse.pl deleted file mode 100755 index c9656ece9931..000000000000 --- a/third_party/git/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 -###################################################################### -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 = ; -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/third_party/git/contrib/coccinelle/.gitignore b/third_party/git/contrib/coccinelle/.gitignore deleted file mode 100644 index d3f29646dc3a..000000000000 --- a/third_party/git/contrib/coccinelle/.gitignore +++ /dev/null @@ -1 +0,0 @@ -*.patch* diff --git a/third_party/git/contrib/coccinelle/README b/third_party/git/contrib/coccinelle/README deleted file mode 100644 index f0e80bd7f037..000000000000 --- a/third_party/git/contrib/coccinelle/README +++ /dev/null @@ -1,43 +0,0 @@ -This directory provides examples of Coccinelle (http://coccinelle.lip6.fr/) -semantic patches that might be useful to developers. - -There are two types of semantic patches: - - * Using the semantic transformation to check for bad patterns in the code; - The target 'make coccicheck' is designed to check for these patterns and - it is expected that any resulting patch indicates a regression. - The patches resulting from 'make coccicheck' are small and infrequent, - so once they are found, they can be sent to the mailing list as per usual. - - Example for introducing new patterns: - 67947c34ae (convert "hashcmp() != 0" to "!hasheq()", 2018-08-28) - b84c783882 (fsck: s/++i > 1/i++/, 2018-10-24) - - Example of fixes using this approach: - 248f66ed8e (run-command: use strbuf_addstr() for adding a string to - a strbuf, 2018-03-25) - f919ffebed (Use MOVE_ARRAY, 2018-01-22) - - These types of semantic patches are usually part of testing, c.f. - 0860a7641b (travis-ci: fail if Coccinelle static analysis found something - to transform, 2018-07-23) - - * Using semantic transformations in large scale refactorings throughout - the code base. - - When applying the semantic patch into a real patch, sending it to the - mailing list in the usual way, such a patch would be expected to have a - lot of textual and semantic conflicts as such large scale refactorings - change function signatures that are used widely in the code base. - A textual conflict would arise if surrounding code near any call of such - function changes. A semantic conflict arises when other patch series in - flight introduce calls to such functions. - - So to aid these large scale refactorings, semantic patches can be used. - However we do not want to store them in the same place as the checks for - bad patterns, as then automated builds would fail. - That is why semantic patches 'contrib/coccinelle/*.pending.cocci' - are ignored for checks, and can be applied using 'make coccicheck-pending'. - - This allows to expose plans of pending large scale refactorings without - impacting the bad pattern checks. diff --git a/third_party/git/contrib/coccinelle/array.cocci b/third_party/git/contrib/coccinelle/array.cocci deleted file mode 100644 index 46b8d2ee1115..000000000000 --- a/third_party/git/contrib/coccinelle/array.cocci +++ /dev/null @@ -1,90 +0,0 @@ -@@ -expression dst, src, n, E; -@@ - memcpy(dst, src, n * sizeof( -- E[...] -+ *(E) - )) - -@@ -type T; -T *ptr; -T[] arr; -expression E, n; -@@ -( - memcpy(ptr, E, -- n * sizeof(*(ptr)) -+ n * sizeof(T) - ) -| - memcpy(arr, E, -- n * sizeof(*(arr)) -+ n * sizeof(T) - ) -| - memcpy(E, ptr, -- n * sizeof(*(ptr)) -+ n * sizeof(T) - ) -| - memcpy(E, arr, -- n * sizeof(*(arr)) -+ n * sizeof(T) - ) -) - -@@ -type T; -T *dst_ptr; -T *src_ptr; -T[] dst_arr; -T[] src_arr; -expression n; -@@ -( -- memcpy(dst_ptr, src_ptr, (n) * sizeof(T)) -+ COPY_ARRAY(dst_ptr, src_ptr, n) -| -- memcpy(dst_ptr, src_arr, (n) * sizeof(T)) -+ COPY_ARRAY(dst_ptr, src_arr, n) -| -- memcpy(dst_arr, src_ptr, (n) * sizeof(T)) -+ COPY_ARRAY(dst_arr, src_ptr, n) -| -- memcpy(dst_arr, src_arr, (n) * sizeof(T)) -+ COPY_ARRAY(dst_arr, src_arr, n) -) - -@@ -type T; -T *dst; -T *src; -expression n; -@@ -( -- memmove(dst, src, (n) * sizeof(*dst)); -+ MOVE_ARRAY(dst, src, n); -| -- memmove(dst, src, (n) * sizeof(*src)); -+ MOVE_ARRAY(dst, src, n); -| -- memmove(dst, src, (n) * sizeof(T)); -+ MOVE_ARRAY(dst, src, n); -) - -@@ -type T; -T *ptr; -expression n; -@@ -- ptr = xmalloc((n) * sizeof(*ptr)); -+ ALLOC_ARRAY(ptr, n); - -@@ -type T; -T *ptr; -expression n; -@@ -- ptr = xmalloc((n) * sizeof(T)); -+ ALLOC_ARRAY(ptr, n); diff --git a/third_party/git/contrib/coccinelle/commit.cocci b/third_party/git/contrib/coccinelle/commit.cocci deleted file mode 100644 index af6dd4c20cae..000000000000 --- a/third_party/git/contrib/coccinelle/commit.cocci +++ /dev/null @@ -1,52 +0,0 @@ -@@ -expression c; -@@ -- &c->maybe_tree->object.oid -+ get_commit_tree_oid(c) - -@@ -expression c; -@@ -- c->maybe_tree->object.oid.hash -+ get_commit_tree_oid(c)->hash - -@@ -identifier f !~ "^set_commit_tree$"; -expression c; -expression s; -@@ - f(...) {<... -- c->maybe_tree = s -+ set_commit_tree(c, s) - ...>} - -// These excluded functions must access c->maybe_tree directly. -// Note that if c->maybe_tree is written somewhere outside of these -// 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)$"; -expression c; -@@ - f(...) {<... -- c->maybe_tree -+ repo_get_commit_tree(specify_the_right_repo_here, c) - ...>} - -@@ -struct commit *c; -expression E; -@@ -( -- c->generation = E; -+ commit_graph_data_at(c)->generation = E; -| -- c->graph_pos = E; -+ commit_graph_data_at(c)->graph_pos = E; -| -- c->generation -+ commit_graph_generation(c) -| -- c->graph_pos -+ commit_graph_position(c) -) diff --git a/third_party/git/contrib/coccinelle/flex_alloc.cocci b/third_party/git/contrib/coccinelle/flex_alloc.cocci deleted file mode 100644 index e9f7f6d861a4..000000000000 --- a/third_party/git/contrib/coccinelle/flex_alloc.cocci +++ /dev/null @@ -1,13 +0,0 @@ -@@ -expression str; -identifier x, flexname; -@@ -- FLEX_ALLOC_MEM(x, flexname, str, strlen(str)); -+ FLEX_ALLOC_STR(x, flexname, str); - -@@ -expression str; -identifier x, ptrname; -@@ -- FLEXPTR_ALLOC_MEM(x, ptrname, str, strlen(str)); -+ FLEXPTR_ALLOC_STR(x, ptrname, str); diff --git a/third_party/git/contrib/coccinelle/free.cocci b/third_party/git/contrib/coccinelle/free.cocci deleted file mode 100644 index 4490069df965..000000000000 --- a/third_party/git/contrib/coccinelle/free.cocci +++ /dev/null @@ -1,18 +0,0 @@ -@@ -expression E; -@@ -- if (E) - free(E); - -@@ -expression E; -@@ -- if (!E) - free(E); - -@@ -expression E; -@@ -- free(E); -+ FREE_AND_NULL(E); -- E = NULL; diff --git a/third_party/git/contrib/coccinelle/hashmap.cocci b/third_party/git/contrib/coccinelle/hashmap.cocci deleted file mode 100644 index d69e120ccffc..000000000000 --- a/third_party/git/contrib/coccinelle/hashmap.cocci +++ /dev/null @@ -1,16 +0,0 @@ -@ hashmap_entry_init_usage @ -expression E; -struct hashmap_entry HME; -@@ -- HME.hash = E; -+ hashmap_entry_init(&HME, E); - -@@ -identifier f !~ "^hashmap_entry_init$"; -expression E; -struct hashmap_entry *HMEP; -@@ - f(...) {<... -- HMEP->hash = E; -+ hashmap_entry_init(HMEP, E); - ...>} diff --git a/third_party/git/contrib/coccinelle/object_id.cocci b/third_party/git/contrib/coccinelle/object_id.cocci deleted file mode 100644 index ddf4f22bd722..000000000000 --- a/third_party/git/contrib/coccinelle/object_id.cocci +++ /dev/null @@ -1,87 +0,0 @@ -@@ -struct object_id OID; -@@ -- is_null_sha1(OID.hash) -+ is_null_oid(&OID) - -@@ -struct object_id *OIDPTR; -@@ -- is_null_sha1(OIDPTR->hash) -+ is_null_oid(OIDPTR) - -@@ -struct object_id OID; -@@ -- hashclr(OID.hash) -+ oidclr(&OID) - -@@ -identifier f != oidclr; -struct object_id *OIDPTR; -@@ - f(...) {<... -- hashclr(OIDPTR->hash) -+ oidclr(OIDPTR) - ...>} - -@@ -struct object_id OID1, OID2; -@@ -- hashcmp(OID1.hash, OID2.hash) -+ oidcmp(&OID1, &OID2) - -@@ -identifier f != oidcmp; -struct object_id *OIDPTR1, OIDPTR2; -@@ - f(...) {<... -- hashcmp(OIDPTR1->hash, OIDPTR2->hash) -+ oidcmp(OIDPTR1, OIDPTR2) - ...>} - -@@ -struct object_id *OIDPTR; -struct object_id OID; -@@ -- hashcmp(OIDPTR->hash, OID.hash) -+ oidcmp(OIDPTR, &OID) - -@@ -struct object_id *OIDPTR; -struct object_id OID; -@@ -- hashcmp(OID.hash, OIDPTR->hash) -+ oidcmp(&OID, OIDPTR) - -@@ -struct object_id *OIDPTR1; -struct object_id *OIDPTR2; -@@ -- oidcmp(OIDPTR1, OIDPTR2) == 0 -+ oideq(OIDPTR1, OIDPTR2) - -@@ -identifier f != hasheq; -expression E1, E2; -@@ - f(...) {<... -- hashcmp(E1, E2) == 0 -+ hasheq(E1, E2) - ...>} - -@@ -struct object_id *OIDPTR1; -struct object_id *OIDPTR2; -@@ -- oidcmp(OIDPTR1, OIDPTR2) != 0 -+ !oideq(OIDPTR1, OIDPTR2) - -@@ -identifier f != hasheq; -expression E1, E2; -@@ - f(...) {<... -- hashcmp(E1, E2) != 0 -+ !hasheq(E1, E2) - ...>} diff --git a/third_party/git/contrib/coccinelle/preincr.cocci b/third_party/git/contrib/coccinelle/preincr.cocci deleted file mode 100644 index 7fe1e8d2d9a0..000000000000 --- a/third_party/git/contrib/coccinelle/preincr.cocci +++ /dev/null @@ -1,5 +0,0 @@ -@ preincrement @ -identifier i; -@@ -- ++i > 1 -+ i++ diff --git a/third_party/git/contrib/coccinelle/qsort.cocci b/third_party/git/contrib/coccinelle/qsort.cocci deleted file mode 100644 index 22b93a99664d..000000000000 --- a/third_party/git/contrib/coccinelle/qsort.cocci +++ /dev/null @@ -1,37 +0,0 @@ -@@ -expression base, nmemb, compar; -@@ -- qsort(base, nmemb, sizeof(*base), compar); -+ QSORT(base, nmemb, compar); - -@@ -expression base, nmemb, compar; -@@ -- qsort(base, nmemb, sizeof(base[0]), compar); -+ QSORT(base, nmemb, compar); - -@@ -type T; -T *base; -expression nmemb, compar; -@@ -- qsort(base, nmemb, sizeof(T), compar); -+ QSORT(base, nmemb, compar); - -@@ -expression base, nmemb, compar; -@@ -- if (nmemb) - QSORT(base, nmemb, compar); - -@@ -expression base, nmemb, compar; -@@ -- if (nmemb > 0) - QSORT(base, nmemb, compar); - -@@ -expression base, nmemb, compar; -@@ -- if (nmemb > 1) - QSORT(base, nmemb, compar); diff --git a/third_party/git/contrib/coccinelle/strbuf.cocci b/third_party/git/contrib/coccinelle/strbuf.cocci deleted file mode 100644 index d9ada69b4323..000000000000 --- a/third_party/git/contrib/coccinelle/strbuf.cocci +++ /dev/null @@ -1,62 +0,0 @@ -@ strbuf_addf_with_format_only @ -expression E; -constant fmt !~ "%"; -@@ -- strbuf_addf -+ strbuf_addstr - (E, -( - fmt -| - _(fmt) -) - ); - -@@ -expression E; -struct strbuf SB; -format F =~ "s"; -@@ -- strbuf_addf(E, "%@F@", SB.buf); -+ strbuf_addbuf(E, &SB); - -@@ -expression E; -struct strbuf *SBP; -format F =~ "s"; -@@ -- strbuf_addf(E, "%@F@", SBP->buf); -+ strbuf_addbuf(E, SBP); - -@@ -expression E; -struct strbuf SB; -@@ -- strbuf_addstr(E, SB.buf); -+ strbuf_addbuf(E, &SB); - -@@ -expression E; -struct strbuf *SBP; -@@ -- strbuf_addstr(E, SBP->buf); -+ strbuf_addbuf(E, SBP); - -@@ -expression E1, E2; -format F =~ "s"; -@@ -- strbuf_addf(E1, "%@F@", E2); -+ strbuf_addstr(E1, E2); - -@@ -expression E1, E2, E3; -@@ -- strbuf_addstr(E1, find_unique_abbrev(E2, E3)); -+ strbuf_add_unique_abbrev(E1, E2, E3); - -@@ -expression E1, E2; -@@ -- strbuf_addstr(E1, real_path(E2)); -+ strbuf_add_real_path(E1, E2); diff --git a/third_party/git/contrib/coccinelle/swap.cocci b/third_party/git/contrib/coccinelle/swap.cocci deleted file mode 100644 index a0934d1fdaf0..000000000000 --- a/third_party/git/contrib/coccinelle/swap.cocci +++ /dev/null @@ -1,28 +0,0 @@ -@ swap_with_declaration @ -type T; -identifier tmp; -T a, b; -@@ -- T tmp = a; -+ T tmp; -+ tmp = a; - a = b; - b = tmp; - -@ swap @ -type T; -T tmp, a, b; -@@ -- tmp = a; -- a = b; -- b = tmp; -+ SWAP(a, b); - -@ extends swap @ -identifier unused; -@@ - { - ... -- T unused; - ... when != unused - } diff --git a/third_party/git/contrib/coccinelle/the_repository.pending.cocci b/third_party/git/contrib/coccinelle/the_repository.pending.cocci deleted file mode 100644 index 2ee702ecf7fe..000000000000 --- a/third_party/git/contrib/coccinelle/the_repository.pending.cocci +++ /dev/null @@ -1,144 +0,0 @@ -// This file is used for the ongoing refactoring of -// bringing the index or repository struct in all of -// our code base. - -@@ -expression E; -expression F; -expression G; -@@ -- read_object_file( -+ repo_read_object_file(the_repository, - E, F, G) - -@@ -expression E; -@@ -- has_sha1_file( -+ repo_has_sha1_file(the_repository, - E) - -@@ -expression E; -expression F; -@@ -- has_sha1_file_with_flags( -+ repo_has_sha1_file_with_flags(the_repository, - E) - -@@ -expression E; -@@ -- has_object_file( -+ repo_has_object_file(the_repository, - E) - -@@ -expression E; -expression F; -@@ -- has_object_file_with_flags( -+ repo_has_object_file_with_flags(the_repository, - E) - -@@ -expression E; -expression F; -expression G; -@@ -- parse_commit_internal( -+ repo_parse_commit_internal(the_repository, - E, F, G) - -@@ -expression E; -expression F; -@@ -- parse_commit_gently( -+ repo_parse_commit_gently(the_repository, - E, F) - -@@ -expression E; -@@ -- parse_commit( -+ repo_parse_commit(the_repository, - E) - -@@ -expression E; -expression F; -@@ -- get_merge_bases( -+ repo_get_merge_bases(the_repository, - E, F); - -@@ -expression E; -expression F; -expression G; -@@ -- get_merge_bases_many( -+ repo_get_merge_bases_many(the_repository, - E, F, G); - -@@ -expression E; -expression F; -expression G; -@@ -- get_merge_bases_many_dirty( -+ repo_get_merge_bases_many_dirty(the_repository, - E, F, G); - -@@ -expression E; -expression F; -@@ -- in_merge_bases( -+ repo_in_merge_bases(the_repository, - E, F); - -@@ -expression E; -expression F; -expression G; -@@ -- in_merge_bases_many( -+ repo_in_merge_bases_many(the_repository, - E, F, G); - -@@ -expression E; -expression F; -@@ -- get_commit_buffer( -+ repo_get_commit_buffer(the_repository, - E, F); - -@@ -expression E; -expression F; -@@ -- unuse_commit_buffer( -+ repo_unuse_commit_buffer(the_repository, - E, F); - -@@ -expression E; -expression F; -expression G; -@@ -- logmsg_reencode( -+ repo_logmsg_reencode(the_repository, - E, F, G); - -@@ -expression E; -expression F; -expression G; -expression H; -@@ -- format_commit_message( -+ repo_format_commit_message(the_repository, - E, F, G, H); diff --git a/third_party/git/contrib/coccinelle/xstrdup_or_null.cocci b/third_party/git/contrib/coccinelle/xstrdup_or_null.cocci deleted file mode 100644 index 8e05d1ca4b61..000000000000 --- a/third_party/git/contrib/coccinelle/xstrdup_or_null.cocci +++ /dev/null @@ -1,13 +0,0 @@ -@@ -expression E; -expression V; -@@ -- if (E) -- V = xstrdup(E); -+ V = xstrdup_or_null(E); - -@@ -expression E; -@@ -- xstrdup(absolute_path(E)) -+ absolute_pathdup(E) diff --git a/third_party/git/contrib/completion/.gitattributes b/third_party/git/contrib/completion/.gitattributes deleted file mode 100644 index 19116944c15c..000000000000 --- a/third_party/git/contrib/completion/.gitattributes +++ /dev/null @@ -1 +0,0 @@ -*.bash eol=lf diff --git a/third_party/git/contrib/completion/git-completion.bash b/third_party/git/contrib/completion/git-completion.bash deleted file mode 100644 index 0a96ad87e7b6..000000000000 --- a/third_party/git/contrib/completion/git-completion.bash +++ /dev/null @@ -1,3585 +0,0 @@ -# bash/zsh completion support for core Git. -# -# Copyright (C) 2006,2007 Shawn O. Pearce -# Conceptually based on gitcompletion (http://gitweb.hawaga.org.uk/). -# Distributed under the GNU General Public License, version 2.0. -# -# The contained completion routines provide support for completing: -# -# *) local and remote branch names -# *) local and remote tag names -# *) .git/remotes file names -# *) git 'subcommands' -# *) git email aliases for git-send-email -# *) tree paths within 'ref:path/to/file' expressions -# *) file paths within current working directory and index -# *) common --long-options -# -# To use these routines: -# -# 1) Copy this file to somewhere (e.g. ~/.git-completion.bash). -# 2) Add the following line to your .bashrc/.zshrc: -# source ~/.git-completion.bash -# 3) Consider changing your PS1 to also show the current branch, -# see git-prompt.sh for details. -# -# If you use complex aliases of form '!f() { ... }; f', you can use the null -# command ':' as the first command in the function body to declare the desired -# completion style. For example '!f() { : git commit ; ... }; f' will -# tell the completion to use commit completion. This also works with aliases -# of form "!sh -c '...'". For example, "!sh -c ': git commit ; ... '". -# -# Compatible with bash 3.2.57. -# -# You can set the following environment variables to influence the behavior of -# the completion routines: -# -# GIT_COMPLETION_CHECKOUT_NO_GUESS -# -# When set to "1", do not include "DWIM" suggestions in git-checkout -# and git-switch completion (e.g., completing "foo" when "origin/foo" -# exists). -# -# GIT_COMPLETION_SHOW_ALL -# -# When set to "1" suggest all options, including options which are -# typically hidden (e.g. '--allow-empty' for 'git commit'). - -case "$COMP_WORDBREAKS" in -*:*) : great ;; -*) COMP_WORDBREAKS="$COMP_WORDBREAKS:" -esac - -# Discovers the path to the git repository taking any '--git-dir=' and -# '-C ' options into account and stores it in the $__git_repo_path -# variable. -__git_find_repo_path () -{ - if [ -n "${__git_repo_path-}" ]; then - # we already know where it is - return - fi - - if [ -n "${__git_C_args-}" ]; then - __git_repo_path="$(git "${__git_C_args[@]}" \ - ${__git_dir:+--git-dir="$__git_dir"} \ - rev-parse --absolute-git-dir 2>/dev/null)" - elif [ -n "${__git_dir-}" ]; then - test -d "$__git_dir" && - __git_repo_path="$__git_dir" - elif [ -n "${GIT_DIR-}" ]; then - test -d "${GIT_DIR-}" && - __git_repo_path="$GIT_DIR" - elif [ -d .git ]; then - __git_repo_path=.git - else - __git_repo_path="$(git rev-parse --git-dir 2>/dev/null)" - fi -} - -# Deprecated: use __git_find_repo_path() and $__git_repo_path instead -# __gitdir accepts 0 or 1 arguments (i.e., location) -# returns location of .git repo -__gitdir () -{ - if [ -z "${1-}" ]; then - __git_find_repo_path || return 1 - echo "$__git_repo_path" - elif [ -d "$1/.git" ]; then - echo "$1/.git" - else - echo "$1" - fi -} - -# Runs git with all the options given as argument, respecting any -# '--git-dir=' and '-C ' options present on the command line -__git () -{ - git ${__git_C_args:+"${__git_C_args[@]}"} \ - ${__git_dir:+--git-dir="$__git_dir"} "$@" 2>/dev/null -} - -# Removes backslash escaping, single quotes and double quotes from a word, -# stores the result in the variable $dequoted_word. -# 1: The word to dequote. -__git_dequote () -{ - local rest="$1" len ch - - dequoted_word="" - - while test -n "$rest"; do - len=${#dequoted_word} - dequoted_word="$dequoted_word${rest%%[\\\'\"]*}" - rest="${rest:$((${#dequoted_word}-$len))}" - - case "${rest:0:1}" in - \\) - ch="${rest:1:1}" - case "$ch" in - $'\n') - ;; - *) - dequoted_word="$dequoted_word$ch" - ;; - esac - rest="${rest:2}" - ;; - \') - rest="${rest:1}" - len=${#dequoted_word} - dequoted_word="$dequoted_word${rest%%\'*}" - rest="${rest:$((${#dequoted_word}-$len+1))}" - ;; - \") - rest="${rest:1}" - while test -n "$rest" ; do - len=${#dequoted_word} - dequoted_word="$dequoted_word${rest%%[\\\"]*}" - rest="${rest:$((${#dequoted_word}-$len))}" - case "${rest:0:1}" in - \\) - ch="${rest:1:1}" - case "$ch" in - \"|\\|\$|\`) - dequoted_word="$dequoted_word$ch" - ;; - $'\n') - ;; - *) - dequoted_word="$dequoted_word\\$ch" - ;; - esac - rest="${rest:2}" - ;; - \") - rest="${rest:1}" - break - ;; - esac - done - ;; - esac - done -} - -# The following function is based on code from: -# -# bash_completion - programmable completion functions for bash 3.2+ -# -# Copyright © 2006-2008, Ian Macdonald -# © 2009-2010, Bash Completion Maintainers -# -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2, or (at your option) -# any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, see . -# -# The latest version of this software can be obtained here: -# -# http://bash-completion.alioth.debian.org/ -# -# RELEASE: 2.x - -# This function can be used to access a tokenized list of words -# on the command line: -# -# __git_reassemble_comp_words_by_ref '=:' -# if test "${words_[cword_-1]}" = -w -# then -# ... -# fi -# -# The argument should be a collection of characters from the list of -# word completion separators (COMP_WORDBREAKS) to treat as ordinary -# characters. -# -# This is roughly equivalent to going back in time and setting -# COMP_WORDBREAKS to exclude those characters. The intent is to -# make option types like --date= and : easy to -# recognize by treating each shell word as a single token. -# -# It is best not to set COMP_WORDBREAKS directly because the value is -# shared with other completion scripts. By the time the completion -# function gets called, COMP_WORDS has already been populated so local -# changes to COMP_WORDBREAKS have no effect. -# -# Output: words_, cword_, cur_. - -__git_reassemble_comp_words_by_ref() -{ - local exclude i j first - # Which word separators to exclude? - exclude="${1//[^$COMP_WORDBREAKS]}" - cword_=$COMP_CWORD - if [ -z "$exclude" ]; then - words_=("${COMP_WORDS[@]}") - return - fi - # List of word completion separators has shrunk; - # re-assemble words to complete. - for ((i=0, j=0; i < ${#COMP_WORDS[@]}; i++, j++)); do - # Append each nonempty word consisting of just - # word separator characters to the current word. - first=t - while - [ $i -gt 0 ] && - [ -n "${COMP_WORDS[$i]}" ] && - # word consists of excluded word separators - [ "${COMP_WORDS[$i]//[^$exclude]}" = "${COMP_WORDS[$i]}" ] - do - # Attach to the previous token, - # unless the previous token is the command name. - if [ $j -ge 2 ] && [ -n "$first" ]; then - ((j--)) - fi - first= - words_[$j]=${words_[j]}${COMP_WORDS[i]} - if [ $i = $COMP_CWORD ]; then - cword_=$j - fi - if (($i < ${#COMP_WORDS[@]} - 1)); then - ((i++)) - else - # Done. - return - fi - done - words_[$j]=${words_[j]}${COMP_WORDS[i]} - if [ $i = $COMP_CWORD ]; then - cword_=$j - fi - done -} - -if ! type _get_comp_words_by_ref >/dev/null 2>&1; then -_get_comp_words_by_ref () -{ - local exclude cur_ words_ cword_ - if [ "$1" = "-n" ]; then - exclude=$2 - shift 2 - fi - __git_reassemble_comp_words_by_ref "$exclude" - cur_=${words_[cword_]} - while [ $# -gt 0 ]; do - case "$1" in - cur) - cur=$cur_ - ;; - prev) - prev=${words_[$cword_-1]} - ;; - words) - words=("${words_[@]}") - ;; - cword) - cword=$cword_ - ;; - esac - shift - done -} -fi - -# Fills the COMPREPLY array with prefiltered words without any additional -# processing. -# Callers must take care of providing only words that match the current word -# to be completed and adding any prefix and/or suffix (trailing space!), if -# necessary. -# 1: List of newline-separated matching completion words, complete with -# prefix and suffix. -__gitcomp_direct () -{ - local IFS=$'\n' - - COMPREPLY=($1) -} - -# Similar to __gitcomp_direct, but appends to COMPREPLY instead. -# Callers must take care of providing only words that match the current word -# to be completed and adding any prefix and/or suffix (trailing space!), if -# necessary. -# 1: List of newline-separated matching completion words, complete with -# prefix and suffix. -__gitcomp_direct_append () -{ - local IFS=$'\n' - - COMPREPLY+=($1) -} - -__gitcompappend () -{ - local x i=${#COMPREPLY[@]} - for x in $1; do - if [[ "$x" == "$3"* ]]; then - COMPREPLY[i++]="$2$x$4" - fi - done -} - -__gitcompadd () -{ - COMPREPLY=() - __gitcompappend "$@" -} - -# Generates completion reply, appending a space to possible completion words, -# if necessary. -# It accepts 1 to 4 arguments: -# 1: List of possible completion words. -# 2: A prefix to be added to each possible completion word (optional). -# 3: Generate possible completion matches for this word (optional). -# 4: A suffix to be appended to each possible completion word (optional). -__gitcomp () -{ - local cur_="${3-$cur}" - - case "$cur_" in - --*=) - ;; - --no-*) - local c i=0 IFS=$' \t\n' - for c in $1; do - if [[ $c == "--" ]]; then - continue - fi - c="$c${4-}" - if [[ $c == "$cur_"* ]]; then - case $c in - --*=|*.) ;; - *) c="$c " ;; - esac - COMPREPLY[i++]="${2-}$c" - fi - done - ;; - *) - local c i=0 IFS=$' \t\n' - for c in $1; do - if [[ $c == "--" ]]; then - c="--no-...${4-}" - if [[ $c == "$cur_"* ]]; then - COMPREPLY[i++]="${2-}$c " - fi - break - fi - c="$c${4-}" - if [[ $c == "$cur_"* ]]; then - case $c in - *=|*.) ;; - *) c="$c " ;; - esac - COMPREPLY[i++]="${2-}$c" - fi - done - ;; - esac -} - -# Clear the variables caching builtins' options when (re-)sourcing -# the completion script. -if [[ -n ${ZSH_VERSION-} ]]; then - unset ${(M)${(k)parameters[@]}:#__gitcomp_builtin_*} 2>/dev/null -else - unset $(compgen -v __gitcomp_builtin_) -fi - -# This function is equivalent to -# -# __gitcomp "$(git xxx --git-completion-helper) ..." -# -# except that the output is cached. Accept 1-3 arguments: -# 1: the git command to execute, this is also the cache key -# 2: extra options to be added on top (e.g. negative forms) -# 3: options to be excluded -__gitcomp_builtin () -{ - # spaces must be replaced with underscore for multi-word - # commands, e.g. "git remote add" becomes remote_add. - local cmd="$1" - local incl="${2-}" - local excl="${3-}" - - local var=__gitcomp_builtin_"${cmd/-/_}" - local options - eval "options=\${$var-}" - - local completion_helper - if [ "$GIT_COMPLETION_SHOW_ALL" = "1" ]; then - completion_helper="--git-completion-helper-all" - else - completion_helper="--git-completion-helper" - fi - - if [ -z "$options" ]; then - # leading and trailing spaces are significant to make - # option removal work correctly. - options=" $incl $(__git ${cmd/_/ } $completion_helper) " || return - - for i in $excl; do - options="${options/ $i / }" - done - eval "$var=\"$options\"" - fi - - __gitcomp "$options" -} - -# Variation of __gitcomp_nl () that appends to the existing list of -# completion candidates, COMPREPLY. -__gitcomp_nl_append () -{ - local IFS=$'\n' - __gitcompappend "$1" "${2-}" "${3-$cur}" "${4- }" -} - -# Generates completion reply from newline-separated possible completion words -# by appending a space to all of them. -# It accepts 1 to 4 arguments: -# 1: List of possible completion words, separated by a single newline. -# 2: A prefix to be added to each possible completion word (optional). -# 3: Generate possible completion matches for this word (optional). -# 4: A suffix to be appended to each possible completion word instead of -# the default space (optional). If specified but empty, nothing is -# appended. -__gitcomp_nl () -{ - COMPREPLY=() - __gitcomp_nl_append "$@" -} - -# Fills the COMPREPLY array with prefiltered paths without any additional -# processing. -# Callers must take care of providing only paths that match the current path -# to be completed and adding any prefix path components, if necessary. -# 1: List of newline-separated matching paths, complete with all prefix -# path components. -__gitcomp_file_direct () -{ - local IFS=$'\n' - - COMPREPLY=($1) - - # use a hack to enable file mode in bash < 4 - compopt -o filenames +o nospace 2>/dev/null || - compgen -f /non-existing-dir/ >/dev/null || - true -} - -# Generates completion reply with compgen from newline-separated possible -# completion filenames. -# It accepts 1 to 3 arguments: -# 1: List of possible completion filenames, separated by a single newline. -# 2: A directory prefix to be added to each possible completion filename -# (optional). -# 3: Generate possible completion matches for this word (optional). -__gitcomp_file () -{ - local IFS=$'\n' - - # XXX does not work when the directory prefix contains a tilde, - # since tilde expansion is not applied. - # This means that COMPREPLY will be empty and Bash default - # completion will be used. - __gitcompadd "$1" "${2-}" "${3-$cur}" "" - - # use a hack to enable file mode in bash < 4 - compopt -o filenames +o nospace 2>/dev/null || - compgen -f /non-existing-dir/ >/dev/null || - true -} - -# Execute 'git ls-files', unless the --committable option is specified, in -# which case it runs 'git diff-index' to find out the files that can be -# committed. It return paths relative to the directory specified in the first -# argument, and using the options specified in the second argument. -__git_ls_files_helper () -{ - if [ "$2" == "--committable" ]; then - __git -C "$1" -c core.quotePath=false diff-index \ - --name-only --relative HEAD -- "${3//\\/\\\\}*" - else - # NOTE: $2 is not quoted in order to support multiple options - __git -C "$1" -c core.quotePath=false ls-files \ - --exclude-standard $2 -- "${3//\\/\\\\}*" - fi -} - - -# __git_index_files accepts 1 or 2 arguments: -# 1: Options to pass to ls-files (required). -# 2: A directory path (optional). -# If provided, only files within the specified directory are listed. -# Sub directories are never recursed. Path must have a trailing -# slash. -# 3: List only paths matching this path component (optional). -__git_index_files () -{ - local root="$2" match="$3" - - __git_ls_files_helper "$root" "$1" "${match:-?}" | - awk -F / -v pfx="${2//\\/\\\\}" '{ - paths[$1] = 1 - } - END { - for (p in paths) { - if (substr(p, 1, 1) != "\"") { - # No special characters, easy! - print pfx p - continue - } - - # The path is quoted. - p = dequote(p) - if (p == "") - continue - - # Even when a directory name itself does not contain - # any special characters, it will still be quoted if - # any of its (stripped) trailing path components do. - # Because of this we may have seen the same directory - # both quoted and unquoted. - if (p in paths) - # We have seen the same directory unquoted, - # skip it. - continue - else - print pfx p - } - } - function dequote(p, bs_idx, out, esc, esc_idx, dec) { - # Skip opening double quote. - p = substr(p, 2) - - # Interpret backslash escape sequences. - while ((bs_idx = index(p, "\\")) != 0) { - out = out substr(p, 1, bs_idx - 1) - esc = substr(p, bs_idx + 1, 1) - p = substr(p, bs_idx + 2) - - if ((esc_idx = index("abtvfr\"\\", esc)) != 0) { - # C-style one-character escape sequence. - out = out substr("\a\b\t\v\f\r\"\\", - esc_idx, 1) - } else if (esc == "n") { - # Uh-oh, a newline character. - # We cannot reliably put a pathname - # containing a newline into COMPREPLY, - # and the newline would create a mess. - # Skip this path. - return "" - } else { - # Must be a \nnn octal value, then. - dec = esc * 64 + \ - substr(p, 1, 1) * 8 + \ - substr(p, 2, 1) - out = out sprintf("%c", dec) - p = substr(p, 3) - } - } - # Drop closing double quote, if there is one. - # (There is not any if this is a directory, as it was - # already stripped with the trailing path components.) - if (substr(p, length(p), 1) == "\"") - out = out substr(p, 1, length(p) - 1) - else - out = out p - - return out - }' -} - -# __git_complete_index_file requires 1 argument: -# 1: the options to pass to ls-file -# -# The exception is --committable, which finds the files appropriate commit. -__git_complete_index_file () -{ - local dequoted_word pfx="" cur_ - - __git_dequote "$cur" - - case "$dequoted_word" in - ?*/*) - pfx="${dequoted_word%/*}/" - cur_="${dequoted_word##*/}" - ;; - *) - cur_="$dequoted_word" - esac - - __gitcomp_file_direct "$(__git_index_files "$1" "$pfx" "$cur_")" -} - -# Lists branches from the local repository. -# 1: A prefix to be added to each listed branch (optional). -# 2: List only branches matching this word (optional; list all branches if -# unset or empty). -# 3: A suffix to be appended to each listed branch (optional). -__git_heads () -{ - local pfx="${1-}" cur_="${2-}" sfx="${3-}" - - __git for-each-ref --format="${pfx//\%/%%}%(refname:strip=2)$sfx" \ - "refs/heads/$cur_*" "refs/heads/$cur_*/**" -} - -# Lists branches from remote repositories. -# 1: A prefix to be added to each listed branch (optional). -# 2: List only branches matching this word (optional; list all branches if -# unset or empty). -# 3: A suffix to be appended to each listed branch (optional). -__git_remote_heads () -{ - local pfx="${1-}" cur_="${2-}" sfx="${3-}" - - __git for-each-ref --format="${pfx//\%/%%}%(refname:strip=2)$sfx" \ - "refs/remotes/$cur_*" "refs/remotes/$cur_*/**" -} - -# Lists tags from the local repository. -# Accepts the same positional parameters as __git_heads() above. -__git_tags () -{ - local pfx="${1-}" cur_="${2-}" sfx="${3-}" - - __git for-each-ref --format="${pfx//\%/%%}%(refname:strip=2)$sfx" \ - "refs/tags/$cur_*" "refs/tags/$cur_*/**" -} - -# List unique branches from refs/remotes used for 'git checkout' and 'git -# switch' tracking DWIMery. -# 1: A prefix to be added to each listed branch (optional) -# 2: List only branches matching this word (optional; list all branches if -# unset or empty). -# 3: A suffix to be appended to each listed branch (optional). -__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" \ - "refs/remotes/*/$cur_*" "refs/remotes/*/$cur_*/**" | \ - uniq -u -} - -# Lists refs from the local (by default) or from a remote repository. -# It accepts 0, 1 or 2 arguments: -# 1: The remote to list refs from (optional; ignored, if set but empty). -# Can be the name of a configured remote, a path, or a URL. -# 2: In addition to local refs, list unique branches from refs/remotes/ for -# 'git checkout's tracking DWIMery (optional; ignored, if set but empty). -# 3: A prefix to be added to each listed ref (optional). -# 4: List only refs matching this word (optional; list all refs if unset or -# empty). -# 5: A suffix to be appended to each listed ref (optional; ignored, if set -# but empty). -# -# Use __git_complete_refs() instead. -__git_refs () -{ - local i hash dir track="${2-}" - local list_refs_from=path remote="${1-}" - local format refs - local pfx="${3-}" cur_="${4-$cur}" sfx="${5-}" - local match="${4-}" - local fer_pfx="${pfx//\%/%%}" # "escape" for-each-ref format specifiers - - __git_find_repo_path - dir="$__git_repo_path" - - if [ -z "$remote" ]; then - if [ -z "$dir" ]; then - return - fi - else - if __git_is_configured_remote "$remote"; then - # configured remote takes precedence over a - # local directory with the same name - list_refs_from=remote - elif [ -d "$remote/.git" ]; then - dir="$remote/.git" - elif [ -d "$remote" ]; then - dir="$remote" - else - list_refs_from=url - fi - fi - - if [ "$list_refs_from" = path ]; then - if [[ "$cur_" == ^* ]]; then - pfx="$pfx^" - fer_pfx="$fer_pfx^" - cur_=${cur_#^} - match=${match#^} - fi - case "$cur_" in - refs|refs/*) - format="refname" - refs=("$match*" "$match*/**") - track="" - ;; - *) - for i in HEAD FETCH_HEAD ORIG_HEAD MERGE_HEAD REBASE_HEAD; do - case "$i" in - $match*) - if [ -e "$dir/$i" ]; then - echo "$pfx$i$sfx" - fi - ;; - esac - done - format="refname:strip=2" - refs=("refs/tags/$match*" "refs/tags/$match*/**" - "refs/heads/$match*" "refs/heads/$match*/**" - "refs/remotes/$match*" "refs/remotes/$match*/**") - ;; - esac - __git_dir="$dir" __git for-each-ref --format="$fer_pfx%($format)$sfx" \ - "${refs[@]}" - if [ -n "$track" ]; then - __git_dwim_remote_heads "$pfx" "$match" "$sfx" - fi - return - fi - case "$cur_" in - refs|refs/*) - __git ls-remote "$remote" "$match*" | \ - while read -r hash i; do - case "$i" in - *^{}) ;; - *) echo "$pfx$i$sfx" ;; - esac - done - ;; - *) - if [ "$list_refs_from" = remote ]; then - case "HEAD" in - $match*) echo "${pfx}HEAD$sfx" ;; - esac - __git for-each-ref --format="$fer_pfx%(refname:strip=3)$sfx" \ - "refs/remotes/$remote/$match*" \ - "refs/remotes/$remote/$match*/**" - else - local query_symref - case "HEAD" in - $match*) query_symref="HEAD" ;; - esac - __git ls-remote "$remote" $query_symref \ - "refs/tags/$match*" "refs/heads/$match*" \ - "refs/remotes/$match*" | - while read -r hash i; do - case "$i" in - *^{}) ;; - refs/*) echo "$pfx${i#refs/*/}$sfx" ;; - *) echo "$pfx$i$sfx" ;; # symbolic refs - esac - done - fi - ;; - esac -} - -# Completes refs, short and long, local and remote, symbolic and pseudo. -# -# Usage: __git_complete_refs [