@ai-ecoverse/wasm-git 2.55.0-3 → 2.55.0-4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/libexec/git-core/git-difftool--helper +125 -0
- package/libexec/git-core/git-filter-branch +665 -0
- package/libexec/git-core/git-merge-octopus +112 -0
- package/libexec/git-core/git-merge-one-file +167 -0
- package/libexec/git-core/git-merge-resolve +64 -0
- package/libexec/git-core/git-mergetool +579 -0
- package/libexec/git-core/git-mergetool--lib +549 -0
- package/libexec/git-core/git-quiltimport +155 -0
- package/libexec/git-core/git-request-pull +178 -0
- package/libexec/git-core/git-sh-i18n +79 -0
- package/libexec/git-core/git-sh-setup +357 -0
- package/libexec/git-core/git-submodule +671 -0
- package/libexec/git-core/git-web--browse +196 -0
- package/package.json +1 -1
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
#!/bin/sh
|
|
2
|
+
# Copyright 2005, Ryan Anderson <ryan@michonline.com>
|
|
3
|
+
#
|
|
4
|
+
# This file is licensed under the GPL v2, or a later version
|
|
5
|
+
# at the discretion of Linus Torvalds.
|
|
6
|
+
|
|
7
|
+
SUBDIRECTORY_OK='Yes'
|
|
8
|
+
OPTIONS_KEEPDASHDASH=
|
|
9
|
+
OPTIONS_STUCKLONG=
|
|
10
|
+
OPTIONS_SPEC='git request-pull [options] start url [end]
|
|
11
|
+
--
|
|
12
|
+
p show patch text as well
|
|
13
|
+
'
|
|
14
|
+
|
|
15
|
+
. git-sh-setup
|
|
16
|
+
|
|
17
|
+
GIT_PAGER=
|
|
18
|
+
export GIT_PAGER
|
|
19
|
+
|
|
20
|
+
patch=
|
|
21
|
+
while case "$#" in 0) break ;; esac
|
|
22
|
+
do
|
|
23
|
+
case "$1" in
|
|
24
|
+
-p)
|
|
25
|
+
patch=-p ;;
|
|
26
|
+
--)
|
|
27
|
+
shift; break ;;
|
|
28
|
+
-*)
|
|
29
|
+
usage ;;
|
|
30
|
+
*)
|
|
31
|
+
break ;;
|
|
32
|
+
esac
|
|
33
|
+
shift
|
|
34
|
+
done
|
|
35
|
+
|
|
36
|
+
base=$1 url=$2 status=0
|
|
37
|
+
|
|
38
|
+
test -n "$base" && test -n "$url" || usage
|
|
39
|
+
|
|
40
|
+
baserev=$(git rev-parse --verify --quiet "$base"^0)
|
|
41
|
+
if test -z "$baserev"
|
|
42
|
+
then
|
|
43
|
+
die "fatal: Not a valid revision: $base"
|
|
44
|
+
fi
|
|
45
|
+
|
|
46
|
+
#
|
|
47
|
+
# $3 must be a symbolic ref, a unique ref, or
|
|
48
|
+
# a SHA object expression. It can also be of
|
|
49
|
+
# the format 'local-name:remote-name'.
|
|
50
|
+
#
|
|
51
|
+
local=${3%:*}
|
|
52
|
+
local=${local:-HEAD}
|
|
53
|
+
remote=${3#*:}
|
|
54
|
+
pretty_remote=${remote#refs/}
|
|
55
|
+
pretty_remote=${pretty_remote#heads/}
|
|
56
|
+
head=$(git symbolic-ref -q "$local")
|
|
57
|
+
head=${head:-$(git show-ref --heads --tags "$local" | cut -d' ' -f2)}
|
|
58
|
+
head=${head:-$(git rev-parse --quiet --verify "$local")}
|
|
59
|
+
|
|
60
|
+
# None of the above? Bad.
|
|
61
|
+
test -z "$head" && die "fatal: Not a valid revision: $local"
|
|
62
|
+
|
|
63
|
+
# This also verifies that the resulting head is unique:
|
|
64
|
+
# "git show-ref" could have shown multiple matching refs..
|
|
65
|
+
headrev=$(git rev-parse --verify --quiet "$head"^0)
|
|
66
|
+
test -z "$headrev" && die "fatal: Ambiguous revision: $local"
|
|
67
|
+
|
|
68
|
+
local_sha1=$(git rev-parse --verify --quiet "$head")
|
|
69
|
+
|
|
70
|
+
# Was it a branch with a description?
|
|
71
|
+
branch_name=${head#refs/heads/}
|
|
72
|
+
if test "z$branch_name" = "z$headref" ||
|
|
73
|
+
! git config "branch.$branch_name.description" >/dev/null
|
|
74
|
+
then
|
|
75
|
+
branch_name=
|
|
76
|
+
fi
|
|
77
|
+
|
|
78
|
+
merge_base=$(git merge-base $baserev $headrev) ||
|
|
79
|
+
die "fatal: No commits in common between $base and $head"
|
|
80
|
+
|
|
81
|
+
find_matching_ref () {
|
|
82
|
+
while read sha1 ref
|
|
83
|
+
do
|
|
84
|
+
case "$ref" in
|
|
85
|
+
*"^"?*)
|
|
86
|
+
ref="${ref%"^"*}"
|
|
87
|
+
deref=true
|
|
88
|
+
;;
|
|
89
|
+
*)
|
|
90
|
+
deref=
|
|
91
|
+
;;
|
|
92
|
+
esac
|
|
93
|
+
|
|
94
|
+
if test "$sha1" = "${remote:-HEAD}"
|
|
95
|
+
then
|
|
96
|
+
echo "$sha1 $sha1"
|
|
97
|
+
break
|
|
98
|
+
fi
|
|
99
|
+
|
|
100
|
+
case "$ref" in
|
|
101
|
+
"${remote:-HEAD}"|*"/${remote:-HEAD}")
|
|
102
|
+
if test -z "$deref"
|
|
103
|
+
then
|
|
104
|
+
# Remember the matching unpeeled object on the
|
|
105
|
+
# remote side.
|
|
106
|
+
remote_sha1="$sha1"
|
|
107
|
+
fi
|
|
108
|
+
|
|
109
|
+
if test "$sha1" = "$headrev"
|
|
110
|
+
then
|
|
111
|
+
echo "${remote_sha1:-$headrev} $ref"
|
|
112
|
+
break
|
|
113
|
+
fi
|
|
114
|
+
;;
|
|
115
|
+
esac
|
|
116
|
+
done
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
# Find a ref with the same name as $remote that exists at the remote
|
|
120
|
+
# and points to the same commit as the local object.
|
|
121
|
+
set fnord $(git ls-remote "$url" | find_matching_ref)
|
|
122
|
+
remote_sha1=$2
|
|
123
|
+
ref=$3
|
|
124
|
+
|
|
125
|
+
if test -z "$ref"
|
|
126
|
+
then
|
|
127
|
+
echo "warn: No match for commit $headrev found at $url" >&2
|
|
128
|
+
echo "warn: Are you sure you pushed '${remote:-HEAD}' there?" >&2
|
|
129
|
+
status=1
|
|
130
|
+
elif test "$local_sha1" != "$remote_sha1"
|
|
131
|
+
then
|
|
132
|
+
echo "warn: $head found at $url but points to a different object" >&2
|
|
133
|
+
echo "warn: Are you sure you pushed '${remote:-HEAD}' there?" >&2
|
|
134
|
+
status=1
|
|
135
|
+
fi
|
|
136
|
+
|
|
137
|
+
# Special case: turn "for_linus" to "tags/for_linus" when it is correct
|
|
138
|
+
if test "$ref" = "refs/tags/$pretty_remote"
|
|
139
|
+
then
|
|
140
|
+
pretty_remote=tags/$pretty_remote
|
|
141
|
+
fi
|
|
142
|
+
|
|
143
|
+
url=$(git ls-remote --get-url "$url")
|
|
144
|
+
|
|
145
|
+
git show -s --format='The following changes since commit %H:
|
|
146
|
+
|
|
147
|
+
%s (%ci)
|
|
148
|
+
|
|
149
|
+
are available in the Git repository at:
|
|
150
|
+
' $merge_base &&
|
|
151
|
+
echo " $url $pretty_remote" &&
|
|
152
|
+
git show -s --format='
|
|
153
|
+
for you to fetch changes up to %H:
|
|
154
|
+
|
|
155
|
+
%s (%ci)
|
|
156
|
+
|
|
157
|
+
----------------------------------------------------------------' $headrev &&
|
|
158
|
+
|
|
159
|
+
if test $(git cat-file -t "$head") = tag
|
|
160
|
+
then
|
|
161
|
+
git cat-file tag "$head" |
|
|
162
|
+
sed -n -e '1,/^$/d' -e '/^-----BEGIN \(PGP\|SSH\|SIGNED\) /q' -e p
|
|
163
|
+
echo
|
|
164
|
+
echo "----------------------------------------------------------------"
|
|
165
|
+
fi &&
|
|
166
|
+
|
|
167
|
+
if test -n "$branch_name"
|
|
168
|
+
then
|
|
169
|
+
echo "(from the branch description for $branch_name local branch)"
|
|
170
|
+
echo
|
|
171
|
+
git config "branch.$branch_name.description"
|
|
172
|
+
echo "----------------------------------------------------------------"
|
|
173
|
+
fi &&
|
|
174
|
+
|
|
175
|
+
git shortlog ^$baserev $headrev &&
|
|
176
|
+
git diff -M --stat --summary $patch $merge_base..$headrev || status=1
|
|
177
|
+
|
|
178
|
+
exit $status
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
# This shell library is Git's interface to gettext.sh. See po/README
|
|
2
|
+
# for usage instructions.
|
|
3
|
+
#
|
|
4
|
+
# Copyright (c) 2010 Ævar Arnfjörð Bjarmason
|
|
5
|
+
#
|
|
6
|
+
|
|
7
|
+
# Export the TEXTDOMAIN* data that we need for Git
|
|
8
|
+
TEXTDOMAIN=git
|
|
9
|
+
export TEXTDOMAIN
|
|
10
|
+
if test -z "$GIT_TEXTDOMAINDIR"
|
|
11
|
+
then
|
|
12
|
+
TEXTDOMAINDIR="//share/locale"
|
|
13
|
+
else
|
|
14
|
+
TEXTDOMAINDIR="$GIT_TEXTDOMAINDIR"
|
|
15
|
+
fi
|
|
16
|
+
export TEXTDOMAINDIR
|
|
17
|
+
|
|
18
|
+
# First decide what scheme to use...
|
|
19
|
+
GIT_INTERNAL_GETTEXT_SH_SCHEME=fallthrough
|
|
20
|
+
if test -n "fallthrough"
|
|
21
|
+
then
|
|
22
|
+
GIT_INTERNAL_GETTEXT_SH_SCHEME="fallthrough"
|
|
23
|
+
elif test -n "$GIT_INTERNAL_GETTEXT_TEST_FALLBACKS"
|
|
24
|
+
then
|
|
25
|
+
: no probing necessary
|
|
26
|
+
elif type gettext.sh >/dev/null 2>&1
|
|
27
|
+
then
|
|
28
|
+
# GNU libintl's gettext.sh
|
|
29
|
+
GIT_INTERNAL_GETTEXT_SH_SCHEME=gnu
|
|
30
|
+
elif test "$(gettext -h 2>&1)" = "-h"
|
|
31
|
+
then
|
|
32
|
+
# gettext binary exists but no gettext.sh. likely to be a gettext
|
|
33
|
+
# binary on a Solaris or something that is not GNU libintl and
|
|
34
|
+
# lack eval_gettext.
|
|
35
|
+
GIT_INTERNAL_GETTEXT_SH_SCHEME=gettext_without_eval_gettext
|
|
36
|
+
fi
|
|
37
|
+
export GIT_INTERNAL_GETTEXT_SH_SCHEME
|
|
38
|
+
|
|
39
|
+
# ... and then follow that decision.
|
|
40
|
+
case "$GIT_INTERNAL_GETTEXT_SH_SCHEME" in
|
|
41
|
+
gnu)
|
|
42
|
+
# Use libintl's gettext.sh, or fall back to English if we can't.
|
|
43
|
+
. gettext.sh
|
|
44
|
+
;;
|
|
45
|
+
gettext_without_eval_gettext)
|
|
46
|
+
# Solaris has a gettext(1) but no eval_gettext(1)
|
|
47
|
+
eval_gettext () {
|
|
48
|
+
gettext "$1" | (
|
|
49
|
+
export PATH $(git sh-i18n--envsubst --variables "$1");
|
|
50
|
+
git sh-i18n--envsubst "$1"
|
|
51
|
+
)
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
;;
|
|
55
|
+
*)
|
|
56
|
+
gettext () {
|
|
57
|
+
printf "%s" "$1"
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
eval_gettext () {
|
|
61
|
+
printf "%s" "$1" | (
|
|
62
|
+
export PATH $(git sh-i18n--envsubst --variables "$1");
|
|
63
|
+
git sh-i18n--envsubst "$1"
|
|
64
|
+
)
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
;;
|
|
68
|
+
esac
|
|
69
|
+
|
|
70
|
+
# Git-specific wrapper functions
|
|
71
|
+
gettextln () {
|
|
72
|
+
gettext "$1"
|
|
73
|
+
echo
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
eval_gettextln () {
|
|
77
|
+
eval_gettext "$1"
|
|
78
|
+
echo
|
|
79
|
+
}
|
|
@@ -0,0 +1,357 @@
|
|
|
1
|
+
# This shell scriplet is meant to be included by other shell scripts
|
|
2
|
+
# to set up some variables pointing at the normal git directories and
|
|
3
|
+
# a few helper shell functions.
|
|
4
|
+
|
|
5
|
+
# Having this variable in your environment would break scripts because
|
|
6
|
+
# you would cause "cd" to be taken to unexpected places. If you
|
|
7
|
+
# like CDPATH, define it for your interactive shell sessions without
|
|
8
|
+
# exporting it.
|
|
9
|
+
# But we protect ourselves from such a user mistake nevertheless.
|
|
10
|
+
unset CDPATH
|
|
11
|
+
|
|
12
|
+
# Similarly for IFS, but some shells (e.g. FreeBSD 7.2) are buggy and
|
|
13
|
+
# do not equate an unset IFS with IFS with the default, so here is
|
|
14
|
+
# an explicit SP HT LF.
|
|
15
|
+
IFS='
|
|
16
|
+
'
|
|
17
|
+
|
|
18
|
+
git_broken_path_fix () {
|
|
19
|
+
case ":$PATH:" in
|
|
20
|
+
*:$1:*) : ok ;;
|
|
21
|
+
*)
|
|
22
|
+
PATH=$(
|
|
23
|
+
SANE_TOOL_PATH="$1"
|
|
24
|
+
IFS=: path= sep=
|
|
25
|
+
set x $PATH
|
|
26
|
+
shift
|
|
27
|
+
for elem
|
|
28
|
+
do
|
|
29
|
+
case "$SANE_TOOL_PATH:$elem" in
|
|
30
|
+
(?*:/bin | ?*:/usr/bin)
|
|
31
|
+
path="$path$sep$SANE_TOOL_PATH"
|
|
32
|
+
sep=:
|
|
33
|
+
SANE_TOOL_PATH=
|
|
34
|
+
esac
|
|
35
|
+
path="$path$sep$elem"
|
|
36
|
+
sep=:
|
|
37
|
+
done
|
|
38
|
+
echo "$path"
|
|
39
|
+
)
|
|
40
|
+
;;
|
|
41
|
+
esac
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
# Source git-sh-i18n for gettext support.
|
|
46
|
+
. "$(git --exec-path)/git-sh-i18n"
|
|
47
|
+
|
|
48
|
+
die () {
|
|
49
|
+
die_with_status 1 "$@"
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
die_with_status () {
|
|
53
|
+
status=$1
|
|
54
|
+
shift
|
|
55
|
+
printf >&2 '%s\n' "$*"
|
|
56
|
+
exit "$status"
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
if test -n "$OPTIONS_SPEC"; then
|
|
60
|
+
usage() {
|
|
61
|
+
"$0" -h
|
|
62
|
+
exit 1
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
parseopt_extra=
|
|
66
|
+
[ -n "$OPTIONS_KEEPDASHDASH" ] &&
|
|
67
|
+
parseopt_extra="--keep-dashdash"
|
|
68
|
+
[ -n "$OPTIONS_STUCKLONG" ] &&
|
|
69
|
+
parseopt_extra="$parseopt_extra --stuck-long"
|
|
70
|
+
|
|
71
|
+
eval "$(
|
|
72
|
+
echo "$OPTIONS_SPEC" |
|
|
73
|
+
git rev-parse --parseopt $parseopt_extra -- "$@" ||
|
|
74
|
+
echo exit $?
|
|
75
|
+
)"
|
|
76
|
+
else
|
|
77
|
+
dashless=$(basename -- "$0" | sed -e 's/-/ /')
|
|
78
|
+
usage() {
|
|
79
|
+
die "$(eval_gettext "usage: \$dashless \$USAGE")"
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
if [ -z "$LONG_USAGE" ]
|
|
83
|
+
then
|
|
84
|
+
LONG_USAGE="$(eval_gettext "usage: \$dashless \$USAGE")"
|
|
85
|
+
else
|
|
86
|
+
LONG_USAGE="$(eval_gettext "usage: \$dashless \$USAGE
|
|
87
|
+
|
|
88
|
+
$LONG_USAGE")"
|
|
89
|
+
fi
|
|
90
|
+
|
|
91
|
+
case "$1" in
|
|
92
|
+
-h)
|
|
93
|
+
echo "$LONG_USAGE"
|
|
94
|
+
exit
|
|
95
|
+
esac
|
|
96
|
+
fi
|
|
97
|
+
|
|
98
|
+
# Set the name of the end-user facing command in the reflog when the
|
|
99
|
+
# script may update refs. When GIT_REFLOG_ACTION is already set, this
|
|
100
|
+
# will not overwrite it, so that a scripted Porcelain (e.g. "git
|
|
101
|
+
# rebase") can set it to its own name (e.g. "rebase") and then call
|
|
102
|
+
# another scripted Porcelain (e.g. "git am") and a call to this
|
|
103
|
+
# function in the latter will keep the name of the end-user facing
|
|
104
|
+
# program (e.g. "rebase") in GIT_REFLOG_ACTION, ensuring whatever it
|
|
105
|
+
# does will be record as actions done as part of the end-user facing
|
|
106
|
+
# operation (e.g. "rebase").
|
|
107
|
+
#
|
|
108
|
+
# NOTE NOTE NOTE: consequently, after assigning a specific message to
|
|
109
|
+
# GIT_REFLOG_ACTION when calling a "git" command to record a custom
|
|
110
|
+
# reflog message, do not leave that custom value in GIT_REFLOG_ACTION,
|
|
111
|
+
# after you are done. Other callers of "git" commands that rely on
|
|
112
|
+
# writing the default "program name" in reflog expect the variable to
|
|
113
|
+
# contain the value set by this function.
|
|
114
|
+
#
|
|
115
|
+
# To use a custom reflog message, do either one of these three:
|
|
116
|
+
#
|
|
117
|
+
# (a) use a single-shot export form:
|
|
118
|
+
# GIT_REFLOG_ACTION="$GIT_REFLOG_ACTION: preparing frotz" \
|
|
119
|
+
# git command-that-updates-a-ref
|
|
120
|
+
#
|
|
121
|
+
# (b) save the original away and restore:
|
|
122
|
+
# SAVED_ACTION=$GIT_REFLOG_ACTION
|
|
123
|
+
# GIT_REFLOG_ACTION="$GIT_REFLOG_ACTION: preparing frotz"
|
|
124
|
+
# git command-that-updates-a-ref
|
|
125
|
+
# GIT_REFLOG_ACITON=$SAVED_ACTION
|
|
126
|
+
#
|
|
127
|
+
# (c) assign the variable in a subshell:
|
|
128
|
+
# (
|
|
129
|
+
# GIT_REFLOG_ACTION="$GIT_REFLOG_ACTION: preparing frotz"
|
|
130
|
+
# git command-that-updates-a-ref
|
|
131
|
+
# )
|
|
132
|
+
set_reflog_action() {
|
|
133
|
+
if [ -z "${GIT_REFLOG_ACTION:+set}" ]
|
|
134
|
+
then
|
|
135
|
+
GIT_REFLOG_ACTION="$*"
|
|
136
|
+
export GIT_REFLOG_ACTION
|
|
137
|
+
fi
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
git_editor() {
|
|
141
|
+
if test -z "${GIT_EDITOR:+set}"
|
|
142
|
+
then
|
|
143
|
+
GIT_EDITOR="$(git var GIT_EDITOR)" || return $?
|
|
144
|
+
fi
|
|
145
|
+
|
|
146
|
+
eval "$GIT_EDITOR" '"$@"'
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
git_pager() {
|
|
150
|
+
if test -t 1
|
|
151
|
+
then
|
|
152
|
+
GIT_PAGER=$(git var GIT_PAGER)
|
|
153
|
+
else
|
|
154
|
+
GIT_PAGER=cat
|
|
155
|
+
fi
|
|
156
|
+
for vardef in LESS=FRX LV=-c
|
|
157
|
+
do
|
|
158
|
+
var=${vardef%%=*}
|
|
159
|
+
eval ": \"\${$vardef}\" && export $var"
|
|
160
|
+
done
|
|
161
|
+
|
|
162
|
+
eval "$GIT_PAGER" '"$@"'
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
is_bare_repository () {
|
|
166
|
+
git rev-parse --is-bare-repository
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
cd_to_toplevel () {
|
|
170
|
+
cdup=$(git rev-parse --show-toplevel) &&
|
|
171
|
+
cd "$cdup" || {
|
|
172
|
+
gettextln "Cannot chdir to \$cdup, the toplevel of the working tree" >&2
|
|
173
|
+
exit 1
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
require_work_tree_exists () {
|
|
178
|
+
if test "z$(git rev-parse --is-bare-repository)" != zfalse
|
|
179
|
+
then
|
|
180
|
+
program_name=$0
|
|
181
|
+
die "$(eval_gettext "fatal: \$program_name cannot be used without a working tree.")"
|
|
182
|
+
fi
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
require_work_tree () {
|
|
186
|
+
test "$(git rev-parse --is-inside-work-tree 2>/dev/null)" = true || {
|
|
187
|
+
program_name=$0
|
|
188
|
+
die "$(eval_gettext "fatal: \$program_name cannot be used without a working tree.")"
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
require_clean_work_tree () {
|
|
193
|
+
git rev-parse --verify HEAD >/dev/null || exit 1
|
|
194
|
+
git update-index -q --ignore-submodules --refresh
|
|
195
|
+
err=0
|
|
196
|
+
|
|
197
|
+
if ! git diff-files --quiet --ignore-submodules
|
|
198
|
+
then
|
|
199
|
+
action=$1
|
|
200
|
+
case "$action" in
|
|
201
|
+
"rewrite branches")
|
|
202
|
+
gettextln "Cannot rewrite branches: You have unstaged changes." >&2
|
|
203
|
+
;;
|
|
204
|
+
*)
|
|
205
|
+
eval_gettextln "Cannot \$action: You have unstaged changes." >&2
|
|
206
|
+
;;
|
|
207
|
+
esac
|
|
208
|
+
err=1
|
|
209
|
+
fi
|
|
210
|
+
|
|
211
|
+
if ! git diff-index --cached --quiet --ignore-submodules HEAD --
|
|
212
|
+
then
|
|
213
|
+
if test $err = 0
|
|
214
|
+
then
|
|
215
|
+
action=$1
|
|
216
|
+
eval_gettextln "Cannot \$action: Your index contains uncommitted changes." >&2
|
|
217
|
+
else
|
|
218
|
+
gettextln "Additionally, your index contains uncommitted changes." >&2
|
|
219
|
+
fi
|
|
220
|
+
err=1
|
|
221
|
+
fi
|
|
222
|
+
|
|
223
|
+
if test $err = 1
|
|
224
|
+
then
|
|
225
|
+
test -n "$2" && echo "$2" >&2
|
|
226
|
+
exit 1
|
|
227
|
+
fi
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
# Generate a sed script to parse identities from a commit.
|
|
231
|
+
#
|
|
232
|
+
# Reads the commit from stdin, which should be in raw format (e.g., from
|
|
233
|
+
# cat-file or "--pretty=raw").
|
|
234
|
+
#
|
|
235
|
+
# The first argument specifies the ident line to parse (e.g., "author"), and
|
|
236
|
+
# the second specifies the environment variable to put it in (e.g., "AUTHOR"
|
|
237
|
+
# for "GIT_AUTHOR_*"). Multiple pairs can be given to parse author and
|
|
238
|
+
# committer.
|
|
239
|
+
pick_ident_script () {
|
|
240
|
+
while test $# -gt 0
|
|
241
|
+
do
|
|
242
|
+
lid=$1; shift
|
|
243
|
+
uid=$1; shift
|
|
244
|
+
printf '%s' "
|
|
245
|
+
/^$lid /{
|
|
246
|
+
s/'/'\\\\''/g
|
|
247
|
+
h
|
|
248
|
+
s/^$lid "'\([^<]*\) <[^>]*> .*$/\1/'"
|
|
249
|
+
s/.*/GIT_${uid}_NAME='&'/p
|
|
250
|
+
|
|
251
|
+
g
|
|
252
|
+
s/^$lid "'[^<]* <\([^>]*\)> .*$/\1/'"
|
|
253
|
+
s/.*/GIT_${uid}_EMAIL='&'/p
|
|
254
|
+
|
|
255
|
+
g
|
|
256
|
+
s/^$lid "'[^<]* <[^>]*> \(.*\)$/@\1/'"
|
|
257
|
+
s/.*/GIT_${uid}_DATE='&'/p
|
|
258
|
+
}
|
|
259
|
+
"
|
|
260
|
+
done
|
|
261
|
+
echo '/^$/q'
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
# Create a pick-script as above and feed it to sed. Stdout is suitable for
|
|
265
|
+
# feeding to eval.
|
|
266
|
+
parse_ident_from_commit () {
|
|
267
|
+
LANG=C LC_ALL=C sed -ne "$(pick_ident_script "$@")"
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
# Parse the author from a commit given as an argument. Stdout is suitable for
|
|
271
|
+
# feeding to eval to set the usual GIT_* ident variables.
|
|
272
|
+
get_author_ident_from_commit () {
|
|
273
|
+
encoding=$(git config i18n.commitencoding || echo UTF-8)
|
|
274
|
+
git show -s --pretty=raw --encoding="$encoding" "$1" -- |
|
|
275
|
+
parse_ident_from_commit author AUTHOR
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
# Generate a virtual base file for a two-file merge. Uses git apply to
|
|
279
|
+
# remove lines from $1 that are not in $2, leaving only common lines.
|
|
280
|
+
create_virtual_base() {
|
|
281
|
+
sz0=$(wc -c <"$1")
|
|
282
|
+
diff -u -La/"$1" -Lb/"$1" "$1" "$2" | git apply --no-add
|
|
283
|
+
sz1=$(wc -c <"$1")
|
|
284
|
+
|
|
285
|
+
# If we do not have enough common material, it is not
|
|
286
|
+
# worth trying two-file merge using common subsections.
|
|
287
|
+
expr $sz0 \< $sz1 \* 2 >/dev/null || : >"$1"
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
|
|
291
|
+
# Platform specific tweaks to work around some commands
|
|
292
|
+
case $(uname -s) in
|
|
293
|
+
*MINGW*)
|
|
294
|
+
# Windows has its own (incompatible) sort and find
|
|
295
|
+
sort () {
|
|
296
|
+
/usr/bin/sort "$@"
|
|
297
|
+
}
|
|
298
|
+
find () {
|
|
299
|
+
/usr/bin/find "$@"
|
|
300
|
+
}
|
|
301
|
+
# git sees Windows-style pwd
|
|
302
|
+
pwd () {
|
|
303
|
+
builtin pwd -W
|
|
304
|
+
}
|
|
305
|
+
is_absolute_path () {
|
|
306
|
+
case "$1" in
|
|
307
|
+
[/\\]* | [A-Za-z]:*)
|
|
308
|
+
return 0 ;;
|
|
309
|
+
esac
|
|
310
|
+
return 1
|
|
311
|
+
}
|
|
312
|
+
;;
|
|
313
|
+
*)
|
|
314
|
+
is_absolute_path () {
|
|
315
|
+
case "$1" in
|
|
316
|
+
/*)
|
|
317
|
+
return 0 ;;
|
|
318
|
+
esac
|
|
319
|
+
return 1
|
|
320
|
+
}
|
|
321
|
+
esac
|
|
322
|
+
|
|
323
|
+
# Make sure we are in a valid repository of a vintage we understand,
|
|
324
|
+
# if we require to be in a git repository.
|
|
325
|
+
git_dir_init () {
|
|
326
|
+
GIT_DIR=$(git rev-parse --git-dir) || exit
|
|
327
|
+
if [ -z "$SUBDIRECTORY_OK" ]
|
|
328
|
+
then
|
|
329
|
+
test -z "$(git rev-parse --show-cdup)" || {
|
|
330
|
+
exit=$?
|
|
331
|
+
gettextln "You need to run this command from the toplevel of the working tree." >&2
|
|
332
|
+
exit $exit
|
|
333
|
+
}
|
|
334
|
+
fi
|
|
335
|
+
test -n "$GIT_DIR" && GIT_DIR=$(cd "$GIT_DIR" && pwd) || {
|
|
336
|
+
gettextln "Unable to determine absolute path of git directory" >&2
|
|
337
|
+
exit 1
|
|
338
|
+
}
|
|
339
|
+
: "${GIT_OBJECT_DIRECTORY="$(git rev-parse --git-path objects)"}"
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
if test -z "$NONGIT_OK"
|
|
343
|
+
then
|
|
344
|
+
git_dir_init
|
|
345
|
+
fi
|
|
346
|
+
|
|
347
|
+
peel_committish () {
|
|
348
|
+
case "$1" in
|
|
349
|
+
:/*)
|
|
350
|
+
peeltmp=$(git rev-parse --verify "$1") &&
|
|
351
|
+
git rev-parse --verify "${peeltmp}^0"
|
|
352
|
+
;;
|
|
353
|
+
*)
|
|
354
|
+
git rev-parse --verify "${1}^0"
|
|
355
|
+
;;
|
|
356
|
+
esac
|
|
357
|
+
}
|