made the pack completely portable and wrote relevent bat files to go with it

This commit is contained in:
Draqoken
2025-04-09 17:04:56 +03:00
parent 5e77d7e9cf
commit 5e4144c3c0
7417 changed files with 2181044 additions and 19 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -0,0 +1,25 @@
#!/bin/sh
# Tcl ignores the next line -*- tcl -*- \
exec wish "$0" -- "$@"
if { $argc >=2 && [lindex $argv 0] == "--working-dir" } {
set workdir [lindex $argv 1]
cd $workdir
if {[lindex [file split $workdir] end] eq {.git}} {
# Workaround for Explorer right click "Git GUI Here" on .git/
cd ..
}
set argv [lrange $argv 2 end]
incr argc -2
}
set basedir [file dirname \
[file dirname \
[file dirname [info script]]]]
set bindir [file join $basedir bin]
set bindir "$bindir;[file join $basedir mingw bin]"
regsub -all ";" $bindir "\\;" bindir
set env(PATH) "$bindir;$env(PATH)"
unset bindir
source [file join [file dirname [info script]] git-gui.tcl]

Binary file not shown.

View File

@@ -0,0 +1,125 @@
#!/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
initialize_merge_tool "$merge_tool" || exit 1
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)"
subshell_exit_status=$?
if test $subshell_exit_status -gt 1
then
exit $subshell_exit_status
fi
fi
fi
if test -n "$GIT_DIFFTOOL_DIRDIFF"
then
LOCAL="$1"
REMOTE="$2"
initialize_merge_tool "$merge_tool" || exit 1
run_merge_tool "$merge_tool" false
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 "$GIT_DIFFTOOL_TRUST_EXIT_CODE" = true
then
exit $status
fi
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

View File

@@ -0,0 +1,664 @@
#!/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
}
if test -z "$FILTER_BRANCH_SQUELCH_WARNING$GIT_TEST_DISALLOW_ABBREVIATED_OPTIONS"
then
cat <<EOF
WARNING: git-filter-branch has a glut of gotchas generating mangled history
rewrites. Hit Ctrl-C before proceeding to abort, then use an
alternative filtering tool such as 'git filter-repo'
(https://github.com/newren/git-filter-repo/) instead. See the
filter-branch manual page for more details; to squelch this warning,
set FILTER_BRANCH_SQUELCH_WARNING=1.
EOF
sleep 10
printf "Proceeding with filter-branch...\n\n"
fi
USAGE="[--setup <command>] [--subdirectory-filter <directory>] [--env-filter <command>]
[--tree-filter <command>] [--index-filter <command>]
[--parent-filter <command>] [--msg-filter <command>]
[--commit-filter <command>] [--tag-name-filter <command>]
[--original <namespace>]
[-d <directory>] [-f | --force] [--state-branch <branch>]
[--] [<rev-list options>...]"
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 (<MAP>) {
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
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"
;;
*)
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
;;
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" | \
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 = <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

View File

@@ -0,0 +1,25 @@
#!/bin/sh
# Tcl ignores the next line -*- tcl -*- \
exec wish "$0" -- "$@"
if { $argc >=2 && [lindex $argv 0] == "--working-dir" } {
set workdir [lindex $argv 1]
cd $workdir
if {[lindex [file split $workdir] end] eq {.git}} {
# Workaround for Explorer right click "Git GUI Here" on .git/
cd ..
}
set argv [lrange $argv 2 end]
incr argc -2
}
set basedir [file dirname \
[file dirname \
[file dirname [info script]]]]
set bindir [file join $basedir bin]
set bindir "$bindir;[file join $basedir mingw bin]"
regsub -all ";" $bindir "\\;" bindir
set env(PATH) "$bindir;$env(PATH)"
unset bindir
source [file join [file dirname [info script]] git-gui.tcl]

View File

@@ -0,0 +1,84 @@
#!/bin/sh
# Tcl ignores the next line -*- tcl -*- \
exec wish "$0" -- "$@"
# This is a trivial implementation of an SSH_ASKPASS handler.
# Git-gui uses this script if none are already configured.
package require Tk
set answer {}
set yesno 0
set rc 255
if {$argc < 1} {
set prompt "Enter your OpenSSH passphrase:"
} else {
set prompt [join $argv " "]
if {[regexp -nocase {\(yes\/no\)\?\s*$} $prompt]} {
set yesno 1
}
}
message .m -text $prompt -justify center -aspect 4000
pack .m -side top -fill x -padx 20 -pady 20 -expand 1
entry .e -textvariable answer -width 50
pack .e -side top -fill x -padx 10 -pady 10
proc on_show_input_changed {args} {
global show_input
if {$show_input} {
.e configure -show ""
} else {
.e configure -show "*"
}
}
trace add variable show_input write "on_show_input_changed"
set show_input 0
if {!$yesno} {
checkbutton .cb_show -text "Show input" -variable show_input
pack .cb_show -side top -anchor nw
}
frame .b
button .b.ok -text OK -command finish
button .b.cancel -text Cancel -command cancel
pack .b.ok -side left -expand 1
pack .b.cancel -side right -expand 1
pack .b -side bottom -fill x -padx 10 -pady 10
bind . <Visibility> {focus -force .e}
bind . <Key-Return> [list .b.ok invoke]
bind . <Key-Escape> [list .b.cancel invoke]
bind . <Destroy> {set rc $rc}
proc cancel {} {
set ::rc 255
}
proc finish {} {
if {$::yesno} {
if {$::answer ne "yes" && $::answer ne "no"} {
tk_messageBox -icon error -title "Error" -type ok \
-message "Only 'yes' or 'no' input allowed."
return
}
}
# On Windows, force the encoding to UTF-8: it is what `git.exe` expects
if {$::tcl_platform(platform) eq {windows}} {
set ::answer [encoding convertto utf-8 $::answer]
}
puts $::answer
set ::rc 0
}
wm title . "OpenSSH"
tk::PlaceWindow .
vwait rc
exit $rc

View File

@@ -0,0 +1,68 @@
#!/bin/sh
# Tcl ignores the next line -*- tcl -*- \
exec wish "$0" -- "$@"
# This is an implementation of a simple yes no dialog
# which is injected into the git commandline by git gui
# in case a yesno question needs to be answered.
set NS {}
set use_ttk [package vsatisfies [package provide Tk] 8.5]
if {$use_ttk} {
set NS ttk
}
set title "Question?"
if {$argc < 1} {
puts stderr "Usage: $argv0 <question>"
exit 1
} else {
if {$argc > 2 && [lindex $argv 0] == "--title"} {
set title [lindex $argv 1]
set argv [lreplace $argv 0 1]
}
set prompt [join $argv " "]
}
${NS}::frame .t
${NS}::label .t.m -text $prompt -justify center -width 400px
.t.m configure -wraplength 400px
pack .t.m -side top -fill x -padx 20 -pady 20 -expand 1
pack .t -side top -fill x -ipadx 20 -ipady 20 -expand 1
${NS}::frame .b
${NS}::frame .b.left -width 200
${NS}::button .b.yes -text Yes -command yes
${NS}::button .b.no -text No -command no
pack .b.left -side left -expand 1 -fill x
pack .b.yes -side left -expand 1
pack .b.no -side right -expand 1 -ipadx 5
pack .b -side bottom -fill x -ipadx 20 -ipady 15
bind . <Key-Return> {exit 0}
bind . <Key-Escape> {exit 1}
proc no {} {
exit 1
}
proc yes {} {
exit 0
}
if {$::tcl_platform(platform) eq {windows}} {
set icopath [file dirname [file normalize $argv0]]
if {[file tail $icopath] eq {git-core}} {
set icopath [file dirname $icopath]
}
set icopath [file dirname $icopath]
set icopath [file join $icopath share git git-for-windows.ico]
if {[file exists $icopath]} {
wm iconbitmap . -default $icopath
}
}
wm title . $title
tk::PlaceWindow .

File diff suppressed because it is too large Load Diff

Binary file not shown.

Binary file not shown.

View File

@@ -0,0 +1,786 @@
#!/bin/sh
#
# Copyright (c) 2006 Eric Wong
#
PERL='/usr/bin/perl'
OPTIONS_KEEPDASHDASH=
OPTIONS_STUCKLONG=
OPTIONS_SPEC="\
git instaweb [options] (--start | --stop | --restart)
--
l,local only bind on 127.0.0.1
p,port= the port to bind to
d,httpd= the command to launch
b,browser= the browser to launch
m,module-path= the module path (only needed for apache2)
Action
stop stop the web server
start start the web server
restart restart the web server
"
SUBDIRECTORY_OK=Yes
. git-sh-setup
fqgitdir="$GIT_DIR"
local="$(git config --bool --get instaweb.local)"
httpd="$(git config --get instaweb.httpd)"
root="$(git config --get instaweb.gitwebdir)"
port=$(git config --get instaweb.port)
module_path="$(git config --get instaweb.modulepath)"
action="browse"
conf="$GIT_DIR/gitweb/httpd.conf"
# Defaults:
# if installed, it doesn't need further configuration (module_path)
test -z "$httpd" && httpd='lighttpd -f'
# Default is /mingw64/share/gitweb
test -z "$root" && root='/mingw64/share/gitweb'
# any untaken local port will do...
test -z "$port" && port=1234
resolve_full_httpd () {
case "$httpd" in
*apache2*|*lighttpd*|*httpd*)
# yes, *httpd* covers *lighttpd* above, but it is there for clarity
# ensure that the apache2/lighttpd command ends with "-f"
if ! echo "$httpd" | grep -- '-f *$' >/dev/null 2>&1
then
httpd="$httpd -f"
fi
;;
*plackup*)
# server is started by running via generated gitweb.psgi in $fqgitdir/gitweb
full_httpd="$fqgitdir/gitweb/gitweb.psgi"
httpd_only="${httpd%% *}" # cut on first space
return
;;
*webrick*)
# server is started by running via generated webrick.rb in
# $fqgitdir/gitweb
full_httpd="$fqgitdir/gitweb/webrick.rb"
httpd_only="${httpd%% *}" # cut on first space
return
;;
*python*)
# server is started by running via generated gitweb.py in
# $fqgitdir/gitweb
full_httpd="$fqgitdir/gitweb/gitweb.py"
httpd_only="${httpd%% *}" # cut on first space
return
;;
esac
httpd_only="$(echo $httpd | cut -f1 -d' ')"
if case "$httpd_only" in /*) : ;; *) which $httpd_only >/dev/null 2>&1;; esac
then
full_httpd=$httpd
else
# many httpds are installed in /usr/sbin or /usr/local/sbin
# these days and those are not in most users $PATHs
# in addition, we may have generated a server script
# in $fqgitdir/gitweb.
for i in /usr/local/sbin /usr/sbin "$root" "$fqgitdir/gitweb"
do
if test -x "$i/$httpd_only"
then
full_httpd=$i/$httpd
return
fi
done
echo >&2 "$httpd_only not found. Install $httpd_only or use" \
"--httpd to specify another httpd daemon."
exit 1
fi
}
start_httpd () {
if test -f "$fqgitdir/pid"; then
echo "Instance already running. Restarting..."
stop_httpd
fi
# here $httpd should have a meaningful value
resolve_full_httpd
mkdir -p "$fqgitdir/gitweb/$httpd_only"
conf="$fqgitdir/gitweb/$httpd_only.conf"
# generate correct config file if it doesn't exist
test -f "$conf" || configure_httpd
test -f "$fqgitdir/gitweb/gitweb_config.perl" || gitweb_conf
# don't quote $full_httpd, there can be arguments to it (-f)
case "$httpd" in
*mongoose*|*plackup*|*python*)
#These servers don't have a daemon mode so we'll have to fork it
$full_httpd "$conf" &
#Save the pid before doing anything else (we'll print it later)
pid=$!
if test $? != 0; then
echo "Could not execute http daemon $httpd."
exit 1
fi
cat > "$fqgitdir/pid" <<EOF
$pid
EOF
;;
*)
$full_httpd "$conf"
if test $? != 0; then
echo "Could not execute http daemon $httpd."
exit 1
fi
;;
esac
}
stop_httpd () {
test -f "$fqgitdir/pid" && kill $(cat "$fqgitdir/pid")
rm -f "$fqgitdir/pid"
}
httpd_is_ready () {
"$PERL" -MIO::Socket::INET -e "
local \$| = 1; # turn on autoflush
exit if (IO::Socket::INET->new('127.0.0.1:$port'));
print 'Waiting for \'$httpd\' to start ..';
do {
print '.';
sleep(1);
} until (IO::Socket::INET->new('127.0.0.1:$port'));
print qq! (done)\n!;
"
}
while test $# != 0
do
case "$1" in
--stop|stop)
action="stop"
;;
--start|start)
action="start"
;;
--restart|restart)
action="restart"
;;
-l|--local)
local=true
;;
-d|--httpd)
shift
httpd="$1"
;;
-b|--browser)
shift
browser="$1"
;;
-p|--port)
shift
port="$1"
;;
-m|--module-path)
shift
module_path="$1"
;;
--)
;;
*)
usage
;;
esac
shift
done
mkdir -p "$GIT_DIR/gitweb/tmp"
GIT_EXEC_PATH="$(git --exec-path)"
GIT_DIR="$fqgitdir"
GITWEB_CONFIG="$fqgitdir/gitweb/gitweb_config.perl"
export GIT_EXEC_PATH GIT_DIR GITWEB_CONFIG
webrick_conf () {
# webrick seems to have no way of passing arbitrary environment
# variables to the underlying CGI executable, so we wrap the
# actual gitweb.cgi using a shell script to force it
wrapper="$fqgitdir/gitweb/$httpd/wrapper.sh"
cat > "$wrapper" <<EOF
#!/bin/sh
# we use this shell script wrapper around the real gitweb.cgi since
# there appears to be no other way to pass arbitrary environment variables
# into the CGI process
GIT_EXEC_PATH=$GIT_EXEC_PATH GIT_DIR=$GIT_DIR GITWEB_CONFIG=$GITWEB_CONFIG
export GIT_EXEC_PATH GIT_DIR GITWEB_CONFIG
exec $root/gitweb.cgi
EOF
chmod +x "$wrapper"
# This assumes _ruby_ is in the user's $PATH. that's _one_
# portable way to run ruby, which could be installed anywhere, really.
# generate a standalone server script in $fqgitdir/gitweb.
cat >"$fqgitdir/gitweb/$httpd.rb" <<EOF
#!/usr/bin/env ruby
require 'webrick'
require 'logger'
options = {
:Port => $port,
:DocumentRoot => "$root",
:Logger => Logger.new('$fqgitdir/gitweb/error.log'),
:AccessLog => [
[ Logger.new('$fqgitdir/gitweb/access.log'),
WEBrick::AccessLog::COMBINED_LOG_FORMAT ]
],
:DirectoryIndex => ["gitweb.cgi"],
:CGIInterpreter => "$wrapper",
:StartCallback => lambda do
File.open("$fqgitdir/pid", "w") { |f| f.puts Process.pid }
end,
:ServerType => WEBrick::Daemon,
}
options[:BindAddress] = '127.0.0.1' if "$local" == "true"
server = WEBrick::HTTPServer.new(options)
['INT', 'TERM'].each do |signal|
trap(signal) {server.shutdown}
end
server.start
EOF
chmod +x "$fqgitdir/gitweb/$httpd.rb"
# configuration is embedded in server script file, webrick.rb
rm -f "$conf"
}
lighttpd_conf () {
cat > "$conf" <<EOF
server.document-root = "$root"
server.port = $port
server.modules = ( "mod_setenv", "mod_cgi" )
server.indexfiles = ( "gitweb.cgi" )
server.pid-file = "$fqgitdir/pid"
server.errorlog = "$fqgitdir/gitweb/$httpd_only/error.log"
# to enable, add "mod_access", "mod_accesslog" to server.modules
# variable above and uncomment this
#accesslog.filename = "$fqgitdir/gitweb/$httpd_only/access.log"
setenv.add-environment = ( "PATH" => env.PATH, "GITWEB_CONFIG" => env.GITWEB_CONFIG )
cgi.assign = ( ".cgi" => "" )
# mimetype mapping
mimetype.assign = (
".pdf" => "application/pdf",
".sig" => "application/pgp-signature",
".spl" => "application/futuresplash",
".class" => "application/octet-stream",
".ps" => "application/postscript",
".torrent" => "application/x-bittorrent",
".dvi" => "application/x-dvi",
".gz" => "application/x-gzip",
".pac" => "application/x-ns-proxy-autoconfig",
".swf" => "application/x-shockwave-flash",
".tar.gz" => "application/x-tgz",
".tgz" => "application/x-tgz",
".tar" => "application/x-tar",
".zip" => "application/zip",
".mp3" => "audio/mpeg",
".m3u" => "audio/x-mpegurl",
".wma" => "audio/x-ms-wma",
".wax" => "audio/x-ms-wax",
".ogg" => "application/ogg",
".wav" => "audio/x-wav",
".gif" => "image/gif",
".jpg" => "image/jpeg",
".jpeg" => "image/jpeg",
".png" => "image/png",
".xbm" => "image/x-xbitmap",
".xpm" => "image/x-xpixmap",
".xwd" => "image/x-xwindowdump",
".css" => "text/css",
".html" => "text/html",
".htm" => "text/html",
".js" => "text/javascript",
".asc" => "text/plain",
".c" => "text/plain",
".cpp" => "text/plain",
".log" => "text/plain",
".conf" => "text/plain",
".text" => "text/plain",
".txt" => "text/plain",
".dtd" => "text/xml",
".xml" => "text/xml",
".mpeg" => "video/mpeg",
".mpg" => "video/mpeg",
".mov" => "video/quicktime",
".qt" => "video/quicktime",
".avi" => "video/x-msvideo",
".asf" => "video/x-ms-asf",
".asx" => "video/x-ms-asf",
".wmv" => "video/x-ms-wmv",
".bz2" => "application/x-bzip",
".tbz" => "application/x-bzip-compressed-tar",
".tar.bz2" => "application/x-bzip-compressed-tar",
"" => "text/plain"
)
EOF
test x"$local" = xtrue && echo 'server.bind = "127.0.0.1"' >> "$conf"
}
apache2_conf () {
for candidate in \
/etc/httpd \
/usr/lib/apache2 \
/usr/lib/httpd ;
do
if test -d "$candidate/modules"
then
module_path="$candidate/modules"
break
fi
done
bind=
test x"$local" = xtrue && bind='127.0.0.1:'
echo 'text/css css' > "$fqgitdir/mime.types"
cat > "$conf" <<EOF
ServerName "git-instaweb"
ServerRoot "$root"
DocumentRoot "$root"
ErrorLog "$fqgitdir/gitweb/$httpd_only/error.log"
CustomLog "$fqgitdir/gitweb/$httpd_only/access.log" combined
PidFile "$fqgitdir/pid"
Listen $bind$port
EOF
for mod in mpm_event mpm_prefork mpm_worker
do
if test -e $module_path/mod_${mod}.so
then
echo "LoadModule ${mod}_module " \
"$module_path/mod_${mod}.so" >> "$conf"
# only one mpm module permitted
break
fi
done
for mod in mime dir env log_config authz_core unixd
do
if test -e $module_path/mod_${mod}.so
then
echo "LoadModule ${mod}_module " \
"$module_path/mod_${mod}.so" >> "$conf"
fi
done
cat >> "$conf" <<EOF
TypesConfig "$fqgitdir/mime.types"
DirectoryIndex gitweb.cgi
EOF
if test -f "$module_path/mod_perl.so"
then
# favor mod_perl if available
cat >> "$conf" <<EOF
LoadModule perl_module $module_path/mod_perl.so
PerlPassEnv GIT_DIR
PerlPassEnv GIT_EXEC_PATH
PerlPassEnv GITWEB_CONFIG
<Location /gitweb.cgi>
SetHandler perl-script
PerlResponseHandler ModPerl::Registry
PerlOptions +ParseHeaders
Options +ExecCGI
</Location>
EOF
else
# plain-old CGI
resolve_full_httpd
list_mods=$(echo "$full_httpd" | sed 's/-f$/-l/')
$list_mods | grep 'mod_cgi\.c' >/dev/null 2>&1 || \
if test -f "$module_path/mod_cgi.so"
then
echo "LoadModule cgi_module $module_path/mod_cgi.so" >> "$conf"
else
$list_mods | grep 'mod_cgid\.c' >/dev/null 2>&1 || \
if test -f "$module_path/mod_cgid.so"
then
echo "LoadModule cgid_module $module_path/mod_cgid.so" \
>> "$conf"
else
echo "You have no CGI support!"
exit 2
fi
echo "ScriptSock logs/gitweb.sock" >> "$conf"
fi
cat >> "$conf" <<EOF
PassEnv GIT_DIR
PassEnv GIT_EXEC_PATH
PassEnv GITWEB_CONFIG
AddHandler cgi-script .cgi
<Location /gitweb.cgi>
Options +ExecCGI
</Location>
EOF
fi
}
mongoose_conf() {
cat > "$conf" <<EOF
# Mongoose web server configuration file.
# Lines starting with '#' and empty lines are ignored.
# For detailed description of every option, visit
# https://code.google.com/p/mongoose/wiki/MongooseManual
root $root
ports $port
index_files gitweb.cgi
#ssl_cert $fqgitdir/gitweb/ssl_cert.pem
error_log $fqgitdir/gitweb/$httpd_only/error.log
access_log $fqgitdir/gitweb/$httpd_only/access.log
#cgi setup
cgi_env PATH=$PATH,GIT_DIR=$GIT_DIR,GIT_EXEC_PATH=$GIT_EXEC_PATH,GITWEB_CONFIG=$GITWEB_CONFIG
cgi_interp $PERL
cgi_ext cgi,pl
# mimetype mapping
mime_types .gz=application/x-gzip,.tar.gz=application/x-tgz,.tgz=application/x-tgz,.tar=application/x-tar,.zip=application/zip,.gif=image/gif,.jpg=image/jpeg,.jpeg=image/jpeg,.png=image/png,.css=text/css,.html=text/html,.htm=text/html,.js=text/javascript,.c=text/plain,.cpp=text/plain,.log=text/plain,.conf=text/plain,.text=text/plain,.txt=text/plain,.dtd=text/xml,.bz2=application/x-bzip,.tbz=application/x-bzip-compressed-tar,.tar.bz2=application/x-bzip-compressed-tar
EOF
}
plackup_conf () {
# generate a standalone 'plackup' server script in $fqgitdir/gitweb
# with embedded configuration; it does not use "$conf" file
cat > "$fqgitdir/gitweb/gitweb.psgi" <<EOF
#!$PERL
# gitweb - simple web interface to track changes in git repositories
# PSGI wrapper and server starter (see https://plackperl.org)
use strict;
use IO::Handle;
use Plack::MIME;
use Plack::Builder;
use Plack::App::WrapCGI;
use CGI::Emulate::PSGI 0.07; # minimum version required to work with gitweb
# mimetype mapping (from lighttpd_conf)
Plack::MIME->add_type(
".pdf" => "application/pdf",
".sig" => "application/pgp-signature",
".spl" => "application/futuresplash",
".class" => "application/octet-stream",
".ps" => "application/postscript",
".torrent" => "application/x-bittorrent",
".dvi" => "application/x-dvi",
".gz" => "application/x-gzip",
".pac" => "application/x-ns-proxy-autoconfig",
".swf" => "application/x-shockwave-flash",
".tar.gz" => "application/x-tgz",
".tgz" => "application/x-tgz",
".tar" => "application/x-tar",
".zip" => "application/zip",
".mp3" => "audio/mpeg",
".m3u" => "audio/x-mpegurl",
".wma" => "audio/x-ms-wma",
".wax" => "audio/x-ms-wax",
".ogg" => "application/ogg",
".wav" => "audio/x-wav",
".gif" => "image/gif",
".jpg" => "image/jpeg",
".jpeg" => "image/jpeg",
".png" => "image/png",
".xbm" => "image/x-xbitmap",
".xpm" => "image/x-xpixmap",
".xwd" => "image/x-xwindowdump",
".css" => "text/css",
".html" => "text/html",
".htm" => "text/html",
".js" => "text/javascript",
".asc" => "text/plain",
".c" => "text/plain",
".cpp" => "text/plain",
".log" => "text/plain",
".conf" => "text/plain",
".text" => "text/plain",
".txt" => "text/plain",
".dtd" => "text/xml",
".xml" => "text/xml",
".mpeg" => "video/mpeg",
".mpg" => "video/mpeg",
".mov" => "video/quicktime",
".qt" => "video/quicktime",
".avi" => "video/x-msvideo",
".asf" => "video/x-ms-asf",
".asx" => "video/x-ms-asf",
".wmv" => "video/x-ms-wmv",
".bz2" => "application/x-bzip",
".tbz" => "application/x-bzip-compressed-tar",
".tar.bz2" => "application/x-bzip-compressed-tar",
"" => "text/plain"
);
my \$app = builder {
# to be able to override \$SIG{__WARN__} to log build time warnings
use CGI::Carp; # it sets \$SIG{__WARN__} itself
my \$logdir = "$fqgitdir/gitweb/$httpd_only";
open my \$access_log_fh, '>>', "\$logdir/access.log"
or die "Couldn't open access log '\$logdir/access.log': \$!";
open my \$error_log_fh, '>>', "\$logdir/error.log"
or die "Couldn't open error log '\$logdir/error.log': \$!";
\$access_log_fh->autoflush(1);
\$error_log_fh->autoflush(1);
# redirect build time warnings to error.log
\$SIG{'__WARN__'} = sub {
my \$msg = shift;
# timestamp warning like in CGI::Carp::warn
my \$stamp = CGI::Carp::stamp();
\$msg =~ s/^/\$stamp/gm;
print \$error_log_fh \$msg;
};
# write errors to error.log, access to access.log
enable 'AccessLog',
format => "combined",
logger => sub { print \$access_log_fh @_; };
enable sub {
my \$app = shift;
sub {
my \$env = shift;
\$env->{'psgi.errors'} = \$error_log_fh;
\$app->(\$env);
}
};
# gitweb currently doesn't work with $SIG{CHLD} set to 'IGNORE',
# because it uses 'close $fd or die...' on piped filehandle $fh
# (which causes the parent process to wait for child to finish).
enable_if { \$SIG{'CHLD'} eq 'IGNORE' } sub {
my \$app = shift;
sub {
my \$env = shift;
local \$SIG{'CHLD'} = 'DEFAULT';
local \$SIG{'CLD'} = 'DEFAULT';
\$app->(\$env);
}
};
# serve static files, i.e. stylesheet, images, script
enable 'Static',
path => sub { m!\.(js|css|png)\$! && s!^/gitweb/!! },
root => "$root/",
encoding => 'utf-8'; # encoding for 'text/plain' files
# convert CGI application to PSGI app
Plack::App::WrapCGI->new(script => "$root/gitweb.cgi")->to_app;
};
# make it runnable as standalone app,
# like it would be run via 'plackup' utility
if (caller) {
return \$app;
} else {
require Plack::Runner;
my \$runner = Plack::Runner->new();
\$runner->parse_options(qw(--env deployment --port $port),
"$local" ? qw(--host 127.0.0.1) : ());
\$runner->run(\$app);
}
__END__
EOF
chmod a+x "$fqgitdir/gitweb/gitweb.psgi"
# configuration is embedded in server script file, gitweb.psgi
rm -f "$conf"
}
python_conf() {
# Python's builtin http.server and its CGI support is very limited.
# CGI handler is capable of running CGI script only from inside a directory.
# Trying to set cgi_directories=["/"] will add double slash to SCRIPT_NAME
# and that in turn breaks gitweb's relative link generation.
# create a simple web root where $fqgitdir/gitweb/$httpd_only is our root
mkdir -p "$fqgitdir/gitweb/$httpd_only/cgi-bin"
# Python http.server follows the symlinks
ln -sf "$root/gitweb.cgi" "$fqgitdir/gitweb/$httpd_only/cgi-bin/gitweb.cgi"
ln -sf "$root/static" "$fqgitdir/gitweb/$httpd_only/"
# generate a standalone 'python http.server' script in $fqgitdir/gitweb
# This assumes that python is in user's $PATH
# This script is Python 2 and 3 compatible
cat > "$fqgitdir/gitweb/gitweb.py" <<EOF
#!/usr/bin/env python
import os
import sys
# Open log file in line buffering mode
accesslogfile = open("$fqgitdir/gitweb/access.log", 'a', buffering=1)
errorlogfile = open("$fqgitdir/gitweb/error.log", 'a', buffering=1)
# and replace our stdout and stderr with log files
# also do a lowlevel duplicate of the logfile file descriptors so that
# our CGI child process writes any stderr warning also to the log file
_orig_stdout_fd = sys.stdout.fileno()
sys.stdout.close()
os.dup2(accesslogfile.fileno(), _orig_stdout_fd)
sys.stdout = accesslogfile
_orig_stderr_fd = sys.stderr.fileno()
sys.stderr.close()
os.dup2(errorlogfile.fileno(), _orig_stderr_fd)
sys.stderr = errorlogfile
from functools import partial
if sys.version_info < (3, 0): # Python 2
from CGIHTTPServer import CGIHTTPRequestHandler
from BaseHTTPServer import HTTPServer as ServerClass
else: # Python 3
from http.server import CGIHTTPRequestHandler
from http.server import HTTPServer as ServerClass
# Those environment variables will be passed to the cgi script
os.environ.update({
"GIT_EXEC_PATH": "$GIT_EXEC_PATH",
"GIT_DIR": "$GIT_DIR",
"GITWEB_CONFIG": "$GITWEB_CONFIG"
})
class GitWebRequestHandler(CGIHTTPRequestHandler):
def log_message(self, format, *args):
# Write access logs to stdout
sys.stdout.write("%s - - [%s] %s\n" %
(self.address_string(),
self.log_date_time_string(),
format%args))
def do_HEAD(self):
self.redirect_path()
CGIHTTPRequestHandler.do_HEAD(self)
def do_GET(self):
if self.path == "/":
self.send_response(303, "See Other")
self.send_header("Location", "/cgi-bin/gitweb.cgi")
self.end_headers()
return
self.redirect_path()
CGIHTTPRequestHandler.do_GET(self)
def do_POST(self):
self.redirect_path()
CGIHTTPRequestHandler.do_POST(self)
# rewrite path of every request that is not gitweb.cgi to out of cgi-bin
def redirect_path(self):
if not self.path.startswith("/cgi-bin/gitweb.cgi"):
self.path = self.path.replace("/cgi-bin/", "/")
# gitweb.cgi is the only thing that is ever going to be run here.
# Ignore everything else
def is_cgi(self):
result = False
if self.path.startswith('/cgi-bin/gitweb.cgi'):
result = CGIHTTPRequestHandler.is_cgi(self)
return result
bind = "0.0.0.0"
if "$local" == "true":
bind = "127.0.0.1"
# Set our http root directory
# This is a work around for a missing directory argument in older Python versions
# as this was added to SimpleHTTPRequestHandler in Python 3.7
os.chdir("$fqgitdir/gitweb/$httpd_only/")
GitWebRequestHandler.protocol_version = "HTTP/1.0"
httpd = ServerClass((bind, $port), GitWebRequestHandler)
sa = httpd.socket.getsockname()
print("Serving HTTP on", sa[0], "port", sa[1], "...")
httpd.serve_forever()
EOF
chmod a+x "$fqgitdir/gitweb/gitweb.py"
}
gitweb_conf() {
cat > "$fqgitdir/gitweb/gitweb_config.perl" <<EOF
#!/usr/bin/perl
our \$projectroot = "$(dirname "$fqgitdir")";
our \$git_temp = "$fqgitdir/gitweb/tmp";
our \$projects_list = \$projectroot;
\$feature{'remote_heads'}{'default'} = [1];
EOF
}
configure_httpd() {
case "$httpd" in
*lighttpd*)
lighttpd_conf
;;
*apache2*|*httpd*)
apache2_conf
;;
webrick)
webrick_conf
;;
*mongoose*)
mongoose_conf
;;
*plackup*)
plackup_conf
;;
*python*)
python_conf
;;
*)
echo "Unknown httpd specified: $httpd"
exit 1
;;
esac
}
case "$action" in
stop)
stop_httpd
exit 0
;;
start)
start_httpd
exit 0
;;
restart)
stop_httpd
start_httpd
exit 0
;;
esac
gitweb_conf
resolve_full_httpd
mkdir -p "$fqgitdir/gitweb/$httpd_only"
conf="$fqgitdir/gitweb/$httpd_only.conf"
configure_httpd
start_httpd
url=http://127.0.0.1:$port
if test -n "$browser"; then
httpd_is_ready && git web--browse -b "$browser" $url || echo $url
else
httpd_is_ready && git web--browse -c "instaweb.browser" $url || echo $url
fi

View File

@@ -0,0 +1,112 @@
#!/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"

View File

@@ -0,0 +1,167 @@
#!/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='<orig blob> <our blob> <their blob> <path>'
USAGE="$USAGE <orig mode> <our mode> <their mode>"
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

View File

@@ -0,0 +1,64 @@
#!/bin/sh
#
# Copyright (c) 2005 Linus Torvalds
# Copyright (c) 2005 Junio C Hamano
#
# Resolve two trees, using enhanced multi-base read-tree.
. git-sh-setup
# Abort if index does not match HEAD
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
# 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

View File

@@ -0,0 +1,579 @@
#!/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] [-g|--gui|--no-gui] [-O<orderfile>] [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="$(git checkout-index --temp --stage="$1" "$2" 2>/dev/null)" &&
tmpfile=${tmpfile%%' '*}
if test $? -eq 0 && test -n "$tmpfile"
then
mv -- "$(git rev-parse --show-cdup)$tmpfile" "$3"
else
>"$3"
fi
}
hide_resolved () {
git merge-file --ours -q -p "$LOCAL" "$BASE" "$REMOTE" >"$LCONFL"
git merge-file --theirs -q -p "$LOCAL" "$BASE" "$REMOTE" >"$RCONFL"
mv -- "$LCONFL" "$LOCAL"
mv -- "$RCONFL" "$REMOTE"
}
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
# extract file extension from the last path component
case "${MERGED##*/}" in
*.*)
ext=.${MERGED##*.}
BASE=${MERGED%"$ext"}
;;
*)
BASE=$MERGED
ext=
esac
initialize_merge_tool "$merge_tool" || return
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"
LCONFL="$MERGETOOL_TMPDIR/${BASE}_LOCAL_LCONFL_$$$ext"
REMOTE="$MERGETOOL_TMPDIR/${BASE}_REMOTE_$$$ext"
RCONFL="$MERGETOOL_TMPDIR/${BASE}_REMOTE_RCONFL_$$$ext"
BASE="$MERGETOOL_TMPDIR/${BASE}_BASE_$$$ext"
base_mode= local_mode= remote_mode=
# here, $IFS is just a LF
for line in $f
do
mode=${line%% *} # 1st word
sha1=${line#"$mode "}
sha1=${sha1%% *} # 2nd word
case "${line#$mode $sha1 }" in # remainder
'1 '*)
base_mode=$mode
;;
'2 '*)
local_mode=$mode local_sha1=$sha1
;;
'3 '*)
remote_mode=$mode remote_sha1=$sha1
;;
esac
done
if is_submodule "$local_mode" || is_submodule "$remote_mode"
then
echo "Submodule merge conflict for '$MERGED':"
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"
# hideResolved preferences hierarchy.
global_config="mergetool.hideResolved"
tool_config="mergetool.${merge_tool}.hideResolved"
if enabled=$(git config --type=bool "$tool_config")
then
# The user has a specific preference for a specific tool and no
# other preferences should override that.
: ;
elif enabled=$(git config --type=bool "$global_config")
then
# The user has a general preference for all tools.
#
# 'true' means the user likes the feature so we should use it
# where possible but tool authors can still override.
#
# 'false' means the user doesn't like the feature so we should
# not use it anywhere.
if test "$enabled" = true && hide_resolved_enabled
then
enabled=true
else
enabled=false
fi
else
# The user does not have a preference. Default to disabled.
enabled=false
fi
if test "$enabled" = true
then
hide_resolved
fi
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)
GIT_MERGETOOL_GUI=
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=${1#*=}
;;
1,*)
usage ;;
*)
merge_tool="$2"
shift ;;
esac
;;
--no-gui)
GIT_MERGETOOL_GUI=false
;;
-g|--gui)
GIT_MERGETOOL_GUI=true
;;
-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
merge_tool=$(get_merge_tool)
subshell_exit_status=$?
if test $subshell_exit_status = 1
then
guessed_merge_tool=true
elif test $subshell_exit_status -gt 1
then
exit $subshell_exit_status
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 "$@"

View File

@@ -0,0 +1,549 @@
# 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 scriptname
do
setup_tool "$scriptname" 2>/dev/null
# We need an actual line feed here
variants="$variants
$(list_tool_variants)"
done
variants="$(echo "$variants" | sort -u)"
for toolname in $variants
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%-15s %s\n" "$per_line_prefix" "$toolname" $(diff_mode && diff_cmd_help "$toolname" || merge_cmd_help "$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
}
get_gui_default () {
if diff_mode
then
GUI_DEFAULT_KEY="difftool.guiDefault"
else
GUI_DEFAULT_KEY="mergetool.guiDefault"
fi
GUI_DEFAULT_CONFIG_LCASE=$(git config --default false --get "$GUI_DEFAULT_KEY" | tr 'A-Z' 'a-z')
if test "$GUI_DEFAULT_CONFIG_LCASE" = "auto"
then
if test -n "$DISPLAY"
then
GUI_DEFAULT=true
else
GUI_DEFAULT=false
fi
else
GUI_DEFAULT=$(git config --default false --bool --get "$GUI_DEFAULT_KEY")
subshell_exit_status=$?
if test $subshell_exit_status -ne 0
then
exit $subshell_exit_status
fi
fi
echo $GUI_DEFAULT
}
gui_mode () {
if test -z "$GIT_MERGETOOL_GUI"
then
GIT_MERGETOOL_GUI=$(get_gui_default)
if test $? -ne 0
then
exit 2
fi
fi
test "$GIT_MERGETOOL_GUI" = true
}
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" 2>/dev/null && 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 )
}
list_tool_variants () {
echo "$tool"
}
}
setup_tool () {
tool="$1"
# Fallback definitions, to be overridden by tools.
can_merge () {
return 0
}
can_diff () {
return 0
}
diff_cmd () {
return 1
}
diff_cmd_help () {
return 0
}
merge_cmd () {
return 1
}
merge_cmd_help () {
return 0
}
hide_resolved_enabled () {
return 0
}
translate_merge_tool_path () {
echo "$1"
}
list_tool_variants () {
echo "$tool"
}
# 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
. "$MERGE_TOOLS_DIR/$tool"
elif test -f "$MERGE_TOOLS_DIR/${tool%[0-9]}"
then
. "$MERGE_TOOLS_DIR/${tool%[0-9]}"
else
setup_user_tool
rc=$?
if test $rc -ne 0
then
echo >&2 "error: ${TOOL_MODE}tool.$tool.cmd not set for tool '$tool'"
fi
return $rc
fi
# 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 ! list_tool_variants | grep -q "^$tool$"
then
echo "error: unknown tool variant '$tool'" >&2
return 1
fi
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
}
initialize_merge_tool () {
# Bring tool-specific functions into scope
setup_tool "$1" || return 1
}
# 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"
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"
tools="$tools smerge"
fi
case "${VISUAL:-$EDITOR}" in
*nvim*)
tools="$tools nvimdiff vimdiff emerge"
;;
*vim*)
tools="$tools vimdiff nvimdiff emerge"
;;
*)
tools="$tools emerge vimdiff nvimdiff"
;;
esac
}
show_tool_help () {
tool_opt="'git ${TOOL_MODE}tool --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=<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 () {
keys=
if diff_mode
then
if gui_mode
then
keys="diff.guitool merge.guitool diff.tool merge.tool"
else
keys="diff.tool merge.tool"
fi
else
if gui_mode
then
keys="merge.guitool merge.tool"
else
keys="merge.tool"
fi
fi
merge_tool=$(
IFS=' '
for key in $keys
do
selected=$(git config $key)
if test -n "$selected"
then
echo "$selected"
return
fi
done)
if test -n "$merge_tool" && ! valid_tool "$merge_tool"
then
echo >&2 "git config option $TOOL_MODE.${gui_prefix}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 $TOOL_MODE 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 () {
is_guessed=false
# Check if a merge tool has been configured
merge_tool=$(get_configured_merge_tool)
subshell_exit_status=$?
if test $subshell_exit_status -gt "1"
then
exit $subshell_exit_status
fi
# 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
is_guessed=true
fi
echo "$merge_tool"
test "$is_guessed" = false
}
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"
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,155 @@
#!/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
keep-non-patch Pass -b to git mailinfo
"
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"
;;
--keep-non-patch)
MAILINFO_OPT="-b"
;;
--)
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 $MAILINFO_OPT "$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

View File

@@ -0,0 +1,172 @@
#!/bin/sh
# Copyright 2005, Ryan Anderson <ryan@michonline.com>
#
# This file is licensed under the GPL v2, or a later version
# at the discretion of Linus Torvalds.
SUBDIRECTORY_OK='Yes'
OPTIONS_KEEPDASHDASH=
OPTIONS_STUCKLONG=
OPTIONS_SPEC='git request-pull [options] start url [end]
--
p show patch text as well
'
. git-sh-setup
GIT_PAGER=
export GIT_PAGER
patch=
while case "$#" in 0) break ;; esac
do
case "$1" in
-p)
patch=-p ;;
--)
shift; break ;;
-*)
usage ;;
*)
break ;;
esac
shift
done
base=$1 url=$2 status=0
test -n "$base" && test -n "$url" || usage
baserev=$(git rev-parse --verify --quiet "$base"^0)
if test -z "$baserev"
then
die "fatal: Not a valid revision: $base"
fi
#
# $3 must be a symbolic ref, a unique ref, or
# a SHA object expression. It can also be of
# the format 'local-name:remote-name'.
#
local=${3%:*}
local=${local:-HEAD}
remote=${3#*:}
pretty_remote=${remote#refs/}
pretty_remote=${pretty_remote#heads/}
head=$(git symbolic-ref -q "$local")
head=${head:-$(git show-ref --heads --tags "$local" | cut -d' ' -f2)}
head=${head:-$(git rev-parse --quiet --verify "$local")}
# None of the above? Bad.
test -z "$head" && die "fatal: Not a valid revision: $local"
# This also verifies that the resulting head is unique:
# "git show-ref" could have shown multiple matching refs..
headrev=$(git rev-parse --verify --quiet "$head"^0)
test -z "$headrev" && die "fatal: Ambiguous revision: $local"
local_sha1=$(git rev-parse --verify --quiet "$head")
# Was it a branch with a description?
branch_name=${head#refs/heads/}
if test "z$branch_name" = "z$headref" ||
! git config "branch.$branch_name.description" >/dev/null
then
branch_name=
fi
merge_base=$(git merge-base $baserev $headrev) ||
die "fatal: No commits in common between $base and $head"
# $head is the refname from the command line.
# Find a ref with the same name as $head that exists at the remote
# and points to the same commit as the local object.
find_matching_ref='
my ($head,$headrev) = (@ARGV);
my $pattern = qr{/\Q$head\E$};
my ($remote_sha1, $found);
while (<STDIN>) {
chomp;
my ($sha1, $ref, $deref) = /^(\S+)\s+([^^]+)(\S*)$/;
if ($sha1 eq $head) {
$found = $remote_sha1 = $sha1;
break;
}
if ($ref eq $head || $ref =~ $pattern) {
if ($deref eq "") {
# Remember the matching object on the remote side
$remote_sha1 = $sha1;
}
if ($sha1 eq $headrev) {
$found = $ref;
break;
}
}
}
if ($found) {
$remote_sha1 = $headrev if ! defined $remote_sha1;
print "$remote_sha1 $found\n";
}
'
set fnord $(git ls-remote "$url" | /usr/bin/perl -e "$find_matching_ref" "${remote:-HEAD}" "$headrev")
remote_sha1=$2
ref=$3
if test -z "$ref"
then
echo "warn: No match for commit $headrev found at $url" >&2
echo "warn: Are you sure you pushed '${remote:-HEAD}' there?" >&2
status=1
elif test "$local_sha1" != "$remote_sha1"
then
echo "warn: $head found at $url but points to a different object" >&2
echo "warn: Are you sure you pushed '${remote:-HEAD}' there?" >&2
status=1
fi
# Special case: turn "for_linus" to "tags/for_linus" when it is correct
if test "$ref" = "refs/tags/$pretty_remote"
then
pretty_remote=tags/$pretty_remote
fi
url=$(git ls-remote --get-url "$url")
git show -s --format='The following changes since commit %H:
%s (%ci)
are available in the Git repository at:
' $merge_base &&
echo " $url $pretty_remote" &&
git show -s --format='
for you to fetch changes up to %H:
%s (%ci)
----------------------------------------------------------------' $headrev &&
if test $(git cat-file -t "$head") = tag
then
git cat-file tag "$head" |
sed -n -e '1,/^$/d' -e '/^-----BEGIN \(PGP\|SSH\|SIGNED\) /q' -e p
echo
echo "----------------------------------------------------------------"
fi &&
if test -n "$branch_name"
then
echo "(from the branch description for $branch_name local branch)"
echo
git config "branch.$branch_name.description"
echo "----------------------------------------------------------------"
fi &&
git shortlog ^$baserev $headrev &&
git diff -M --stat --summary $patch $merge_base..$headrev || status=1
exit $status

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,79 @@
# This shell library is Git's interface to gettext.sh. See po/README
# for usage instructions.
#
# Copyright (c) 2010 Ævar Arnfjörð Bjarmason
#
# Export the TEXTDOMAIN* data that we need for Git
TEXTDOMAIN=git
export TEXTDOMAIN
if test -z "$GIT_TEXTDOMAINDIR"
then
TEXTDOMAINDIR="/mingw64/share/locale"
else
TEXTDOMAINDIR="$GIT_TEXTDOMAINDIR"
fi
export TEXTDOMAINDIR
# First decide what scheme to use...
GIT_INTERNAL_GETTEXT_SH_SCHEME=fallthrough
if test -n "fallthrough"
then
GIT_INTERNAL_GETTEXT_SH_SCHEME="fallthrough"
elif test -n "$GIT_INTERNAL_GETTEXT_TEST_FALLBACKS"
then
: no probing necessary
elif type gettext.sh >/dev/null 2>&1
then
# GNU libintl's gettext.sh
GIT_INTERNAL_GETTEXT_SH_SCHEME=gnu
elif test "$(gettext -h 2>&1)" = "-h"
then
# gettext binary exists but no gettext.sh. likely to be a gettext
# binary on a Solaris or something that is not GNU libintl and
# lack eval_gettext.
GIT_INTERNAL_GETTEXT_SH_SCHEME=gettext_without_eval_gettext
fi
export GIT_INTERNAL_GETTEXT_SH_SCHEME
# ... and then follow that decision.
case "$GIT_INTERNAL_GETTEXT_SH_SCHEME" in
gnu)
# Use libintl's gettext.sh, or fall back to English if we can't.
. gettext.sh
;;
gettext_without_eval_gettext)
# Solaris has a gettext(1) but no eval_gettext(1)
eval_gettext () {
gettext "$1" | (
export PATH $(git sh-i18n--envsubst --variables "$1");
git sh-i18n--envsubst "$1"
)
}
;;
*)
gettext () {
printf "%s" "$1"
}
eval_gettext () {
printf "%s" "$1" | (
export PATH $(git sh-i18n--envsubst --variables "$1");
git sh-i18n--envsubst "$1"
)
}
;;
esac
# Git-specific wrapper functions
gettextln () {
gettext "$1"
echo
}
eval_gettextln () {
eval_gettext "$1"
echo
}

View File

@@ -0,0 +1,370 @@
# This shell scriplet is meant to be included by other shell scripts
# to set up some variables pointing at the normal git directories and
# a few helper shell functions.
# Having this variable in your environment would break scripts because
# you would cause "cd" to be taken to unexpected places. If you
# like CDPATH, define it for your interactive shell sessions without
# exporting it.
# But we protect ourselves from such a user mistake nevertheless.
unset CDPATH
# Similarly for IFS, but some shells (e.g. FreeBSD 7.2) are buggy and
# do not equate an unset IFS with IFS with the default, so here is
# an explicit SP HT LF.
IFS='
'
git_broken_path_fix () {
case ":$PATH:" in
*:$1:*) : ok ;;
*)
PATH=$(
SANE_TOOL_PATH="$1"
IFS=: path= sep=
set x $PATH
shift
for elem
do
case "$SANE_TOOL_PATH:$elem" in
(?*:/bin | ?*:/usr/bin)
path="$path$sep$SANE_TOOL_PATH"
sep=:
SANE_TOOL_PATH=
esac
path="$path$sep$elem"
sep=:
done
echo "$path"
)
;;
esac
}
# Source git-sh-i18n for gettext support.
. "$(git --exec-path)/git-sh-i18n"
die () {
die_with_status 1 "$@"
}
die_with_status () {
status=$1
shift
printf >&2 '%s\n' "$*"
exit "$status"
}
if test -n "$OPTIONS_SPEC"; then
usage() {
"$0" -h
exit 1
}
parseopt_extra=
[ -n "$OPTIONS_KEEPDASHDASH" ] &&
parseopt_extra="--keep-dashdash"
[ -n "$OPTIONS_STUCKLONG" ] &&
parseopt_extra="$parseopt_extra --stuck-long"
eval "$(
echo "$OPTIONS_SPEC" |
git rev-parse --parseopt $parseopt_extra -- "$@" ||
echo exit $?
)"
else
dashless=$(basename -- "$0" | sed -e 's/-/ /')
usage() {
die "$(eval_gettext "usage: \$dashless \$USAGE")"
}
if [ -z "$LONG_USAGE" ]
then
LONG_USAGE="$(eval_gettext "usage: \$dashless \$USAGE")"
else
LONG_USAGE="$(eval_gettext "usage: \$dashless \$USAGE
$LONG_USAGE")"
fi
case "$1" in
-h)
echo "$LONG_USAGE"
exit
esac
fi
# Set the name of the end-user facing command in the reflog when the
# script may update refs. When GIT_REFLOG_ACTION is already set, this
# will not overwrite it, so that a scripted Porcelain (e.g. "git
# rebase") can set it to its own name (e.g. "rebase") and then call
# another scripted Porcelain (e.g. "git am") and a call to this
# function in the latter will keep the name of the end-user facing
# program (e.g. "rebase") in GIT_REFLOG_ACTION, ensuring whatever it
# does will be record as actions done as part of the end-user facing
# operation (e.g. "rebase").
#
# NOTE NOTE NOTE: consequently, after assigning a specific message to
# GIT_REFLOG_ACTION when calling a "git" command to record a custom
# reflog message, do not leave that custom value in GIT_REFLOG_ACTION,
# after you are done. Other callers of "git" commands that rely on
# writing the default "program name" in reflog expect the variable to
# contain the value set by this function.
#
# To use a custom reflog message, do either one of these three:
#
# (a) use a single-shot export form:
# GIT_REFLOG_ACTION="$GIT_REFLOG_ACTION: preparing frotz" \
# git command-that-updates-a-ref
#
# (b) save the original away and restore:
# SAVED_ACTION=$GIT_REFLOG_ACTION
# GIT_REFLOG_ACTION="$GIT_REFLOG_ACTION: preparing frotz"
# git command-that-updates-a-ref
# GIT_REFLOG_ACITON=$SAVED_ACTION
#
# (c) assign the variable in a subshell:
# (
# GIT_REFLOG_ACTION="$GIT_REFLOG_ACTION: preparing frotz"
# git command-that-updates-a-ref
# )
set_reflog_action() {
if [ -z "${GIT_REFLOG_ACTION:+set}" ]
then
GIT_REFLOG_ACTION="$*"
export GIT_REFLOG_ACTION
fi
}
git_editor() {
if test -z "${GIT_EDITOR:+set}"
then
GIT_EDITOR="$(git var GIT_EDITOR)" || return $?
fi
eval "$GIT_EDITOR" '"$@"'
}
git_pager() {
if test -t 1
then
GIT_PAGER=$(git var GIT_PAGER)
else
GIT_PAGER=cat
fi
for vardef in LESS=FRX LV=-c
do
var=${vardef%%=*}
eval ": \"\${$vardef}\" && export $var"
done
eval "$GIT_PAGER" '"$@"'
}
is_bare_repository () {
git rev-parse --is-bare-repository
}
cd_to_toplevel () {
cdup=$(git rev-parse --show-toplevel) &&
cd "$cdup" || {
gettextln "Cannot chdir to \$cdup, the toplevel of the working tree" >&2
exit 1
}
}
require_work_tree_exists () {
if test "z$(git rev-parse --is-bare-repository)" != zfalse
then
program_name=$0
die "$(eval_gettext "fatal: \$program_name cannot be used without a working tree.")"
fi
}
require_work_tree () {
test "$(git rev-parse --is-inside-work-tree 2>/dev/null)" = true || {
program_name=$0
die "$(eval_gettext "fatal: \$program_name cannot be used without a working tree.")"
}
}
require_clean_work_tree () {
git rev-parse --verify HEAD >/dev/null || exit 1
git update-index -q --ignore-submodules --refresh
err=0
if ! git diff-files --quiet --ignore-submodules
then
action=$1
case "$action" in
"rewrite branches")
gettextln "Cannot rewrite branches: You have unstaged changes." >&2
;;
*)
eval_gettextln "Cannot \$action: You have unstaged changes." >&2
;;
esac
err=1
fi
if ! git diff-index --cached --quiet --ignore-submodules HEAD --
then
if test $err = 0
then
action=$1
eval_gettextln "Cannot \$action: Your index contains uncommitted changes." >&2
else
gettextln "Additionally, your index contains uncommitted changes." >&2
fi
err=1
fi
if test $err = 1
then
test -n "$2" && echo "$2" >&2
exit 1
fi
}
# Generate a sed script to parse identities from a commit.
#
# Reads the commit from stdin, which should be in raw format (e.g., from
# cat-file or "--pretty=raw").
#
# The first argument specifies the ident line to parse (e.g., "author"), and
# the second specifies the environment variable to put it in (e.g., "AUTHOR"
# for "GIT_AUTHOR_*"). Multiple pairs can be given to parse author and
# committer.
pick_ident_script () {
while test $# -gt 0
do
lid=$1; shift
uid=$1; shift
printf '%s' "
/^$lid /{
s/'/'\\\\''/g
h
s/^$lid "'\([^<]*\) <[^>]*> .*$/\1/'"
s/.*/GIT_${uid}_NAME='&'/p
g
s/^$lid "'[^<]* <\([^>]*\)> .*$/\1/'"
s/.*/GIT_${uid}_EMAIL='&'/p
g
s/^$lid "'[^<]* <[^>]*> \(.*\)$/@\1/'"
s/.*/GIT_${uid}_DATE='&'/p
}
"
done
echo '/^$/q'
}
# Create a pick-script as above and feed it to sed. Stdout is suitable for
# feeding to eval.
parse_ident_from_commit () {
LANG=C LC_ALL=C sed -ne "$(pick_ident_script "$@")"
}
# Parse the author from a commit given as an argument. Stdout is suitable for
# feeding to eval to set the usual GIT_* ident variables.
get_author_ident_from_commit () {
encoding=$(git config i18n.commitencoding || echo UTF-8)
git show -s --pretty=raw --encoding="$encoding" "$1" -- |
parse_ident_from_commit author AUTHOR
}
# Generate a virtual base file for a two-file merge. Uses git apply to
# remove lines from $1 that are not in $2, leaving only common lines.
create_virtual_base() {
sz0=$(wc -c <"$1")
diff -u -La/"$1" -Lb/"$1" "$1" "$2" | git apply --no-add
sz1=$(wc -c <"$1")
# If we do not have enough common material, it is not
# worth trying two-file merge using common subsections.
expr $sz0 \< $sz1 \* 2 >/dev/null || : >"$1"
}
# Platform specific tweaks to work around some commands
case $(uname -s) in
*MINGW*)
if test -x /usr/bin/sort
then
# Windows has its own (incompatible) sort; override
sort () {
/usr/bin/sort "$@"
}
fi
if test -x /usr/bin/find
then
# Windows has its own (incompatible) find; override
find () {
/usr/bin/find "$@"
}
fi
# On Windows, Git wants Windows paths. But /usr/bin/pwd spits out
# Unix-style paths. At least in Bash, we have a builtin pwd that
# understands the -W option to force "mixed" paths, i.e. with drive
# prefix but still with forward slashes. Let's use that, if available.
if type builtin >/dev/null 2>&1
then
pwd () {
builtin pwd -W
}
fi
is_absolute_path () {
case "$1" in
[/\\]* | [A-Za-z]:*)
return 0 ;;
esac
return 1
}
;;
*)
is_absolute_path () {
case "$1" in
/*)
return 0 ;;
esac
return 1
}
esac
# Make sure we are in a valid repository of a vintage we understand,
# if we require to be in a git repository.
git_dir_init () {
GIT_DIR=$(git rev-parse --git-dir) || exit
if [ -z "$SUBDIRECTORY_OK" ]
then
test -z "$(git rev-parse --show-cdup)" || {
exit=$?
gettextln "You need to run this command from the toplevel of the working tree." >&2
exit $exit
}
fi
test -n "$GIT_DIR" && GIT_DIR=$(cd "$GIT_DIR" && pwd) || {
gettextln "Unable to determine absolute path of git directory" >&2
exit 1
}
: "${GIT_OBJECT_DIRECTORY="$(git rev-parse --git-path objects)"}"
}
if test -z "$NONGIT_OK"
then
git_dir_init
fi
peel_committish () {
case "$1" in
:/*)
peeltmp=$(git rev-parse --verify "$1") &&
git rev-parse --verify "${peeltmp}^0"
;;
*)
git rev-parse --verify "${1}^0"
;;
esac
}

View File

@@ -0,0 +1,671 @@
#!/bin/sh
#
# git-submodule.sh: add, init, update or list git submodules
#
# Copyright (c) 2007 Lars Hjemli
dashless=$(basename "$0" | sed -e 's/-/ /')
USAGE="[--quiet] [--cached]
or: $dashless [--quiet] add [-b <branch>] [-f|--force] [--name <name>] [--reference <repository>] [--] <repository> [<path>]
or: $dashless [--quiet] status [--cached] [--recursive] [--] [<path>...]
or: $dashless [--quiet] init [--] [<path>...]
or: $dashless [--quiet] deinit [-f|--force] (--all| [--] <path>...)
or: $dashless [--quiet] update [--init [--filter=<filter-spec>]] [--remote] [-N|--no-fetch] [-f|--force] [--checkout|--merge|--rebase] [--[no-]recommend-shallow] [--reference <repository>] [--recursive] [--[no-]single-branch] [--] [<path>...]
or: $dashless [--quiet] set-branch (--default|--branch <branch>) [--] <path>
or: $dashless [--quiet] set-url [--] <path> <newurl>
or: $dashless [--quiet] summary [--cached|--files] [--summary-limit <n>] [commit] [--] [<path>...]
or: $dashless [--quiet] foreach [--recursive] <command>
or: $dashless [--quiet] sync [--recursive] [--] [<path>...]
or: $dashless [--quiet] absorbgitdirs [--] [<path>...]"
OPTIONS_SPEC=
SUBDIRECTORY_OK=Yes
. git-sh-setup
require_work_tree
wt_prefix=$(git rev-parse --show-prefix)
cd_to_toplevel
# Tell the rest of git that any URLs we get don't come
# directly from the user, so it can apply policy as appropriate.
GIT_PROTOCOL_FROM_USER=0
export GIT_PROTOCOL_FROM_USER
command=
quiet=
branch=
force=
reference=
cached=
recursive=
init=
require_init=
files=
remote=
no_fetch=
rebase=
merge=
checkout=
name=
depth=
progress=
dissociate=
single_branch=
jobs=
recommend_shallow=
filter=
all=
default=
summary_limit=
for_status=
#
# Add a new submodule to the working tree, .gitmodules and the index
#
# $@ = repo path
#
# optional branch is stored in global branch variable
#
cmd_add()
{
# parse $args after "submodule ... add".
while test $# -ne 0
do
case "$1" in
-b | --branch)
case "$2" in '') usage ;; esac
branch="--branch=$2"
shift
;;
-b* | --branch=*)
branch="$1"
;;
-f | --force)
force=$1
;;
-q|--quiet)
quiet=$1
;;
--progress)
progress=$1
;;
--reference)
case "$2" in '') usage ;; esac
reference="--reference=$2"
shift
;;
--reference=*)
reference="$1"
;;
--ref-format)
case "$2" in '') usage ;; esac
ref_format="--ref-format=$2"
shift
;;
--ref-format=*)
ref_format="$1"
;;
--dissociate)
dissociate=$1
;;
--name)
case "$2" in '') usage ;; esac
name="--name=$2"
shift
;;
--name=*)
name="$1"
;;
--depth)
case "$2" in '') usage ;; esac
depth="--depth=$2"
shift
;;
--depth=*)
depth="$1"
;;
--)
shift
break
;;
-*)
usage
;;
*)
break
;;
esac
shift
done
if test -z "$1"
then
usage
fi
git ${wt_prefix:+-C "$wt_prefix"} submodule--helper add \
$quiet \
$force \
$progress \
${branch:+"$branch"} \
${reference:+"$reference"} \
${ref_format:+"$ref_format"} \
$dissociate \
${name:+"$name"} \
${depth:+"$depth"} \
-- \
"$@"
}
#
# Execute an arbitrary command sequence in each checked out
# submodule
#
# $@ = command to execute
#
cmd_foreach()
{
# parse $args after "submodule ... foreach".
while test $# -ne 0
do
case "$1" in
-q|--quiet)
quiet=$1
;;
--recursive)
recursive=$1
;;
-*)
usage
;;
*)
break
;;
esac
shift
done
git ${wt_prefix:+-C "$wt_prefix"} submodule--helper foreach \
$quiet \
$recursive \
-- \
"$@"
}
#
# Register submodules in .git/config
#
# $@ = requested paths (default to all)
#
cmd_init()
{
# parse $args after "submodule ... init".
while test $# -ne 0
do
case "$1" in
-q|--quiet)
quiet=$1
;;
--)
shift
break
;;
-*)
usage
;;
*)
break
;;
esac
shift
done
git ${wt_prefix:+-C "$wt_prefix"} submodule--helper init \
$quiet \
-- \
"$@"
}
#
# Unregister submodules from .git/config and remove their work tree
#
cmd_deinit()
{
# parse $args after "submodule ... deinit".
while test $# -ne 0
do
case "$1" in
-f|--force)
force=$1
;;
-q|--quiet)
quiet=$1
;;
--all)
all=$1
;;
--)
shift
break
;;
-*)
usage
;;
*)
break
;;
esac
shift
done
git ${wt_prefix:+-C "$wt_prefix"} submodule--helper deinit \
$quiet \
$force \
$all \
-- \
"$@"
}
#
# Update each submodule path to correct revision, using clone and checkout as needed
#
# $@ = requested paths (default to all)
#
cmd_update()
{
# parse $args after "submodule ... update".
while test $# -ne 0
do
case "$1" in
-q|--quiet)
quiet=$1
;;
-v|--verbose)
quiet=
;;
--progress)
progress=$1
;;
-i|--init)
init=$1
;;
--require-init)
require_init=$1
;;
--remote)
remote=$1
;;
-N|--no-fetch)
no_fetch=$1
;;
-f|--force)
force=$1
;;
-r|--rebase)
rebase=$1
;;
--ref-format)
case "$2" in '') usage ;; esac
ref_format="--ref-format=$2"
shift
;;
--ref-format=*)
ref_format="$1"
;;
--reference)
case "$2" in '') usage ;; esac
reference="--reference=$2"
shift
;;
--reference=*)
reference="$1"
;;
--dissociate)
dissociate=$1
;;
-m|--merge)
merge=$1
;;
--recursive)
recursive=$1
;;
--checkout)
checkout=$1
;;
--recommend-shallow|--no-recommend-shallow)
recommend_shallow=$1
;;
--depth)
case "$2" in '') usage ;; esac
depth="--depth=$2"
shift
;;
--depth=*)
depth="$1"
;;
-j|--jobs)
case "$2" in '') usage ;; esac
jobs="--jobs=$2"
shift
;;
-j*|--jobs=*)
jobs="$1"
;;
--single-branch|--no-single-branch)
single_branch=$1
;;
--filter)
case "$2" in '') usage ;; esac
filter="--filter=$2"
shift
;;
--filter=*)
filter="$1"
;;
--)
shift
break
;;
-*)
usage
;;
*)
break
;;
esac
shift
done
git ${wt_prefix:+-C "$wt_prefix"} submodule--helper update \
$quiet \
$force \
$progress \
$remote \
$recursive \
$init \
$no_fetch \
$rebase \
$merge \
$checkout \
${ref_format:+"$ref_format"} \
${reference:+"$reference"} \
$dissociate \
${depth:+"$depth"} \
$require_init \
$single_branch \
$recommend_shallow \
$jobs \
$filter \
-- \
"$@"
}
#
# Configures a submodule's default branch
#
# $@ = requested path
#
cmd_set_branch() {
# parse $args after "submodule ... set-branch".
while test $# -ne 0
do
case "$1" in
-q|--quiet)
# we don't do anything with this but we need to accept it
;;
-d|--default)
default=$1
;;
-b|--branch)
case "$2" in '') usage ;; esac
branch="--branch=$2"
shift
;;
-b*|--branch=*)
branch="$1"
;;
--)
shift
break
;;
-*)
usage
;;
*)
break
;;
esac
shift
done
git ${wt_prefix:+-C "$wt_prefix"} submodule--helper set-branch \
$quiet \
${branch:+"$branch"} \
$default \
-- \
"$@"
}
#
# Configures a submodule's remote url
#
# $@ = requested path, requested url
#
cmd_set_url() {
# parse $args after "submodule ... set-url".
while test $# -ne 0
do
case "$1" in
-q|--quiet)
quiet=$1
;;
--)
shift
break
;;
-*)
usage
;;
*)
break
;;
esac
shift
done
git ${wt_prefix:+-C "$wt_prefix"} submodule--helper set-url \
$quiet \
-- \
"$@"
}
#
# Show commit summary for submodules in index or working tree
#
# If '--cached' is given, show summary between index and given commit,
# or between working tree and given commit
#
# $@ = [commit (default 'HEAD'),] requested paths (default all)
#
cmd_summary() {
# parse $args after "submodule ... summary".
while test $# -ne 0
do
case "$1" in
--cached)
cached=$1
;;
--files)
files=$1
;;
--for-status)
for_status=$1
;;
-n|--summary-limit)
case "$2" in '') usage ;; esac
summary_limit="--summary-limit=$2"
shift
;;
-n*|--summary-limit=*)
summary_limit="$1"
;;
--)
shift
break
;;
-*)
usage
;;
*)
break
;;
esac
shift
done
git ${wt_prefix:+-C "$wt_prefix"} submodule--helper summary \
$files \
$cached \
$for_status \
${summary_limit:+"$summary_limit"} \
-- \
"$@"
}
#
# List all submodules, prefixed with:
# - submodule not initialized
# + different revision checked out
#
# If --cached was specified the revision in the index will be printed
# instead of the currently checked out revision.
#
# $@ = requested paths (default to all)
#
cmd_status()
{
# parse $args after "submodule ... status".
while test $# -ne 0
do
case "$1" in
-q|--quiet)
quiet=$1
;;
--cached)
cached=$1
;;
--recursive)
recursive=$1
;;
--)
shift
break
;;
-*)
usage
;;
*)
break
;;
esac
shift
done
git ${wt_prefix:+-C "$wt_prefix"} submodule--helper status \
$quiet \
$cached \
$recursive \
-- \
"$@"
}
#
# Sync remote urls for submodules
# This makes the value for remote.$remote.url match the value
# specified in .gitmodules.
#
cmd_sync()
{
# parse $args after "submodule ... sync".
while test $# -ne 0
do
case "$1" in
-q|--quiet)
quiet=$1
shift
;;
--recursive)
recursive=$1
shift
;;
--)
shift
break
;;
-*)
usage
;;
*)
break
;;
esac
done
git ${wt_prefix:+-C "$wt_prefix"} submodule--helper sync \
$quiet \
$recursive \
-- \
"$@"
}
cmd_absorbgitdirs()
{
git ${wt_prefix:+-C "$wt_prefix"} submodule--helper absorbgitdirs "$@"
}
# This loop parses the command line arguments to find the
# subcommand name to dispatch. Parsing of the subcommand specific
# options are primarily done by the subcommand implementations.
# Subcommand specific options such as --branch and --cached are
# parsed here as well, for backward compatibility.
while test $# != 0 && test -z "$command"
do
case "$1" in
add | foreach | init | deinit | update | set-branch | set-url | status | summary | sync | absorbgitdirs)
command=$1
;;
-q|--quiet)
quiet=$1
;;
--cached)
cached=$1
;;
--)
break
;;
-*)
usage
;;
*)
break
;;
esac
shift
done
# No command word defaults to "status"
if test -z "$command"
then
if test $# = 0
then
command=status
else
usage
fi
fi
# "--cached" is accepted only by "status" and "summary"
if test -n "$cached" && test "$command" != status && test "$command" != summary
then
usage
fi
"cmd_$(echo $command | sed -e s/-/_/g)" "$@"

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,8 @@
#!/bin/sh
# Placeholder for the deprecated `git update` command
echo 'Warning! `git update` has been deprecated;' >&2
echo 'Please use `git update-git-for-windows` instead.' >&2
exec git update-git-for-windows "$@"

View File

@@ -0,0 +1,196 @@
#!/bin/sh
#
# This program launch a web browser on the html page
# describing a git command.
#
# Copyright (c) 2007 Christian Couder
# Copyright (c) 2006 Theodore Y. Ts'o
#
# This file is heavily stolen from git-mergetool.sh, by
# Theodore Y. Ts'o (thanks) that is:
#
# Copyright (c) 2006 Theodore Y. Ts'o
#
# This file is licensed under the GPL v2, or a later version
# at the discretion of Junio C Hamano or any other official
# git maintainer.
#
USAGE='[--browser=browser|--tool=browser] [--config=conf.var] url/file ...'
# This must be capable of running outside of git directory, so
# the vanilla git-sh-setup should not be used.
NONGIT_OK=Yes
. git-sh-setup
valid_custom_tool()
{
browser_cmd="$(git config "browser.$1.cmd")"
test -n "$browser_cmd"
}
valid_tool() {
case "$1" in
firefox | iceweasel | seamonkey | iceape | \
chrome | google-chrome | chromium | chromium-browser | \
konqueror | opera | w3m | elinks | links | lynx | dillo | open | \
start | cygstart | xdg-open)
;; # happy
*)
valid_custom_tool "$1" || return 1
;;
esac
}
init_browser_path() {
browser_path=$(git config "browser.$1.path")
if test -z "$browser_path" &&
test "$1" = chromium &&
type chromium-browser >/dev/null 2>&1
then
browser_path=chromium-browser
fi
: ${browser_path:="$1"}
}
while test $# != 0
do
case "$1" in
-b|--browser*|-t|--tool*)
case "$#,$1" in
*,*=*)
browser=$(expr "z$1" : 'z-[^=]*=\(.*\)')
;;
1,*)
usage ;;
*)
browser="$2"
shift ;;
esac
;;
-c|--config*)
case "$#,$1" in
*,*=*)
conf=$(expr "z$1" : 'z-[^=]*=\(.*\)')
;;
1,*)
usage ;;
*)
conf="$2"
shift ;;
esac
;;
--)
break
;;
-*)
usage
;;
*)
break
;;
esac
shift
done
test $# = 0 && usage
if test -z "$browser"
then
for opt in "$conf" "web.browser"
do
test -z "$opt" && continue
browser="$(git config $opt)"
test -z "$browser" || break
done
if test -n "$browser" && ! valid_tool "$browser"; then
echo >&2 "git config option $opt set to unknown browser: $browser"
echo >&2 "Resetting to default..."
unset browser
fi
fi
if test -z "$browser" ; then
if test -n "$DISPLAY"; then
browser_candidates="firefox iceweasel google-chrome chrome chromium chromium-browser konqueror opera seamonkey iceape w3m elinks links lynx dillo xdg-open"
if test "$KDE_FULL_SESSION" = "true"; then
browser_candidates="konqueror $browser_candidates"
fi
else
browser_candidates="w3m elinks links lynx"
fi
# SECURITYSESSIONID indicates an OS X GUI login session
if test -n "$SECURITYSESSIONID" || test -n "$TERM_PROGRAM"
then
browser_candidates="open $browser_candidates"
fi
# /bin/start indicates MinGW
if test -x /bin/start; then
browser_candidates="start $browser_candidates"
fi
# /usr/bin/cygstart indicates Cygwin
if test -x /usr/bin/cygstart; then
browser_candidates="cygstart $browser_candidates"
fi
for i in $browser_candidates; do
init_browser_path $i
if type "$browser_path" > /dev/null 2>&1; then
browser=$i
break
fi
done
test -z "$browser" && die "No known browser available."
else
valid_tool "$browser" || die "Unknown browser '$browser'."
init_browser_path "$browser"
if test -z "$browser_cmd" && ! type "$browser_path" > /dev/null 2>&1; then
die "The browser $browser is not available as '$browser_path'."
fi
fi
case "$browser" in
firefox|iceweasel|seamonkey|iceape)
# Check version because firefox < 2.0 does not support "-new-tab".
vers=$(expr "$($browser_path -version)" : '.* \([0-9][0-9]*\)\..*')
NEWTAB='-new-tab'
test "$vers" -lt 2 && NEWTAB=''
"$browser_path" $NEWTAB "$@" &
;;
google-chrome|chrome|chromium|chromium-browser)
# No need to specify newTab. It's default in chromium
"$browser_path" "$@" &
;;
konqueror)
case "$(basename "$browser_path")" in
konqueror)
# It's simpler to use kfmclient to open a new tab in konqueror.
browser_path="$(echo "$browser_path" | sed -e 's/konqueror$/kfmclient/')"
type "$browser_path" > /dev/null 2>&1 || die "No '$browser_path' found."
"$browser_path" newTab "$@" &
;;
kfmclient)
"$browser_path" newTab "$@" &
;;
*)
"$browser_path" "$@" &
;;
esac
;;
w3m|elinks|links|lynx|open|cygstart|xdg-open)
"$browser_path" "$@"
;;
start)
exec "$browser_path" '"web-browse"' "$@"
;;
opera|dillo)
"$browser_path" "$@" &
;;
*)
if test -n "$browser_cmd"; then
( eval "$browser_cmd \"\$@\"" )
fi
;;
esac

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Some files were not shown because too many files have changed in this diff Show More