diff --git a/.gitignore b/.gitignore index 069b4707..57256fdd 100644 --- a/.gitignore +++ b/.gitignore @@ -3,12 +3,14 @@ export # Download bin/package -bin/kv2json aws awscliv2.zip -bin/aws -bin/aws_completer -bin/awscli +bin/ +!bin/.gitkeep +share/ +!share/.gitkeep +lib/ +!lib/.gitkeep # Byte-compiled / optimized / DLL files __pycache__/ diff --git a/Makefile b/Makefile index bec013ab..22bc91c1 100644 --- a/Makefile +++ b/Makefile @@ -1,20 +1,24 @@ SHELL = /usr/bin/env bash -xe AWSCLI_VERSION := 2.0.30 +JQ_VERSION := 1.6 PWD := $(shell pwd) -build_on_docker: archives/awscli-exe-linux-x86_64-$(AWSCLI_VERSION).zip +build_on_docker: yumda archives/awscli-exe-linux-x86_64-$(AWSCLI_VERSION).zip docker build -t bash-lambda-layer-builder docker/builder docker run -v $(PWD):/root/bash-lambda-layer -v $(PWD)/bin:/opt/bin \ --workdir="/root/bash-lambda-layer" \ bash-lambda-layer-builder \ make build -build: bin/kv2json awscli +build: awscli bin/jq @rm -rf export @mkdir export - @zip -yr export/layer.zip bootstrap bin lib libexec share + @zip -yr export/layer.zip bootstrap bin lib share @zip -yr export/bash-lambda-layer.zip export/layer.zip publish.sh publish-only.sh README.publish.md +yumda: + docker run --rm -v $(PWD):/lambda/opt lambci/yumda:2 yum install -y zip-3.0 unzip-6.0 + publish: @$(PWD)/publish.sh @@ -37,20 +41,25 @@ awscli: archives/awscli-exe-linux-x86_64-$(AWSCLI_VERSION).zip && ./aws/install -i /opt/bin/awscli -b /opt/bin --update \ && rm -rf aws -bin/kv2json: +bin/jq: cd bin/ \ - && curl -sOL https://raw.githubusercontent.com/Songmu/App-KV2JSON/master/kv2json \ - && chmod +x kv2json + && curl -o jq -sL https://github.com/stedolan/jq/releases/download/jq-$(JQ_VERSION)/jq-linux64 \ + && chmod +x jq clean: - rm -f bin/aws - rm -rf bin/awscli - rm -f bin/aws_completer - rm -f bin/kv2json - rm -f archives/*.zip + rm -rf bin/ + mkdir bin + touch bin/.gitkeep + rm -rf share/ + mkdir share + touch share/.gitkeep + rm -rf lib/ + mkdir lib + touch lib/.gitkeep .PHONY: \ build publish publish-staging awscli + yumda diff --git a/README.md b/README.md index d856c1ac..ebff8fa8 100644 --- a/README.md +++ b/README.md @@ -1,11 +1,16 @@ # Bash in AWS Lambda [Modified by Kayac inc.] forked [gkrizek/bash-lambda-layer](https://github.com/gkrizek/bash-lambda-layer) because we needed to modify and maintain it in our organization. -See the [original REDME](README.original.md) for details. Respect for the original gkrizek/bash-lambda-layer. +The original gkrizek/bash-lambda-layer is no longer supported on August 20, 2020. +Click [here](https://github.com/gkrizek/bash-lambda-layer/commit/703b0ade8174022d44779d823172ab7ac33a5505) for details. + ## Difference from the original +### compatible runtimes +only `provided.al2` + ### ARN ``` @@ -13,11 +18,14 @@ arn:aws:lambda::513375597510:layer:bash:4 ``` ### tools version +In kayac/bash-lambda-layer,the following executables. * AWS CLI v2.0.30 -* kv2json v0.02 +* jq 1.6 +* zip 3.0 +* unzip 6.0 ### function -* Error handling using kv2json. +* Error handling using jq, for json escape. ## How to publish to local AWS account. @@ -34,3 +42,10 @@ $ ./publish.sh ``` $AWS_REGION= ./publish-only.sh ``` + +## If want additional executable commands... + +Let's stack layers +Check `examples/additional-git-layer` for more details. + +Only add executables to kayac/bash-lambda-layer if it is often needed by our organization. diff --git a/share/git-core/templates/.gitkeep b/bin/.gitkeep similarity index 100% rename from share/git-core/templates/.gitkeep rename to bin/.gitkeep diff --git a/bin/bc b/bin/bc deleted file mode 100755 index 681431f7..00000000 Binary files a/bin/bc and /dev/null differ diff --git a/bin/git b/bin/git deleted file mode 100755 index 8b3a298e..00000000 Binary files a/bin/git and /dev/null differ diff --git a/bin/git-cvsserver b/bin/git-cvsserver deleted file mode 100755 index 0994c2ce..00000000 --- a/bin/git-cvsserver +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/sh - -echo >&2 "fatal: git was built without support for $(basename $0) (NO_PERL=1)." -exit 128 diff --git a/bin/git-receive-pack b/bin/git-receive-pack deleted file mode 120000 index 0899c299..00000000 --- a/bin/git-receive-pack +++ /dev/null @@ -1 +0,0 @@ -git \ No newline at end of file diff --git a/bin/git-shell b/bin/git-shell deleted file mode 100755 index 01febadb..00000000 Binary files a/bin/git-shell and /dev/null differ diff --git a/bin/git-upload-archive b/bin/git-upload-archive deleted file mode 120000 index 0899c299..00000000 --- a/bin/git-upload-archive +++ /dev/null @@ -1 +0,0 @@ -git \ No newline at end of file diff --git a/bin/git-upload-pack b/bin/git-upload-pack deleted file mode 120000 index 0899c299..00000000 --- a/bin/git-upload-pack +++ /dev/null @@ -1 +0,0 @@ -git \ No newline at end of file diff --git a/bin/jq b/bin/jq deleted file mode 100755 index f48b0ca9..00000000 Binary files a/bin/jq and /dev/null differ diff --git a/bin/rsync b/bin/rsync deleted file mode 100755 index 733d5c39..00000000 Binary files a/bin/rsync and /dev/null differ diff --git a/bin/scp b/bin/scp deleted file mode 100755 index 9025e295..00000000 Binary files a/bin/scp and /dev/null differ diff --git a/bin/sftp b/bin/sftp deleted file mode 100755 index 3a1c64ae..00000000 Binary files a/bin/sftp and /dev/null differ diff --git a/bin/slogin b/bin/slogin deleted file mode 120000 index 174e983b..00000000 --- a/bin/slogin +++ /dev/null @@ -1 +0,0 @@ -./ssh \ No newline at end of file diff --git a/bin/ssh b/bin/ssh deleted file mode 100755 index 5897c49c..00000000 Binary files a/bin/ssh and /dev/null differ diff --git a/bin/ssh-add b/bin/ssh-add deleted file mode 100755 index bfe28d5a..00000000 Binary files a/bin/ssh-add and /dev/null differ diff --git a/bin/ssh-agent b/bin/ssh-agent deleted file mode 100755 index 5bf6268b..00000000 Binary files a/bin/ssh-agent and /dev/null differ diff --git a/bin/ssh-copy-id b/bin/ssh-copy-id deleted file mode 100755 index b5bb723f..00000000 --- a/bin/ssh-copy-id +++ /dev/null @@ -1,303 +0,0 @@ -#!/bin/sh - -# Copyright (c) 1999-2013 Philip Hands -# 2013 Martin Kletzander -# 2010 Adeodato =?iso-8859-1?Q?Sim=F3?= -# 2010 Eric Moret -# 2009 Xr -# 2007 Justin Pryzby -# 2004 Reini Urban -# 2003 Colin Watson -# All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR -# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, -# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT -# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -# Shell script to install your public key(s) on a remote machine -# See the ssh-copy-id(1) man page for details - -# check that we have something mildly sane as our shell, or try to find something better -if false ^ printf "%s: WARNING: ancient shell, hunting for a more modern one... " "$0" -then - SANE_SH=${SANE_SH:-/usr/bin/ksh} - if printf 'true ^ false\n' | "$SANE_SH" - then - printf "'%s' seems viable.\n" "$SANE_SH" - exec "$SANE_SH" "$0" "$@" - else - cat <<-EOF - oh dear. - - If you have a more recent shell available, that supports \$(...) etc. - please try setting the environment variable SANE_SH to the path of that - shell, and then retry running this script. If that works, please report - a bug describing your setup, and the shell you used to make it work. - - EOF - printf "%s: ERROR: Less dimwitted shell required.\n" "$0" - exit 1 - fi -fi - -DEFAULT_PUB_ID_FILE=$(ls -t ${HOME}/.ssh/id*.pub 2>/dev/null | grep -v -- '-cert.pub$' | head -n 1) - -usage () { - printf 'Usage: %s [-h|-?|-n] [-i [identity_file]] [-p port] [[-o ] ...] [user@]hostname\n' "$0" >&2 - exit 1 -} - -# escape any single quotes in an argument -quote() { - printf "%s\n" "$1" | sed -e "s/'/'\\\\''/g" -} - -use_id_file() { - local L_ID_FILE="$1" - - if expr "$L_ID_FILE" : ".*\.pub$" >/dev/null ; then - PUB_ID_FILE="$L_ID_FILE" - else - PUB_ID_FILE="$L_ID_FILE.pub" - fi - - [ "x$SSH_COPY_ID_LEGACY" != "x" ] || PRIV_ID_FILE=$(dirname "$PUB_ID_FILE")/$(basename "$PUB_ID_FILE" .pub) - - # check that the files are readable - for f in $PUB_ID_FILE $PRIV_ID_FILE ; do - ErrMSG=$( { : < $f ; } 2>&1 ) || { - printf "\n%s: ERROR: failed to open ID file '%s': %s\n\n" "$0" "$f" "$(printf "%s\n" "$ErrMSG" | sed -e 's/.*: *//')" - exit 1 - } - done - GET_ID="cat \"$PUB_ID_FILE\"" -} - -if [ -n "$SSH_AUTH_SOCK" ] && ssh-add -L >/dev/null 2>&1 ; then - GET_ID="ssh-add -L" -fi - -while test "$#" -gt 0 -do - [ "${SEEN_OPT_I}" ] && expr "$1" : "[-]i" >/dev/null && { - printf "\n%s: ERROR: -i option must not be specified more than once\n\n" "$0" - usage - } - - OPT= OPTARG= - # implement something like getopt to avoid Solaris pain - case "$1" in - -i?*|-o?*|-p?*) - OPT="$(printf -- "$1"|cut -c1-2)" - OPTARG="$(printf -- "$1"|cut -c3-)" - shift - ;; - -o|-p) - OPT="$1" - OPTARG="$2" - shift 2 - ;; - -i) - OPT="$1" - test "$#" -le 2 || expr "$2" : "[-]" >/dev/null || { - OPTARG="$2" - shift - } - shift - ;; - -n|-h|-\?) - OPT="$1" - OPTARG= - shift - ;; - --) - shift - while test "$#" -gt 0 - do - SAVEARGS="${SAVEARGS:+$SAVEARGS }'$(quote "$1")'" - shift - done - break - ;; - -*) - printf "\n%s: ERROR: invalid option (%s)\n\n" "$0" "$1" - usage - ;; - *) - SAVEARGS="${SAVEARGS:+$SAVEARGS }'$(quote "$1")'" - shift - continue - ;; - esac - - case "$OPT" in - -i) - SEEN_OPT_I="yes" - use_id_file "${OPTARG:-$DEFAULT_PUB_ID_FILE}" - ;; - -o|-p) - SSH_OPTS="${SSH_OPTS:+$SSH_OPTS }$OPT '$(quote "$OPTARG")'" - ;; - -n) - DRY_RUN=1 - ;; - -h|-\?) - usage - ;; - esac -done - -eval set -- "$SAVEARGS" - -if [ $# = 0 ] ; then - usage -fi -if [ $# != 1 ] ; then - printf '%s: ERROR: Too many arguments. Expecting a target hostname, got: %s\n\n' "$0" "$SAVEARGS" >&2 - usage -fi - -# drop trailing colon -USER_HOST=$(printf "%s\n" "$1" | sed 's/:$//') -# tack the hostname onto SSH_OPTS -SSH_OPTS="${SSH_OPTS:+$SSH_OPTS }'$(quote "$USER_HOST")'" -# and populate "$@" for later use (only way to get proper quoting of options) -eval set -- "$SSH_OPTS" - -if [ -z "$(eval $GET_ID)" ] && [ -r "${PUB_ID_FILE:=$DEFAULT_PUB_ID_FILE}" ] ; then - use_id_file "$PUB_ID_FILE" -fi - -if [ -z "$(eval $GET_ID)" ] ; then - printf '%s: ERROR: No identities found\n' "$0" >&2 - exit 1 -fi - -# populate_new_ids() uses several global variables ($USER_HOST, $SSH_OPTS ...) -# and has the side effect of setting $NEW_IDS -populate_new_ids() { - local L_SUCCESS="$1" - - # repopulate "$@" inside this function - eval set -- "$SSH_OPTS" - - umask 0177 - local L_TMP_ID_FILE=$(mktemp ~/.ssh/ssh-copy-id_id.XXXXXXXXXX) - if test $? -ne 0 || test "x$L_TMP_ID_FILE" = "x" ; then - echo "mktemp failed" 1>&2 - exit 1 - fi - trap "rm -f $L_TMP_ID_FILE ${L_TMP_ID_FILE}.pub" EXIT TERM INT QUIT - printf '%s: INFO: attempting to log in with the new key(s), to filter out any that are already installed\n' "$0" >&2 - NEW_IDS=$( - eval $GET_ID | { - while read ID ; do - printf '%s\n' "$ID" > $L_TMP_ID_FILE - - # the next line assumes $PRIV_ID_FILE only set if using a single id file - this - # assumption will break if we implement the possibility of multiple -i options. - # The point being that if file based, ssh needs the private key, which it cannot - # find if only given the contents of the .pub file in an unrelated tmpfile - ssh -i "${PRIV_ID_FILE:-$L_TMP_ID_FILE}" \ - -o LogLevel=INFO \ - -o PreferredAuthentications=publickey \ - -o IdentitiesOnly=yes "$@" exit 2>$L_TMP_ID_FILE.stderr $L_TMP_ID_FILE - else - grep 'Permission denied' $L_TMP_ID_FILE.stderr >/dev/null || { - sed -e 's/^/ERROR: /' <$L_TMP_ID_FILE.stderr >$L_TMP_ID_FILE - cat >/dev/null #consume the other keys, causing loop to end - } - fi - - cat $L_TMP_ID_FILE - done - } - ) - rm -f $L_TMP_ID_FILE* && trap - EXIT TERM INT QUIT - - if expr "$NEW_IDS" : "^ERROR: " >/dev/null ; then - printf '\n%s: %s\n\n' "$0" "$NEW_IDS" >&2 - exit 1 - fi - if [ -z "$NEW_IDS" ] ; then - printf '\n%s: WARNING: All keys were skipped because they already exist on the remote system.\n\n' "$0" >&2 - exit 0 - fi - printf '%s: INFO: %d key(s) remain to be installed -- if you are prompted now it is to install the new keys\n' "$0" "$(printf '%s\n' "$NEW_IDS" | wc -l)" >&2 -} - -[ "x$SSH_COPY_ID_LEGACY" != "x" ] || REMOTE_VERSION=$(ssh -v -o PreferredAuthentications=',' "$@" 2>&1 | - sed -ne 's/.*remote software version //p') - -case "$REMOTE_VERSION" in - NetScreen*) - populate_new_ids 1 - for KEY in $(printf "%s" "$NEW_IDS" | cut -d' ' -f2) ; do - KEY_NO=$(($KEY_NO + 1)) - printf "%s\n" "$KEY" | grep ssh-dss >/dev/null || { - printf '%s: WARNING: Non-dsa key (#%d) skipped (NetScreen only supports DSA keys)\n' "$0" "$KEY_NO" >&2 - continue - } - [ "$DRY_RUN" ] || printf 'set ssh pka-dsa key %s\nsave\nexit\n' "$KEY" | ssh -T "$@" >/dev/null 2>&1 - if [ $? = 255 ] ; then - printf '%s: ERROR: installation of key #%d failed (please report a bug describing what caused this, so that we can make this message useful)\n' "$0" "$KEY_NO" >&2 - else - ADDED=$(($ADDED + 1)) - fi - done - if [ -z "$ADDED" ] ; then - exit 1 - fi - ;; - *) - # Assuming that the remote host treats ~/.ssh/authorized_keys as one might expect - if [ "x$SSH_COPY_ID_LEGACY" != "x" ]; then - NEW_IDS=`eval "$GET_ID"` - else - populate_new_ids 0 - fi - [ "$DRY_RUN" ] || printf '%s\n' "$NEW_IDS" | ssh "$@" " - exec sh -c 'umask 077; mkdir -p .ssh && cat >> .ssh/authorized_keys || exit 1; if type restorecon >/dev/null 2>&1; then restorecon -F .ssh .ssh/authorized_keys; fi'" \ - || exit 1 - ADDED=$(printf '%s\n' "$NEW_IDS" | wc -l) - ;; -esac - -if [ "$DRY_RUN" ] ; then - cat <<-EOF - =-=-=-=-=-=-=-= - Would have added the following key(s): - - $NEW_IDS - =-=-=-=-=-=-=-= - EOF -else - cat <<-EOF - - Number of key(s) added: $ADDED - - Now try logging into the machine, with: "ssh $SSH_OPTS" - and check to make sure that only the key(s) you wanted were added. - - EOF -fi - -# =-=-=-= diff --git a/bin/ssh-keygen b/bin/ssh-keygen deleted file mode 100755 index 8b2895ce..00000000 Binary files a/bin/ssh-keygen and /dev/null differ diff --git a/bin/ssh-keyscan b/bin/ssh-keyscan deleted file mode 100755 index 70f57356..00000000 Binary files a/bin/ssh-keyscan and /dev/null differ diff --git a/bin/sshpass b/bin/sshpass deleted file mode 100755 index 46ef7502..00000000 Binary files a/bin/sshpass and /dev/null differ diff --git a/bin/time b/bin/time deleted file mode 100755 index 2ef38c01..00000000 Binary files a/bin/time and /dev/null differ diff --git a/bin/traceroute b/bin/traceroute deleted file mode 100755 index 85d9e162..00000000 Binary files a/bin/traceroute and /dev/null differ diff --git a/bin/tree b/bin/tree deleted file mode 100755 index 42ab1f5f..00000000 Binary files a/bin/tree and /dev/null differ diff --git a/bin/unzip b/bin/unzip deleted file mode 100755 index 84c4dc82..00000000 Binary files a/bin/unzip and /dev/null differ diff --git a/bin/vim b/bin/vim deleted file mode 100755 index 245810a5..00000000 Binary files a/bin/vim and /dev/null differ diff --git a/bin/wget b/bin/wget deleted file mode 100755 index f4905e6d..00000000 Binary files a/bin/wget and /dev/null differ diff --git a/bin/zip b/bin/zip deleted file mode 100755 index 380f160a..00000000 Binary files a/bin/zip and /dev/null differ diff --git a/bootstrap b/bootstrap index f84825f4..fb818db6 100755 --- a/bootstrap +++ b/bootstrap @@ -13,7 +13,11 @@ export AWS_CONFIG_FILE="/tmp/.aws/config" sendInitError () { ERROR_MESSAGE=$1 ERROR_TYPE=$2 - ERROR=$(kv2json errorMessage="$ERROR_MESSAGE" errorType="$ERROR_TYPE" ) + ERROR=$(jq -n \ + --arg em "$ERROR_MESSAGE" \ + --arg et "$ERROR_TYPE" \ + '{errorMessage: $em, errorType: $et}' + ) curl -sS -X POST -d "$ERROR" --header "Lambda-Runtime-Function-Error-Type: Unhandled" "http://${AWS_LAMBDA_RUNTIME_API}/${RUNTIME_PATH}/init/error" > /dev/null } @@ -23,7 +27,12 @@ sendRuntimeError () { ERROR_MESSAGE=$2 ERROR_TYPE=$3 STACK_TRACE=$4 - ERROR=$(kv2json errorMessage="$ERROR_MESSAGE" errorType="$ERROR_TYPE" stackTrace="$STACK_TRACE") + ERROR=$(jq -n \ + --arg em "$ERROR_MESSAGE" \ + --arg et "$ERROR_TYPE" \ + --arg st "$STACK_TRACE"\ + '{errorMessage: $em, errorType: $et, stackTrace: $st}' + ) curl -sS -X POST -d "$ERROR" --header "Lambda-Runtime-Function-Error-Type: Unhandled" "http://${AWS_LAMBDA_RUNTIME_API}/${RUNTIME_PATH}/invocation/${REQUEST_ID}/error" > /dev/null } diff --git a/examples/.gitignore b/examples/.gitignore new file mode 100644 index 00000000..b3ec2920 --- /dev/null +++ b/examples/.gitignore @@ -0,0 +1 @@ +additional-git-layer-publish-result.json diff --git a/examples/Makefile b/examples/Makefile new file mode 100644 index 00000000..e09dd7ef --- /dev/null +++ b/examples/Makefile @@ -0,0 +1,18 @@ + +export AWS_REGION=ap-northeast-1 + +all: deploy/basic + +tools: + brew install fujiwara/tap/lambroll + +deploy/%: + cd $*/ && lambroll --region ${AWS_REGION} deploy + +deploy/additional-git-layer: additional-git-layer-publish-result.json + export GIT_LAYER_ARN=$(shell cat ./additional-git-layer-publish-result.json | jq -r .LayerVersionArn) + cd additional-git-layer/ && lambroll --region ${AWS_REGION} deploy + +additional-git-layer-publish-result.json: + $(PWD)/publish-addtional-git-layer.sh + diff --git a/examples/additional-git-layer/function.json b/examples/additional-git-layer/function.json new file mode 100644 index 00000000..6706b696 --- /dev/null +++ b/examples/additional-git-layer/function.json @@ -0,0 +1,12 @@ +{ + "FunctionName": "bash-lambda-layer-example-additional-git-layer", + "Handler": "index.handler", + "MemorySize": 128, + "Layers": [ + "{{must_env `BASH_LAYER_ARN`}}", + "{{must_env `GIT_LAYER_ARN`}}" + ], + "Role": "{{must_env `LAMBDA_IAM_ARN`}}", + "Runtime": "provided.al2", + "Timeout": 30 +} diff --git a/examples/additional-git-layer/index.sh b/examples/additional-git-layer/index.sh new file mode 100644 index 00000000..52002543 --- /dev/null +++ b/examples/additional-git-layer/index.sh @@ -0,0 +1,15 @@ +function handler { + set -e + AWS_VERSION=$(aws --version) + JQ_VERSION=$(jq --version) + GIT_VERSION=$(git --version) + + OUTPUT=$( \ + jq -n \ + --arg awsVersion "$AWS_VERSION" \ + --arg jqVersion "$JQ_VERSION" \ + --arg gitVersion "$GIT_VERSION" \ + '{aws: $awsVersion, jq: $jqVersion, git: $gitVersion}' + ) + echo "${OUTPUT}" >&2 +} diff --git a/examples/basic/function.json b/examples/basic/function.json new file mode 100644 index 00000000..312dfa20 --- /dev/null +++ b/examples/basic/function.json @@ -0,0 +1,11 @@ +{ + "FunctionName": "bash-lambda-layer-example-basic", + "Handler": "index.handler", + "MemorySize": 128, + "Layers": [ + "{{must_env `BASH_LAYER_ARN`}}" + ], + "Role": "{{must_env `LAMBDA_IAM_ARN`}}", + "Runtime": "provided.al2", + "Timeout": 30 +} diff --git a/examples/example-basic.sh b/examples/basic/index.sh old mode 100755 new mode 100644 similarity index 99% rename from examples/example-basic.sh rename to examples/basic/index.sh index e164204a..987e9122 --- a/examples/example-basic.sh +++ b/examples/basic/index.sh @@ -16,4 +16,4 @@ handler () { # This is the return value because it's being sent to stderr (>&2) echo "{\"success\": true}" >&2 -} \ No newline at end of file +} diff --git a/examples/example-git.sh b/examples/example-git.sh deleted file mode 100755 index a004dcc4..00000000 --- a/examples/example-git.sh +++ /dev/null @@ -1,23 +0,0 @@ - -handler () { - set -e - - EVENT_DATA=$1 - echo $EVENT_DATA - - REPO=$(echo $EVENT_DATA | jq -r ."repository") - OWNER=$(echo $EVENT_DATA | jq -r ."owner") - BUCKET=$(echo $EVENT_DATA | jq -r ."bucket") - mkdir -p /tmp/.ssh - aws s3 cp s3://$BUCKET/id_rsa /tmp/.ssh/id_rsa - chmod 400 /tmp/.ssh/id_rsa - eval `ssh-agent -s` - export GIT_SSH="/tmp" - export GIT_SSH_COMMAND="ssh -o UserKnownHostsFile=/tmp/.ssh/known_hosts -i /tmp/.ssh/id_rsa" - ssh-add /tmp/.ssh/id_rsa 2>&1 - ssh-keyscan github.com >> /tmp/.ssh/known_hosts 2>&1 - git clone ssh://git@github.com/$OWNER/$REPO.git /tmp/$REPO 2>&1 - ls -al /tmp/$REPO - - echo "Successfully cloned repository" >&2 -} \ No newline at end of file diff --git a/examples/publish-addtional-git-layer.sh b/examples/publish-addtional-git-layer.sh new file mode 100755 index 00000000..d2872a6f --- /dev/null +++ b/examples/publish-addtional-git-layer.sh @@ -0,0 +1,15 @@ +#!/bin/bash -e + +mkdir -p layer +docker run --rm -v $(PWD)/layer:/lambda/opt lambci/yumda:2 yum install -y git +cd layer && zip -yr layer.zip * && cd ../ +aws lambda publish-layer-version \ + --region ${AWS_REGION} \ + --layer-name bash-lambda-layer-example-git-layer \ + --description "bash-lambda-layer example additional layer for git" \ + --compatible-runtimes provided.al2 \ + --license MIT \ + --zip-file fileb://layer/layer.zip > additional-git-layer-publish-result.json +GIT_LAYER_ARN=$(cat additional-git-layer-publish-result.jso | jq -r .LayerVersionArn) +echo ${GIT_LAYER_ARN} +rm -rf layer diff --git a/lib/.gitkeep b/lib/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/lib/fipscheck/fipscheck.hmac b/lib/fipscheck/fipscheck.hmac deleted file mode 100644 index c961a742..00000000 --- a/lib/fipscheck/fipscheck.hmac +++ /dev/null @@ -1 +0,0 @@ -5dc9d8898144156e2a69cb3fa42e50d07f66c1e8dd0374f6bf88c8aed32e91c7 diff --git a/lib/fipscheck/libfipscheck.so.1.1.0.hmac b/lib/fipscheck/libfipscheck.so.1.1.0.hmac deleted file mode 100644 index 0c3b8533..00000000 --- a/lib/fipscheck/libfipscheck.so.1.1.0.hmac +++ /dev/null @@ -1 +0,0 @@ -afbb0be94f39a0c1ecd1b09148c0d28943d768795e4523e201fb3d31a070eca9 diff --git a/lib/fipscheck/libfipscheck.so.1.hmac b/lib/fipscheck/libfipscheck.so.1.hmac deleted file mode 120000 index 82eb32f8..00000000 --- a/lib/fipscheck/libfipscheck.so.1.hmac +++ /dev/null @@ -1 +0,0 @@ -libfipscheck.so.1.1.0.hmac \ No newline at end of file diff --git a/lib/fipscheck/ssh.hmac b/lib/fipscheck/ssh.hmac deleted file mode 100644 index 28a29b20..00000000 --- a/lib/fipscheck/ssh.hmac +++ /dev/null @@ -1 +0,0 @@ -b3c1093f66233c5e0e2000ab0b430f6f6176eb613c755a627fbc1e4bb80c1ad4 diff --git a/lib/libedit.so.0 b/lib/libedit.so.0 deleted file mode 120000 index 892100bd..00000000 --- a/lib/libedit.so.0 +++ /dev/null @@ -1 +0,0 @@ -libedit.so.0.0.27 \ No newline at end of file diff --git a/lib/libedit.so.0.0.27 b/lib/libedit.so.0.0.27 deleted file mode 100755 index 8112e5d3..00000000 Binary files a/lib/libedit.so.0.0.27 and /dev/null differ diff --git a/lib/libfipscheck.so.1 b/lib/libfipscheck.so.1 deleted file mode 120000 index 217fb8b6..00000000 --- a/lib/libfipscheck.so.1 +++ /dev/null @@ -1 +0,0 @@ -libfipscheck.so.1.1.0 \ No newline at end of file diff --git a/lib/libfipscheck.so.1.1.0 b/lib/libfipscheck.so.1.1.0 deleted file mode 100755 index 4b1bab4a..00000000 Binary files a/lib/libfipscheck.so.1.1.0 and /dev/null differ diff --git a/lib/libgpm.so.2 b/lib/libgpm.so.2 deleted file mode 120000 index 933ff81e..00000000 --- a/lib/libgpm.so.2 +++ /dev/null @@ -1 +0,0 @@ -libgpm.so.2.1.0 \ No newline at end of file diff --git a/lib/libgpm.so.2.1.0 b/lib/libgpm.so.2.1.0 deleted file mode 100755 index 4583e832..00000000 Binary files a/lib/libgpm.so.2.1.0 and /dev/null differ diff --git a/lib/libidn.so.11 b/lib/libidn.so.11 deleted file mode 100755 index abd1252f..00000000 Binary files a/lib/libidn.so.11 and /dev/null differ diff --git a/lib/libruby.so.2.0 b/lib/libruby.so.2.0 deleted file mode 120000 index 18a6bbcd..00000000 --- a/lib/libruby.so.2.0 +++ /dev/null @@ -1 +0,0 @@ -libruby.so.2.0.0 \ No newline at end of file diff --git a/lib/libruby.so.2.0.0 b/lib/libruby.so.2.0.0 deleted file mode 100755 index d3292500..00000000 Binary files a/lib/libruby.so.2.0.0 and /dev/null differ diff --git a/libexec/git-core/git b/libexec/git-core/git deleted file mode 120000 index f2cccfc2..00000000 --- a/libexec/git-core/git +++ /dev/null @@ -1 +0,0 @@ -../../bin/git \ No newline at end of file diff --git a/libexec/git-core/git-add b/libexec/git-core/git-add deleted file mode 120000 index f2cccfc2..00000000 --- a/libexec/git-core/git-add +++ /dev/null @@ -1 +0,0 @@ -../../bin/git \ No newline at end of file diff --git a/libexec/git-core/git-add--interactive b/libexec/git-core/git-add--interactive deleted file mode 100755 index 0994c2ce..00000000 --- a/libexec/git-core/git-add--interactive +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/sh - -echo >&2 "fatal: git was built without support for $(basename $0) (NO_PERL=1)." -exit 128 diff --git a/libexec/git-core/git-am b/libexec/git-core/git-am deleted file mode 120000 index f2cccfc2..00000000 --- a/libexec/git-core/git-am +++ /dev/null @@ -1 +0,0 @@ -../../bin/git \ No newline at end of file diff --git a/libexec/git-core/git-annotate b/libexec/git-core/git-annotate deleted file mode 120000 index f2cccfc2..00000000 --- a/libexec/git-core/git-annotate +++ /dev/null @@ -1 +0,0 @@ -../../bin/git \ No newline at end of file diff --git a/libexec/git-core/git-apply b/libexec/git-core/git-apply deleted file mode 120000 index f2cccfc2..00000000 --- a/libexec/git-core/git-apply +++ /dev/null @@ -1 +0,0 @@ -../../bin/git \ No newline at end of file diff --git a/libexec/git-core/git-archimport b/libexec/git-core/git-archimport deleted file mode 100755 index 0994c2ce..00000000 --- a/libexec/git-core/git-archimport +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/sh - -echo >&2 "fatal: git was built without support for $(basename $0) (NO_PERL=1)." -exit 128 diff --git a/libexec/git-core/git-archive b/libexec/git-core/git-archive deleted file mode 120000 index f2cccfc2..00000000 --- a/libexec/git-core/git-archive +++ /dev/null @@ -1 +0,0 @@ -../../bin/git \ No newline at end of file diff --git a/libexec/git-core/git-bisect b/libexec/git-core/git-bisect deleted file mode 100755 index 54cbfecc..00000000 --- a/libexec/git-core/git-bisect +++ /dev/null @@ -1,628 +0,0 @@ -#!/bin/sh - -USAGE='[help|start|bad|good|new|old|terms|skip|next|reset|visualize|view|replay|log|run]' -LONG_USAGE='git bisect help - print this long help message. -git bisect start [--term-{old,good}= --term-{new,bad}=] - [--no-checkout] [ [...]] [--] [...] - reset bisect state and start bisection. -git bisect (bad|new) [] - mark a known-bad revision/ - a revision after change in a given property. -git bisect (good|old) [...] - mark ... known-good revisions/ - revisions before change in a given property. -git bisect terms [--term-good | --term-bad] - show the terms used for old and new commits (default: bad, good) -git bisect skip [(|)...] - mark ... untestable revisions. -git bisect next - find next bisection to test and check it out. -git bisect reset [] - finish bisection search and go back to commit. -git bisect (visualize|view) - show bisect status in gitk. -git bisect replay - replay bisection log. -git bisect log - show bisect log. -git bisect run ... - use ... to automatically bisect. - -Please use "git help bisect" to get the full man page.' - -OPTIONS_SPEC= -. git-sh-setup - -_x40='[0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f]' -_x40="$_x40$_x40$_x40$_x40$_x40$_x40$_x40$_x40" -TERM_BAD=bad -TERM_GOOD=good - -bisect_head() -{ - if test -f "$GIT_DIR/BISECT_HEAD" - then - echo BISECT_HEAD - else - echo HEAD - fi -} - -bisect_autostart() { - test -s "$GIT_DIR/BISECT_START" || { - gettextln "You need to start by \"git bisect start\"" >&2 - if test -t 0 - then - # TRANSLATORS: Make sure to include [Y] and [n] in your - # translation. The program will only accept English input - # at this point. - gettext "Do you want me to do it for you [Y/n]? " >&2 - read yesno - case "$yesno" in - [Nn]*) - exit ;; - esac - bisect_start - else - exit 1 - fi - } -} - -bisect_start() { - # - # Check for one bad and then some good revisions. - # - has_double_dash=0 - for arg; do - case "$arg" in --) has_double_dash=1; break ;; esac - done - orig_args=$(git rev-parse --sq-quote "$@") - bad_seen=0 - eval='' - must_write_terms=0 - revs='' - if test "z$(git rev-parse --is-bare-repository)" != zfalse - then - mode=--no-checkout - else - mode='' - fi - while [ $# -gt 0 ]; do - arg="$1" - case "$arg" in - --) - shift - break - ;; - --no-checkout) - mode=--no-checkout - shift ;; - --term-good|--term-old) - shift - must_write_terms=1 - TERM_GOOD=$1 - shift ;; - --term-good=*|--term-old=*) - must_write_terms=1 - TERM_GOOD=${1#*=} - shift ;; - --term-bad|--term-new) - shift - must_write_terms=1 - TERM_BAD=$1 - shift ;; - --term-bad=*|--term-new=*) - must_write_terms=1 - TERM_BAD=${1#*=} - shift ;; - --*) - die "$(eval_gettext "unrecognised option: '\$arg'")" ;; - *) - rev=$(git rev-parse -q --verify "$arg^{commit}") || { - test $has_double_dash -eq 1 && - die "$(eval_gettext "'\$arg' does not appear to be a valid revision")" - break - } - revs="$revs $rev" - shift - ;; - esac - done - - for rev in $revs - do - # The user ran "git bisect start - # ", hence did not explicitly specify - # the terms, but we are already starting to - # set references named with the default terms, - # and won't be able to change afterwards. - must_write_terms=1 - - case $bad_seen in - 0) state=$TERM_BAD ; bad_seen=1 ;; - *) state=$TERM_GOOD ;; - esac - eval="$eval bisect_write '$state' '$rev' 'nolog' &&" - done - # - # Verify HEAD. - # - head=$(GIT_DIR="$GIT_DIR" git symbolic-ref -q HEAD) || - head=$(GIT_DIR="$GIT_DIR" git rev-parse --verify HEAD) || - die "$(gettext "Bad HEAD - I need a HEAD")" - - # - # Check if we are bisecting. - # - start_head='' - if test -s "$GIT_DIR/BISECT_START" - then - # Reset to the rev from where we started. - start_head=$(cat "$GIT_DIR/BISECT_START") - if test "z$mode" != "z--no-checkout" - then - git checkout "$start_head" -- || - die "$(eval_gettext "Checking out '\$start_head' failed. Try 'git bisect reset '.")" - fi - else - # Get rev from where we start. - case "$head" in - refs/heads/*|$_x40) - # This error message should only be triggered by - # cogito usage, and cogito users should understand - # it relates to cg-seek. - [ -s "$GIT_DIR/head-name" ] && - die "$(gettext "won't bisect on cg-seek'ed tree")" - start_head="${head#refs/heads/}" - ;; - *) - die "$(gettext "Bad HEAD - strange symbolic ref")" - ;; - esac - fi - - # - # Get rid of any old bisect state. - # - git bisect--helper --bisect-clean-state || exit - - # - # Change state. - # In case of mistaken revs or checkout error, or signals received, - # "bisect_auto_next" below may exit or misbehave. - # We have to trap this to be able to clean up using - # "bisect_clean_state". - # - trap 'git bisect--helper --bisect-clean-state' 0 - trap 'exit 255' 1 2 3 15 - - # - # Write new start state. - # - echo "$start_head" >"$GIT_DIR/BISECT_START" && { - test "z$mode" != "z--no-checkout" || - git update-ref --no-deref BISECT_HEAD "$start_head" - } && - git rev-parse --sq-quote "$@" >"$GIT_DIR/BISECT_NAMES" && - eval "$eval true" && - if test $must_write_terms -eq 1 - then - git bisect--helper --write-terms "$TERM_BAD" "$TERM_GOOD" || exit - fi && - echo "git bisect start$orig_args" >>"$GIT_DIR/BISECT_LOG" || exit - # - # Check if we can proceed to the next bisect state. - # - bisect_auto_next - - trap '-' 0 -} - -bisect_write() { - state="$1" - rev="$2" - nolog="$3" - case "$state" in - "$TERM_BAD") - tag="$state" ;; - "$TERM_GOOD"|skip) - tag="$state"-"$rev" ;; - *) - die "$(eval_gettext "Bad bisect_write argument: \$state")" ;; - esac - git update-ref "refs/bisect/$tag" "$rev" || exit - echo "# $state: $(git show-branch $rev)" >>"$GIT_DIR/BISECT_LOG" - test -n "$nolog" || echo "git bisect $state $rev" >>"$GIT_DIR/BISECT_LOG" -} - -bisect_skip() { - all='' - for arg in "$@" - do - case "$arg" in - *..*) - revs=$(git rev-list "$arg") || die "$(eval_gettext "Bad rev input: \$arg")" ;; - *) - revs=$(git rev-parse --sq-quote "$arg") ;; - esac - all="$all $revs" - done - eval bisect_state 'skip' $all -} - -bisect_state() { - bisect_autostart - state=$1 - check_and_set_terms $state - case "$#,$state" in - 0,*) - die "Please call 'bisect_state' with at least one argument." ;; - 1,"$TERM_BAD"|1,"$TERM_GOOD"|1,skip) - bisected_head=$(bisect_head) - rev=$(git rev-parse --verify "$bisected_head") || - die "$(eval_gettext "Bad rev input: \$bisected_head")" - bisect_write "$state" "$rev" - git bisect--helper --check-expected-revs "$rev" ;; - 2,"$TERM_BAD"|*,"$TERM_GOOD"|*,skip) - shift - hash_list='' - for rev in "$@" - do - sha=$(git rev-parse --verify "$rev^{commit}") || - die "$(eval_gettext "Bad rev input: \$rev")" - hash_list="$hash_list $sha" - done - for rev in $hash_list - do - bisect_write "$state" "$rev" - done - git bisect--helper --check-expected-revs $hash_list ;; - *,"$TERM_BAD") - die "$(eval_gettext "'git bisect \$TERM_BAD' can take only one argument.")" ;; - *) - usage ;; - esac - bisect_auto_next -} - -bisect_next_check() { - missing_good= missing_bad= - git show-ref -q --verify refs/bisect/$TERM_BAD || missing_bad=t - test -n "$(git for-each-ref "refs/bisect/$TERM_GOOD-*")" || missing_good=t - - case "$missing_good,$missing_bad,$1" in - ,,*) - : have both $TERM_GOOD and $TERM_BAD - ok - ;; - *,) - # do not have both but not asked to fail - just report. - false - ;; - t,,"$TERM_GOOD") - # have bad (or new) but not good (or old). we could bisect although - # this is less optimum. - eval_gettextln "Warning: bisecting only with a \$TERM_BAD commit." >&2 - if test -t 0 - then - # TRANSLATORS: Make sure to include [Y] and [n] in your - # translation. The program will only accept English input - # at this point. - gettext "Are you sure [Y/n]? " >&2 - read yesno - case "$yesno" in [Nn]*) exit 1 ;; esac - fi - : bisect without $TERM_GOOD... - ;; - *) - bad_syn=$(bisect_voc bad) - good_syn=$(bisect_voc good) - if test -s "$GIT_DIR/BISECT_START" - then - - eval_gettextln "You need to give me at least one \$bad_syn and one \$good_syn revision. -(You can use \"git bisect \$bad_syn\" and \"git bisect \$good_syn\" for that.)" >&2 - else - eval_gettextln "You need to start by \"git bisect start\". -You then need to give me at least one \$good_syn and one \$bad_syn revision. -(You can use \"git bisect \$bad_syn\" and \"git bisect \$good_syn\" for that.)" >&2 - fi - exit 1 ;; - esac -} - -bisect_auto_next() { - bisect_next_check && bisect_next || : -} - -bisect_next() { - case "$#" in 0) ;; *) usage ;; esac - bisect_autostart - bisect_next_check $TERM_GOOD - - # Perform all bisection computation, display and checkout - git bisect--helper --next-all $(test -f "$GIT_DIR/BISECT_HEAD" && echo --no-checkout) - res=$? - - # Check if we should exit because bisection is finished - if test $res -eq 10 - then - bad_rev=$(git show-ref --hash --verify refs/bisect/$TERM_BAD) - bad_commit=$(git show-branch $bad_rev) - echo "# first $TERM_BAD commit: $bad_commit" >>"$GIT_DIR/BISECT_LOG" - exit 0 - elif test $res -eq 2 - then - echo "# only skipped commits left to test" >>"$GIT_DIR/BISECT_LOG" - good_revs=$(git for-each-ref --format="%(objectname)" "refs/bisect/$TERM_GOOD-*") - for skipped in $(git rev-list refs/bisect/$TERM_BAD --not $good_revs) - do - skipped_commit=$(git show-branch $skipped) - echo "# possible first $TERM_BAD commit: $skipped_commit" >>"$GIT_DIR/BISECT_LOG" - done - exit $res - fi - - # Check for an error in the bisection process - test $res -ne 0 && exit $res - - return 0 -} - -bisect_visualize() { - bisect_next_check fail - - if test $# = 0 - then - if test -n "${DISPLAY+set}${SESSIONNAME+set}${MSYSTEM+set}${SECURITYSESSIONID+set}" && - type gitk >/dev/null 2>&1 - then - set gitk - else - set git log - fi - else - case "$1" in - git*|tig) ;; - -*) set git log "$@" ;; - *) set git "$@" ;; - esac - fi - - eval '"$@"' --bisect -- $(cat "$GIT_DIR/BISECT_NAMES") -} - -bisect_reset() { - test -s "$GIT_DIR/BISECT_START" || { - gettextln "We are not bisecting." - return - } - case "$#" in - 0) branch=$(cat "$GIT_DIR/BISECT_START") ;; - 1) git rev-parse --quiet --verify "$1^{commit}" >/dev/null || { - invalid="$1" - die "$(eval_gettext "'\$invalid' is not a valid commit")" - } - branch="$1" ;; - *) - usage ;; - esac - - if ! test -f "$GIT_DIR/BISECT_HEAD" && ! git checkout "$branch" -- - then - die "$(eval_gettext "Could not check out original HEAD '\$branch'. -Try 'git bisect reset '.")" - fi - git bisect--helper --bisect-clean-state || exit -} - -bisect_replay () { - file="$1" - test "$#" -eq 1 || die "$(gettext "No logfile given")" - test -r "$file" || die "$(eval_gettext "cannot read \$file for replaying")" - bisect_reset - while read git bisect command rev - do - test "$git $bisect" = "git bisect" || test "$git" = "git-bisect" || continue - if test "$git" = "git-bisect" - then - rev="$command" - command="$bisect" - fi - get_terms - check_and_set_terms "$command" - case "$command" in - start) - cmd="bisect_start $rev" - eval "$cmd" ;; - "$TERM_GOOD"|"$TERM_BAD"|skip) - bisect_write "$command" "$rev" ;; - terms) - bisect_terms $rev ;; - *) - die "$(gettext "?? what are you talking about?")" ;; - esac - done <"$file" - bisect_auto_next -} - -bisect_run () { - bisect_next_check fail - - test -n "$*" || die "$(gettext "bisect run failed: no command provided.")" - - while true - do - command="$@" - eval_gettextln "running \$command" - "$@" - res=$? - - # Check for really bad run error. - if [ $res -lt 0 -o $res -ge 128 ] - then - eval_gettextln "bisect run failed: -exit code \$res from '\$command' is < 0 or >= 128" >&2 - exit $res - fi - - # Find current state depending on run success or failure. - # A special exit code of 125 means cannot test. - if [ $res -eq 125 ] - then - state='skip' - elif [ $res -gt 0 ] - then - state="$TERM_BAD" - else - state="$TERM_GOOD" - fi - - # We have to use a subshell because "bisect_state" can exit. - ( bisect_state $state >"$GIT_DIR/BISECT_RUN" ) - res=$? - - cat "$GIT_DIR/BISECT_RUN" - - if sane_grep "first $TERM_BAD commit could be any of" "$GIT_DIR/BISECT_RUN" \ - >/dev/null - then - gettextln "bisect run cannot continue any more" >&2 - exit $res - fi - - if [ $res -ne 0 ] - then - eval_gettextln "bisect run failed: -'bisect_state \$state' exited with error code \$res" >&2 - exit $res - fi - - if sane_grep "is the first $TERM_BAD commit" "$GIT_DIR/BISECT_RUN" >/dev/null - then - gettextln "bisect run success" - exit 0; - fi - - done -} - -bisect_log () { - test -s "$GIT_DIR/BISECT_LOG" || die "$(gettext "We are not bisecting.")" - cat "$GIT_DIR/BISECT_LOG" -} - -get_terms () { - if test -s "$GIT_DIR/BISECT_TERMS" - then - { - read TERM_BAD - read TERM_GOOD - } <"$GIT_DIR/BISECT_TERMS" - fi -} - -check_and_set_terms () { - cmd="$1" - case "$cmd" in - skip|start|terms) ;; - *) - if test -s "$GIT_DIR/BISECT_TERMS" && test "$cmd" != "$TERM_BAD" && test "$cmd" != "$TERM_GOOD" - then - die "$(eval_gettext "Invalid command: you're currently in a \$TERM_BAD/\$TERM_GOOD bisect.")" - fi - case "$cmd" in - bad|good) - if ! test -s "$GIT_DIR/BISECT_TERMS" - then - TERM_BAD=bad - TERM_GOOD=good - git bisect--helper --write-terms "$TERM_BAD" "$TERM_GOOD" || exit - fi - ;; - new|old) - if ! test -s "$GIT_DIR/BISECT_TERMS" - then - TERM_BAD=new - TERM_GOOD=old - git bisect--helper --write-terms "$TERM_BAD" "$TERM_GOOD" || exit - fi - ;; - esac ;; - esac -} - -bisect_voc () { - case "$1" in - bad) echo "bad|new" ;; - good) echo "good|old" ;; - esac -} - -bisect_terms () { - get_terms - if ! test -s "$GIT_DIR/BISECT_TERMS" - then - die "$(gettext "no terms defined")" - fi - case "$#" in - 0) - gettextln "Your current terms are $TERM_GOOD for the old state -and $TERM_BAD for the new state." - ;; - 1) - arg=$1 - case "$arg" in - --term-good|--term-old) - printf '%s\n' "$TERM_GOOD" - ;; - --term-bad|--term-new) - printf '%s\n' "$TERM_BAD" - ;; - *) - die "$(eval_gettext "invalid argument \$arg for 'git bisect terms'. -Supported options are: --term-good|--term-old and --term-bad|--term-new.")" - ;; - esac - ;; - *) - usage ;; - esac -} - -case "$#" in -0) - usage ;; -*) - cmd="$1" - get_terms - shift - case "$cmd" in - help) - git bisect -h ;; - start) - bisect_start "$@" ;; - bad|good|new|old|"$TERM_BAD"|"$TERM_GOOD") - bisect_state "$cmd" "$@" ;; - skip) - bisect_skip "$@" ;; - next) - # Not sure we want "next" at the UI level anymore. - bisect_next "$@" ;; - visualize|view) - bisect_visualize "$@" ;; - reset) - bisect_reset "$@" ;; - replay) - bisect_replay "$@" ;; - log) - bisect_log ;; - run) - bisect_run "$@" ;; - terms) - bisect_terms "$@" ;; - *) - usage ;; - esac -esac diff --git a/libexec/git-core/git-bisect--helper b/libexec/git-core/git-bisect--helper deleted file mode 120000 index f2cccfc2..00000000 --- a/libexec/git-core/git-bisect--helper +++ /dev/null @@ -1 +0,0 @@ -../../bin/git \ No newline at end of file diff --git a/libexec/git-core/git-blame b/libexec/git-core/git-blame deleted file mode 120000 index f2cccfc2..00000000 --- a/libexec/git-core/git-blame +++ /dev/null @@ -1 +0,0 @@ -../../bin/git \ No newline at end of file diff --git a/libexec/git-core/git-branch b/libexec/git-core/git-branch deleted file mode 120000 index f2cccfc2..00000000 --- a/libexec/git-core/git-branch +++ /dev/null @@ -1 +0,0 @@ -../../bin/git \ No newline at end of file diff --git a/libexec/git-core/git-bundle b/libexec/git-core/git-bundle deleted file mode 120000 index f2cccfc2..00000000 --- a/libexec/git-core/git-bundle +++ /dev/null @@ -1 +0,0 @@ -../../bin/git \ No newline at end of file diff --git a/libexec/git-core/git-cat-file b/libexec/git-core/git-cat-file deleted file mode 120000 index f2cccfc2..00000000 --- a/libexec/git-core/git-cat-file +++ /dev/null @@ -1 +0,0 @@ -../../bin/git \ No newline at end of file diff --git a/libexec/git-core/git-check-attr b/libexec/git-core/git-check-attr deleted file mode 120000 index f2cccfc2..00000000 --- a/libexec/git-core/git-check-attr +++ /dev/null @@ -1 +0,0 @@ -../../bin/git \ No newline at end of file diff --git a/libexec/git-core/git-check-ignore b/libexec/git-core/git-check-ignore deleted file mode 120000 index f2cccfc2..00000000 --- a/libexec/git-core/git-check-ignore +++ /dev/null @@ -1 +0,0 @@ -../../bin/git \ No newline at end of file diff --git a/libexec/git-core/git-check-mailmap b/libexec/git-core/git-check-mailmap deleted file mode 120000 index f2cccfc2..00000000 --- a/libexec/git-core/git-check-mailmap +++ /dev/null @@ -1 +0,0 @@ -../../bin/git \ No newline at end of file diff --git a/libexec/git-core/git-check-ref-format b/libexec/git-core/git-check-ref-format deleted file mode 120000 index f2cccfc2..00000000 --- a/libexec/git-core/git-check-ref-format +++ /dev/null @@ -1 +0,0 @@ -../../bin/git \ No newline at end of file diff --git a/libexec/git-core/git-checkout b/libexec/git-core/git-checkout deleted file mode 120000 index f2cccfc2..00000000 --- a/libexec/git-core/git-checkout +++ /dev/null @@ -1 +0,0 @@ -../../bin/git \ No newline at end of file diff --git a/libexec/git-core/git-checkout-index b/libexec/git-core/git-checkout-index deleted file mode 120000 index f2cccfc2..00000000 --- a/libexec/git-core/git-checkout-index +++ /dev/null @@ -1 +0,0 @@ -../../bin/git \ No newline at end of file diff --git a/libexec/git-core/git-cherry b/libexec/git-core/git-cherry deleted file mode 120000 index f2cccfc2..00000000 --- a/libexec/git-core/git-cherry +++ /dev/null @@ -1 +0,0 @@ -../../bin/git \ No newline at end of file diff --git a/libexec/git-core/git-cherry-pick b/libexec/git-core/git-cherry-pick deleted file mode 120000 index f2cccfc2..00000000 --- a/libexec/git-core/git-cherry-pick +++ /dev/null @@ -1 +0,0 @@ -../../bin/git \ No newline at end of file diff --git a/libexec/git-core/git-clean b/libexec/git-core/git-clean deleted file mode 120000 index f2cccfc2..00000000 --- a/libexec/git-core/git-clean +++ /dev/null @@ -1 +0,0 @@ -../../bin/git \ No newline at end of file diff --git a/libexec/git-core/git-clone b/libexec/git-core/git-clone deleted file mode 120000 index f2cccfc2..00000000 --- a/libexec/git-core/git-clone +++ /dev/null @@ -1 +0,0 @@ -../../bin/git \ No newline at end of file diff --git a/libexec/git-core/git-column b/libexec/git-core/git-column deleted file mode 120000 index f2cccfc2..00000000 --- a/libexec/git-core/git-column +++ /dev/null @@ -1 +0,0 @@ -../../bin/git \ No newline at end of file diff --git a/libexec/git-core/git-commit b/libexec/git-core/git-commit deleted file mode 120000 index f2cccfc2..00000000 --- a/libexec/git-core/git-commit +++ /dev/null @@ -1 +0,0 @@ -../../bin/git \ No newline at end of file diff --git a/libexec/git-core/git-commit-graph b/libexec/git-core/git-commit-graph deleted file mode 120000 index f2cccfc2..00000000 --- a/libexec/git-core/git-commit-graph +++ /dev/null @@ -1 +0,0 @@ -../../bin/git \ No newline at end of file diff --git a/libexec/git-core/git-commit-tree b/libexec/git-core/git-commit-tree deleted file mode 120000 index f2cccfc2..00000000 --- a/libexec/git-core/git-commit-tree +++ /dev/null @@ -1 +0,0 @@ -../../bin/git \ No newline at end of file diff --git a/libexec/git-core/git-config b/libexec/git-core/git-config deleted file mode 120000 index f2cccfc2..00000000 --- a/libexec/git-core/git-config +++ /dev/null @@ -1 +0,0 @@ -../../bin/git \ No newline at end of file diff --git a/libexec/git-core/git-count-objects b/libexec/git-core/git-count-objects deleted file mode 120000 index f2cccfc2..00000000 --- a/libexec/git-core/git-count-objects +++ /dev/null @@ -1 +0,0 @@ -../../bin/git \ No newline at end of file diff --git a/libexec/git-core/git-credential b/libexec/git-core/git-credential deleted file mode 120000 index f2cccfc2..00000000 --- a/libexec/git-core/git-credential +++ /dev/null @@ -1 +0,0 @@ -../../bin/git \ No newline at end of file diff --git a/libexec/git-core/git-credential-cache b/libexec/git-core/git-credential-cache deleted file mode 100755 index 67d8a081..00000000 Binary files a/libexec/git-core/git-credential-cache and /dev/null differ diff --git a/libexec/git-core/git-credential-cache--daemon b/libexec/git-core/git-credential-cache--daemon deleted file mode 100755 index d05b2248..00000000 Binary files a/libexec/git-core/git-credential-cache--daemon and /dev/null differ diff --git a/libexec/git-core/git-credential-store b/libexec/git-core/git-credential-store deleted file mode 100755 index 83f353dc..00000000 Binary files a/libexec/git-core/git-credential-store and /dev/null differ diff --git a/libexec/git-core/git-cvsexportcommit b/libexec/git-core/git-cvsexportcommit deleted file mode 100755 index 0994c2ce..00000000 --- a/libexec/git-core/git-cvsexportcommit +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/sh - -echo >&2 "fatal: git was built without support for $(basename $0) (NO_PERL=1)." -exit 128 diff --git a/libexec/git-core/git-cvsimport b/libexec/git-core/git-cvsimport deleted file mode 100755 index 0994c2ce..00000000 --- a/libexec/git-core/git-cvsimport +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/sh - -echo >&2 "fatal: git was built without support for $(basename $0) (NO_PERL=1)." -exit 128 diff --git a/libexec/git-core/git-cvsserver b/libexec/git-core/git-cvsserver deleted file mode 120000 index ac71ee82..00000000 --- a/libexec/git-core/git-cvsserver +++ /dev/null @@ -1 +0,0 @@ -../../bin/git-cvsserver \ No newline at end of file diff --git a/libexec/git-core/git-daemon b/libexec/git-core/git-daemon deleted file mode 100755 index dc1d5286..00000000 Binary files a/libexec/git-core/git-daemon and /dev/null differ diff --git a/libexec/git-core/git-describe b/libexec/git-core/git-describe deleted file mode 120000 index f2cccfc2..00000000 --- a/libexec/git-core/git-describe +++ /dev/null @@ -1 +0,0 @@ -../../bin/git \ No newline at end of file diff --git a/libexec/git-core/git-diff b/libexec/git-core/git-diff deleted file mode 120000 index f2cccfc2..00000000 --- a/libexec/git-core/git-diff +++ /dev/null @@ -1 +0,0 @@ -../../bin/git \ No newline at end of file diff --git a/libexec/git-core/git-diff-files b/libexec/git-core/git-diff-files deleted file mode 120000 index f2cccfc2..00000000 --- a/libexec/git-core/git-diff-files +++ /dev/null @@ -1 +0,0 @@ -../../bin/git \ No newline at end of file diff --git a/libexec/git-core/git-diff-index b/libexec/git-core/git-diff-index deleted file mode 120000 index f2cccfc2..00000000 --- a/libexec/git-core/git-diff-index +++ /dev/null @@ -1 +0,0 @@ -../../bin/git \ No newline at end of file diff --git a/libexec/git-core/git-diff-tree b/libexec/git-core/git-diff-tree deleted file mode 120000 index f2cccfc2..00000000 --- a/libexec/git-core/git-diff-tree +++ /dev/null @@ -1 +0,0 @@ -../../bin/git \ No newline at end of file diff --git a/libexec/git-core/git-difftool b/libexec/git-core/git-difftool deleted file mode 120000 index f2cccfc2..00000000 --- a/libexec/git-core/git-difftool +++ /dev/null @@ -1 +0,0 @@ -../../bin/git \ No newline at end of file diff --git a/libexec/git-core/git-difftool--helper b/libexec/git-core/git-difftool--helper deleted file mode 100755 index 7bfb6737..00000000 --- a/libexec/git-core/git-difftool--helper +++ /dev/null @@ -1,105 +0,0 @@ -#!/bin/sh -# git-difftool--helper is a GIT_EXTERNAL_DIFF-compatible diff tool launcher. -# This script is typically launched by using the 'git difftool' -# convenience command. -# -# Copyright (c) 2009, 2010 David Aguilar - -TOOL_MODE=diff -. git-mergetool--lib - -# difftool.prompt controls the default prompt/no-prompt behavior -# and is overridden with $GIT_DIFFTOOL*_PROMPT. -should_prompt () { - prompt_merge=$(git config --bool mergetool.prompt || echo true) - prompt=$(git config --bool difftool.prompt || echo $prompt_merge) - if test "$prompt" = true - then - test -z "$GIT_DIFFTOOL_NO_PROMPT" - else - test -n "$GIT_DIFFTOOL_PROMPT" - fi -} - -# Indicates that --extcmd=... was specified -use_ext_cmd () { - test -n "$GIT_DIFFTOOL_EXTCMD" -} - -launch_merge_tool () { - # Merged is the filename as it appears in the work tree - # Local is the contents of a/filename - # Remote is the contents of b/filename - # Custom merge tool commands might use $BASE so we provide it - MERGED="$1" - LOCAL="$2" - REMOTE="$3" - BASE="$1" - - # $LOCAL and $REMOTE are temporary files so prompt - # the user with the real $MERGED name before launching $merge_tool. - if should_prompt - then - printf "\nViewing (%s/%s): '%s'\n" "$GIT_DIFF_PATH_COUNTER" \ - "$GIT_DIFF_PATH_TOTAL" "$MERGED" - if use_ext_cmd - then - printf "Launch '%s' [Y/n]? " \ - "$GIT_DIFFTOOL_EXTCMD" - else - printf "Launch '%s' [Y/n]? " "$merge_tool" - fi - read ans || return - if test "$ans" = n - then - return - fi - fi - - if use_ext_cmd - then - export BASE - eval $GIT_DIFFTOOL_EXTCMD '"$LOCAL"' '"$REMOTE"' - else - run_merge_tool "$merge_tool" - fi -} - -if ! use_ext_cmd -then - if test -n "$GIT_DIFF_TOOL" - then - merge_tool="$GIT_DIFF_TOOL" - else - merge_tool="$(get_merge_tool)" || exit - fi -fi - -if test -n "$GIT_DIFFTOOL_DIRDIFF" -then - LOCAL="$1" - REMOTE="$2" - run_merge_tool "$merge_tool" false -else - # Launch the merge tool on each path provided by 'git diff' - while test $# -gt 6 - do - launch_merge_tool "$1" "$2" "$5" - status=$? - if test $status -ge 126 - then - # Command not found (127), not executable (126) or - # exited via a signal (>= 128). - exit $status - fi - - if test "$status" != 0 && - test "$GIT_DIFFTOOL_TRUST_EXIT_CODE" = true - then - exit $status - fi - shift 7 - done -fi - -exit 0 diff --git a/libexec/git-core/git-fast-export b/libexec/git-core/git-fast-export deleted file mode 120000 index f2cccfc2..00000000 --- a/libexec/git-core/git-fast-export +++ /dev/null @@ -1 +0,0 @@ -../../bin/git \ No newline at end of file diff --git a/libexec/git-core/git-fast-import b/libexec/git-core/git-fast-import deleted file mode 100755 index f91202c8..00000000 Binary files a/libexec/git-core/git-fast-import and /dev/null differ diff --git a/libexec/git-core/git-fetch b/libexec/git-core/git-fetch deleted file mode 120000 index f2cccfc2..00000000 --- a/libexec/git-core/git-fetch +++ /dev/null @@ -1 +0,0 @@ -../../bin/git \ No newline at end of file diff --git a/libexec/git-core/git-fetch-pack b/libexec/git-core/git-fetch-pack deleted file mode 120000 index f2cccfc2..00000000 --- a/libexec/git-core/git-fetch-pack +++ /dev/null @@ -1 +0,0 @@ -../../bin/git \ No newline at end of file diff --git a/libexec/git-core/git-filter-branch b/libexec/git-core/git-filter-branch deleted file mode 100755 index 4464f699..00000000 --- a/libexec/git-core/git-filter-branch +++ /dev/null @@ -1,662 +0,0 @@ -#!/bin/sh -# -# Rewrite revision history -# Copyright (c) Petr Baudis, 2006 -# Minimal changes to "port" it to core-git (c) Johannes Schindelin, 2007 -# -# Lets you rewrite the revision history of the current branch, creating -# a new branch. You can specify a number of filters to modify the commits, -# files and trees. - -# The following functions will also be available in the commit filter: - -functions=$(cat << \EOF -EMPTY_TREE=$(git hash-object -t tree /dev/null) - -warn () { - echo "$*" >&2 -} - -map() -{ - # if it was not rewritten, take the original - if test -r "$workdir/../map/$1" - then - cat "$workdir/../map/$1" - else - echo "$1" - fi -} - -# if you run 'skip_commit "$@"' in a commit filter, it will print -# the (mapped) parents, effectively skipping the commit. - -skip_commit() -{ - shift; - while [ -n "$1" ]; - do - shift; - map "$1"; - shift; - done; -} - -# if you run 'git_commit_non_empty_tree "$@"' in a commit filter, -# it will skip commits that leave the tree untouched, commit the other. -git_commit_non_empty_tree() -{ - if test $# = 3 && test "$1" = $(git rev-parse "$3^{tree}"); then - map "$3" - elif test $# = 1 && test "$1" = $EMPTY_TREE; then - : - else - git commit-tree "$@" - fi -} -# override die(): this version puts in an extra line break, so that -# the progress is still visible - -die() -{ - echo >&2 - echo "$*" >&2 - exit 1 -} -EOF -) - -eval "$functions" - -finish_ident() { - # Ensure non-empty id name. - echo "case \"\$GIT_$1_NAME\" in \"\") GIT_$1_NAME=\"\${GIT_$1_EMAIL%%@*}\" && export GIT_$1_NAME;; esac" - # And make sure everything is exported. - echo "export GIT_$1_NAME" - echo "export GIT_$1_EMAIL" - echo "export GIT_$1_DATE" -} - -set_ident () { - parse_ident_from_commit author AUTHOR committer COMMITTER - finish_ident AUTHOR - finish_ident COMMITTER -} - -USAGE="[--setup ] [--subdirectory-filter ] [--env-filter ] - [--tree-filter ] [--index-filter ] - [--parent-filter ] [--msg-filter ] - [--commit-filter ] [--tag-name-filter ] - [--original ] - [-d ] [-f | --force] [--state-branch ] - [--] [...]" - -OPTIONS_SPEC= -. git-sh-setup - -if [ "$(is_bare_repository)" = false ]; then - require_clean_work_tree 'rewrite branches' -fi - -tempdir=.git-rewrite -filter_setup= -filter_env= -filter_tree= -filter_index= -filter_parent= -filter_msg=cat -filter_commit= -filter_tag_name= -filter_subdir= -state_branch= -orig_namespace=refs/original/ -force= -prune_empty= -remap_to_ancestor= -while : -do - case "$1" in - --) - shift - break - ;; - --force|-f) - shift - force=t - continue - ;; - --remap-to-ancestor) - # deprecated ($remap_to_ancestor is set now automatically) - shift - remap_to_ancestor=t - continue - ;; - --prune-empty) - shift - prune_empty=t - continue - ;; - -*) - ;; - *) - break; - esac - - # all switches take one argument - ARG="$1" - case "$#" in 1) usage ;; esac - shift - OPTARG="$1" - shift - - case "$ARG" in - -d) - tempdir="$OPTARG" - ;; - --setup) - filter_setup="$OPTARG" - ;; - --subdirectory-filter) - filter_subdir="$OPTARG" - remap_to_ancestor=t - ;; - --env-filter) - filter_env="$OPTARG" - ;; - --tree-filter) - filter_tree="$OPTARG" - ;; - --index-filter) - filter_index="$OPTARG" - ;; - --parent-filter) - filter_parent="$OPTARG" - ;; - --msg-filter) - filter_msg="$OPTARG" - ;; - --commit-filter) - filter_commit="$functions; $OPTARG" - ;; - --tag-name-filter) - filter_tag_name="$OPTARG" - ;; - --original) - orig_namespace=$(expr "$OPTARG/" : '\(.*[^/]\)/*$')/ - ;; - --state-branch) - state_branch="$OPTARG" - ;; - *) - usage - ;; - esac -done - -case "$prune_empty,$filter_commit" in -,) - filter_commit='git commit-tree "$@"';; -t,) - filter_commit="$functions;"' git_commit_non_empty_tree "$@"';; -,*) - ;; -*) - die "Cannot set --prune-empty and --commit-filter at the same time" -esac - -case "$force" in -t) - rm -rf "$tempdir" -;; -'') - test -d "$tempdir" && - die "$tempdir already exists, please remove it" -esac -orig_dir=$(pwd) -mkdir -p "$tempdir/t" && -tempdir="$(cd "$tempdir"; pwd)" && -cd "$tempdir/t" && -workdir="$(pwd)" || -die "" - -# Remove tempdir on exit -trap 'cd "$orig_dir"; rm -rf "$tempdir"' 0 - -ORIG_GIT_DIR="$GIT_DIR" -ORIG_GIT_WORK_TREE="$GIT_WORK_TREE" -ORIG_GIT_INDEX_FILE="$GIT_INDEX_FILE" -ORIG_GIT_AUTHOR_NAME="$GIT_AUTHOR_NAME" -ORIG_GIT_AUTHOR_EMAIL="$GIT_AUTHOR_EMAIL" -ORIG_GIT_AUTHOR_DATE="$GIT_AUTHOR_DATE" -ORIG_GIT_COMMITTER_NAME="$GIT_COMMITTER_NAME" -ORIG_GIT_COMMITTER_EMAIL="$GIT_COMMITTER_EMAIL" -ORIG_GIT_COMMITTER_DATE="$GIT_COMMITTER_DATE" - -GIT_WORK_TREE=. -export GIT_DIR GIT_WORK_TREE - -# Make sure refs/original is empty -git for-each-ref > "$tempdir"/backup-refs || exit -while read sha1 type name -do - case "$force,$name" in - ,$orig_namespace*) - die "Cannot create a new backup. -A previous backup already exists in $orig_namespace -Force overwriting the backup with -f" - ;; - t,$orig_namespace*) - git update-ref -d "$name" $sha1 - ;; - esac -done < "$tempdir"/backup-refs - -# The refs should be updated if their heads were rewritten -git rev-parse --no-flags --revs-only --symbolic-full-name \ - --default HEAD "$@" > "$tempdir"/raw-refs || exit -while read ref -do - case "$ref" in ^?*) continue ;; esac - - if git rev-parse --verify "$ref"^0 >/dev/null 2>&1 - then - echo "$ref" - else - warn "WARNING: not rewriting '$ref' (not a committish)" - fi -done >"$tempdir"/heads <"$tempdir"/raw-refs - -test -s "$tempdir"/heads || - die "You must specify a ref to rewrite." - -GIT_INDEX_FILE="$(pwd)/../index" -export GIT_INDEX_FILE - -# map old->new commit ids for rewriting parents -mkdir ../map || die "Could not create map/ directory" - -if test -n "$state_branch" -then - state_commit=$(git rev-parse --no-flags --revs-only "$state_branch") - if test -n "$state_commit" - then - echo "Populating map from $state_branch ($state_commit)" 1>&2 - perl -e'open(MAP, "-|", "git show $ARGV[0]:filter.map") or die; - while () { - m/(.*):(.*)/ or die; - open F, ">../map/$1" or die; - print F "$2" or die; - close(F) or die; - } - close(MAP) or die;' "$state_commit" \ - || die "Unable to load state from $state_branch:filter.map" - else - echo "Branch $state_branch does not exist. Will create" 1>&2 - fi -fi - -# we need "--" only if there are no path arguments in $@ -nonrevs=$(git rev-parse --no-revs "$@") || exit -if test -z "$nonrevs" -then - dashdash=-- -else - dashdash= - remap_to_ancestor=t -fi - -git rev-parse --revs-only "$@" >../parse - -case "$filter_subdir" in -"") - eval set -- "$(git rev-parse --sq --no-revs "$@")" - ;; -*) - eval set -- "$(git rev-parse --sq --no-revs "$@" $dashdash \ - "$filter_subdir")" - ;; -esac - -git rev-list --reverse --topo-order --default HEAD \ - --parents --simplify-merges --stdin "$@" <../parse >../revs || - die "Could not get the commits" -commits=$(wc -l <../revs | tr -d " ") - -test $commits -eq 0 && die_with_status 2 "Found nothing to rewrite" - -# Rewrite the commits -report_progress () -{ - if test -n "$progress" && - test $git_filter_branch__commit_count -gt $next_sample_at - then - count=$git_filter_branch__commit_count - - now=$(date +%s) - elapsed=$(($now - $start_timestamp)) - remaining=$(( ($commits - $count) * $elapsed / $count )) - if test $elapsed -gt 0 - then - next_sample_at=$(( ($elapsed + 1) * $count / $elapsed )) - else - next_sample_at=$(($next_sample_at + 1)) - fi - progress=" ($elapsed seconds passed, remaining $remaining predicted)" - fi - printf "\rRewrite $commit ($count/$commits)$progress " -} - -git_filter_branch__commit_count=0 - -progress= start_timestamp= -if date '+%s' 2>/dev/null | grep -q '^[0-9][0-9]*$' -then - next_sample_at=0 - progress="dummy to ensure this is not empty" - start_timestamp=$(date '+%s') -fi - -if test -n "$filter_index" || - test -n "$filter_tree" || - test -n "$filter_subdir" -then - need_index=t -else - need_index= -fi - -eval "$filter_setup" < /dev/null || - die "filter setup failed: $filter_setup" - -while read commit parents; do - git_filter_branch__commit_count=$(($git_filter_branch__commit_count+1)) - - report_progress - test -f "$workdir"/../map/$commit && continue - - case "$filter_subdir" in - "") - if test -n "$need_index" - then - GIT_ALLOW_NULL_SHA1=1 git read-tree -i -m $commit - fi - ;; - *) - # The commit may not have the subdirectory at all - err=$(GIT_ALLOW_NULL_SHA1=1 \ - git read-tree -i -m $commit:"$filter_subdir" 2>&1) || { - if ! git rev-parse -q --verify $commit:"$filter_subdir" - then - rm -f "$GIT_INDEX_FILE" - else - echo >&2 "$err" - false - fi - } - esac || die "Could not initialize the index" - - GIT_COMMIT=$commit - export GIT_COMMIT - git cat-file commit "$commit" >../commit || - die "Cannot read commit $commit" - - eval "$(set_ident <../commit)" || - die "setting author/committer failed for commit $commit" - eval "$filter_env" < /dev/null || - die "env filter failed: $filter_env" - - if [ "$filter_tree" ]; then - git checkout-index -f -u -a || - die "Could not checkout the index" - # files that $commit removed are now still in the working tree; - # remove them, else they would be added again - git clean -d -q -f -x - eval "$filter_tree" < /dev/null || - die "tree filter failed: $filter_tree" - - ( - git diff-index -r --name-only --ignore-submodules $commit -- && - git ls-files --others - ) > "$tempdir"/tree-state || exit - git update-index --add --replace --remove --stdin \ - < "$tempdir"/tree-state || exit - fi - - eval "$filter_index" < /dev/null || - die "index filter failed: $filter_index" - - parentstr= - for parent in $parents; do - for reparent in $(map "$parent"); do - case "$parentstr " in - *" -p $reparent "*) - ;; - *) - parentstr="$parentstr -p $reparent" - ;; - esac - done - done - if [ "$filter_parent" ]; then - parentstr="$(echo "$parentstr" | eval "$filter_parent")" || - die "parent filter failed: $filter_parent" - fi - - { - while IFS='' read -r header_line && test -n "$header_line" - do - # skip header lines... - :; - done - # and output the actual commit message - cat - } <../commit | - eval "$filter_msg" > ../message || - die "msg filter failed: $filter_msg" - - if test -n "$need_index" - then - tree=$(git write-tree) - else - tree=$(git rev-parse "$commit^{tree}") - fi - workdir=$workdir /bin/sh -c "$filter_commit" "git commit-tree" \ - "$tree" $parentstr < ../message > ../map/$commit || - die "could not write rewritten commit" -done <../revs - -# If we are filtering for paths, as in the case of a subdirectory -# filter, it is possible that a specified head is not in the set of -# rewritten commits, because it was pruned by the revision walker. -# Ancestor remapping fixes this by mapping these heads to the unique -# nearest ancestor that survived the pruning. - -if test "$remap_to_ancestor" = t -then - while read ref - do - sha1=$(git rev-parse "$ref"^0) - test -f "$workdir"/../map/$sha1 && continue - ancestor=$(git rev-list --simplify-merges -1 "$ref" "$@") - test "$ancestor" && echo $(map $ancestor) >> "$workdir"/../map/$sha1 - done < "$tempdir"/heads -fi - -# Finally update the refs - -_x40='[0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f]' -_x40="$_x40$_x40$_x40$_x40$_x40$_x40$_x40$_x40" -echo -while read ref -do - # avoid rewriting a ref twice - test -f "$orig_namespace$ref" && continue - - sha1=$(git rev-parse "$ref"^0) - rewritten=$(map $sha1) - - test $sha1 = "$rewritten" && - warn "WARNING: Ref '$ref' is unchanged" && - continue - - case "$rewritten" in - '') - echo "Ref '$ref' was deleted" - git update-ref -m "filter-branch: delete" -d "$ref" $sha1 || - die "Could not delete $ref" - ;; - $_x40) - echo "Ref '$ref' was rewritten" - if ! git update-ref -m "filter-branch: rewrite" \ - "$ref" $rewritten $sha1 2>/dev/null; then - if test $(git cat-file -t "$ref") = tag; then - if test -z "$filter_tag_name"; then - warn "WARNING: You said to rewrite tagged commits, but not the corresponding tag." - warn "WARNING: Perhaps use '--tag-name-filter cat' to rewrite the tag." - fi - else - die "Could not rewrite $ref" - fi - fi - ;; - *) - # NEEDSWORK: possibly add -Werror, making this an error - warn "WARNING: '$ref' was rewritten into multiple commits:" - warn "$rewritten" - warn "WARNING: Ref '$ref' points to the first one now." - rewritten=$(echo "$rewritten" | head -n 1) - git update-ref -m "filter-branch: rewrite to first" \ - "$ref" $rewritten $sha1 || - die "Could not rewrite $ref" - ;; - esac - git update-ref -m "filter-branch: backup" "$orig_namespace$ref" $sha1 || - exit -done < "$tempdir"/heads - -# TODO: This should possibly go, with the semantics that all positive given -# refs are updated, and their original heads stored in refs/original/ -# Filter tags - -if [ "$filter_tag_name" ]; then - git for-each-ref --format='%(objectname) %(objecttype) %(refname)' refs/tags | - while read sha1 type ref; do - ref="${ref#refs/tags/}" - # XXX: Rewrite tagged trees as well? - if [ "$type" != "commit" -a "$type" != "tag" ]; then - continue; - fi - - if [ "$type" = "tag" ]; then - # Dereference to a commit - sha1t="$sha1" - sha1="$(git rev-parse -q "$sha1"^{commit})" || continue - fi - - [ -f "../map/$sha1" ] || continue - new_sha1="$(cat "../map/$sha1")" - GIT_COMMIT="$sha1" - export GIT_COMMIT - new_ref="$(echo "$ref" | eval "$filter_tag_name")" || - die "tag name filter failed: $filter_tag_name" - - echo "$ref -> $new_ref ($sha1 -> $new_sha1)" - - if [ "$type" = "tag" ]; then - new_sha1=$( ( printf 'object %s\ntype commit\ntag %s\n' \ - "$new_sha1" "$new_ref" - git cat-file tag "$ref" | - sed -n \ - -e '1,/^$/{ - /^object /d - /^type /d - /^tag /d - }' \ - -e '/^-----BEGIN PGP SIGNATURE-----/q' \ - -e 'p' ) | - git hash-object -t tag -w --stdin) || - die "Could not create new tag object for $ref" - if git cat-file tag "$ref" | \ - sane_grep '^-----BEGIN PGP SIGNATURE-----' >/dev/null 2>&1 - then - warn "gpg signature stripped from tag object $sha1t" - fi - fi - - git update-ref "refs/tags/$new_ref" "$new_sha1" || - die "Could not write tag $new_ref" - done -fi - -unset GIT_DIR GIT_WORK_TREE GIT_INDEX_FILE -unset GIT_AUTHOR_NAME GIT_AUTHOR_EMAIL GIT_AUTHOR_DATE -unset GIT_COMMITTER_NAME GIT_COMMITTER_EMAIL GIT_COMMITTER_DATE -test -z "$ORIG_GIT_DIR" || { - GIT_DIR="$ORIG_GIT_DIR" && export GIT_DIR -} -test -z "$ORIG_GIT_WORK_TREE" || { - GIT_WORK_TREE="$ORIG_GIT_WORK_TREE" && - export GIT_WORK_TREE -} -test -z "$ORIG_GIT_INDEX_FILE" || { - GIT_INDEX_FILE="$ORIG_GIT_INDEX_FILE" && - export GIT_INDEX_FILE -} -test -z "$ORIG_GIT_AUTHOR_NAME" || { - GIT_AUTHOR_NAME="$ORIG_GIT_AUTHOR_NAME" && - export GIT_AUTHOR_NAME -} -test -z "$ORIG_GIT_AUTHOR_EMAIL" || { - GIT_AUTHOR_EMAIL="$ORIG_GIT_AUTHOR_EMAIL" && - export GIT_AUTHOR_EMAIL -} -test -z "$ORIG_GIT_AUTHOR_DATE" || { - GIT_AUTHOR_DATE="$ORIG_GIT_AUTHOR_DATE" && - export GIT_AUTHOR_DATE -} -test -z "$ORIG_GIT_COMMITTER_NAME" || { - GIT_COMMITTER_NAME="$ORIG_GIT_COMMITTER_NAME" && - export GIT_COMMITTER_NAME -} -test -z "$ORIG_GIT_COMMITTER_EMAIL" || { - GIT_COMMITTER_EMAIL="$ORIG_GIT_COMMITTER_EMAIL" && - export GIT_COMMITTER_EMAIL -} -test -z "$ORIG_GIT_COMMITTER_DATE" || { - GIT_COMMITTER_DATE="$ORIG_GIT_COMMITTER_DATE" && - export GIT_COMMITTER_DATE -} - -if test -n "$state_branch" -then - echo "Saving rewrite state to $state_branch" 1>&2 - state_blob=$( - perl -e'opendir D, "../map" or die; - open H, "|-", "git hash-object -w --stdin" or die; - foreach (sort readdir(D)) { - next if m/^\.\.?$/; - open F, "<../map/$_" or die; - chomp($f = ); - print H "$_:$f\n" or die; - } - close(H) or die;' || die "Unable to save state") - state_tree=$(printf '100644 blob %s\tfilter.map\n' "$state_blob" | git mktree) - if test -n "$state_commit" - then - state_commit=$(echo "Sync" | git commit-tree "$state_tree" -p "$state_commit") - else - state_commit=$(echo "Sync" | git commit-tree "$state_tree" ) - fi - git update-ref "$state_branch" "$state_commit" -fi - -cd "$orig_dir" -rm -rf "$tempdir" - -trap - 0 - -if [ "$(is_bare_repository)" = false ]; then - git read-tree -u -m HEAD || exit -fi - -exit 0 diff --git a/libexec/git-core/git-fmt-merge-msg b/libexec/git-core/git-fmt-merge-msg deleted file mode 120000 index f2cccfc2..00000000 --- a/libexec/git-core/git-fmt-merge-msg +++ /dev/null @@ -1 +0,0 @@ -../../bin/git \ No newline at end of file diff --git a/libexec/git-core/git-for-each-ref b/libexec/git-core/git-for-each-ref deleted file mode 120000 index f2cccfc2..00000000 --- a/libexec/git-core/git-for-each-ref +++ /dev/null @@ -1 +0,0 @@ -../../bin/git \ No newline at end of file diff --git a/libexec/git-core/git-format-patch b/libexec/git-core/git-format-patch deleted file mode 120000 index f2cccfc2..00000000 --- a/libexec/git-core/git-format-patch +++ /dev/null @@ -1 +0,0 @@ -../../bin/git \ No newline at end of file diff --git a/libexec/git-core/git-fsck b/libexec/git-core/git-fsck deleted file mode 120000 index f2cccfc2..00000000 --- a/libexec/git-core/git-fsck +++ /dev/null @@ -1 +0,0 @@ -../../bin/git \ No newline at end of file diff --git a/libexec/git-core/git-fsck-objects b/libexec/git-core/git-fsck-objects deleted file mode 120000 index f2cccfc2..00000000 --- a/libexec/git-core/git-fsck-objects +++ /dev/null @@ -1 +0,0 @@ -../../bin/git \ No newline at end of file diff --git a/libexec/git-core/git-gc b/libexec/git-core/git-gc deleted file mode 120000 index f2cccfc2..00000000 --- a/libexec/git-core/git-gc +++ /dev/null @@ -1 +0,0 @@ -../../bin/git \ No newline at end of file diff --git a/libexec/git-core/git-get-tar-commit-id b/libexec/git-core/git-get-tar-commit-id deleted file mode 120000 index f2cccfc2..00000000 --- a/libexec/git-core/git-get-tar-commit-id +++ /dev/null @@ -1 +0,0 @@ -../../bin/git \ No newline at end of file diff --git a/libexec/git-core/git-grep b/libexec/git-core/git-grep deleted file mode 120000 index f2cccfc2..00000000 --- a/libexec/git-core/git-grep +++ /dev/null @@ -1 +0,0 @@ -../../bin/git \ No newline at end of file diff --git a/libexec/git-core/git-hash-object b/libexec/git-core/git-hash-object deleted file mode 120000 index f2cccfc2..00000000 --- a/libexec/git-core/git-hash-object +++ /dev/null @@ -1 +0,0 @@ -../../bin/git \ No newline at end of file diff --git a/libexec/git-core/git-help b/libexec/git-core/git-help deleted file mode 120000 index f2cccfc2..00000000 --- a/libexec/git-core/git-help +++ /dev/null @@ -1 +0,0 @@ -../../bin/git \ No newline at end of file diff --git a/libexec/git-core/git-http-backend b/libexec/git-core/git-http-backend deleted file mode 100755 index a1e506b4..00000000 Binary files a/libexec/git-core/git-http-backend and /dev/null differ diff --git a/libexec/git-core/git-http-fetch b/libexec/git-core/git-http-fetch deleted file mode 100755 index 36015cca..00000000 Binary files a/libexec/git-core/git-http-fetch and /dev/null differ diff --git a/libexec/git-core/git-http-push b/libexec/git-core/git-http-push deleted file mode 100755 index b25e0416..00000000 Binary files a/libexec/git-core/git-http-push and /dev/null differ diff --git a/libexec/git-core/git-imap-send b/libexec/git-core/git-imap-send deleted file mode 100755 index a1035884..00000000 Binary files a/libexec/git-core/git-imap-send and /dev/null differ diff --git a/libexec/git-core/git-index-pack b/libexec/git-core/git-index-pack deleted file mode 120000 index f2cccfc2..00000000 --- a/libexec/git-core/git-index-pack +++ /dev/null @@ -1 +0,0 @@ -../../bin/git \ No newline at end of file diff --git a/libexec/git-core/git-init b/libexec/git-core/git-init deleted file mode 120000 index f2cccfc2..00000000 --- a/libexec/git-core/git-init +++ /dev/null @@ -1 +0,0 @@ -../../bin/git \ No newline at end of file diff --git a/libexec/git-core/git-init-db b/libexec/git-core/git-init-db deleted file mode 120000 index f2cccfc2..00000000 --- a/libexec/git-core/git-init-db +++ /dev/null @@ -1 +0,0 @@ -../../bin/git \ No newline at end of file diff --git a/libexec/git-core/git-instaweb b/libexec/git-core/git-instaweb deleted file mode 100755 index 0994c2ce..00000000 --- a/libexec/git-core/git-instaweb +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/sh - -echo >&2 "fatal: git was built without support for $(basename $0) (NO_PERL=1)." -exit 128 diff --git a/libexec/git-core/git-interpret-trailers b/libexec/git-core/git-interpret-trailers deleted file mode 120000 index f2cccfc2..00000000 --- a/libexec/git-core/git-interpret-trailers +++ /dev/null @@ -1 +0,0 @@ -../../bin/git \ No newline at end of file diff --git a/libexec/git-core/git-log b/libexec/git-core/git-log deleted file mode 120000 index f2cccfc2..00000000 --- a/libexec/git-core/git-log +++ /dev/null @@ -1 +0,0 @@ -../../bin/git \ No newline at end of file diff --git a/libexec/git-core/git-ls-files b/libexec/git-core/git-ls-files deleted file mode 120000 index f2cccfc2..00000000 --- a/libexec/git-core/git-ls-files +++ /dev/null @@ -1 +0,0 @@ -../../bin/git \ No newline at end of file diff --git a/libexec/git-core/git-ls-remote b/libexec/git-core/git-ls-remote deleted file mode 120000 index f2cccfc2..00000000 --- a/libexec/git-core/git-ls-remote +++ /dev/null @@ -1 +0,0 @@ -../../bin/git \ No newline at end of file diff --git a/libexec/git-core/git-ls-tree b/libexec/git-core/git-ls-tree deleted file mode 120000 index f2cccfc2..00000000 --- a/libexec/git-core/git-ls-tree +++ /dev/null @@ -1 +0,0 @@ -../../bin/git \ No newline at end of file diff --git a/libexec/git-core/git-mailinfo b/libexec/git-core/git-mailinfo deleted file mode 120000 index f2cccfc2..00000000 --- a/libexec/git-core/git-mailinfo +++ /dev/null @@ -1 +0,0 @@ -../../bin/git \ No newline at end of file diff --git a/libexec/git-core/git-mailsplit b/libexec/git-core/git-mailsplit deleted file mode 120000 index f2cccfc2..00000000 --- a/libexec/git-core/git-mailsplit +++ /dev/null @@ -1 +0,0 @@ -../../bin/git \ No newline at end of file diff --git a/libexec/git-core/git-merge b/libexec/git-core/git-merge deleted file mode 120000 index f2cccfc2..00000000 --- a/libexec/git-core/git-merge +++ /dev/null @@ -1 +0,0 @@ -../../bin/git \ No newline at end of file diff --git a/libexec/git-core/git-merge-base b/libexec/git-core/git-merge-base deleted file mode 120000 index f2cccfc2..00000000 --- a/libexec/git-core/git-merge-base +++ /dev/null @@ -1 +0,0 @@ -../../bin/git \ No newline at end of file diff --git a/libexec/git-core/git-merge-file b/libexec/git-core/git-merge-file deleted file mode 120000 index f2cccfc2..00000000 --- a/libexec/git-core/git-merge-file +++ /dev/null @@ -1 +0,0 @@ -../../bin/git \ No newline at end of file diff --git a/libexec/git-core/git-merge-index b/libexec/git-core/git-merge-index deleted file mode 120000 index f2cccfc2..00000000 --- a/libexec/git-core/git-merge-index +++ /dev/null @@ -1 +0,0 @@ -../../bin/git \ No newline at end of file diff --git a/libexec/git-core/git-merge-octopus b/libexec/git-core/git-merge-octopus deleted file mode 100755 index 7d19d379..00000000 --- a/libexec/git-core/git-merge-octopus +++ /dev/null @@ -1,112 +0,0 @@ -#!/bin/sh -# -# Copyright (c) 2005 Junio C Hamano -# -# Resolve two or more trees. -# - -. git-sh-setup - -LF=' -' - -# The first parameters up to -- are merge bases; the rest are heads. -bases= head= remotes= sep_seen= -for arg -do - case ",$sep_seen,$head,$arg," in - *,--,) - sep_seen=yes - ;; - ,yes,,*) - head=$arg - ;; - ,yes,*) - remotes="$remotes$arg " - ;; - *) - bases="$bases$arg " - ;; - esac -done - -# Reject if this is not an octopus -- resolve should be used instead. -case "$remotes" in -?*' '?*) - ;; -*) - exit 2 ;; -esac - -# MRC is the current "merge reference commit" -# MRT is the current "merge result tree" - -if ! git diff-index --quiet --cached HEAD -- -then - gettextln "Error: Your local changes to the following files would be overwritten by merge" - git diff-index --cached --name-only HEAD -- | sed -e 's/^/ /' - exit 2 -fi -MRC=$(git rev-parse --verify -q $head) -MRT=$(git write-tree) -NON_FF_MERGE=0 -OCTOPUS_FAILURE=0 -for SHA1 in $remotes -do - case "$OCTOPUS_FAILURE" in - 1) - # We allow only last one to have a hand-resolvable - # conflicts. Last round failed and we still had - # a head to merge. - gettextln "Automated merge did not work." - gettextln "Should not be doing an octopus." - exit 2 - esac - - eval pretty_name=\${GITHEAD_$SHA1:-$SHA1} - if test "$SHA1" = "$pretty_name" - then - SHA1_UP="$(echo "$SHA1" | tr a-z A-Z)" - eval pretty_name=\${GITHEAD_$SHA1_UP:-$pretty_name} - fi - common=$(git merge-base --all $SHA1 $MRC) || - die "$(eval_gettext "Unable to find common commit with \$pretty_name")" - - case "$LF$common$LF" in - *"$LF$SHA1$LF"*) - eval_gettextln "Already up to date with \$pretty_name" - continue - ;; - esac - - if test "$common,$NON_FF_MERGE" = "$MRC,0" - then - # The first head being merged was a fast-forward. - # Advance MRC to the head being merged, and use that - # tree as the intermediate result of the merge. - # We still need to count this as part of the parent set. - - eval_gettextln "Fast-forwarding to: \$pretty_name" - git read-tree -u -m $head $SHA1 || exit - MRC=$SHA1 MRT=$(git write-tree) - continue - fi - - NON_FF_MERGE=1 - - eval_gettextln "Trying simple merge with \$pretty_name" - git read-tree -u -m --aggressive $common $MRT $SHA1 || exit 2 - next=$(git write-tree 2>/dev/null) - if test $? -ne 0 - then - gettextln "Simple merge did not work, trying automatic merge." - git merge-index -o git-merge-one-file -a || - OCTOPUS_FAILURE=1 - next=$(git write-tree 2>/dev/null) - fi - - MRC="$MRC $SHA1" - MRT=$next -done - -exit "$OCTOPUS_FAILURE" diff --git a/libexec/git-core/git-merge-one-file b/libexec/git-core/git-merge-one-file deleted file mode 100755 index f6d9852d..00000000 --- a/libexec/git-core/git-merge-one-file +++ /dev/null @@ -1,167 +0,0 @@ -#!/bin/sh -# -# Copyright (c) Linus Torvalds, 2005 -# -# This is the git per-file merge script, called with -# -# $1 - original file SHA1 (or empty) -# $2 - file in branch1 SHA1 (or empty) -# $3 - file in branch2 SHA1 (or empty) -# $4 - pathname in repository -# $5 - original file mode (or empty) -# $6 - file in branch1 mode (or empty) -# $7 - file in branch2 mode (or empty) -# -# Handle some trivial cases.. The _really_ trivial cases have -# been handled already by git read-tree, but that one doesn't -# do any merges that might change the tree layout. - -USAGE=' ' -USAGE="$USAGE " -LONG_USAGE="usage: git merge-one-file $USAGE - -Blob ids and modes should be empty for missing files." - -SUBDIRECTORY_OK=Yes -. git-sh-setup -cd_to_toplevel -require_work_tree - -if test $# != 7 -then - echo "$LONG_USAGE" - exit 1 -fi - -case "${1:-.}${2:-.}${3:-.}" in -# -# Deleted in both or deleted in one and unchanged in the other -# -"$1.." | "$1.$1" | "$1$1.") - if { test -z "$6" && test "$5" != "$7"; } || - { test -z "$7" && test "$5" != "$6"; } - then - echo "ERROR: File $4 deleted on one branch but had its" >&2 - echo "ERROR: permissions changed on the other." >&2 - exit 1 - fi - - if test -n "$2" - then - echo "Removing $4" - else - # read-tree checked that index matches HEAD already, - # so we know we do not have this path tracked. - # there may be an unrelated working tree file here, - # which we should just leave unmolested. Make sure - # we do not have it in the index, though. - exec git update-index --remove -- "$4" - fi - if test -f "$4" - then - rm -f -- "$4" && - rmdir -p "$(expr "z$4" : 'z\(.*\)/')" 2>/dev/null || : - fi && - exec git update-index --remove -- "$4" - ;; - -# -# Added in one. -# -".$2.") - # the other side did not add and we added so there is nothing - # to be done, except making the path merged. - exec git update-index --add --cacheinfo "$6" "$2" "$4" - ;; -"..$3") - echo "Adding $4" - if test -f "$4" - then - echo "ERROR: untracked $4 is overwritten by the merge." >&2 - exit 1 - fi - git update-index --add --cacheinfo "$7" "$3" "$4" && - exec git checkout-index -u -f -- "$4" - ;; - -# -# Added in both, identically (check for same permissions). -# -".$3$2") - if test "$6" != "$7" - then - echo "ERROR: File $4 added identically in both branches," >&2 - echo "ERROR: but permissions conflict $6->$7." >&2 - exit 1 - fi - echo "Adding $4" - git update-index --add --cacheinfo "$6" "$2" "$4" && - exec git checkout-index -u -f -- "$4" - ;; - -# -# Modified in both, but differently. -# -"$1$2$3" | ".$2$3") - - case ",$6,$7," in - *,120000,*) - echo "ERROR: $4: Not merging symbolic link changes." >&2 - exit 1 - ;; - *,160000,*) - echo "ERROR: $4: Not merging conflicting submodule changes." >&2 - exit 1 - ;; - esac - - src1=$(git unpack-file $2) - src2=$(git unpack-file $3) - case "$1" in - '') - echo "Added $4 in both, but differently." - orig=$(git unpack-file $(git hash-object /dev/null)) - ;; - *) - echo "Auto-merging $4" - orig=$(git unpack-file $1) - ;; - esac - - git merge-file "$src1" "$orig" "$src2" - ret=$? - msg= - if test $ret != 0 || test -z "$1" - then - msg='content conflict' - ret=1 - fi - - # Create the working tree file, using "our tree" version from the - # index, and then store the result of the merge. - git checkout-index -f --stage=2 -- "$4" && cat "$src1" >"$4" || exit 1 - rm -f -- "$orig" "$src1" "$src2" - - if test "$6" != "$7" - then - if test -n "$msg" - then - msg="$msg, " - fi - msg="${msg}permissions conflict: $5->$6,$7" - ret=1 - fi - - if test $ret != 0 - then - echo "ERROR: $msg in $4" >&2 - exit 1 - fi - exec git update-index -- "$4" - ;; - -*) - echo "ERROR: $4: Not handling case $1 -> $2 -> $3" >&2 - ;; -esac -exit 1 diff --git a/libexec/git-core/git-merge-ours b/libexec/git-core/git-merge-ours deleted file mode 120000 index f2cccfc2..00000000 --- a/libexec/git-core/git-merge-ours +++ /dev/null @@ -1 +0,0 @@ -../../bin/git \ No newline at end of file diff --git a/libexec/git-core/git-merge-recursive b/libexec/git-core/git-merge-recursive deleted file mode 120000 index f2cccfc2..00000000 --- a/libexec/git-core/git-merge-recursive +++ /dev/null @@ -1 +0,0 @@ -../../bin/git \ No newline at end of file diff --git a/libexec/git-core/git-merge-resolve b/libexec/git-core/git-merge-resolve deleted file mode 100755 index 343fe7bc..00000000 --- a/libexec/git-core/git-merge-resolve +++ /dev/null @@ -1,54 +0,0 @@ -#!/bin/sh -# -# Copyright (c) 2005 Linus Torvalds -# Copyright (c) 2005 Junio C Hamano -# -# Resolve two trees, using enhanced multi-base read-tree. - -# The first parameters up to -- are merge bases; the rest are heads. -bases= head= remotes= sep_seen= -for arg -do - case ",$sep_seen,$head,$arg," in - *,--,) - sep_seen=yes - ;; - ,yes,,*) - head=$arg - ;; - ,yes,*) - remotes="$remotes$arg " - ;; - *) - bases="$bases$arg " - ;; - esac -done - -# Give up if we are given two or more remotes -- not handling octopus. -case "$remotes" in -?*' '?*) - exit 2 ;; -esac - -# Give up if this is a baseless merge. -if test '' = "$bases" -then - exit 2 -fi - -git update-index -q --refresh -git read-tree -u -m --aggressive $bases $head $remotes || exit 2 -echo "Trying simple merge." -if result_tree=$(git write-tree 2>/dev/null) -then - exit 0 -else - echo "Simple merge failed, trying Automatic merge." - if git merge-index -o git-merge-one-file -a - then - exit 0 - else - exit 1 - fi -fi diff --git a/libexec/git-core/git-merge-subtree b/libexec/git-core/git-merge-subtree deleted file mode 120000 index f2cccfc2..00000000 --- a/libexec/git-core/git-merge-subtree +++ /dev/null @@ -1 +0,0 @@ -../../bin/git \ No newline at end of file diff --git a/libexec/git-core/git-merge-tree b/libexec/git-core/git-merge-tree deleted file mode 120000 index f2cccfc2..00000000 --- a/libexec/git-core/git-merge-tree +++ /dev/null @@ -1 +0,0 @@ -../../bin/git \ No newline at end of file diff --git a/libexec/git-core/git-mergetool b/libexec/git-core/git-mergetool deleted file mode 100755 index d07c7f38..00000000 --- a/libexec/git-core/git-mergetool +++ /dev/null @@ -1,509 +0,0 @@ -#!/bin/sh -# -# This program resolves merge conflicts in git -# -# Copyright (c) 2006 Theodore Y. Ts'o -# Copyright (c) 2009-2016 David Aguilar -# -# This file is licensed under the GPL v2, or a later version -# at the discretion of Junio C Hamano. -# - -USAGE='[--tool=tool] [--tool-help] [-y|--no-prompt|--prompt] [-O] [file to merge] ...' -SUBDIRECTORY_OK=Yes -NONGIT_OK=Yes -OPTIONS_SPEC= -TOOL_MODE=merge -. git-sh-setup -. git-mergetool--lib - -# Returns true if the mode reflects a symlink -is_symlink () { - test "$1" = 120000 -} - -is_submodule () { - test "$1" = 160000 -} - -local_present () { - test -n "$local_mode" -} - -remote_present () { - test -n "$remote_mode" -} - -base_present () { - test -n "$base_mode" -} - -mergetool_tmpdir_init () { - if test "$(git config --bool mergetool.writeToTemp)" != true - then - MERGETOOL_TMPDIR=. - return 0 - fi - if MERGETOOL_TMPDIR=$(mktemp -d -t "git-mergetool-XXXXXX" 2>/dev/null) - then - return 0 - fi - die "error: mktemp is needed when 'mergetool.writeToTemp' is true" -} - -cleanup_temp_files () { - if test "$1" = --save-backup - then - rm -rf -- "$MERGED.orig" - test -e "$BACKUP" && mv -- "$BACKUP" "$MERGED.orig" - rm -f -- "$LOCAL" "$REMOTE" "$BASE" - else - rm -f -- "$LOCAL" "$REMOTE" "$BASE" "$BACKUP" - fi - if test "$MERGETOOL_TMPDIR" != "." - then - rmdir "$MERGETOOL_TMPDIR" - fi -} - -describe_file () { - mode="$1" - branch="$2" - file="$3" - - printf " {%s}: " "$branch" - if test -z "$mode" - then - echo "deleted" - elif is_symlink "$mode" - then - echo "a symbolic link -> '$(cat "$file")'" - elif is_submodule "$mode" - then - echo "submodule commit $file" - elif base_present - then - echo "modified file" - else - echo "created file" - fi -} - -resolve_symlink_merge () { - while true - do - printf "Use (l)ocal or (r)emote, or (a)bort? " - read ans || return 1 - case "$ans" in - [lL]*) - git checkout-index -f --stage=2 -- "$MERGED" - git add -- "$MERGED" - cleanup_temp_files --save-backup - return 0 - ;; - [rR]*) - git checkout-index -f --stage=3 -- "$MERGED" - git add -- "$MERGED" - cleanup_temp_files --save-backup - return 0 - ;; - [aA]*) - return 1 - ;; - esac - done -} - -resolve_deleted_merge () { - while true - do - if base_present - then - printf "Use (m)odified or (d)eleted file, or (a)bort? " - else - printf "Use (c)reated or (d)eleted file, or (a)bort? " - fi - read ans || return 1 - case "$ans" in - [mMcC]*) - git add -- "$MERGED" - if test "$merge_keep_backup" = "true" - then - cleanup_temp_files --save-backup - else - cleanup_temp_files - fi - return 0 - ;; - [dD]*) - git rm -- "$MERGED" > /dev/null - cleanup_temp_files - return 0 - ;; - [aA]*) - if test "$merge_keep_temporaries" = "false" - then - cleanup_temp_files - fi - return 1 - ;; - esac - done -} - -resolve_submodule_merge () { - while true - do - printf "Use (l)ocal or (r)emote, or (a)bort? " - read ans || return 1 - case "$ans" in - [lL]*) - if ! local_present - then - if test -n "$(git ls-tree HEAD -- "$MERGED")" - then - # Local isn't present, but it's a subdirectory - git ls-tree --full-name -r HEAD -- "$MERGED" | - git update-index --index-info || exit $? - else - test -e "$MERGED" && mv -- "$MERGED" "$BACKUP" - git update-index --force-remove "$MERGED" - cleanup_temp_files --save-backup - fi - elif is_submodule "$local_mode" - then - stage_submodule "$MERGED" "$local_sha1" - else - git checkout-index -f --stage=2 -- "$MERGED" - git add -- "$MERGED" - fi - return 0 - ;; - [rR]*) - if ! remote_present - then - if test -n "$(git ls-tree MERGE_HEAD -- "$MERGED")" - then - # Remote isn't present, but it's a subdirectory - git ls-tree --full-name -r MERGE_HEAD -- "$MERGED" | - git update-index --index-info || exit $? - else - test -e "$MERGED" && mv -- "$MERGED" "$BACKUP" - git update-index --force-remove "$MERGED" - fi - elif is_submodule "$remote_mode" - then - ! is_submodule "$local_mode" && - test -e "$MERGED" && - mv -- "$MERGED" "$BACKUP" - stage_submodule "$MERGED" "$remote_sha1" - else - test -e "$MERGED" && mv -- "$MERGED" "$BACKUP" - git checkout-index -f --stage=3 -- "$MERGED" - git add -- "$MERGED" - fi - cleanup_temp_files --save-backup - return 0 - ;; - [aA]*) - return 1 - ;; - esac - done -} - -stage_submodule () { - path="$1" - submodule_sha1="$2" - mkdir -p "$path" || - die "fatal: unable to create directory for module at $path" - # Find $path relative to work tree - work_tree_root=$(cd_to_toplevel && pwd) - work_rel_path=$(cd "$path" && - GIT_WORK_TREE="${work_tree_root}" git rev-parse --show-prefix - ) - test -n "$work_rel_path" || - die "fatal: unable to get path of module $path relative to work tree" - git update-index --add --replace --cacheinfo 160000 "$submodule_sha1" "${work_rel_path%/}" || die -} - -checkout_staged_file () { - tmpfile=$(expr \ - "$(git checkout-index --temp --stage="$1" "$2" 2>/dev/null)" \ - : '\([^ ]*\) ') - - if test $? -eq 0 && test -n "$tmpfile" - then - mv -- "$(git rev-parse --show-cdup)$tmpfile" "$3" - else - >"$3" - fi -} - -merge_file () { - MERGED="$1" - - f=$(git ls-files -u -- "$MERGED") - if test -z "$f" - then - if test ! -f "$MERGED" - then - echo "$MERGED: file not found" - else - echo "$MERGED: file does not need merging" - fi - return 1 - fi - - if BASE=$(expr "$MERGED" : '\(.*\)\.[^/]*$') - then - ext=$(expr "$MERGED" : '.*\(\.[^/]*\)$') - else - BASE=$MERGED - ext= - fi - - mergetool_tmpdir_init - - if test "$MERGETOOL_TMPDIR" != "." - then - # If we're using a temporary directory then write to the - # top-level of that directory. - BASE=${BASE##*/} - fi - - BACKUP="$MERGETOOL_TMPDIR/${BASE}_BACKUP_$$$ext" - LOCAL="$MERGETOOL_TMPDIR/${BASE}_LOCAL_$$$ext" - REMOTE="$MERGETOOL_TMPDIR/${BASE}_REMOTE_$$$ext" - BASE="$MERGETOOL_TMPDIR/${BASE}_BASE_$$$ext" - - base_mode=$(git ls-files -u -- "$MERGED" | awk '{if ($3==1) print $1;}') - local_mode=$(git ls-files -u -- "$MERGED" | awk '{if ($3==2) print $1;}') - remote_mode=$(git ls-files -u -- "$MERGED" | awk '{if ($3==3) print $1;}') - - if is_submodule "$local_mode" || is_submodule "$remote_mode" - then - echo "Submodule merge conflict for '$MERGED':" - local_sha1=$(git ls-files -u -- "$MERGED" | awk '{if ($3==2) print $2;}') - remote_sha1=$(git ls-files -u -- "$MERGED" | awk '{if ($3==3) print $2;}') - describe_file "$local_mode" "local" "$local_sha1" - describe_file "$remote_mode" "remote" "$remote_sha1" - resolve_submodule_merge - return - fi - - if test -f "$MERGED" - then - mv -- "$MERGED" "$BACKUP" - cp -- "$BACKUP" "$MERGED" - fi - # Create a parent directory to handle delete/delete conflicts - # where the base's directory no longer exists. - mkdir -p "$(dirname "$MERGED")" - - checkout_staged_file 1 "$MERGED" "$BASE" - checkout_staged_file 2 "$MERGED" "$LOCAL" - checkout_staged_file 3 "$MERGED" "$REMOTE" - - if test -z "$local_mode" || test -z "$remote_mode" - then - echo "Deleted merge conflict for '$MERGED':" - describe_file "$local_mode" "local" "$LOCAL" - describe_file "$remote_mode" "remote" "$REMOTE" - resolve_deleted_merge - status=$? - rmdir -p "$(dirname "$MERGED")" 2>/dev/null - return $status - fi - - if is_symlink "$local_mode" || is_symlink "$remote_mode" - then - echo "Symbolic link merge conflict for '$MERGED':" - describe_file "$local_mode" "local" "$LOCAL" - describe_file "$remote_mode" "remote" "$REMOTE" - resolve_symlink_merge - return - fi - - echo "Normal merge conflict for '$MERGED':" - describe_file "$local_mode" "local" "$LOCAL" - describe_file "$remote_mode" "remote" "$REMOTE" - if test "$guessed_merge_tool" = true || test "$prompt" = true - then - printf "Hit return to start merge resolution tool (%s): " "$merge_tool" - read ans || return 1 - fi - - if base_present - then - present=true - else - present=false - fi - - if ! run_merge_tool "$merge_tool" "$present" - then - echo "merge of $MERGED failed" 1>&2 - mv -- "$BACKUP" "$MERGED" - - if test "$merge_keep_temporaries" = "false" - then - cleanup_temp_files - fi - - return 1 - fi - - if test "$merge_keep_backup" = "true" - then - mv -- "$BACKUP" "$MERGED.orig" - else - rm -- "$BACKUP" - fi - - git add -- "$MERGED" - cleanup_temp_files - return 0 -} - -prompt_after_failed_merge () { - while true - do - printf "Continue merging other unresolved paths [y/n]? " - read ans || return 1 - case "$ans" in - [yY]*) - return 0 - ;; - [nN]*) - return 1 - ;; - esac - done -} - -print_noop_and_exit () { - echo "No files need merging" - exit 0 -} - -main () { - prompt=$(git config --bool mergetool.prompt) - guessed_merge_tool=false - orderfile= - - while test $# != 0 - do - case "$1" in - --tool-help=*) - TOOL_MODE=${1#--tool-help=} - show_tool_help - ;; - --tool-help) - show_tool_help - ;; - -t|--tool*) - case "$#,$1" in - *,*=*) - merge_tool=$(expr "z$1" : 'z-[^=]*=\(.*\)') - ;; - 1,*) - usage ;; - *) - merge_tool="$2" - shift ;; - esac - ;; - -y|--no-prompt) - prompt=false - ;; - --prompt) - prompt=true - ;; - -O*) - orderfile="${1#-O}" - ;; - --) - shift - break - ;; - -*) - usage - ;; - *) - break - ;; - esac - shift - done - - git_dir_init - require_work_tree - - if test -z "$merge_tool" - then - # Check if a merge tool has been configured - merge_tool=$(get_configured_merge_tool) - # Try to guess an appropriate merge tool if no tool has been set. - if test -z "$merge_tool" - then - merge_tool=$(guess_merge_tool) || exit - guessed_merge_tool=true - fi - fi - merge_keep_backup="$(git config --bool mergetool.keepBackup || echo true)" - merge_keep_temporaries="$(git config --bool mergetool.keepTemporaries || echo false)" - - prefix=$(git rev-parse --show-prefix) || exit 1 - cd_to_toplevel - - if test -n "$orderfile" - then - orderfile=$( - git rev-parse --prefix "$prefix" -- "$orderfile" | - sed -e 1d - ) - fi - - if test $# -eq 0 && test -e "$GIT_DIR/MERGE_RR" - then - set -- $(git rerere remaining) - if test $# -eq 0 - then - print_noop_and_exit - fi - elif test $# -ge 0 - then - # rev-parse provides the -- needed for 'set' - eval "set $(git rev-parse --sq --prefix "$prefix" -- "$@")" - fi - - files=$(git -c core.quotePath=false \ - diff --name-only --diff-filter=U \ - ${orderfile:+"-O$orderfile"} -- "$@") - - if test -z "$files" - then - print_noop_and_exit - fi - - printf "Merging:\n" - printf "%s\n" "$files" - - rc=0 - set -- $files - while test $# -ne 0 - do - printf "\n" - if ! merge_file "$1" - then - rc=1 - test $# -ne 1 && prompt_after_failed_merge || exit 1 - fi - shift - done - - exit $rc -} - -main "$@" diff --git a/libexec/git-core/git-mergetool--lib b/libexec/git-core/git-mergetool--lib deleted file mode 100644 index 9a8b97a2..00000000 --- a/libexec/git-core/git-mergetool--lib +++ /dev/null @@ -1,433 +0,0 @@ -# git-mergetool--lib is a shell library for common merge tool functions - -: ${MERGE_TOOLS_DIR=$(git --exec-path)/mergetools} - -IFS=' -' - -mode_ok () { - if diff_mode - then - can_diff - elif merge_mode - then - can_merge - else - false - fi -} - -is_available () { - merge_tool_path=$(translate_merge_tool_path "$1") && - type "$merge_tool_path" >/dev/null 2>&1 -} - -list_config_tools () { - section=$1 - line_prefix=${2:-} - - git config --get-regexp $section'\..*\.cmd' | - while read -r key value - do - toolname=${key#$section.} - toolname=${toolname%.cmd} - - printf "%s%s\n" "$line_prefix" "$toolname" - done -} - -show_tool_names () { - condition=${1:-true} per_line_prefix=${2:-} preamble=${3:-} - not_found_msg=${4:-} - extra_content=${5:-} - - shown_any= - ( cd "$MERGE_TOOLS_DIR" && ls ) | { - while read toolname - do - if setup_tool "$toolname" 2>/dev/null && - (eval "$condition" "$toolname") - then - if test -n "$preamble" - then - printf "%s\n" "$preamble" - preamble= - fi - shown_any=yes - printf "%s%s\n" "$per_line_prefix" "$toolname" - fi - done - - if test -n "$extra_content" - then - if test -n "$preamble" - then - # Note: no '\n' here since we don't want a - # blank line if there is no initial content. - printf "%s" "$preamble" - preamble= - fi - shown_any=yes - printf "\n%s\n" "$extra_content" - fi - - if test -n "$preamble" && test -n "$not_found_msg" - then - printf "%s\n" "$not_found_msg" - fi - - test -n "$shown_any" - } -} - -diff_mode() { - test "$TOOL_MODE" = diff -} - -merge_mode() { - test "$TOOL_MODE" = merge -} - -translate_merge_tool_path () { - echo "$1" -} - -check_unchanged () { - if test "$MERGED" -nt "$BACKUP" - then - return 0 - else - while true - do - echo "$MERGED seems unchanged." - printf "Was the merge successful [y/n]? " - read answer || return 1 - case "$answer" in - y*|Y*) return 0 ;; - n*|N*) return 1 ;; - esac - done - fi -} - -valid_tool () { - setup_tool "$1" && return 0 - cmd=$(get_merge_tool_cmd "$1") - test -n "$cmd" -} - -setup_user_tool () { - merge_tool_cmd=$(get_merge_tool_cmd "$tool") - test -n "$merge_tool_cmd" || return 1 - - diff_cmd () { - ( eval $merge_tool_cmd ) - } - - merge_cmd () { - ( eval $merge_tool_cmd ) - } -} - -setup_tool () { - tool="$1" - - # Fallback definitions, to be overridden by tools. - can_merge () { - return 0 - } - - can_diff () { - return 0 - } - - diff_cmd () { - return 1 - } - - merge_cmd () { - return 1 - } - - translate_merge_tool_path () { - echo "$1" - } - - # Most tools' exit codes cannot be trusted, so By default we ignore - # their exit code and check the merged file's modification time in - # check_unchanged() to determine whether or not the merge was - # successful. The return value from run_merge_cmd, by default, is - # determined by check_unchanged(). - # - # When a tool's exit code can be trusted then the return value from - # run_merge_cmd is simply the tool's exit code, and check_unchanged() - # is not called. - # - # The return value of exit_code_trustable() tells us whether or not we - # can trust the tool's exit code. - # - # User-defined and built-in tools default to false. - # Built-in tools advertise that their exit code is trustable by - # redefining exit_code_trustable() to true. - - exit_code_trustable () { - false - } - - - if ! test -f "$MERGE_TOOLS_DIR/$tool" - then - setup_user_tool - return $? - fi - - # Load the redefined functions - . "$MERGE_TOOLS_DIR/$tool" - # Now let the user override the default command for the tool. If - # they have not done so then this will return 1 which we ignore. - setup_user_tool - - if merge_mode && ! can_merge - then - echo "error: '$tool' can not be used to resolve merges" >&2 - return 1 - elif diff_mode && ! can_diff - then - echo "error: '$tool' can only be used to resolve merges" >&2 - return 1 - fi - return 0 -} - -get_merge_tool_cmd () { - merge_tool="$1" - if diff_mode - then - git config "difftool.$merge_tool.cmd" || - git config "mergetool.$merge_tool.cmd" - else - git config "mergetool.$merge_tool.cmd" - fi -} - -trust_exit_code () { - if git config --bool "mergetool.$1.trustExitCode" - then - :; # OK - elif exit_code_trustable - then - echo true - else - echo false - fi -} - - -# Entry point for running tools -run_merge_tool () { - # If GIT_PREFIX is empty then we cannot use it in tools - # that expect to be able to chdir() to its value. - GIT_PREFIX=${GIT_PREFIX:-.} - export GIT_PREFIX - - merge_tool_path=$(get_merge_tool_path "$1") || exit - base_present="$2" - - # Bring tool-specific functions into scope - setup_tool "$1" || return 1 - - if merge_mode - then - run_merge_cmd "$1" - else - run_diff_cmd "$1" - fi -} - -# Run a either a configured or built-in diff tool -run_diff_cmd () { - diff_cmd "$1" -} - -# Run a either a configured or built-in merge tool -run_merge_cmd () { - mergetool_trust_exit_code=$(trust_exit_code "$1") - if test "$mergetool_trust_exit_code" = "true" - then - merge_cmd "$1" - else - touch "$BACKUP" - merge_cmd "$1" - check_unchanged - fi -} - -list_merge_tool_candidates () { - if merge_mode - then - tools="tortoisemerge" - else - tools="kompare" - fi - if test -n "$DISPLAY" - then - if test -n "$GNOME_DESKTOP_SESSION_ID" - then - tools="meld opendiff kdiff3 tkdiff xxdiff $tools" - else - tools="opendiff kdiff3 tkdiff xxdiff meld $tools" - fi - tools="$tools gvimdiff diffuse diffmerge ecmerge" - tools="$tools p4merge araxis bc codecompare" - fi - case "${VISUAL:-$EDITOR}" in - *vim*) - tools="$tools vimdiff emerge" - ;; - *) - tools="$tools emerge vimdiff" - ;; - esac -} - -show_tool_help () { - tool_opt="'git ${TOOL_MODE}tool --tool='" - - tab=' ' - LF=' -' - any_shown=no - - cmd_name=${TOOL_MODE}tool - config_tools=$({ - diff_mode && list_config_tools difftool "$tab$tab" - list_config_tools mergetool "$tab$tab" - } | sort) - extra_content= - if test -n "$config_tools" - then - extra_content="${tab}user-defined:${LF}$config_tools" - fi - - show_tool_names 'mode_ok && is_available' "$tab$tab" \ - "$tool_opt may be set to one of the following:" \ - "No suitable tool for 'git $cmd_name --tool=' found." \ - "$extra_content" && - any_shown=yes - - show_tool_names 'mode_ok && ! is_available' "$tab$tab" \ - "${LF}The following tools are valid, but not currently available:" && - any_shown=yes - - if test "$any_shown" = yes - then - echo - echo "Some of the tools listed above only work in a windowed" - echo "environment. If run in a terminal-only session, they will fail." - fi - exit 0 -} - -guess_merge_tool () { - list_merge_tool_candidates - cat >&2 <<-EOF - - This message is displayed because '$TOOL_MODE.tool' is not configured. - See 'git ${TOOL_MODE}tool --tool-help' or 'git help config' for more details. - 'git ${TOOL_MODE}tool' will now attempt to use one of the following tools: - $tools - EOF - - # Loop over each candidate and stop when a valid merge tool is found. - IFS=' ' - for tool in $tools - do - is_available "$tool" && echo "$tool" && return 0 - done - - echo >&2 "No known ${TOOL_MODE} tool is available." - return 1 -} - -get_configured_merge_tool () { - # Diff mode first tries diff.tool and falls back to merge.tool. - # Merge mode only checks merge.tool - if diff_mode - then - merge_tool=$(git config diff.tool || git config merge.tool) - else - merge_tool=$(git config merge.tool) - fi - if test -n "$merge_tool" && ! valid_tool "$merge_tool" - then - echo >&2 "git config option $TOOL_MODE.tool set to unknown tool: $merge_tool" - echo >&2 "Resetting to default..." - return 1 - fi - echo "$merge_tool" -} - -get_merge_tool_path () { - # A merge tool has been set, so verify that it's valid. - merge_tool="$1" - if ! valid_tool "$merge_tool" - then - echo >&2 "Unknown merge tool $merge_tool" - exit 1 - fi - if diff_mode - then - merge_tool_path=$(git config difftool."$merge_tool".path || - git config mergetool."$merge_tool".path) - else - merge_tool_path=$(git config mergetool."$merge_tool".path) - fi - if test -z "$merge_tool_path" - then - merge_tool_path=$(translate_merge_tool_path "$merge_tool") - fi - if test -z "$(get_merge_tool_cmd "$merge_tool")" && - ! type "$merge_tool_path" >/dev/null 2>&1 - then - echo >&2 "The $TOOL_MODE tool $merge_tool is not available as"\ - "'$merge_tool_path'" - exit 1 - fi - echo "$merge_tool_path" -} - -get_merge_tool () { - # Check if a merge tool has been configured - merge_tool=$(get_configured_merge_tool) - # Try to guess an appropriate merge tool if no tool has been set. - if test -z "$merge_tool" - then - merge_tool=$(guess_merge_tool) || exit - fi - echo "$merge_tool" -} - -mergetool_find_win32_cmd () { - executable=$1 - sub_directory=$2 - - # Use $executable if it exists in $PATH - if type -p "$executable" >/dev/null 2>&1 - then - printf '%s' "$executable" - return - fi - - # Look for executable in the typical locations - for directory in $(env | grep -Ei '^PROGRAM(FILES(\(X86\))?|W6432)=' | - cut -d '=' -f 2- | sort -u) - do - if test -n "$directory" && test -x "$directory/$sub_directory/$executable" - then - printf '%s' "$directory/$sub_directory/$executable" - return - fi - done - - printf '%s' "$executable" -} diff --git a/libexec/git-core/git-mktag b/libexec/git-core/git-mktag deleted file mode 120000 index f2cccfc2..00000000 --- a/libexec/git-core/git-mktag +++ /dev/null @@ -1 +0,0 @@ -../../bin/git \ No newline at end of file diff --git a/libexec/git-core/git-mktree b/libexec/git-core/git-mktree deleted file mode 120000 index f2cccfc2..00000000 --- a/libexec/git-core/git-mktree +++ /dev/null @@ -1 +0,0 @@ -../../bin/git \ No newline at end of file diff --git a/libexec/git-core/git-mv b/libexec/git-core/git-mv deleted file mode 120000 index f2cccfc2..00000000 --- a/libexec/git-core/git-mv +++ /dev/null @@ -1 +0,0 @@ -../../bin/git \ No newline at end of file diff --git a/libexec/git-core/git-name-rev b/libexec/git-core/git-name-rev deleted file mode 120000 index f2cccfc2..00000000 --- a/libexec/git-core/git-name-rev +++ /dev/null @@ -1 +0,0 @@ -../../bin/git \ No newline at end of file diff --git a/libexec/git-core/git-notes b/libexec/git-core/git-notes deleted file mode 120000 index f2cccfc2..00000000 --- a/libexec/git-core/git-notes +++ /dev/null @@ -1 +0,0 @@ -../../bin/git \ No newline at end of file diff --git a/libexec/git-core/git-p4 b/libexec/git-core/git-p4 deleted file mode 100755 index 50177f55..00000000 --- a/libexec/git-core/git-p4 +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/sh - -echo >&2 "fatal: git was built without support for $(basename $0) (NO_PYTHON=1)." -exit 128 diff --git a/libexec/git-core/git-pack-objects b/libexec/git-core/git-pack-objects deleted file mode 120000 index f2cccfc2..00000000 --- a/libexec/git-core/git-pack-objects +++ /dev/null @@ -1 +0,0 @@ -../../bin/git \ No newline at end of file diff --git a/libexec/git-core/git-pack-redundant b/libexec/git-core/git-pack-redundant deleted file mode 120000 index f2cccfc2..00000000 --- a/libexec/git-core/git-pack-redundant +++ /dev/null @@ -1 +0,0 @@ -../../bin/git \ No newline at end of file diff --git a/libexec/git-core/git-pack-refs b/libexec/git-core/git-pack-refs deleted file mode 120000 index f2cccfc2..00000000 --- a/libexec/git-core/git-pack-refs +++ /dev/null @@ -1 +0,0 @@ -../../bin/git \ No newline at end of file diff --git a/libexec/git-core/git-parse-remote b/libexec/git-core/git-parse-remote deleted file mode 100644 index d3c39980..00000000 --- a/libexec/git-core/git-parse-remote +++ /dev/null @@ -1,101 +0,0 @@ -# This is a shell library to calculate the remote repository and -# upstream branch that should be pulled by "git pull" from the current -# branch. - -# git-ls-remote could be called from outside a git managed repository; -# this would fail in that case and would issue an error message. -GIT_DIR=$(git rev-parse -q --git-dir) || :; - -get_default_remote () { - curr_branch=$(git symbolic-ref -q HEAD) - curr_branch="${curr_branch#refs/heads/}" - origin=$(git config --get "branch.$curr_branch.remote") - echo ${origin:-origin} -} - -get_remote_merge_branch () { - case "$#" in - 0|1) - origin="$1" - default=$(get_default_remote) - test -z "$origin" && origin=$default - curr_branch=$(git symbolic-ref -q HEAD) && - [ "$origin" = "$default" ] && - echo $(git for-each-ref --format='%(upstream)' $curr_branch) - ;; - *) - repo=$1 - shift - ref=$1 - # FIXME: It should return the tracking branch - # Currently only works with the default mapping - case "$ref" in - +*) - ref=$(expr "z$ref" : 'z+\(.*\)') - ;; - esac - expr "z$ref" : 'z.*:' >/dev/null || ref="${ref}:" - remote=$(expr "z$ref" : 'z\([^:]*\):') - case "$remote" in - '' | HEAD ) remote=HEAD ;; - heads/*) remote=${remote#heads/} ;; - refs/heads/*) remote=${remote#refs/heads/} ;; - refs/* | tags/* | remotes/* ) remote= - esac - [ -n "$remote" ] && case "$repo" in - .) - echo "refs/heads/$remote" - ;; - *) - echo "refs/remotes/$repo/$remote" - ;; - esac - esac -} - -error_on_missing_default_upstream () { - cmd="$1" - op_type="$2" - op_prep="$3" # FIXME: op_prep is no longer used - example="$4" - branch_name=$(git symbolic-ref -q HEAD) - display_branch_name="${branch_name#refs/heads/}" - # If there's only one remote, use that in the suggestion - remote="$(gettext "")" - branch="$(gettext "")" - if test $(git remote | wc -l) = 1 - then - remote=$(git remote) - fi - - if test -z "$branch_name" - then - gettextln "You are not currently on a branch." - else - gettextln "There is no tracking information for the current branch." - fi - case "$op_type" in - rebase) - gettextln "Please specify which branch you want to rebase against." - ;; - merge) - gettextln "Please specify which branch you want to merge with." - ;; - *) - echo >&2 "BUG: unknown operation type: $op_type" - exit 1 - ;; - esac - eval_gettextln "See git-\${cmd}(1) for details." - echo - echo " $example" - echo - if test -n "$branch_name" - then - gettextln "If you wish to set tracking information for this branch you can do so with:" - echo - echo " git branch --set-upstream-to=$remote/$branch $display_branch_name" - echo - fi - exit 1 -} diff --git a/libexec/git-core/git-patch-id b/libexec/git-core/git-patch-id deleted file mode 120000 index f2cccfc2..00000000 --- a/libexec/git-core/git-patch-id +++ /dev/null @@ -1 +0,0 @@ -../../bin/git \ No newline at end of file diff --git a/libexec/git-core/git-prune b/libexec/git-core/git-prune deleted file mode 120000 index f2cccfc2..00000000 --- a/libexec/git-core/git-prune +++ /dev/null @@ -1 +0,0 @@ -../../bin/git \ No newline at end of file diff --git a/libexec/git-core/git-prune-packed b/libexec/git-core/git-prune-packed deleted file mode 120000 index f2cccfc2..00000000 --- a/libexec/git-core/git-prune-packed +++ /dev/null @@ -1 +0,0 @@ -../../bin/git \ No newline at end of file diff --git a/libexec/git-core/git-pull b/libexec/git-core/git-pull deleted file mode 120000 index f2cccfc2..00000000 --- a/libexec/git-core/git-pull +++ /dev/null @@ -1 +0,0 @@ -../../bin/git \ No newline at end of file diff --git a/libexec/git-core/git-push b/libexec/git-core/git-push deleted file mode 120000 index f2cccfc2..00000000 --- a/libexec/git-core/git-push +++ /dev/null @@ -1 +0,0 @@ -../../bin/git \ No newline at end of file diff --git a/libexec/git-core/git-quiltimport b/libexec/git-core/git-quiltimport deleted file mode 100755 index 6d3a88de..00000000 --- a/libexec/git-core/git-quiltimport +++ /dev/null @@ -1,151 +0,0 @@ -#!/bin/sh -OPTIONS_KEEPDASHDASH= -OPTIONS_STUCKLONG= -OPTIONS_SPEC="\ -git quiltimport [options] --- -n,dry-run dry run -author= author name and email address for patches without any -patches= path to the quilt patches -series= path to the quilt series file -" -SUBDIRECTORY_ON=Yes -. git-sh-setup - -dry_run="" -quilt_author="" -while test $# != 0 -do - case "$1" in - --author) - shift - quilt_author="$1" - ;; - -n|--dry-run) - dry_run=1 - ;; - --patches) - shift - QUILT_PATCHES="$1" - ;; - --series) - shift - QUILT_SERIES="$1" - ;; - --) - shift - break;; - *) - usage - ;; - esac - shift -done - -# Quilt Author -if [ -n "$quilt_author" ] ; then - quilt_author_name=$(expr "z$quilt_author" : 'z\(.*[^ ]\) *<.*') && - quilt_author_email=$(expr "z$quilt_author" : '.*<\([^>]*\)') && - test '' != "$quilt_author_name" && - test '' != "$quilt_author_email" || - die "malformed --author parameter" -fi - -# Quilt patch directory -: ${QUILT_PATCHES:=patches} -if ! [ -d "$QUILT_PATCHES" ] ; then - echo "The \"$QUILT_PATCHES\" directory does not exist." - exit 1 -fi - -# Quilt series file -: ${QUILT_SERIES:=$QUILT_PATCHES/series} -if ! [ -e "$QUILT_SERIES" ] ; then - echo "The \"$QUILT_SERIES\" file does not exist." - exit 1 -fi - -# Temporary directories -tmp_dir="$GIT_DIR"/rebase-apply -tmp_msg="$tmp_dir/msg" -tmp_patch="$tmp_dir/patch" -tmp_info="$tmp_dir/info" - - -# Find the initial commit -commit=$(git rev-parse HEAD) - -mkdir $tmp_dir || exit 2 -while read patch_name level garbage <&3 -do - case "$patch_name" in ''|'#'*) continue;; esac - case "$level" in - -p*) ;; - ''|'#'*) - level=;; - *) - echo "unable to parse patch level, ignoring it." - level=;; - esac - case "$garbage" in - ''|'#'*);; - *) - echo "trailing garbage found in series file: $garbage" - exit 1;; - esac - if ! [ -f "$QUILT_PATCHES/$patch_name" ] ; then - echo "$patch_name doesn't exist. Skipping." - continue - fi - echo $patch_name - git mailinfo "$tmp_msg" "$tmp_patch" \ - <"$QUILT_PATCHES/$patch_name" >"$tmp_info" || exit 3 - test -s "$tmp_patch" || { - echo "Patch is empty. Was it split wrong?" - exit 1 - } - - # Parse the author information - GIT_AUTHOR_NAME=$(sed -ne 's/Author: //p' "$tmp_info") - GIT_AUTHOR_EMAIL=$(sed -ne 's/Email: //p' "$tmp_info") - export GIT_AUTHOR_NAME GIT_AUTHOR_EMAIL - while test -z "$GIT_AUTHOR_EMAIL" && test -z "$GIT_AUTHOR_NAME" ; do - if [ -n "$quilt_author" ] ; then - GIT_AUTHOR_NAME="$quilt_author_name"; - GIT_AUTHOR_EMAIL="$quilt_author_email"; - elif [ -n "$dry_run" ]; then - echo "No author found in $patch_name" >&2; - GIT_AUTHOR_NAME="dry-run-not-found"; - GIT_AUTHOR_EMAIL="dry-run-not-found"; - else - echo "No author found in $patch_name" >&2; - echo "---" - cat $tmp_msg - printf "Author: "; - read patch_author - - echo "$patch_author" - - patch_author_name=$(expr "z$patch_author" : 'z\(.*[^ ]\) *<.*') && - patch_author_email=$(expr "z$patch_author" : '.*<\([^>]*\)') && - test '' != "$patch_author_name" && - test '' != "$patch_author_email" && - GIT_AUTHOR_NAME="$patch_author_name" && - GIT_AUTHOR_EMAIL="$patch_author_email" - fi - done - GIT_AUTHOR_DATE=$(sed -ne 's/Date: //p' "$tmp_info") - SUBJECT=$(sed -ne 's/Subject: //p' "$tmp_info") - export GIT_AUTHOR_DATE SUBJECT - if [ -z "$SUBJECT" ] ; then - SUBJECT=$(echo $patch_name | sed -e 's/.patch$//') - fi - - if [ -z "$dry_run" ] ; then - git apply --index -C1 ${level:+"$level"} "$tmp_patch" && - tree=$(git write-tree) && - commit=$( (echo "$SUBJECT"; echo; cat "$tmp_msg") | git commit-tree $tree -p $commit) && - git update-ref -m "quiltimport: $patch_name" HEAD $commit || exit 4 - fi -done 3<"$QUILT_SERIES" -rm -rf $tmp_dir || exit 5 diff --git a/libexec/git-core/git-range-diff b/libexec/git-core/git-range-diff deleted file mode 120000 index f2cccfc2..00000000 --- a/libexec/git-core/git-range-diff +++ /dev/null @@ -1 +0,0 @@ -../../bin/git \ No newline at end of file diff --git a/libexec/git-core/git-read-tree b/libexec/git-core/git-read-tree deleted file mode 120000 index f2cccfc2..00000000 --- a/libexec/git-core/git-read-tree +++ /dev/null @@ -1 +0,0 @@ -../../bin/git \ No newline at end of file diff --git a/libexec/git-core/git-rebase b/libexec/git-core/git-rebase deleted file mode 100755 index 79734476..00000000 --- a/libexec/git-core/git-rebase +++ /dev/null @@ -1,773 +0,0 @@ -#!/bin/sh -# -# Copyright (c) 2005 Junio C Hamano. -# - -SUBDIRECTORY_OK=Yes -OPTIONS_KEEPDASHDASH= -OPTIONS_STUCKLONG=t -OPTIONS_SPEC="\ -git rebase [-i] [options] [--exec ] [--onto ] [] [] -git rebase [-i] [options] [--exec ] [--onto ] --root [] -git rebase --continue | --abort | --skip | --edit-todo --- - Available options are -v,verbose! display a diffstat of what changed upstream -q,quiet! be quiet. implies --no-stat -autostash automatically stash/stash pop before and after -fork-point use 'merge-base --fork-point' to refine upstream -onto=! rebase onto given branch instead of upstream -r,rebase-merges? try to rebase merges instead of skipping them -p,preserve-merges! try to recreate merges instead of ignoring them -s,strategy=! use the given merge strategy -X,strategy-option=! pass the argument through to the merge strategy -no-ff! cherry-pick all commits, even if unchanged -f,force-rebase! cherry-pick all commits, even if unchanged -m,merge! use merging strategies to rebase -i,interactive! let the user edit the list of commits to rebase -x,exec=! add exec lines after each commit of the editable list -k,keep-empty preserve empty commits during rebase -allow-empty-message allow rebasing commits with empty messages -stat! display a diffstat of what changed upstream -n,no-stat! do not show diffstat of what changed upstream -verify allow pre-rebase hook to run -rerere-autoupdate allow rerere to update index with resolved conflicts -root! rebase all reachable commits up to the root(s) -autosquash move commits that begin with squash!/fixup! under -i -signoff add a Signed-off-by: line to each commit -committer-date-is-author-date! passed to 'git am' -ignore-date! passed to 'git am' -whitespace=! passed to 'git apply' -ignore-whitespace! passed to 'git apply' -C=! passed to 'git apply' -S,gpg-sign? GPG-sign commits - Actions: -continue! continue -abort! abort and check out the original branch -skip! skip current patch and continue -edit-todo! edit the todo list during an interactive rebase -quit! abort but keep HEAD where it is -show-current-patch! show the patch file being applied or merged -" -. git-sh-setup -set_reflog_action rebase -require_work_tree_exists -cd_to_toplevel - -LF=' -' -ok_to_skip_pre_rebase= -resolvemsg=" -$(gettext 'Resolve all conflicts manually, mark them as resolved with -"git add/rm ", then run "git rebase --continue". -You can instead skip this commit: run "git rebase --skip". -To abort and get back to the state before "git rebase", run "git rebase --abort".') -" -squash_onto= -unset onto -unset restrict_revision -cmd= -strategy= -strategy_opts= -do_merge= -merge_dir="$GIT_DIR"/rebase-merge -apply_dir="$GIT_DIR"/rebase-apply -verbose= -diffstat= -test "$(git config --bool rebase.stat)" = true && diffstat=t -autostash="$(git config --bool rebase.autostash || echo false)" -fork_point=auto -git_am_opt= -git_format_patch_opt= -rebase_root= -force_rebase= -allow_rerere_autoupdate= -# Non-empty if a rebase was in progress when 'git rebase' was invoked -in_progress= -# One of {am, merge, interactive} -type= -# One of {"$GIT_DIR"/rebase-apply, "$GIT_DIR"/rebase-merge} -state_dir= -# One of {'', continue, skip, abort}, as parsed from command line -action= -rebase_merges= -rebase_cousins= -preserve_merges= -autosquash= -keep_empty= -allow_empty_message=--allow-empty-message -signoff= -test "$(git config --bool rebase.autosquash)" = "true" && autosquash=t -case "$(git config --bool commit.gpgsign)" in -true) gpg_sign_opt=-S ;; -*) gpg_sign_opt= ;; -esac - -read_basic_state () { - test -f "$state_dir/head-name" && - test -f "$state_dir/onto" && - head_name=$(cat "$state_dir"/head-name) && - onto=$(cat "$state_dir"/onto) && - # We always write to orig-head, but interactive rebase used to write to - # head. Fall back to reading from head to cover for the case that the - # user upgraded git with an ongoing interactive rebase. - if test -f "$state_dir"/orig-head - then - orig_head=$(cat "$state_dir"/orig-head) - else - orig_head=$(cat "$state_dir"/head) - fi && - GIT_QUIET=$(cat "$state_dir"/quiet) && - test -f "$state_dir"/verbose && verbose=t - test -f "$state_dir"/strategy && strategy="$(cat "$state_dir"/strategy)" - test -f "$state_dir"/strategy_opts && - strategy_opts="$(cat "$state_dir"/strategy_opts)" - test -f "$state_dir"/allow_rerere_autoupdate && - allow_rerere_autoupdate="$(cat "$state_dir"/allow_rerere_autoupdate)" - test -f "$state_dir"/gpg_sign_opt && - gpg_sign_opt="$(cat "$state_dir"/gpg_sign_opt)" - test -f "$state_dir"/signoff && { - signoff="$(cat "$state_dir"/signoff)" - force_rebase=t - } -} - -write_basic_state () { - echo "$head_name" > "$state_dir"/head-name && - echo "$onto" > "$state_dir"/onto && - echo "$orig_head" > "$state_dir"/orig-head && - echo "$GIT_QUIET" > "$state_dir"/quiet && - test t = "$verbose" && : > "$state_dir"/verbose - test -n "$strategy" && echo "$strategy" > "$state_dir"/strategy - test -n "$strategy_opts" && echo "$strategy_opts" > \ - "$state_dir"/strategy_opts - test -n "$allow_rerere_autoupdate" && echo "$allow_rerere_autoupdate" > \ - "$state_dir"/allow_rerere_autoupdate - test -n "$gpg_sign_opt" && echo "$gpg_sign_opt" > "$state_dir"/gpg_sign_opt - test -n "$signoff" && echo "$signoff" >"$state_dir"/signoff -} - -output () { - case "$verbose" in - '') - output=$("$@" 2>&1 ) - status=$? - test $status != 0 && printf "%s\n" "$output" - return $status - ;; - *) - "$@" - ;; - esac -} - -move_to_original_branch () { - case "$head_name" in - refs/*) - message="rebase finished: $head_name onto $onto" - git update-ref -m "$message" \ - $head_name $(git rev-parse HEAD) $orig_head && - git symbolic-ref \ - -m "rebase finished: returning to $head_name" \ - HEAD $head_name || - die "$(eval_gettext "Could not move back to \$head_name")" - ;; - esac -} - -apply_autostash () { - if test -f "$state_dir/autostash" - then - stash_sha1=$(cat "$state_dir/autostash") - if git stash apply $stash_sha1 >/dev/null 2>&1 - then - echo "$(gettext 'Applied autostash.')" >&2 - else - git stash store -m "autostash" -q $stash_sha1 || - die "$(eval_gettext "Cannot store \$stash_sha1")" - gettext 'Applying autostash resulted in conflicts. -Your changes are safe in the stash. -You can run "git stash pop" or "git stash drop" at any time. -' >&2 - fi - fi -} - -finish_rebase () { - rm -f "$(git rev-parse --git-path REBASE_HEAD)" - apply_autostash && - { git gc --auto || true; } && - rm -rf "$state_dir" -} - -run_specific_rebase () { - if [ "$interactive_rebase" = implied ]; then - GIT_EDITOR=: - export GIT_EDITOR - autosquash= - fi - . git-rebase--$type - - if test -z "$preserve_merges" - then - git_rebase__$type - else - git_rebase__preserve_merges - fi - - ret=$? - if test $ret -eq 0 - then - finish_rebase - elif test $ret -eq 2 # special exit status for rebase -i - then - apply_autostash && - rm -rf "$state_dir" && - die "Nothing to do" - fi - exit $ret -} - -run_pre_rebase_hook () { - if test -z "$ok_to_skip_pre_rebase" && - test -x "$(git rev-parse --git-path hooks/pre-rebase)" - then - "$(git rev-parse --git-path hooks/pre-rebase)" ${1+"$@"} || - die "$(gettext "The pre-rebase hook refused to rebase.")" - fi -} - -test -f "$apply_dir"/applying && - die "$(gettext "It looks like 'git am' is in progress. Cannot rebase.")" - -if test -d "$apply_dir" -then - type=am - state_dir="$apply_dir" -elif test -d "$merge_dir" -then - if test -d "$merge_dir"/rewritten - then - type=preserve-merges - interactive_rebase=explicit - preserve_merges=t - elif test -f "$merge_dir"/interactive - then - type=interactive - interactive_rebase=explicit - else - type=merge - fi - state_dir="$merge_dir" -fi -test -n "$type" && in_progress=t - -total_argc=$# -while test $# != 0 -do - case "$1" in - --no-verify) - ok_to_skip_pre_rebase=yes - ;; - --verify) - ok_to_skip_pre_rebase= - ;; - --continue|--skip|--abort|--quit|--edit-todo|--show-current-patch) - test $total_argc -eq 2 || usage - action=${1##--} - ;; - --onto=*) - onto="${1#--onto=}" - ;; - --exec=*) - cmd="${cmd}exec ${1#--exec=}${LF}" - test -z "$interactive_rebase" && interactive_rebase=implied - ;; - --interactive) - interactive_rebase=explicit - ;; - --keep-empty) - keep_empty=yes - ;; - --allow-empty-message) - allow_empty_message=--allow-empty-message - ;; - --no-keep-empty) - keep_empty= - ;; - --rebase-merges) - rebase_merges=t - test -z "$interactive_rebase" && interactive_rebase=implied - ;; - --rebase-merges=*) - rebase_merges=t - case "${1#*=}" in - rebase-cousins) rebase_cousins=t;; - no-rebase-cousins) rebase_cousins=;; - *) die "Unknown mode: $1";; - esac - test -z "$interactive_rebase" && interactive_rebase=implied - ;; - --preserve-merges) - preserve_merges=t - test -z "$interactive_rebase" && interactive_rebase=implied - ;; - --autosquash) - autosquash=t - ;; - --no-autosquash) - autosquash= - ;; - --fork-point) - fork_point=t - ;; - --no-fork-point) - fork_point= - ;; - --merge) - do_merge=t - ;; - --strategy-option=*) - strategy_opts="$strategy_opts $(git rev-parse --sq-quote "--${1#--strategy-option=}" | sed -e s/^.//)" - do_merge=t - test -z "$strategy" && strategy=recursive - ;; - --strategy=*) - strategy="${1#--strategy=}" - do_merge=t - ;; - --no-stat) - diffstat= - ;; - --stat) - diffstat=t - ;; - --autostash) - autostash=true - ;; - --no-autostash) - autostash=false - ;; - --verbose) - verbose=t - diffstat=t - GIT_QUIET= - ;; - --quiet) - GIT_QUIET=t - git_am_opt="$git_am_opt -q" - verbose= - diffstat= - ;; - --whitespace=*) - git_am_opt="$git_am_opt --whitespace=${1#--whitespace=}" - case "${1#--whitespace=}" in - fix|strip) - force_rebase=t - ;; - esac - ;; - --ignore-whitespace) - git_am_opt="$git_am_opt $1" - ;; - --signoff) - signoff=--signoff - ;; - --no-signoff) - signoff= - ;; - --committer-date-is-author-date|--ignore-date) - git_am_opt="$git_am_opt $1" - force_rebase=t - ;; - -C*) - git_am_opt="$git_am_opt $1" - ;; - --root) - rebase_root=t - ;; - --force-rebase|--no-ff) - force_rebase=t - ;; - --rerere-autoupdate|--no-rerere-autoupdate) - allow_rerere_autoupdate="$1" - ;; - --gpg-sign) - gpg_sign_opt=-S - ;; - --gpg-sign=*) - gpg_sign_opt="-S${1#--gpg-sign=}" - ;; - --) - shift - break - ;; - *) - usage - ;; - esac - shift -done -test $# -gt 2 && usage - -if test -n "$action" -then - test -z "$in_progress" && die "$(gettext "No rebase in progress?")" - # Only interactive rebase uses detailed reflog messages - if test -n "$interactive_rebase" && test "$GIT_REFLOG_ACTION" = rebase - then - GIT_REFLOG_ACTION="rebase -i ($action)" - export GIT_REFLOG_ACTION - fi -fi - -if test "$action" = "edit-todo" && test -z "$interactive_rebase" -then - die "$(gettext "The --edit-todo action can only be used during interactive rebase.")" -fi - -case "$action" in -continue) - # Sanity check - git rev-parse --verify HEAD >/dev/null || - die "$(gettext "Cannot read HEAD")" - git update-index --ignore-submodules --refresh && - git diff-files --quiet --ignore-submodules || { - echo "$(gettext "You must edit all merge conflicts and then -mark them as resolved using git add")" - exit 1 - } - read_basic_state - run_specific_rebase - ;; -skip) - output git reset --hard HEAD || exit $? - read_basic_state - run_specific_rebase - ;; -abort) - git rerere clear - read_basic_state - case "$head_name" in - refs/*) - git symbolic-ref -m "rebase: aborting" HEAD $head_name || - die "$(eval_gettext "Could not move back to \$head_name")" - ;; - esac - output git reset --hard $orig_head - finish_rebase - exit - ;; -quit) - exec rm -rf "$state_dir" - ;; -edit-todo) - run_specific_rebase - ;; -show-current-patch) - run_specific_rebase - die "BUG: run_specific_rebase is not supposed to return here" - ;; -esac - -# Make sure no rebase is in progress -if test -n "$in_progress" -then - state_dir_base=${state_dir##*/} - cmd_live_rebase="git rebase (--continue | --abort | --skip)" - cmd_clear_stale_rebase="rm -fr \"$state_dir\"" - die " -$(eval_gettext 'It seems that there is already a $state_dir_base directory, and -I wonder if you are in the middle of another rebase. If that is the -case, please try - $cmd_live_rebase -If that is not the case, please - $cmd_clear_stale_rebase -and run me again. I am stopping in case you still have something -valuable there.')" -fi - -if test -n "$rebase_root" && test -z "$onto" -then - test -z "$interactive_rebase" && interactive_rebase=implied -fi - -if test -n "$keep_empty" -then - test -z "$interactive_rebase" && interactive_rebase=implied -fi - -if test -n "$interactive_rebase" -then - if test -z "$preserve_merges" - then - type=interactive - else - type=preserve-merges - fi - - state_dir="$merge_dir" -elif test -n "$do_merge" -then - type=merge - state_dir="$merge_dir" -else - type=am - state_dir="$apply_dir" -fi - -if test -t 2 && test -z "$GIT_QUIET" -then - git_format_patch_opt="$git_format_patch_opt --progress" -fi - -if test -n "$git_am_opt"; then - incompatible_opts=$(echo " $git_am_opt " | \ - sed -e 's/ -q / /g' -e 's/^ \(.*\) $/\1/') - if test -n "$interactive_rebase" - then - if test -n "$incompatible_opts" - then - die "$(gettext "error: cannot combine interactive options (--interactive, --exec, --rebase-merges, --preserve-merges, --keep-empty, --root + --onto) with am options ($incompatible_opts)")" - fi - fi - if test -n "$do_merge"; then - if test -n "$incompatible_opts" - then - die "$(gettext "error: cannot combine merge options (--merge, --strategy, --strategy-option) with am options ($incompatible_opts)")" - fi - fi -fi - -if test -n "$signoff" -then - test -n "$preserve_merges" && - die "$(gettext "error: cannot combine '--signoff' with '--preserve-merges'")" - git_am_opt="$git_am_opt $signoff" - force_rebase=t -fi - -if test -n "$preserve_merges" -then - # Note: incompatibility with --signoff handled in signoff block above - # Note: incompatibility with --interactive is just a strong warning; - # git-rebase.txt caveats with "unless you know what you are doing" - test -n "$rebase_merges" && - die "$(gettext "error: cannot combine '--preserve_merges' with '--rebase-merges'")" -fi - -if test -n "$rebase_merges" -then - test -n "$strategy_opts" && - die "$(gettext "error: cannot combine '--rebase_merges' with '--strategy-option'")" - test -n "$strategy" && - die "$(gettext "error: cannot combine '--rebase_merges' with '--strategy'")" -fi - -if test -z "$rebase_root" -then - case "$#" in - 0) - if ! upstream_name=$(git rev-parse --symbolic-full-name \ - --verify -q @{upstream} 2>/dev/null) - then - . git-parse-remote - error_on_missing_default_upstream "rebase" "rebase" \ - "against" "git rebase $(gettext '')" - fi - - test "$fork_point" = auto && fork_point=t - ;; - *) upstream_name="$1" - if test "$upstream_name" = "-" - then - upstream_name="@{-1}" - fi - shift - ;; - esac - upstream=$(peel_committish "${upstream_name}") || - die "$(eval_gettext "invalid upstream '\$upstream_name'")" - upstream_arg="$upstream_name" -else - if test -z "$onto" - then - empty_tree=$(git hash-object -t tree /dev/null) - onto=$(git commit-tree $empty_tree or "detached HEAD" -switch_to= -case "$#" in -1) - # Is it "rebase other $branchname" or "rebase other $commit"? - branch_name="$1" - switch_to="$1" - - # Is it a local branch? - if git show-ref --verify --quiet -- "refs/heads/$branch_name" && - orig_head=$(git rev-parse -q --verify "refs/heads/$branch_name") - then - head_name="refs/heads/$branch_name" - # If not is it a valid ref (branch or commit)? - elif orig_head=$(git rev-parse -q --verify "$branch_name") - then - head_name="detached HEAD" - - else - die "$(eval_gettext "fatal: no such branch/commit '\$branch_name'")" - fi - ;; -0) - # Do not need to switch branches, we are already on it. - if branch_name=$(git symbolic-ref -q HEAD) - then - head_name=$branch_name - branch_name=$(expr "z$branch_name" : 'zrefs/heads/\(.*\)') - else - head_name="detached HEAD" - branch_name=HEAD - fi - orig_head=$(git rev-parse --verify HEAD) || exit - ;; -*) - die "BUG: unexpected number of arguments left to parse" - ;; -esac - -if test "$fork_point" = t -then - new_upstream=$(git merge-base --fork-point "$upstream_name" \ - "${switch_to:-HEAD}") - if test -n "$new_upstream" - then - restrict_revision=$new_upstream - fi -fi - -if test "$autostash" = true && ! (require_clean_work_tree) 2>/dev/null -then - stash_sha1=$(git stash create "autostash") || - die "$(gettext 'Cannot autostash')" - - mkdir -p "$state_dir" && - echo $stash_sha1 >"$state_dir/autostash" && - stash_abbrev=$(git rev-parse --short $stash_sha1) && - echo "$(eval_gettext 'Created autostash: $stash_abbrev')" && - git reset --hard -fi - -require_clean_work_tree "rebase" "$(gettext "Please commit or stash them.")" - -# Now we are rebasing commits $upstream..$orig_head (or with --root, -# everything leading up to $orig_head) on top of $onto - -# Check if we are already based on $onto with linear history, -# but this should be done only when upstream and onto are the same -# and if this is not an interactive rebase. -mb=$(git merge-base "$onto" "$orig_head") -if test -z "$interactive_rebase" && test "$upstream" = "$onto" && - test "$mb" = "$onto" && test -z "$restrict_revision" && - # linear history? - ! (git rev-list --parents "$onto".."$orig_head" | sane_grep " .* ") > /dev/null -then - if test -z "$force_rebase" - then - # Lazily switch to the target branch if needed... - test -z "$switch_to" || - GIT_REFLOG_ACTION="$GIT_REFLOG_ACTION: checkout $switch_to" \ - git checkout -q "$switch_to" -- - if test "$branch_name" = "HEAD" && - ! git symbolic-ref -q HEAD - then - say "$(eval_gettext "HEAD is up to date.")" - else - say "$(eval_gettext "Current branch \$branch_name is up to date.")" - fi - finish_rebase - exit 0 - else - if test "$branch_name" = "HEAD" && - ! git symbolic-ref -q HEAD - then - say "$(eval_gettext "HEAD is up to date, rebase forced.")" - else - say "$(eval_gettext "Current branch \$branch_name is up to date, rebase forced.")" - fi - fi -fi - -# If a hook exists, give it a chance to interrupt -run_pre_rebase_hook "$upstream_arg" "$@" - -if test -n "$diffstat" -then - if test -n "$verbose" - then - echo "$(eval_gettext "Changes from \$mb to \$onto:")" - fi - # We want color (if set), but no pager - GIT_PAGER='' git diff --stat --summary "$mb" "$onto" -fi - -test -n "$interactive_rebase" && run_specific_rebase - -# Detach HEAD and reset the tree -say "$(gettext "First, rewinding head to replay your work on top of it...")" - -GIT_REFLOG_ACTION="$GIT_REFLOG_ACTION: checkout $onto_name" \ - git checkout -q "$onto^0" || die "could not detach HEAD" -git update-ref ORIG_HEAD $orig_head - -# If the $onto is a proper descendant of the tip of the branch, then -# we just fast-forwarded. -if test "$mb" = "$orig_head" -then - say "$(eval_gettext "Fast-forwarded \$branch_name to \$onto_name.")" - move_to_original_branch - finish_rebase - exit 0 -fi - -if test -n "$rebase_root" -then - revisions="$onto..$orig_head" -else - revisions="${restrict_revision-$upstream}..$orig_head" -fi - -run_specific_rebase diff --git a/libexec/git-core/git-rebase--am b/libexec/git-core/git-rebase--am deleted file mode 100644 index 99b8c177..00000000 --- a/libexec/git-core/git-rebase--am +++ /dev/null @@ -1,85 +0,0 @@ -# This shell script fragment is sourced by git-rebase to implement -# its default, fast, patch-based, non-interactive mode. -# -# Copyright (c) 2010 Junio C Hamano. -# - -git_rebase__am () { - -case "$action" in -continue) - git am --resolved --resolvemsg="$resolvemsg" \ - ${gpg_sign_opt:+"$gpg_sign_opt"} && - move_to_original_branch - return - ;; -skip) - git am --skip --resolvemsg="$resolvemsg" && - move_to_original_branch - return - ;; -show-current-patch) - exec git am --show-current-patch - ;; -esac - -if test -z "$rebase_root" - # this is now equivalent to ! -z "$upstream" -then - revisions=$upstream...$orig_head -else - revisions=$onto...$orig_head -fi - -ret=0 -rm -f "$GIT_DIR/rebased-patches" - -git format-patch -k --stdout --full-index --cherry-pick --right-only \ - --src-prefix=a/ --dst-prefix=b/ --no-renames --no-cover-letter \ - --pretty=mboxrd \ - $git_format_patch_opt \ - "$revisions" ${restrict_revision+^$restrict_revision} \ - >"$GIT_DIR/rebased-patches" -ret=$? - -if test 0 != $ret -then - rm -f "$GIT_DIR/rebased-patches" - case "$head_name" in - refs/heads/*) - git checkout -q "$head_name" - ;; - *) - git checkout -q "$orig_head" - ;; - esac - - cat >&2 <<-EOF - - git encountered an error while preparing the patches to replay - these revisions: - - $revisions - - As a result, git cannot rebase them. - EOF - return $ret -fi - -git am $git_am_opt --rebasing --resolvemsg="$resolvemsg" \ - --patch-format=mboxrd \ - $allow_rerere_autoupdate \ - ${gpg_sign_opt:+"$gpg_sign_opt"} <"$GIT_DIR/rebased-patches" -ret=$? - -rm -f "$GIT_DIR/rebased-patches" - -if test 0 != $ret -then - test -d "$state_dir" && write_basic_state - return $ret -fi - -move_to_original_branch - -} diff --git a/libexec/git-core/git-rebase--helper b/libexec/git-core/git-rebase--helper deleted file mode 120000 index f2cccfc2..00000000 --- a/libexec/git-core/git-rebase--helper +++ /dev/null @@ -1 +0,0 @@ -../../bin/git \ No newline at end of file diff --git a/libexec/git-core/git-rebase--interactive b/libexec/git-core/git-rebase--interactive deleted file mode 100644 index 299ded21..00000000 --- a/libexec/git-core/git-rebase--interactive +++ /dev/null @@ -1,283 +0,0 @@ -# This shell script fragment is sourced by git-rebase to implement -# its interactive mode. "git rebase --interactive" makes it easy -# to fix up commits in the middle of a series and rearrange commits. -# -# Copyright (c) 2006 Johannes E. Schindelin -# -# The original idea comes from Eric W. Biederman, in -# https://public-inbox.org/git/m1odwkyuf5.fsf_-_@ebiederm.dsl.xmission.com/ -# -# The file containing rebase commands, comments, and empty lines. -# This file is created by "git rebase -i" then edited by the user. As -# the lines are processed, they are removed from the front of this -# file and written to the tail of $done. -todo="$state_dir"/git-rebase-todo - -GIT_CHERRY_PICK_HELP="$resolvemsg" -export GIT_CHERRY_PICK_HELP - -comment_char=$(git config --get core.commentchar 2>/dev/null) -case "$comment_char" in -'' | auto) - comment_char="#" - ;; -?) - ;; -*) - comment_char=$(echo "$comment_char" | cut -c1) - ;; -esac - -orig_reflog_action="$GIT_REFLOG_ACTION" - -comment_for_reflog () { - case "$orig_reflog_action" in - ''|rebase*) - GIT_REFLOG_ACTION="rebase -i ($1)" - export GIT_REFLOG_ACTION - ;; - esac -} - -append_todo_help () { - gettext " -Commands: -p, pick = use commit -r, reword = use commit, but edit the commit message -e, edit = use commit, but stop for amending -s, squash = use commit, but meld into previous commit -f, fixup = like \"squash\", but discard this commit's log message -x, exec = run command (the rest of the line) using shell -d, drop = remove commit -l, label