Rewrite "git-frotz" to "git frotz"

This uses the remove-dashes target to replace "git-frotz" to "git frotz".

Signed-off-by: Junio C Hamano <gitster@pobox.com>
maint
Junio C Hamano 2007-07-02 22:52:14 -07:00
parent 36e5e70e0f
commit 5be60078c9
142 changed files with 2094 additions and 2094 deletions

View File

@ -10,7 +10,7 @@ USAGE='<refname> <target directory>'
export GIT_DIR export GIT_DIR


test -z "$mandir" && usage test -z "$mandir" && usage
if ! git-rev-parse --verify "$head^0" >/dev/null; then if ! git rev-parse --verify "$head^0" >/dev/null; then
echo >&2 "head: $head does not exist in the current repository" echo >&2 "head: $head does not exist in the current repository"
usage usage
fi fi
@ -18,12 +18,12 @@ fi
GIT_INDEX_FILE=`pwd`/.quick-doc.index GIT_INDEX_FILE=`pwd`/.quick-doc.index
export GIT_INDEX_FILE export GIT_INDEX_FILE
rm -f "$GIT_INDEX_FILE" rm -f "$GIT_INDEX_FILE"
git-read-tree $head git read-tree $head
git-checkout-index -a -f --prefix="$mandir"/ git checkout-index -a -f --prefix="$mandir"/


if test -n "$GZ"; then if test -n "$GZ"; then
cd "$mandir" cd "$mandir"
for i in `git-ls-tree -r --name-only $head` for i in `git ls-tree -r --name-only $head`
do do
gzip < $i > $i.gz && rm $i gzip < $i > $i.gz && rm $i
done done

View File

@ -30,8 +30,8 @@ notbare|"")
esac esac


test "true" != "$pack_refs" || test "true" != "$pack_refs" ||
git-pack-refs --prune && git pack-refs --prune &&
git-reflog expire --all && git reflog expire --all &&
git-repack -a -d -l && git-repack -a -d -l &&
$no_prune git-prune && $no_prune git prune &&
git-rerere gc || exit git rerere gc || exit

View File

@ -17,8 +17,8 @@ dropheads() {
"$GIT_DIR/LAST_MERGE" || exit 1 "$GIT_DIR/LAST_MERGE" || exit 1
} }


head=$(git-rev-parse --verify "$1"^0) && head=$(git rev-parse --verify "$1"^0) &&
merge=$(git-rev-parse --verify "$2"^0) && merge=$(git rev-parse --verify "$2"^0) &&
merge_name="$2" && merge_name="$2" &&
merge_msg="$3" || usage merge_msg="$3" || usage


@ -34,7 +34,7 @@ dropheads
echo $head > "$GIT_DIR"/ORIG_HEAD echo $head > "$GIT_DIR"/ORIG_HEAD
echo $merge > "$GIT_DIR"/LAST_MERGE echo $merge > "$GIT_DIR"/LAST_MERGE


common=$(git-merge-base $head $merge) common=$(git merge-base $head $merge)
if [ -z "$common" ]; then if [ -z "$common" ]; then
die "Unable to find common commit between" $merge $head die "Unable to find common commit between" $merge $head
fi fi
@ -46,11 +46,11 @@ case "$common" in
exit 0 exit 0
;; ;;
"$head") "$head")
echo "Updating $(git-rev-parse --short $head)..$(git-rev-parse --short $merge)" echo "Updating $(git rev-parse --short $head)..$(git rev-parse --short $merge)"
git-read-tree -u -m $head $merge || exit 1 git read-tree -u -m $head $merge || exit 1
git-update-ref -m "resolve $merge_name: Fast forward" \ git update-ref -m "resolve $merge_name: Fast forward" \
HEAD "$merge" "$head" HEAD "$merge" "$head"
git-diff-tree -p $head $merge | git-apply --stat git diff-tree -p $head $merge | git apply --stat
dropheads dropheads
exit 0 exit 0
;; ;;
@ -62,7 +62,7 @@ git var GIT_COMMITTER_IDENT >/dev/null || exit
# Find an optimum merge base if there are more than one candidates. # Find an optimum merge base if there are more than one candidates.
LF=' LF='
' '
common=$(git-merge-base -a $head $merge) common=$(git merge-base -a $head $merge)
case "$common" in case "$common" in
?*"$LF"?*) ?*"$LF"?*)
echo "Trying to find the optimum merge base." echo "Trying to find the optimum merge base."
@ -72,10 +72,10 @@ case "$common" in
for c in $common for c in $common
do do
rm -f $G rm -f $G
GIT_INDEX_FILE=$G git-read-tree -m $c $head $merge \ GIT_INDEX_FILE=$G git read-tree -m $c $head $merge \
2>/dev/null || continue 2>/dev/null || continue
# Count the paths that are unmerged. # Count the paths that are unmerged.
cnt=`GIT_INDEX_FILE=$G git-ls-files --unmerged | wc -l` cnt=`GIT_INDEX_FILE=$G git ls-files --unmerged | wc -l`
if test $best_cnt -le 0 -o $cnt -le $best_cnt if test $best_cnt -le 0 -o $cnt -le $best_cnt
then then
best=$c best=$c
@ -92,9 +92,9 @@ case "$common" in
esac esac


echo "Trying to merge $merge into $head using $common." echo "Trying to merge $merge into $head using $common."
git-update-index --refresh 2>/dev/null git update-index --refresh 2>/dev/null
git-read-tree -u -m $common $head $merge || exit 1 git read-tree -u -m $common $head $merge || exit 1
result_tree=$(git-write-tree 2> /dev/null) result_tree=$(git write-tree 2> /dev/null)
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
echo "Simple merge failed, trying Automatic merge" echo "Simple merge failed, trying Automatic merge"
git-merge-index -o git-merge-one-file -a git-merge-index -o git-merge-one-file -a
@ -102,11 +102,11 @@ if [ $? -ne 0 ]; then
echo $merge > "$GIT_DIR"/MERGE_HEAD echo $merge > "$GIT_DIR"/MERGE_HEAD
die "Automatic merge failed, fix up by hand" die "Automatic merge failed, fix up by hand"
fi fi
result_tree=$(git-write-tree) || exit 1 result_tree=$(git write-tree) || exit 1
fi fi
result_commit=$(echo "$merge_msg" | git-commit-tree $result_tree -p $head -p $merge) result_commit=$(echo "$merge_msg" | git commit-tree $result_tree -p $head -p $merge)
echo "Committed merge $result_commit" echo "Committed merge $result_commit"
git-update-ref -m "resolve $merge_name: In-index merge" \ git update-ref -m "resolve $merge_name: In-index merge" \
HEAD "$result_commit" "$head" HEAD "$result_commit" "$head"
git-diff-tree -p $head $result_commit | git-apply --stat git diff-tree -p $head $result_commit | git apply --stat
dropheads dropheads

View File

@ -26,8 +26,8 @@ if [ -d "$GIT_DIR"/remotes ]; then
mv "$GIT_DIR"/remotes "$GIT_DIR"/remotes.old mv "$GIT_DIR"/remotes "$GIT_DIR"/remotes.old
fi ;; fi ;;
*) *)
echo "git-config $key "$value" $regex" echo "git config $key "$value" $regex"
git-config $key "$value" $regex || error=1 ;; git config $key "$value" $regex || error=1 ;;
esac esac
done done
fi fi

View File

@ -60,17 +60,17 @@ fall_back_3way () {
mkdir "$dotest/patch-merge-tmp-dir" mkdir "$dotest/patch-merge-tmp-dir"


# First see if the patch records the index info that we can use. # First see if the patch records the index info that we can use.
git-apply -z --index-info "$dotest/patch" \ git apply -z --index-info "$dotest/patch" \
>"$dotest/patch-merge-index-info" && >"$dotest/patch-merge-index-info" &&
GIT_INDEX_FILE="$dotest/patch-merge-tmp-index" \ GIT_INDEX_FILE="$dotest/patch-merge-tmp-index" \
git-update-index -z --index-info <"$dotest/patch-merge-index-info" && git update-index -z --index-info <"$dotest/patch-merge-index-info" &&
GIT_INDEX_FILE="$dotest/patch-merge-tmp-index" \ GIT_INDEX_FILE="$dotest/patch-merge-tmp-index" \
git-write-tree >"$dotest/patch-merge-base+" || git write-tree >"$dotest/patch-merge-base+" ||
cannot_fallback "Repository lacks necessary blobs to fall back on 3-way merge." cannot_fallback "Repository lacks necessary blobs to fall back on 3-way merge."


echo Using index info to reconstruct a base tree... echo Using index info to reconstruct a base tree...
if GIT_INDEX_FILE="$dotest/patch-merge-tmp-index" \ if GIT_INDEX_FILE="$dotest/patch-merge-tmp-index" \
git-apply $binary --cached <"$dotest/patch" git apply $binary --cached <"$dotest/patch"
then then
mv "$dotest/patch-merge-base+" "$dotest/patch-merge-base" mv "$dotest/patch-merge-base+" "$dotest/patch-merge-base"
mv "$dotest/patch-merge-tmp-index" "$dotest/patch-merge-index" mv "$dotest/patch-merge-tmp-index" "$dotest/patch-merge-index"
@ -80,7 +80,7 @@ It does not apply to blobs recorded in its index."
fi fi


test -f "$dotest/patch-merge-index" && test -f "$dotest/patch-merge-index" &&
his_tree=$(GIT_INDEX_FILE="$dotest/patch-merge-index" git-write-tree) && his_tree=$(GIT_INDEX_FILE="$dotest/patch-merge-index" git write-tree) &&
orig_tree=$(cat "$dotest/patch-merge-base") && orig_tree=$(cat "$dotest/patch-merge-base") &&
rm -fr "$dotest"/patch-merge-* || exit 1 rm -fr "$dotest"/patch-merge-* || exit 1


@ -97,7 +97,7 @@ It does not apply to blobs recorded in its index."
git-merge-recursive $orig_tree -- HEAD $his_tree || { git-merge-recursive $orig_tree -- HEAD $his_tree || {
if test -d "$GIT_DIR/rr-cache" if test -d "$GIT_DIR/rr-cache"
then then
git-rerere git rerere
fi fi
echo Failed to merge in the changes. echo Failed to merge in the changes.
exit 1 exit 1
@ -198,7 +198,7 @@ else
# Start afresh. # Start afresh.
mkdir -p "$dotest" || exit mkdir -p "$dotest" || exit


git-mailsplit -d"$prec" -o"$dotest" -b -- "$@" > "$dotest/last" || { git mailsplit -d"$prec" -o"$dotest" -b -- "$@" > "$dotest/last" || {
rm -fr "$dotest" rm -fr "$dotest"
exit 1 exit 1
} }
@ -216,7 +216,7 @@ fi


case "$resolved" in case "$resolved" in
'') '')
files=$(git-diff-index --cached --name-only HEAD) || exit files=$(git diff-index --cached --name-only HEAD) || exit
if [ "$files" ]; then if [ "$files" ]; then
echo "Dirty index: cannot apply patches (dirty: $files)" >&2 echo "Dirty index: cannot apply patches (dirty: $files)" >&2
exit 1 exit 1
@ -254,7 +254,7 @@ if test "$skip" = t
then then
if test -d "$GIT_DIR/rr-cache" if test -d "$GIT_DIR/rr-cache"
then then
git-rerere clear git rerere clear
fi fi
this=`expr "$this" + 1` this=`expr "$this" + 1`
resume= resume=
@ -287,14 +287,14 @@ do
# by the user, or the user can tell us to do so by --resolved flag. # by the user, or the user can tell us to do so by --resolved flag.
case "$resume" in case "$resume" in
'') '')
git-mailinfo $keep $utf8 "$dotest/msg" "$dotest/patch" \ git mailinfo $keep $utf8 "$dotest/msg" "$dotest/patch" \
<"$dotest/$msgnum" >"$dotest/info" || <"$dotest/$msgnum" >"$dotest/info" ||
stop_here $this stop_here $this
test -s $dotest/patch || { test -s $dotest/patch || {
echo "Patch is empty. Was it split wrong?" echo "Patch is empty. Was it split wrong?"
stop_here $this stop_here $this
} }
git-stripspace < "$dotest/msg" > "$dotest/msg-clean" git stripspace < "$dotest/msg" > "$dotest/msg-clean"
;; ;;
esac esac


@ -347,7 +347,7 @@ do
case "$resolved$interactive" in case "$resolved$interactive" in
tt) tt)
# This is used only for interactive view option. # This is used only for interactive view option.
git-diff-index -p --cached HEAD >"$dotest/patch" git diff-index -p --cached HEAD >"$dotest/patch"
;; ;;
esac esac
esac esac
@ -399,7 +399,7 @@ do


case "$resolved" in case "$resolved" in
'') '')
git-apply $git_apply_opt $binary --index "$dotest/patch" git apply $git_apply_opt $binary --index "$dotest/patch"
apply_status=$? apply_status=$?
;; ;;
t) t)
@ -408,11 +408,11 @@ do
# trust what the user has in the index file and the # trust what the user has in the index file and the
# working tree. # working tree.
resolved= resolved=
git-diff-index --quiet --cached HEAD && { git diff-index --quiet --cached HEAD && {
echo "No changes - did you forget to use 'git add'?" echo "No changes - did you forget to use 'git add'?"
stop_here_user_resolve $this stop_here_user_resolve $this
} }
unmerged=$(git-ls-files -u) unmerged=$(git ls-files -u)
if test -n "$unmerged" if test -n "$unmerged"
then then
echo "You still have unmerged paths in your index" echo "You still have unmerged paths in your index"
@ -433,7 +433,7 @@ do
then then
# Applying the patch to an earlier tree and merging the # Applying the patch to an earlier tree and merging the
# result may have produced the same tree as ours. # result may have produced the same tree as ours.
git-diff-index --quiet --cached HEAD && { git diff-index --quiet --cached HEAD && {
echo No changes -- Patch already applied. echo No changes -- Patch already applied.
go_next go_next
continue continue
@ -453,12 +453,12 @@ do
"$GIT_DIR"/hooks/pre-applypatch || stop_here $this "$GIT_DIR"/hooks/pre-applypatch || stop_here $this
fi fi


tree=$(git-write-tree) && tree=$(git write-tree) &&
echo Wrote tree $tree && echo Wrote tree $tree &&
parent=$(git-rev-parse --verify HEAD) && parent=$(git rev-parse --verify HEAD) &&
commit=$(git-commit-tree $tree -p $parent <"$dotest/final-commit") && commit=$(git commit-tree $tree -p $parent <"$dotest/final-commit") &&
echo Committed: $commit && echo Committed: $commit &&
git-update-ref -m "$GIT_REFLOG_ACTION: $SUBJECT" HEAD $commit $parent || git update-ref -m "$GIT_REFLOG_ACTION: $SUBJECT" HEAD $commit $parent ||
stop_here $this stop_here $this


if test -x "$GIT_DIR"/hooks/post-applypatch if test -x "$GIT_DIR"/hooks/post-applypatch

View File

@ -56,7 +56,7 @@ bisect_start() {
# Verify HEAD. If we were bisecting before this, reset to the # Verify HEAD. If we were bisecting before this, reset to the
# top-of-line master first! # top-of-line master first!
# #
head=$(GIT_DIR="$GIT_DIR" git-symbolic-ref HEAD) || head=$(GIT_DIR="$GIT_DIR" git symbolic-ref HEAD) ||
die "Bad HEAD - I need a symbolic ref" die "Bad HEAD - I need a symbolic ref"
case "$head" in case "$head" in
refs/heads/bisect) refs/heads/bisect)
@ -99,7 +99,7 @@ bisect_start() {
break break
;; ;;
*) *)
rev=$(git-rev-parse --verify "$arg^{commit}" 2>/dev/null) || { rev=$(git rev-parse --verify "$arg^{commit}" 2>/dev/null) || {
test $has_double_dash -eq 1 && test $has_double_dash -eq 1 &&
die "'$arg' does not appear to be a valid revision" die "'$arg' does not appear to be a valid revision"
break break
@ -124,9 +124,9 @@ bisect_bad() {
bisect_autostart bisect_autostart
case "$#" in case "$#" in
0) 0)
rev=$(git-rev-parse --verify HEAD) ;; rev=$(git rev-parse --verify HEAD) ;;
1) 1)
rev=$(git-rev-parse --verify "$1^{commit}") ;; rev=$(git rev-parse --verify "$1^{commit}") ;;
*) *)
usage ;; usage ;;
esac || exit esac || exit
@ -138,19 +138,19 @@ bisect_bad() {
bisect_write_bad() { bisect_write_bad() {
rev="$1" rev="$1"
echo "$rev" >"$GIT_DIR/refs/bisect/bad" echo "$rev" >"$GIT_DIR/refs/bisect/bad"
echo "# bad: "$(git-show-branch $rev) >>"$GIT_DIR/BISECT_LOG" echo "# bad: "$(git show-branch $rev) >>"$GIT_DIR/BISECT_LOG"
} }


bisect_good() { bisect_good() {
bisect_autostart bisect_autostart
case "$#" in case "$#" in
0) revs=$(git-rev-parse --verify HEAD) || exit ;; 0) revs=$(git rev-parse --verify HEAD) || exit ;;
*) revs=$(git-rev-parse --revs-only --no-flags "$@") && *) revs=$(git rev-parse --revs-only --no-flags "$@") &&
test '' != "$revs" || die "Bad rev input: $@" ;; test '' != "$revs" || die "Bad rev input: $@" ;;
esac esac
for rev in $revs for rev in $revs
do do
rev=$(git-rev-parse --verify "$rev^{commit}") || exit rev=$(git rev-parse --verify "$rev^{commit}") || exit
bisect_write_good "$rev" bisect_write_good "$rev"
echo "git-bisect good $rev" >>"$GIT_DIR/BISECT_LOG" echo "git-bisect good $rev" >>"$GIT_DIR/BISECT_LOG"


@ -161,7 +161,7 @@ bisect_good() {
bisect_write_good() { bisect_write_good() {
rev="$1" rev="$1"
echo "$rev" >"$GIT_DIR/refs/bisect/good-$rev" echo "$rev" >"$GIT_DIR/refs/bisect/good-$rev"
echo "# good: "$(git-show-branch $rev) >>"$GIT_DIR/BISECT_LOG" echo "# good: "$(git show-branch $rev) >>"$GIT_DIR/BISECT_LOG"
} }


bisect_next_check() { bisect_next_check() {
@ -211,10 +211,10 @@ bisect_next() {
bisect_autostart bisect_autostart
bisect_next_check good bisect_next_check good


bad=$(git-rev-parse --verify refs/bisect/bad) && bad=$(git rev-parse --verify refs/bisect/bad) &&
good=$(git for-each-ref --format='^%(objectname)' \ good=$(git for-each-ref --format='^%(objectname)' \
"refs/bisect/good-*" | tr '[\012]' ' ') && "refs/bisect/good-*" | tr '[\012]' ' ') &&
eval="git-rev-list --bisect-vars $good $bad --" && eval="git rev-list --bisect-vars $good $bad --" &&
eval="$eval $(cat "$GIT_DIR/BISECT_NAMES")" && eval="$eval $(cat "$GIT_DIR/BISECT_NAMES")" &&
eval=$(eval "$eval") && eval=$(eval "$eval") &&
eval "$eval" || exit eval "$eval" || exit
@ -225,7 +225,7 @@ bisect_next() {
fi fi
if [ "$bisect_rev" = "$bad" ]; then if [ "$bisect_rev" = "$bad" ]; then
echo "$bisect_rev is first bad commit" echo "$bisect_rev is first bad commit"
git-diff-tree --pretty $bisect_rev git diff-tree --pretty $bisect_rev
exit 0 exit 0
fi fi


@ -233,8 +233,8 @@ bisect_next() {
echo "$bisect_rev" >"$GIT_DIR/refs/heads/new-bisect" echo "$bisect_rev" >"$GIT_DIR/refs/heads/new-bisect"
git checkout -q new-bisect || exit git checkout -q new-bisect || exit
mv "$GIT_DIR/refs/heads/new-bisect" "$GIT_DIR/refs/heads/bisect" && mv "$GIT_DIR/refs/heads/new-bisect" "$GIT_DIR/refs/heads/bisect" &&
GIT_DIR="$GIT_DIR" git-symbolic-ref HEAD refs/heads/bisect GIT_DIR="$GIT_DIR" git symbolic-ref HEAD refs/heads/bisect
git-show-branch "$bisect_rev" git show-branch "$bisect_rev"
} }


bisect_visualize() { bisect_visualize() {
@ -250,7 +250,7 @@ bisect_reset() {
else else
branch=master branch=master
fi ;; fi ;;
1) git-show-ref --verify --quiet -- "refs/heads/$1" || { 1) git show-ref --verify --quiet -- "refs/heads/$1" || {
echo >&2 "$1 does not seem to be a valid branch" echo >&2 "$1 does not seem to be a valid branch"
exit 1 exit 1
} }
@ -288,12 +288,12 @@ bisect_replay () {
;; ;;
good) good)
echo "$rev" >"$GIT_DIR/refs/bisect/good-$rev" echo "$rev" >"$GIT_DIR/refs/bisect/good-$rev"
echo "# good: "$(git-show-branch $rev) >>"$GIT_DIR/BISECT_LOG" echo "# good: "$(git show-branch $rev) >>"$GIT_DIR/BISECT_LOG"
echo "git-bisect good $rev" >>"$GIT_DIR/BISECT_LOG" echo "git-bisect good $rev" >>"$GIT_DIR/BISECT_LOG"
;; ;;
bad) bad)
echo "$rev" >"$GIT_DIR/refs/bisect/bad" echo "$rev" >"$GIT_DIR/refs/bisect/bad"
echo "# bad: "$(git-show-branch $rev) >>"$GIT_DIR/BISECT_LOG" echo "# bad: "$(git show-branch $rev) >>"$GIT_DIR/BISECT_LOG"
echo "git-bisect bad $rev" >>"$GIT_DIR/BISECT_LOG" echo "git-bisect bad $rev" >>"$GIT_DIR/BISECT_LOG"
;; ;;
*) *)

View File

@ -6,8 +6,8 @@ SUBDIRECTORY_OK=Sometimes
require_work_tree require_work_tree


old_name=HEAD old_name=HEAD
old=$(git-rev-parse --verify $old_name 2>/dev/null) old=$(git rev-parse --verify $old_name 2>/dev/null)
oldbranch=$(git-symbolic-ref $old_name 2>/dev/null) oldbranch=$(git symbolic-ref $old_name 2>/dev/null)
new= new=
new_name= new_name=
force= force=
@ -29,9 +29,9 @@ while [ "$#" != "0" ]; do
shift shift
[ -z "$newbranch" ] && [ -z "$newbranch" ] &&
die "git checkout: -b needs a branch name" die "git checkout: -b needs a branch name"
git-show-ref --verify --quiet -- "refs/heads/$newbranch" && git show-ref --verify --quiet -- "refs/heads/$newbranch" &&
die "git checkout: branch $newbranch already exists" die "git checkout: branch $newbranch already exists"
git-check-ref-format "heads/$newbranch" || git check-ref-format "heads/$newbranch" ||
die "git checkout: we do not like '$newbranch' as a branch name." die "git checkout: we do not like '$newbranch' as a branch name."
;; ;;
"-l") "-l")
@ -57,20 +57,20 @@ while [ "$#" != "0" ]; do
usage usage
;; ;;
*) *)
if rev=$(git-rev-parse --verify "$arg^0" 2>/dev/null) if rev=$(git rev-parse --verify "$arg^0" 2>/dev/null)
then then
if [ -z "$rev" ]; then if [ -z "$rev" ]; then
echo "unknown flag $arg" echo "unknown flag $arg"
exit 1 exit 1
fi fi
new_name="$arg" new_name="$arg"
if git-show-ref --verify --quiet -- "refs/heads/$arg" if git show-ref --verify --quiet -- "refs/heads/$arg"
then then
rev=$(git-rev-parse --verify "refs/heads/$arg^0") rev=$(git rev-parse --verify "refs/heads/$arg^0")
branch="$arg" branch="$arg"
fi fi
new="$rev" new="$rev"
elif rev=$(git-rev-parse --verify "$arg^{tree}" 2>/dev/null) elif rev=$(git rev-parse --verify "$arg^{tree}" 2>/dev/null)
then then
# checking out selected paths from a tree-ish. # checking out selected paths from a tree-ish.
new="$rev" new="$rev"
@ -129,14 +129,14 @@ Did you intend to checkout '$@' which can not be resolved as commit?"
# from a specific tree-ish; note that this is for # from a specific tree-ish; note that this is for
# rescuing paths and is never meant to remove what # rescuing paths and is never meant to remove what
# is not in the named tree-ish. # is not in the named tree-ish.
git-ls-tree --full-name -r "$new" "$@" | git ls-tree --full-name -r "$new" "$@" |
git-update-index --index-info || exit $? git update-index --index-info || exit $?
fi fi


# Make sure the request is about existing paths. # Make sure the request is about existing paths.
git-ls-files --error-unmatch -- "$@" >/dev/null || exit git ls-files --error-unmatch -- "$@" >/dev/null || exit
git-ls-files -- "$@" | git ls-files -- "$@" |
git-checkout-index -f -u --stdin git checkout-index -f -u --stdin
exit $? exit $?
else else
# Make sure we did not fall back on $arg^{tree} codepath # Make sure we did not fall back on $arg^{tree} codepath
@ -144,7 +144,7 @@ else
# but switching branches. # but switching branches.
if test '' != "$new" if test '' != "$new"
then then
git-rev-parse --verify "$new^{commit}" >/dev/null 2>&1 || git rev-parse --verify "$new^{commit}" >/dev/null 2>&1 ||
die "Cannot switch branch to a non-commit." die "Cannot switch branch to a non-commit."
fi fi
fi fi
@ -200,10 +200,10 @@ fi


if [ "$force" ] if [ "$force" ]
then then
git-read-tree $v --reset -u $new git read-tree $v --reset -u $new
else else
git-update-index --refresh >/dev/null git update-index --refresh >/dev/null
merge_error=$(git-read-tree -m -u --exclude-per-directory=.gitignore $old $new 2>&1) || ( merge_error=$(git read-tree -m -u --exclude-per-directory=.gitignore $old $new 2>&1) || (
case "$merge" in case "$merge" in
'') '')
echo >&2 "$merge_error" echo >&2 "$merge_error"
@ -254,12 +254,12 @@ fi
# #
if [ "$?" -eq 0 ]; then if [ "$?" -eq 0 ]; then
if [ "$newbranch" ]; then if [ "$newbranch" ]; then
git-branch $track $newbranch_log "$newbranch" "$new_name" || exit git branch $track $newbranch_log "$newbranch" "$new_name" || exit
branch="$newbranch" branch="$newbranch"
fi fi
if test -n "$branch" if test -n "$branch"
then then
GIT_DIR="$GIT_DIR" git-symbolic-ref -m "checkout: moving to $branch" HEAD "refs/heads/$branch" GIT_DIR="$GIT_DIR" git symbolic-ref -m "checkout: moving to $branch" HEAD "refs/heads/$branch"
if test -n "$quiet" if test -n "$quiet"
then then
true # nothing true # nothing
@ -271,7 +271,7 @@ if [ "$?" -eq 0 ]; then
fi fi
elif test -n "$detached" elif test -n "$detached"
then then
git-update-ref --no-deref -m "checkout: moving to $arg" HEAD "$detached" || git update-ref --no-deref -m "checkout: moving to $arg" HEAD "$detached" ||
die "Cannot detach HEAD" die "Cannot detach HEAD"
if test -n "$detach_warn" if test -n "$detach_warn"
then then

View File

@ -20,7 +20,7 @@ require_work_tree
ignored= ignored=
ignoredonly= ignoredonly=
cleandir= cleandir=
disabled="`git-config --bool clean.requireForce`" disabled="`git config --bool clean.requireForce`"
rmf="rm -f --" rmf="rm -f --"
rmrf="rm -rf --" rmrf="rm -rf --"
rm_refuse="echo Not removing" rm_refuse="echo Not removing"
@ -83,7 +83,7 @@ if [ -z "$ignored" ]; then
fi fi
fi fi


git-ls-files --others --directory $excl ${excl_info:+"$excl_info"} -- "$@" | git ls-files --others --directory $excl ${excl_info:+"$excl_info"} -- "$@" |
while read -r file; do while read -r file; do
if [ -d "$file" -a ! -L "$file" ]; then if [ -d "$file" -a ! -L "$file" ]; then
if [ -z "$cleandir" ]; then if [ -z "$cleandir" ]; then

View File

@ -43,7 +43,7 @@ clone_dumb_http () {
clone_tmp="$GIT_DIR/clone-tmp" && clone_tmp="$GIT_DIR/clone-tmp" &&
mkdir -p "$clone_tmp" || exit 1 mkdir -p "$clone_tmp" || exit 1
if [ -n "$GIT_CURL_FTP_NO_EPSV" -o \ if [ -n "$GIT_CURL_FTP_NO_EPSV" -o \
"`git-config --bool http.noEPSV`" = true ]; then "`git config --bool http.noEPSV`" = true ]; then
curl_extra_args="${curl_extra_args} --disable-epsv" curl_extra_args="${curl_extra_args} --disable-epsv"
fi fi
http_fetch "$1/info/refs" "$clone_tmp/refs" || http_fetch "$1/info/refs" "$clone_tmp/refs" ||
@ -132,7 +132,7 @@ while
*/*) */*)
die "'$2' is not suitable for an origin name" die "'$2' is not suitable for an origin name"
esac esac
git-check-ref-format "heads/$2" || git check-ref-format "heads/$2" ||
die "'$2' is not suitable for a branch name" die "'$2' is not suitable for a branch name"
test -z "$origin_override" || test -z "$origin_override" ||
die "Do not give more than one --origin options." die "Do not give more than one --origin options."
@ -195,7 +195,7 @@ yes)
GIT_DIR="$D" ;; GIT_DIR="$D" ;;
*) *)
GIT_DIR="$D/.git" ;; GIT_DIR="$D/.git" ;;
esac && export GIT_DIR && git-init $quiet ${template+"$template"} || usage esac && export GIT_DIR && git init $quiet ${template+"$template"} || usage


if test -n "$reference" if test -n "$reference"
then then
@ -345,7 +345,7 @@ then
*) *)
continue ;; continue ;;
esac esac
git-update-ref -m "clone: from $repo" "$destname" "$sha1" "" git update-ref -m "clone: from $repo" "$destname" "$sha1" ""
done < "$GIT_DIR/CLONE_HEAD" done < "$GIT_DIR/CLONE_HEAD"
fi fi


@ -389,31 +389,31 @@ then
) )


# Upstream URL # Upstream URL
git-config remote."$origin".url "$repo" && git config remote."$origin".url "$repo" &&


# Set up the mappings to track the remote branches. # Set up the mappings to track the remote branches.
git-config remote."$origin".fetch \ git config remote."$origin".fetch \
"+refs/heads/*:$remote_top/*" '^$' && "+refs/heads/*:$remote_top/*" '^$' &&


# Write out remote.$origin config, and update our "$head_points_at". # Write out remote.$origin config, and update our "$head_points_at".
case "$head_points_at" in case "$head_points_at" in
?*) ?*)
# Local default branch # Local default branch
git-symbolic-ref HEAD "refs/heads/$head_points_at" && git symbolic-ref HEAD "refs/heads/$head_points_at" &&


# Tracking branch for the primary branch at the remote. # Tracking branch for the primary branch at the remote.
git-update-ref HEAD "$head_sha1" && git update-ref HEAD "$head_sha1" &&


rm -f "refs/remotes/$origin/HEAD" rm -f "refs/remotes/$origin/HEAD"
git-symbolic-ref "refs/remotes/$origin/HEAD" \ git symbolic-ref "refs/remotes/$origin/HEAD" \
"refs/remotes/$origin/$head_points_at" && "refs/remotes/$origin/$head_points_at" &&


git-config branch."$head_points_at".remote "$origin" && git config branch."$head_points_at".remote "$origin" &&
git-config branch."$head_points_at".merge "refs/heads/$head_points_at" git config branch."$head_points_at".merge "refs/heads/$head_points_at"
;; ;;
'') '')
# Source had detached HEAD pointing nowhere # Source had detached HEAD pointing nowhere
git-update-ref --no-deref HEAD "$head_sha1" && git update-ref --no-deref HEAD "$head_sha1" &&
rm -f "refs/remotes/$origin/HEAD" rm -f "refs/remotes/$origin/HEAD"
;; ;;
esac esac
@ -421,7 +421,7 @@ then
case "$no_checkout" in case "$no_checkout" in
'') '')
test "z$quiet" = z -a "z$no_progress" = z && v=-v || v= test "z$quiet" = z -a "z$no_progress" = z && v=-v || v=
git-read-tree -m -u $v HEAD HEAD git read-tree -m -u $v HEAD HEAD
esac esac
fi fi
rm -f "$GIT_DIR/CLONE_HEAD" "$GIT_DIR/REMOTE_HEAD" rm -f "$GIT_DIR/CLONE_HEAD" "$GIT_DIR/REMOTE_HEAD"

View File

@ -8,7 +8,7 @@ SUBDIRECTORY_OK=Yes
. git-sh-setup . git-sh-setup
require_work_tree require_work_tree


git-rev-parse --verify HEAD >/dev/null 2>&1 || initial_commit=t git rev-parse --verify HEAD >/dev/null 2>&1 || initial_commit=t


case "$0" in case "$0" in
*status) *status)
@ -53,7 +53,7 @@ run_status () {
t) color= ;; t) color= ;;
*) color=--nocolor ;; *) color=--nocolor ;;
esac esac
git-runstatus ${color} \ git runstatus ${color} \
${verbose:+--verbose} \ ${verbose:+--verbose} \
${amend:+--amend} \ ${amend:+--amend} \
${untracked_files:+--untracked} ${untracked_files:+--untracked}
@ -335,20 +335,20 @@ t,)
cd_to_toplevel && cd_to_toplevel &&
GIT_INDEX_FILE="$NEXT_INDEX" && GIT_INDEX_FILE="$NEXT_INDEX" &&
export GIT_INDEX_FILE && export GIT_INDEX_FILE &&
git-diff-files --name-only -z | git diff-files --name-only -z |
git-update-index --remove -z --stdin git update-index --remove -z --stdin
) || exit ) || exit
;; ;;
,t) ,t)
save_index && save_index &&
git-ls-files --error-unmatch -- "$@" >/dev/null || exit git ls-files --error-unmatch -- "$@" >/dev/null || exit


git-diff-files --name-only -z -- "$@" | git diff-files --name-only -z -- "$@" |
( (
cd_to_toplevel && cd_to_toplevel &&
GIT_INDEX_FILE="$NEXT_INDEX" && GIT_INDEX_FILE="$NEXT_INDEX" &&
export GIT_INDEX_FILE && export GIT_INDEX_FILE &&
git-update-index --remove -z --stdin git update-index --remove -z --stdin
) || exit ) || exit
;; ;;
,) ,)
@ -364,28 +364,28 @@ t,)
refuse_partial "Cannot do a partial commit during a merge." refuse_partial "Cannot do a partial commit during a merge."
fi fi
TMP_INDEX="$GIT_DIR/tmp-index$$" TMP_INDEX="$GIT_DIR/tmp-index$$"
commit_only=`git-ls-files --error-unmatch -- "$@"` || exit commit_only=`git ls-files --error-unmatch -- "$@"` || exit


# Build a temporary index and update the real index # Build a temporary index and update the real index
# the same way. # the same way.
if test -z "$initial_commit" if test -z "$initial_commit"
then then
GIT_INDEX_FILE="$THIS_INDEX" \ GIT_INDEX_FILE="$THIS_INDEX" \
git-read-tree --index-output="$TMP_INDEX" -i -m HEAD git read-tree --index-output="$TMP_INDEX" -i -m HEAD
else else
rm -f "$TMP_INDEX" rm -f "$TMP_INDEX"
fi || exit fi || exit


printf '%s\n' "$commit_only" | printf '%s\n' "$commit_only" |
GIT_INDEX_FILE="$TMP_INDEX" \ GIT_INDEX_FILE="$TMP_INDEX" \
git-update-index --add --remove --stdin && git update-index --add --remove --stdin &&


save_index && save_index &&
printf '%s\n' "$commit_only" | printf '%s\n' "$commit_only" |
( (
GIT_INDEX_FILE="$NEXT_INDEX" GIT_INDEX_FILE="$NEXT_INDEX"
export GIT_INDEX_FILE export GIT_INDEX_FILE
git-update-index --remove --stdin git update-index --remove --stdin
) || exit ) || exit
;; ;;
esac esac
@ -408,12 +408,12 @@ case "$status_only" in
t) t)
# This will silently fail in a read-only repository, which is # This will silently fail in a read-only repository, which is
# what we want. # what we want.
GIT_INDEX_FILE="$USE_INDEX" git-update-index -q --unmerged --refresh GIT_INDEX_FILE="$USE_INDEX" git update-index -q --unmerged --refresh
run_status run_status
exit $? exit $?
;; ;;
'') '')
GIT_INDEX_FILE="$USE_INDEX" git-update-index -q --refresh || exit GIT_INDEX_FILE="$USE_INDEX" git update-index -q --refresh || exit
;; ;;
esac esac


@ -454,7 +454,7 @@ then
elif test -f "$GIT_DIR/SQUASH_MSG" elif test -f "$GIT_DIR/SQUASH_MSG"
then then
cat "$GIT_DIR/SQUASH_MSG" cat "$GIT_DIR/SQUASH_MSG"
fi | git-stripspace >"$GIT_DIR"/COMMIT_EDITMSG fi | git stripspace >"$GIT_DIR"/COMMIT_EDITMSG


case "$signoff" in case "$signoff" in
t) t)
@ -505,12 +505,12 @@ then
PARENTS="-p HEAD "`sed -e 's/^/-p /' "$GIT_DIR/MERGE_HEAD"` PARENTS="-p HEAD "`sed -e 's/^/-p /' "$GIT_DIR/MERGE_HEAD"`
elif test -n "$amend"; then elif test -n "$amend"; then
rloga='commit (amend)' rloga='commit (amend)'
PARENTS=$(git-cat-file commit HEAD | PARENTS=$(git cat-file commit HEAD |
sed -n -e '/^$/q' -e 's/^parent /-p /p') sed -n -e '/^$/q' -e 's/^parent /-p /p')
fi fi
current="$(git-rev-parse --verify HEAD)" current="$(git rev-parse --verify HEAD)"
else else
if [ -z "$(git-ls-files)" ]; then if [ -z "$(git ls-files)" ]; then
echo >&2 'nothing to commit (use "git add file1 file2" to include for commit)' echo >&2 'nothing to commit (use "git add file1 file2" to include for commit)'
exit 1 exit 1
fi fi
@ -577,23 +577,23 @@ then
else else
cat "$GIT_DIR"/COMMIT_EDITMSG cat "$GIT_DIR"/COMMIT_EDITMSG
fi | fi |
git-stripspace >"$GIT_DIR"/COMMIT_MSG git stripspace >"$GIT_DIR"/COMMIT_MSG


if cnt=`grep -v -i '^Signed-off-by' "$GIT_DIR"/COMMIT_MSG | if cnt=`grep -v -i '^Signed-off-by' "$GIT_DIR"/COMMIT_MSG |
git-stripspace | git stripspace |
wc -l` && wc -l` &&
test 0 -lt $cnt test 0 -lt $cnt
then then
if test -z "$TMP_INDEX" if test -z "$TMP_INDEX"
then then
tree=$(GIT_INDEX_FILE="$USE_INDEX" git-write-tree) tree=$(GIT_INDEX_FILE="$USE_INDEX" git write-tree)
else else
tree=$(GIT_INDEX_FILE="$TMP_INDEX" git-write-tree) && tree=$(GIT_INDEX_FILE="$TMP_INDEX" git write-tree) &&
rm -f "$TMP_INDEX" rm -f "$TMP_INDEX"
fi && fi &&
commit=$(cat "$GIT_DIR"/COMMIT_MSG | git-commit-tree $tree $PARENTS) && commit=$(cat "$GIT_DIR"/COMMIT_MSG | git commit-tree $tree $PARENTS) &&
rlogm=$(sed -e 1q "$GIT_DIR"/COMMIT_MSG) && rlogm=$(sed -e 1q "$GIT_DIR"/COMMIT_MSG) &&
git-update-ref -m "$GIT_REFLOG_ACTION: $rlogm" HEAD $commit "$current" && git update-ref -m "$GIT_REFLOG_ACTION: $rlogm" HEAD $commit "$current" &&
rm -f -- "$GIT_DIR/MERGE_HEAD" "$GIT_DIR/MERGE_MSG" && rm -f -- "$GIT_DIR/MERGE_HEAD" "$GIT_DIR/MERGE_MSG" &&
if test -f "$NEXT_INDEX" if test -f "$NEXT_INDEX"
then then
@ -612,7 +612,7 @@ cd_to_toplevel


if test -d "$GIT_DIR/rr-cache" if test -d "$GIT_DIR/rr-cache"
then then
git-rerere git rerere
fi fi


if test "$ret" = 0 if test "$ret" = 0
@ -623,7 +623,7 @@ then
fi fi
if test -z "$quiet" if test -z "$quiet"
then then
commit=`git-diff-tree --always --shortstat --pretty="format:%h: %s"\ commit=`git diff-tree --always --shortstat --pretty="format:%h: %s"\
--summary --root HEAD --` --summary --root HEAD --`
echo "Created${initial_commit:+ initial} commit $commit" echo "Created${initial_commit:+ initial} commit $commit"
fi fi

View File

@ -117,20 +117,20 @@ append_fetch_head () {
test -n "$verbose" && flags="$flags$LF-v" test -n "$verbose" && flags="$flags$LF-v"
test -n "$force$single_force" && flags="$flags$LF-f" test -n "$force$single_force" && flags="$flags$LF-f"
GIT_REFLOG_ACTION="$GIT_REFLOG_ACTION" \ GIT_REFLOG_ACTION="$GIT_REFLOG_ACTION" \
git-fetch--tool $flags append-fetch-head "$@" git fetch--tool $flags append-fetch-head "$@"
} }


# updating the current HEAD with git-fetch in a bare # updating the current HEAD with git-fetch in a bare
# repository is always fine. # repository is always fine.
if test -z "$update_head_ok" && test $(is_bare_repository) = false if test -z "$update_head_ok" && test $(is_bare_repository) = false
then then
orig_head=$(git-rev-parse --verify HEAD 2>/dev/null) orig_head=$(git rev-parse --verify HEAD 2>/dev/null)
fi fi


# Allow --notags from remote.$1.tagopt # Allow --notags from remote.$1.tagopt
case "$tags$no_tags" in case "$tags$no_tags" in
'') '')
case "$(git-config --get "remote.$1.tagopt")" in case "$(git config --get "remote.$1.tagopt")" in
--no-tags) --no-tags)
no_tags=t ;; no_tags=t ;;
esac esac
@ -146,7 +146,7 @@ if test "$tags"
then then
taglist=`IFS=' ' && taglist=`IFS=' ' &&
echo "$ls_remote_result" | echo "$ls_remote_result" |
git-show-ref --exclude-existing=refs/tags/ | git show-ref --exclude-existing=refs/tags/ |
while read sha1 name while read sha1 name
do do
echo ".${name}:${name}" echo ".${name}:${name}"
@ -163,18 +163,18 @@ fi


fetch_all_at_once () { fetch_all_at_once () {


eval=$(echo "$1" | git-fetch--tool parse-reflist "-") eval=$(echo "$1" | git fetch--tool parse-reflist "-")
eval "$eval" eval "$eval"


( : subshell because we muck with IFS ( : subshell because we muck with IFS
IFS=" $LF" IFS=" $LF"
( (
if test "$remote" = . ; then if test "$remote" = . ; then
git-show-ref $rref || echo failed "$remote" git show-ref $rref || echo failed "$remote"
elif test -f "$remote" ; then elif test -f "$remote" ; then
test -n "$shallow_depth" && test -n "$shallow_depth" &&
die "shallow clone with bundle is not supported" die "shallow clone with bundle is not supported"
git-bundle unbundle "$remote" $rref || git bundle unbundle "$remote" $rref ||
echo failed "$remote" echo failed "$remote"
else else
if test -d "$remote" && if test -d "$remote" &&
@ -190,16 +190,16 @@ fetch_all_at_once () {
# connected to our repository's tips, in which # connected to our repository's tips, in which
# case we do not have to do any fetch. # case we do not have to do any fetch.
theirs=$(echo "$ls_remote_result" | \ theirs=$(echo "$ls_remote_result" | \
git-fetch--tool -s pick-rref "$rref" "-") && git fetch--tool -s pick-rref "$rref" "-") &&


# This will barf when $theirs reach an object that # This will barf when $theirs reach an object that
# we do not have in our repository. Otherwise, # we do not have in our repository. Otherwise,
# we already have everything the fetch would bring in. # we already have everything the fetch would bring in.
git-rev-list --objects $theirs --not --all \ git rev-list --objects $theirs --not --all \
>/dev/null 2>/dev/null >/dev/null 2>/dev/null
then then
echo "$ls_remote_result" | \ echo "$ls_remote_result" | \
git-fetch--tool pick-rref "$rref" "-" git fetch--tool pick-rref "$rref" "-"
else else
flags= flags=
case $verbose in case $verbose in
@ -218,7 +218,7 @@ fetch_all_at_once () {
test -n "$verbose" && flags="$flags -v" test -n "$verbose" && flags="$flags -v"
test -n "$force" && flags="$flags -f" test -n "$force" && flags="$flags -f"
GIT_REFLOG_ACTION="$GIT_REFLOG_ACTION" \ GIT_REFLOG_ACTION="$GIT_REFLOG_ACTION" \
git-fetch--tool $flags native-store \ git fetch--tool $flags native-store \
"$remote" "$remote_nick" "$refs" "$remote" "$remote_nick" "$refs"
) )
) || exit ) || exit
@ -265,13 +265,13 @@ fetch_per_ref () {
curl_extra_args="-k" curl_extra_args="-k"
fi fi
if [ -n "$GIT_CURL_FTP_NO_EPSV" -o \ if [ -n "$GIT_CURL_FTP_NO_EPSV" -o \
"`git-config --bool http.noEPSV`" = true ]; then "`git config --bool http.noEPSV`" = true ]; then
noepsv_opt="--disable-epsv" noepsv_opt="--disable-epsv"
fi fi


# Find $remote_name from ls-remote output. # Find $remote_name from ls-remote output.
head=$(echo "$ls_remote_result" | \ head=$(echo "$ls_remote_result" | \
git-fetch--tool -s pick-rref "$remote_name" "-") git fetch--tool -s pick-rref "$remote_name" "-")
expr "z$head" : "z$_x40\$" >/dev/null || expr "z$head" : "z$_x40\$" >/dev/null ||
die "No such ref $remote_name at $remote" die "No such ref $remote_name at $remote"
echo >&2 "Fetching $remote_name from $remote using $proto" echo >&2 "Fetching $remote_name from $remote using $proto"
@ -283,7 +283,7 @@ fetch_per_ref () {
die "shallow clone with rsync not supported" die "shallow clone with rsync not supported"
TMP_HEAD="$GIT_DIR/TMP_HEAD" TMP_HEAD="$GIT_DIR/TMP_HEAD"
rsync -L -q "$remote/$remote_name" "$TMP_HEAD" || exit 1 rsync -L -q "$remote/$remote_name" "$TMP_HEAD" || exit 1
head=$(git-rev-parse --verify TMP_HEAD) head=$(git rev-parse --verify TMP_HEAD)
rm -f "$TMP_HEAD" rm -f "$TMP_HEAD"
case "$quiet" in '') v=-v ;; *) v= ;; esac case "$quiet" in '') v=-v ;; *) v= ;; esac
test "$rsync_slurped_objects" || { test "$rsync_slurped_objects" || {
@ -342,10 +342,10 @@ case "$no_tags$tags" in
# using local tracking branch. # using local tracking branch.
taglist=$(IFS=' ' && taglist=$(IFS=' ' &&
echo "$ls_remote_result" | echo "$ls_remote_result" |
git-show-ref --exclude-existing=refs/tags/ | git show-ref --exclude-existing=refs/tags/ |
while read sha1 name while read sha1 name
do do
git-cat-file -t "$sha1" >/dev/null 2>&1 || continue git cat-file -t "$sha1" >/dev/null 2>&1 || continue
echo >&2 "Auto-following $name" echo >&2 "Auto-following $name"
echo ".${name}:${name}" echo ".${name}:${name}"
done) done)
@ -365,10 +365,10 @@ case "$orig_head" in
'') '')
;; ;;
?*) ?*)
curr_head=$(git-rev-parse --verify HEAD 2>/dev/null) curr_head=$(git rev-parse --verify HEAD 2>/dev/null)
if test "$curr_head" != "$orig_head" if test "$curr_head" != "$orig_head"
then then
git-update-ref \ git update-ref \
-m "$GIT_REFLOG_ACTION: Undoing incorrectly fetched HEAD." \ -m "$GIT_REFLOG_ACTION: Undoing incorrectly fetched HEAD." \
HEAD "$orig_head" HEAD "$orig_head"
die "Cannot fetch into the current branch." die "Cannot fetch into the current branch."

View File

@ -81,7 +81,7 @@
# This is the filter for rewriting the commit's parent list. # This is the filter for rewriting the commit's parent list.
# It will receive the parent string on stdin and shall output # It will receive the parent string on stdin and shall output
# the new parent string on stdout. The parent string is in # the new parent string on stdout. The parent string is in
# format accepted by `git-commit-tree`: empty for initial # format accepted by `git commit-tree`: empty for initial
# commit, "-p parent" for a normal commit and "-p parent1 # commit, "-p parent" for a normal commit and "-p parent1
# -p parent2 -p parent3 ..." for a merge commit. # -p parent2 -p parent3 ..." for a merge commit.
# #
@ -93,7 +93,7 @@
# #
# --commit-filter COMMAND:: The filter for performing the commit # --commit-filter COMMAND:: The filter for performing the commit
# If this filter is passed, it will be called instead of the # If this filter is passed, it will be called instead of the
# `git-commit-tree` command, with those arguments: # `git commit-tree` command, with those arguments:
# #
# TREE_ID [-p PARENT_COMMIT_ID]... # TREE_ID [-p PARENT_COMMIT_ID]...
# #
@ -132,7 +132,7 @@
# #
# A significantly faster version: # A significantly faster version:
# #
# git-filter-branch --index-filter 'git-update-index --remove filename' newbranch # git-filter-branch --index-filter 'git update-index --remove filename' newbranch
# #
# Now, you will get the rewritten history saved in the branch 'newbranch' # Now, you will get the rewritten history saved in the branch 'newbranch'
# (your current branch is left untouched). # (your current branch is left untouched).
@ -151,7 +151,7 @@
# #
# To remove commits authored by "Darl McBribe" from the history: # To remove commits authored by "Darl McBribe" from the history:
# #
# git-filter-branch --commit-filter 'if [ "$GIT_AUTHOR_NAME" = "Darl McBribe" ]; then shift; while [ -n "$1" ]; do shift; echo "$1"; shift; done; else git-commit-tree "$@"; fi' newbranch # git-filter-branch --commit-filter 'if [ "$GIT_AUTHOR_NAME" = "Darl McBribe" ]; then shift; while [ -n "$1" ]; do shift; echo "$1"; shift; done; else git commit-tree "$@"; fi' newbranch
# #
# (the shift magic first throws away the tree id and then the -p # (the shift magic first throws away the tree id and then the -p
# parameters). Note that this handles merges properly! In case Darl # parameters). Note that this handles merges properly! In case Darl
@ -182,9 +182,9 @@
# To move the whole tree into a subdirectory, or remove it from there: # To move the whole tree into a subdirectory, or remove it from there:
# #
# git-filter-branch --index-filter \ # git-filter-branch --index-filter \
# 'git-ls-files -s | sed "s-\t-&newsubdir/-" | # 'git ls-files -s | sed "s-\t-&newsubdir/-" |
# GIT_INDEX_FILE=$GIT_INDEX_FILE.new \ # GIT_INDEX_FILE=$GIT_INDEX_FILE.new \
# git-update-index --index-info && # git update-index --index-info &&
# mv $GIT_INDEX_FILE.new $GIT_INDEX_FILE' directorymoved # mv $GIT_INDEX_FILE.new $GIT_INDEX_FILE' directorymoved


# Testsuite: TODO # Testsuite: TODO
@ -240,7 +240,7 @@ filter_tree=
filter_index= filter_index=
filter_parent= filter_parent=
filter_msg=cat filter_msg=cat
filter_commit='git-commit-tree "$@"' filter_commit='git commit-tree "$@"'
filter_tag_name= filter_tag_name=
filter_subdir= filter_subdir=
while case "$#" in 0) usage;; esac while case "$#" in 0) usage;; esac
@ -300,7 +300,7 @@ done
dstbranch="$1" dstbranch="$1"
shift shift
test -n "$dstbranch" || die "missing branch name" test -n "$dstbranch" || die "missing branch name"
git-show-ref "refs/heads/$dstbranch" 2> /dev/null && git show-ref "refs/heads/$dstbranch" 2> /dev/null &&
die "branch $dstbranch already exists" die "branch $dstbranch already exists"


test ! -e "$tempdir" || die "$tempdir already exists, please remove it" test ! -e "$tempdir" || die "$tempdir already exists, please remove it"
@ -318,7 +318,7 @@ esac
export GIT_DIR GIT_WORK_TREE=. export GIT_DIR GIT_WORK_TREE=.


export GIT_INDEX_FILE="$(pwd)/../index" export GIT_INDEX_FILE="$(pwd)/../index"
git-read-tree # seed the index file git read-tree # seed the index file


ret=0 ret=0


@ -327,11 +327,11 @@ mkdir ../map # map old->new commit ids for rewriting parents


case "$filter_subdir" in case "$filter_subdir" in
"") "")
git-rev-list --reverse --topo-order --default HEAD \ git rev-list --reverse --topo-order --default HEAD \
--parents "$@" --parents "$@"
;; ;;
*) *)
git-rev-list --reverse --topo-order --default HEAD \ git rev-list --reverse --topo-order --default HEAD \
--parents --full-history "$@" -- "$filter_subdir" --parents --full-history "$@" -- "$filter_subdir"
esac > ../revs esac > ../revs
commits=$(cat ../revs | wc -l | tr -d " ") commits=$(cat ../revs | wc -l | tr -d " ")
@ -345,29 +345,29 @@ while read commit parents; do


case "$filter_subdir" in case "$filter_subdir" in
"") "")
git-read-tree -i -m $commit git read-tree -i -m $commit
;; ;;
*) *)
git-read-tree -i -m $commit:"$filter_subdir" git read-tree -i -m $commit:"$filter_subdir"
esac esac


export GIT_COMMIT=$commit export GIT_COMMIT=$commit
git-cat-file commit "$commit" >../commit git cat-file commit "$commit" >../commit


eval "$(set_ident AUTHOR <../commit)" eval "$(set_ident AUTHOR <../commit)"
eval "$(set_ident COMMITTER <../commit)" eval "$(set_ident COMMITTER <../commit)"
eval "$filter_env" < /dev/null eval "$filter_env" < /dev/null


if [ "$filter_tree" ]; then if [ "$filter_tree" ]; then
git-checkout-index -f -u -a git checkout-index -f -u -a
# files that $commit removed are now still in the working tree; # files that $commit removed are now still in the working tree;
# remove them, else they would be added again # remove them, else they would be added again
git-ls-files -z --others | xargs -0 rm -f git ls-files -z --others | xargs -0 rm -f
eval "$filter_tree" < /dev/null eval "$filter_tree" < /dev/null
git-diff-index -r $commit | cut -f 2- | tr '\n' '\0' | \ git diff-index -r $commit | cut -f 2- | tr '\n' '\0' | \
xargs -0 git-update-index --add --replace --remove xargs -0 git update-index --add --replace --remove
git-ls-files -z --others | \ git ls-files -z --others | \
xargs -0 git-update-index --add --replace --remove xargs -0 git update-index --add --replace --remove
fi fi


eval "$filter_index" < /dev/null eval "$filter_index" < /dev/null
@ -384,7 +384,7 @@ while read commit parents; do


sed -e '1,/^$/d' <../commit | \ sed -e '1,/^$/d' <../commit | \
eval "$filter_msg" | \ eval "$filter_msg" | \
sh -c "$filter_commit" "git-commit-tree" $(git-write-tree) $parentstr | \ sh -c "$filter_commit" "git commit-tree" $(git write-tree) $parentstr | \
tee ../map/$commit tee ../map/$commit
done <../revs done <../revs


@ -395,7 +395,7 @@ case "$target_head" in
echo Nothing rewritten echo Nothing rewritten
;; ;;
*) *)
git-update-ref refs/heads/"$dstbranch" $target_head git update-ref refs/heads/"$dstbranch" $target_head
if [ $(cat ../map/$src_head | wc -l) -gt 1 ]; then if [ $(cat ../map/$src_head | wc -l) -gt 1 ]; then
echo "WARNING: Your commit filter caused the head commit to expand to several rewritten commits. Only the first such commit was recorded as the current $dstbranch head but you will need to resolve the situation now (probably by manually merging the other commits). These are all the commits:" >&2 echo "WARNING: Your commit filter caused the head commit to expand to several rewritten commits. Only the first such commit was recorded as the current $dstbranch head but you will need to resolve the situation now (probably by manually merging the other commits). These are all the commits:" >&2
sed 's/^/ /' ../map/$src_head >&2 sed 's/^/ /' ../map/$src_head >&2
@ -405,7 +405,7 @@ case "$target_head" in
esac esac


if [ "$filter_tag_name" ]; then if [ "$filter_tag_name" ]; then
git-for-each-ref --format='%(objectname) %(objecttype) %(refname)' refs/tags | git for-each-ref --format='%(objectname) %(objecttype) %(refname)' refs/tags |
while read sha1 type ref; do while read sha1 type ref; do
ref="${ref#refs/tags/}" ref="${ref#refs/tags/}"
# XXX: Rewrite tagged trees as well? # XXX: Rewrite tagged trees as well?
@ -416,7 +416,7 @@ if [ "$filter_tag_name" ]; then
if [ "$type" = "tag" ]; then if [ "$type" = "tag" ]; then
# Dereference to a commit # Dereference to a commit
sha1t="$sha1" sha1t="$sha1"
sha1="$(git-rev-parse "$sha1"^{commit} 2>/dev/null)" || continue sha1="$(git rev-parse "$sha1"^{commit} 2>/dev/null)" || continue
fi fi


[ -f "../map/$sha1" ] || continue [ -f "../map/$sha1" ] || continue
@ -431,7 +431,7 @@ if [ "$filter_tag_name" ]; then
warn "unreferencing tag object $sha1t" warn "unreferencing tag object $sha1t"
fi fi


git-update-ref "refs/tags/$new_ref" "$new_sha1" git update-ref "refs/tags/$new_ref" "$new_sha1"
done done
fi fi



View File

@ -17,10 +17,10 @@ while read dangling type sha1
do do
case "$dangling" in case "$dangling" in
dangling) dangling)
if git-rev-parse --verify "$sha1^0" >/dev/null 2>/dev/null if git rev-parse --verify "$sha1^0" >/dev/null 2>/dev/null
then then
dir="$laf/commit" dir="$laf/commit"
git-show-branch "$sha1" git show-branch "$sha1"
else else
dir="$laf/other" dir="$laf/other"
fi fi

View File

@ -58,7 +58,7 @@ http://* | https://* | ftp://* )
curl_extra_args="-k" curl_extra_args="-k"
fi fi
if [ -n "$GIT_CURL_FTP_NO_EPSV" -o \ if [ -n "$GIT_CURL_FTP_NO_EPSV" -o \
"`git-config --bool http.noEPSV`" = true ]; then "`git config --bool http.noEPSV`" = true ]; then
curl_extra_args="${curl_extra_args} --disable-epsv" curl_extra_args="${curl_extra_args} --disable-epsv"
fi fi
curl -nsf $curl_extra_args --header "Pragma: no-cache" "$peek_repo/info/refs" || curl -nsf $curl_extra_args --header "Pragma: no-cache" "$peek_repo/info/refs" ||

View File

@ -45,7 +45,7 @@ esac
# MRT is the current "merge result tree" # MRT is the current "merge result tree"


MRC=$head MSG= PARENT="-p $head" MRC=$head MSG= PARENT="-p $head"
MRT=$(git-write-tree) MRT=$(git write-tree)
CNT=1 ;# counting our head CNT=1 ;# counting our head
NON_FF_MERGE=0 NON_FF_MERGE=0
OCTOPUS_FAILURE=0 OCTOPUS_FAILURE=0
@ -61,7 +61,7 @@ do
exit 2 exit 2
esac esac


common=$(git-merge-base --all $MRC $SHA1) || common=$(git merge-base --all $MRC $SHA1) ||
die "Unable to find common commit with $SHA1" die "Unable to find common commit with $SHA1"


case "$LF$common$LF" in case "$LF$common$LF" in
@ -82,22 +82,22 @@ do
# We still need to count this as part of the parent set. # We still need to count this as part of the parent set.


echo "Fast forwarding to: $SHA1" echo "Fast forwarding to: $SHA1"
git-read-tree -u -m $head $SHA1 || exit git read-tree -u -m $head $SHA1 || exit
MRC=$SHA1 MRT=$(git-write-tree) MRC=$SHA1 MRT=$(git write-tree)
continue continue
fi fi


NON_FF_MERGE=1 NON_FF_MERGE=1


echo "Trying simple merge with $SHA1" echo "Trying simple merge with $SHA1"
git-read-tree -u -m --aggressive $common $MRT $SHA1 || exit 2 git read-tree -u -m --aggressive $common $MRT $SHA1 || exit 2
next=$(git-write-tree 2>/dev/null) next=$(git write-tree 2>/dev/null)
if test $? -ne 0 if test $? -ne 0
then then
echo "Simple merge did not work, trying automatic merge." echo "Simple merge did not work, trying automatic merge."
git-merge-index -o git-merge-one-file -a || git-merge-index -o git-merge-one-file -a ||
OCTOPUS_FAILURE=1 OCTOPUS_FAILURE=1
next=$(git-write-tree 2>/dev/null) next=$(git write-tree 2>/dev/null)
fi fi


# We have merged the other branch successfully. Ideally # We have merged the other branch successfully. Ideally

View File

@ -13,7 +13,7 @@
# $7 - file in branch2 mode (or empty) # $7 - file in branch2 mode (or empty)
# #
# Handle some trivial cases.. The _really_ trivial cases have # Handle some trivial cases.. The _really_ trivial cases have
# been handled already by git-read-tree, but that one doesn't # been handled already by git read-tree, but that one doesn't
# do any merges that might change the tree layout. # do any merges that might change the tree layout.


case "${1:-.}${2:-.}${3:-.}" in case "${1:-.}${2:-.}${3:-.}" in
@ -34,7 +34,7 @@ case "${1:-.}${2:-.}${3:-.}" in
rm -f -- "$4" && rm -f -- "$4" &&
rmdir -p "$(expr "z$4" : 'z\(.*\)/')" 2>/dev/null || : rmdir -p "$(expr "z$4" : 'z\(.*\)/')" 2>/dev/null || :
fi && fi &&
exec git-update-index --remove -- "$4" exec git update-index --remove -- "$4"
;; ;;


# #
@ -50,8 +50,8 @@ case "${1:-.}${2:-.}${3:-.}" in
echo "ERROR: untracked $4 is overwritten by the merge." echo "ERROR: untracked $4 is overwritten by the merge."
exit 1 exit 1
} }
git-update-index --add --cacheinfo "$6$7" "$2$3" "$4" && git update-index --add --cacheinfo "$6$7" "$2$3" "$4" &&
exec git-checkout-index -u -f -- "$4" exec git checkout-index -u -f -- "$4"
;; ;;


# #
@ -64,8 +64,8 @@ case "${1:-.}${2:-.}${3:-.}" in
exit 1 exit 1
fi fi
echo "Adding $4" echo "Adding $4"
git-update-index --add --cacheinfo "$6" "$2" "$4" && git update-index --add --cacheinfo "$6" "$2" "$4" &&
exec git-checkout-index -u -f -- "$4" exec git checkout-index -u -f -- "$4"
;; ;;


# #
@ -84,11 +84,11 @@ case "${1:-.}${2:-.}${3:-.}" in
case "$1" in case "$1" in
'') '')
echo "Added $4 in both, but differently." echo "Added $4 in both, but differently."
# This extracts OUR file in $orig, and uses git-apply to # This extracts OUR file in $orig, and uses git apply to
# remove lines that are unique to ours. # remove lines that are unique to ours.
orig=`git-unpack-file $2` orig=`git-unpack-file $2`
sz0=`wc -c <"$orig"` sz0=`wc -c <"$orig"`
diff -u -La/$orig -Lb/$orig $orig $src2 | git-apply --no-add diff -u -La/$orig -Lb/$orig $orig $src2 | git apply --no-add
sz1=`wc -c <"$orig"` sz1=`wc -c <"$orig"`


# If we do not have enough common material, it is not # If we do not have enough common material, it is not
@ -104,12 +104,12 @@ case "${1:-.}${2:-.}${3:-.}" in
# Be careful for funny filename such as "-L" in "$4", which # Be careful for funny filename such as "-L" in "$4", which
# would confuse "merge" greatly. # would confuse "merge" greatly.
src1=`git-unpack-file $2` src1=`git-unpack-file $2`
git-merge-file "$src1" "$orig" "$src2" git merge-file "$src1" "$orig" "$src2"
ret=$? ret=$?


# Create the working tree file, using "our tree" version from the # Create the working tree file, using "our tree" version from the
# index, and then store the result of the merge. # index, and then store the result of the merge.
git-checkout-index -f --stage=2 -- "$4" && cat "$src1" >"$4" git checkout-index -f --stage=2 -- "$4" && cat "$src1" >"$4"
rm -f -- "$orig" "$src1" "$src2" rm -f -- "$orig" "$src1" "$src2"


if [ "$6" != "$7" ]; then if [ "$6" != "$7" ]; then
@ -124,7 +124,7 @@ case "${1:-.}${2:-.}${3:-.}" in
echo "ERROR: Merge conflict in $4" echo "ERROR: Merge conflict in $4"
exit 1 exit 1
fi fi
exec git-update-index -- "$4" exec git update-index -- "$4"
;; ;;


*) *)

View File

@ -9,6 +9,6 @@
# because the current index is what we will be committing as the # because the current index is what we will be committing as the
# merge result. # merge result.


git-diff-index --quiet --cached HEAD || exit 2 git diff-index --quiet --cached HEAD || exit 2


exit 0 exit 0

View File

@ -37,10 +37,10 @@ then
exit 2 exit 2
fi fi


git-update-index --refresh 2>/dev/null git update-index --refresh 2>/dev/null
git-read-tree -u -m --aggressive $bases $head $remotes || exit 2 git read-tree -u -m --aggressive $bases $head $remotes || exit 2
echo "Trying simple merge." echo "Trying simple merge."
if result_tree=$(git-write-tree 2>/dev/null) if result_tree=$(git write-tree 2>/dev/null)
then then
exit 0 exit 0
else else

View File

@ -40,10 +40,10 @@ case "$bases" in
for c in $bases for c in $bases
do do
rm -f $G rm -f $G
GIT_INDEX_FILE=$G git-read-tree -m $c $head $remotes \ GIT_INDEX_FILE=$G git read-tree -m $c $head $remotes \
2>/dev/null || continue 2>/dev/null || continue
# Count the paths that are unmerged. # Count the paths that are unmerged.
cnt=`GIT_INDEX_FILE=$G git-ls-files --unmerged | wc -l` cnt=`GIT_INDEX_FILE=$G git ls-files --unmerged | wc -l`
if test $best_cnt -le 0 -o $cnt -le $best_cnt if test $best_cnt -le 0 -o $cnt -le $best_cnt
then then
best=$c best=$c
@ -63,10 +63,10 @@ case "$bases" in
;; ;;
esac esac


git-update-index --refresh 2>/dev/null git update-index --refresh 2>/dev/null
git-read-tree -u -m $common $head $remotes || exit 2 git read-tree -u -m $common $head $remotes || exit 2
echo "Trying simple merge." echo "Trying simple merge."
if result_tree=$(git-write-tree 2>/dev/null) if result_tree=$(git write-tree 2>/dev/null)
then then
exit 0 exit 0
else else

View File

@ -31,7 +31,7 @@ dropsave() {


savestate() { savestate() {
# Stash away any local modifications. # Stash away any local modifications.
git-diff-index -z --name-only $head | git diff-index -z --name-only $head |
cpio -0 -o >"$GIT_DIR/MERGE_SAVE" cpio -0 -o >"$GIT_DIR/MERGE_SAVE"
} }


@ -40,7 +40,7 @@ restorestate() {
then then
git reset --hard $head >/dev/null git reset --hard $head >/dev/null
cpio -iuv <"$GIT_DIR/MERGE_SAVE" cpio -iuv <"$GIT_DIR/MERGE_SAVE"
git-update-index --refresh >/dev/null git update-index --refresh >/dev/null
fi fi
} }


@ -57,7 +57,7 @@ finish_up_to_date () {
squash_message () { squash_message () {
echo Squashed commit of the following: echo Squashed commit of the following:
echo echo
git-log --no-merges ^"$head" $remote git log --no-merges ^"$head" $remote
} }


finish () { finish () {
@ -79,7 +79,7 @@ finish () {
echo "No merge message -- not updating HEAD" echo "No merge message -- not updating HEAD"
;; ;;
*) *)
git-update-ref -m "$rlogm" HEAD "$1" "$head" || exit 1 git update-ref -m "$rlogm" HEAD "$1" "$head" || exit 1
;; ;;
esac esac
;; ;;
@ -91,7 +91,7 @@ finish () {
if test "$show_diffstat" = t if test "$show_diffstat" = t
then then
# We want color (if set), but no pager # We want color (if set), but no pager
GIT_PAGER='' git-diff --stat --summary -M "$head" "$1" GIT_PAGER='' git diff --stat --summary -M "$head" "$1"
fi fi
;; ;;
esac esac
@ -99,13 +99,13 @@ finish () {


merge_name () { merge_name () {
remote="$1" remote="$1"
rh=$(git-rev-parse --verify "$remote^0" 2>/dev/null) || return rh=$(git rev-parse --verify "$remote^0" 2>/dev/null) || return
bh=$(git-show-ref -s --verify "refs/heads/$remote" 2>/dev/null) bh=$(git show-ref -s --verify "refs/heads/$remote" 2>/dev/null)
if test "$rh" = "$bh" if test "$rh" = "$bh"
then then
echo "$rh branch '$remote' of ." echo "$rh branch '$remote' of ."
elif truname=$(expr "$remote" : '\(.*\)~[1-9][0-9]*$') && elif truname=$(expr "$remote" : '\(.*\)~[1-9][0-9]*$') &&
git-show-ref -q --verify "refs/heads/$truname" 2>/dev/null git show-ref -q --verify "refs/heads/$truname" 2>/dev/null
then then
echo "$rh branch '$truname' (early part) of ." echo "$rh branch '$truname' (early part) of ."
elif test "$remote" = "FETCH_HEAD" -a -r "$GIT_DIR/FETCH_HEAD" elif test "$remote" = "FETCH_HEAD" -a -r "$GIT_DIR/FETCH_HEAD"
@ -170,7 +170,7 @@ do
done done


if test -z "$show_diffstat"; then if test -z "$show_diffstat"; then
test "$(git-config --bool merge.diffstat)" = false && show_diffstat=false test "$(git config --bool merge.diffstat)" = false && show_diffstat=false
test -z "$show_diffstat" && show_diffstat=t test -z "$show_diffstat" && show_diffstat=t
fi fi


@ -181,15 +181,15 @@ fi
# have "-m" so it is an additional safety measure to check for it. # have "-m" so it is an additional safety measure to check for it.


if test -z "$have_message" && if test -z "$have_message" &&
second_token=$(git-rev-parse --verify "$2^0" 2>/dev/null) && second_token=$(git rev-parse --verify "$2^0" 2>/dev/null) &&
head_commit=$(git-rev-parse --verify "HEAD" 2>/dev/null) && head_commit=$(git rev-parse --verify "HEAD" 2>/dev/null) &&
test "$second_token" = "$head_commit" test "$second_token" = "$head_commit"
then then
merge_msg="$1" merge_msg="$1"
shift shift
head_arg="$1" head_arg="$1"
shift shift
elif ! git-rev-parse --verify HEAD >/dev/null 2>&1 elif ! git rev-parse --verify HEAD >/dev/null 2>&1
then then
# If the merged head is a valid one there is no reason to # If the merged head is a valid one there is no reason to
# forbid "git merge" into a branch yet to be born. We do # forbid "git merge" into a branch yet to be born. We do
@ -203,8 +203,8 @@ then
rh=$(git rev-parse --verify "$1^0") || rh=$(git rev-parse --verify "$1^0") ||
die "$1 - not something we can merge" die "$1 - not something we can merge"


git-update-ref -m "initial pull" HEAD "$rh" "" && git update-ref -m "initial pull" HEAD "$rh" "" &&
git-read-tree --reset -u HEAD git read-tree --reset -u HEAD
exit exit


else else
@ -219,11 +219,11 @@ else
merge_name=$(for remote merge_name=$(for remote
do do
merge_name "$remote" merge_name "$remote"
done | git-fmt-merge-msg done | git fmt-merge-msg
) )
merge_msg="${merge_msg:+$merge_msg$LF$LF}$merge_name" merge_msg="${merge_msg:+$merge_msg$LF$LF}$merge_name"
fi fi
head=$(git-rev-parse --verify "$head_arg"^0) || usage head=$(git rev-parse --verify "$head_arg"^0) || usage


# All the rest are remote heads # All the rest are remote heads
test "$#" = 0 && usage ;# we need at least one remote head. test "$#" = 0 && usage ;# we need at least one remote head.
@ -232,7 +232,7 @@ set_reflog_action "merge $*"
remoteheads= remoteheads=
for remote for remote
do do
remotehead=$(git-rev-parse --verify "$remote"^0 2>/dev/null) || remotehead=$(git rev-parse --verify "$remote"^0 2>/dev/null) ||
die "$remote - not something we can merge" die "$remote - not something we can merge"
remoteheads="${remoteheads}$remotehead " remoteheads="${remoteheads}$remotehead "
eval GITHEAD_$remotehead='"$remote"' eval GITHEAD_$remotehead='"$remote"'
@ -244,7 +244,7 @@ case "$use_strategies" in
'') '')
case "$#" in case "$#" in
1) 1)
var="`git-config --get pull.twohead`" var="`git config --get pull.twohead`"
if test -n "$var" if test -n "$var"
then then
use_strategies="$var" use_strategies="$var"
@ -252,7 +252,7 @@ case "$use_strategies" in
use_strategies="$default_twohead_strategies" use_strategies="$default_twohead_strategies"
fi ;; fi ;;
*) *)
var="`git-config --get pull.octopus`" var="`git config --get pull.octopus`"
if test -n "$var" if test -n "$var"
then then
use_strategies="$var" use_strategies="$var"
@ -278,10 +278,10 @@ done


case "$#" in case "$#" in
1) 1)
common=$(git-merge-base --all $head "$@") common=$(git merge-base --all $head "$@")
;; ;;
*) *)
common=$(git-show-branch --merge-base $head "$@") common=$(git show-branch --merge-base $head "$@")
;; ;;
esac esac
echo "$head" >"$GIT_DIR/ORIG_HEAD" echo "$head" >"$GIT_DIR/ORIG_HEAD"
@ -301,15 +301,15 @@ f,*)
;; ;;
?,1,"$head",*) ?,1,"$head",*)
# Again the most common case of merging one remote. # Again the most common case of merging one remote.
echo "Updating $(git-rev-parse --short $head)..$(git-rev-parse --short $1)" echo "Updating $(git rev-parse --short $head)..$(git rev-parse --short $1)"
git-update-index --refresh 2>/dev/null git update-index --refresh 2>/dev/null
msg="Fast forward" msg="Fast forward"
if test -n "$have_message" if test -n "$have_message"
then then
msg="$msg (no commit created; -m option ignored)" msg="$msg (no commit created; -m option ignored)"
fi fi
new_head=$(git-rev-parse --verify "$1^0") && new_head=$(git rev-parse --verify "$1^0") &&
git-read-tree -v -m -u --exclude-per-directory=.gitignore $head "$new_head" && git read-tree -v -m -u --exclude-per-directory=.gitignore $head "$new_head" &&
finish "$new_head" "$msg" || exit finish "$new_head" "$msg" || exit
dropsave dropsave
exit 0 exit 0
@ -321,7 +321,7 @@ f,*)
?,1,*,) ?,1,*,)
# We are not doing octopus, not fast forward, and have only # We are not doing octopus, not fast forward, and have only
# one common. # one common.
git-update-index --refresh 2>/dev/null git update-index --refresh 2>/dev/null
case " $use_strategies " in case " $use_strategies " in
*' recursive '*|*' recur '*) *' recursive '*|*' recur '*)
: run merge later : run merge later
@ -330,13 +330,13 @@ f,*)
# See if it is really trivial. # See if it is really trivial.
git var GIT_COMMITTER_IDENT >/dev/null || exit git var GIT_COMMITTER_IDENT >/dev/null || exit
echo "Trying really trivial in-index merge..." echo "Trying really trivial in-index merge..."
if git-read-tree --trivial -m -u -v $common $head "$1" && if git read-tree --trivial -m -u -v $common $head "$1" &&
result_tree=$(git-write-tree) result_tree=$(git write-tree)
then then
echo "Wonderful." echo "Wonderful."
result_commit=$( result_commit=$(
printf '%s\n' "$merge_msg" | printf '%s\n' "$merge_msg" |
git-commit-tree $result_tree -p HEAD -p "$1" git commit-tree $result_tree -p HEAD -p "$1"
) || exit ) || exit
finish "$result_commit" "In-index merge" finish "$result_commit" "In-index merge"
dropsave dropsave
@ -350,7 +350,7 @@ f,*)
up_to_date=t up_to_date=t
for remote for remote
do do
common_one=$(git-merge-base --all $head $remote) common_one=$(git merge-base --all $head $remote)
if test "$common_one" != "$remote" if test "$common_one" != "$remote"
then then
up_to_date=f up_to_date=f
@ -419,8 +419,8 @@ do
if test "$exit" -eq 1 if test "$exit" -eq 1
then then
cnt=`{ cnt=`{
git-diff-files --name-only git diff-files --name-only
git-ls-files --unmerged git ls-files --unmerged
} | wc -l` } | wc -l`
if test $best_cnt -le 0 -o $cnt -le $best_cnt if test $best_cnt -le 0 -o $cnt -le $best_cnt
then then
@ -432,15 +432,15 @@ do
} }


# Automerge succeeded. # Automerge succeeded.
result_tree=$(git-write-tree) && break result_tree=$(git write-tree) && break
done done


# If we have a resulting tree, that means the strategy module # If we have a resulting tree, that means the strategy module
# auto resolved the merge cleanly. # auto resolved the merge cleanly.
if test '' != "$result_tree" if test '' != "$result_tree"
then then
parents=$(git-show-branch --independent "$head" "$@" | sed -e 's/^/-p /') parents=$(git show-branch --independent "$head" "$@" | sed -e 's/^/-p /')
result_commit=$(printf '%s\n' "$merge_msg" | git-commit-tree $result_tree $parents) || exit result_commit=$(printf '%s\n' "$merge_msg" | git commit-tree $result_tree $parents) || exit
finish "$result_commit" "Merge made by $wt_strategy." finish "$result_commit" "Merge made by $wt_strategy."
dropsave dropsave
exit 0 exit 0
@ -498,7 +498,7 @@ Conflicts:
} >>"$GIT_DIR/MERGE_MSG" } >>"$GIT_DIR/MERGE_MSG"
if test -d "$GIT_DIR/rr-cache" if test -d "$GIT_DIR/rr-cache"
then then
git-rerere git rerere
fi fi
die "Automatic merge failed; fix conflicts and then commit the result." die "Automatic merge failed; fix conflicts and then commit the result."
fi fi

View File

@ -65,14 +65,14 @@ resolve_symlink_merge () {
read ans read ans
case "$ans" in case "$ans" in
[lL]*) [lL]*)
git-checkout-index -f --stage=2 -- "$path" git checkout-index -f --stage=2 -- "$path"
git-add -- "$path" git add -- "$path"
cleanup_temp_files --save-backup cleanup_temp_files --save-backup
return return
;; ;;
[rR]*) [rR]*)
git-checkout-index -f --stage=3 -- "$path" git checkout-index -f --stage=3 -- "$path"
git-add -- "$path" git add -- "$path"
cleanup_temp_files --save-backup cleanup_temp_files --save-backup
return return
;; ;;
@ -93,12 +93,12 @@ resolve_deleted_merge () {
read ans read ans
case "$ans" in case "$ans" in
[mMcC]*) [mMcC]*)
git-add -- "$path" git add -- "$path"
cleanup_temp_files --save-backup cleanup_temp_files --save-backup
return return
;; ;;
[dD]*) [dD]*)
git-rm -- "$path" > /dev/null git rm -- "$path" > /dev/null
cleanup_temp_files cleanup_temp_files
return return
;; ;;
@ -140,7 +140,7 @@ remove_backup () {
merge_file () { merge_file () {
path="$1" path="$1"


f=`git-ls-files -u -- "$path"` f=`git ls-files -u -- "$path"`
if test -z "$f" ; then if test -z "$f" ; then
if test ! -f "$path" ; then if test ! -f "$path" ; then
echo "$path: file not found" echo "$path: file not found"
@ -297,7 +297,7 @@ do
done done


if test -z "$merge_tool"; then if test -z "$merge_tool"; then
merge_tool=`git-config merge.tool` merge_tool=`git config merge.tool`
case "$merge_tool" in case "$merge_tool" in
kdiff3 | tkdiff | xxdiff | meld | opendiff | emerge | vimdiff | gvimdiff | "") kdiff3 | tkdiff | xxdiff | meld | opendiff | emerge | vimdiff | gvimdiff | "")
;; # happy ;; # happy

View File

@ -2,7 +2,7 @@


# git-ls-remote could be called from outside a git managed repository; # git-ls-remote could be called from outside a git managed repository;
# this would fail in that case and would issue an error message. # this would fail in that case and would issue an error message.
GIT_DIR=$(git-rev-parse --git-dir 2>/dev/null) || :; GIT_DIR=$(git rev-parse --git-dir 2>/dev/null) || :;


get_data_source () { get_data_source () {
case "$1" in case "$1" in
@ -13,7 +13,7 @@ get_data_source () {
echo self echo self
;; ;;
*) *)
if test "$(git-config --get "remote.$1.url")" if test "$(git config --get "remote.$1.url")"
then then
echo config echo config
elif test -f "$GIT_DIR/remotes/$1" elif test -f "$GIT_DIR/remotes/$1"
@ -38,7 +38,7 @@ get_remote_url () {
echo "$1" echo "$1"
;; ;;
config) config)
git-config --get "remote.$1.url" git config --get "remote.$1.url"
;; ;;
remotes) remotes)
sed -ne '/^URL: */{ sed -ne '/^URL: */{
@ -55,8 +55,8 @@ get_remote_url () {
} }


get_default_remote () { get_default_remote () {
curr_branch=$(git-symbolic-ref -q HEAD | sed -e 's|^refs/heads/||') curr_branch=$(git symbolic-ref -q HEAD | sed -e 's|^refs/heads/||')
origin=$(git-config --get "branch.$curr_branch.remote") origin=$(git config --get "branch.$curr_branch.remote")
echo ${origin:-origin} echo ${origin:-origin}
} }


@ -66,7 +66,7 @@ get_remote_default_refs_for_push () {
'' | branches | self) '' | branches | self)
;; # no default push mapping, just send matching refs. ;; # no default push mapping, just send matching refs.
config) config)
git-config --get-all "remote.$1.push" ;; git config --get-all "remote.$1.push" ;;
remotes) remotes)
sed -ne '/^Push: */{ sed -ne '/^Push: */{
s///p s///p
@ -107,9 +107,9 @@ canon_refs_list_for_fetch () {
shift shift
if test "$remote" = "$(get_default_remote)" if test "$remote" = "$(get_default_remote)"
then then
curr_branch=$(git-symbolic-ref -q HEAD | \ curr_branch=$(git symbolic-ref -q HEAD | \
sed -e 's|^refs/heads/||') sed -e 's|^refs/heads/||')
merge_branches=$(git-config \ merge_branches=$(git config \
--get-all "branch.${curr_branch}.merge") --get-all "branch.${curr_branch}.merge")
fi fi
if test -z "$merge_branches" && test $is_explicit != explicit if test -z "$merge_branches" && test $is_explicit != explicit
@ -156,7 +156,7 @@ canon_refs_list_for_fetch () {


if local_ref_name=$(expr "z$local" : 'zrefs/\(.*\)') if local_ref_name=$(expr "z$local" : 'zrefs/\(.*\)')
then then
git-check-ref-format "$local_ref_name" || git check-ref-format "$local_ref_name" ||
die "* refusing to create funny ref '$local_ref_name' locally" die "* refusing to create funny ref '$local_ref_name' locally"
fi fi
echo "${dot_prefix}${force}${remote}:${local}" echo "${dot_prefix}${force}${remote}:${local}"
@ -171,11 +171,11 @@ get_remote_default_refs_for_fetch () {
echo "HEAD:" ;; echo "HEAD:" ;;
self) self)
canon_refs_list_for_fetch -d "$1" \ canon_refs_list_for_fetch -d "$1" \
$(git-for-each-ref --format='%(refname):') $(git for-each-ref --format='%(refname):')
;; ;;
config) config)
canon_refs_list_for_fetch -d "$1" \ canon_refs_list_for_fetch -d "$1" \
$(git-config --get-all "remote.$1.fetch") ;; $(git config --get-all "remote.$1.fetch") ;;
branches) branches)
remote_branch=$(sed -ne '/#/s/.*#//p' "$GIT_DIR/branches/$1") remote_branch=$(sed -ne '/#/s/.*#//p' "$GIT_DIR/branches/$1")
case "$remote_branch" in '') remote_branch=master ;; esac case "$remote_branch" in '') remote_branch=master ;; esac
@ -254,7 +254,7 @@ get_uploadpack () {
data_source=$(get_data_source "$1") data_source=$(get_data_source "$1")
case "$data_source" in case "$data_source" in
config) config)
uplp=$(git-config --get "remote.$1.uploadpack") uplp=$(git config --get "remote.$1.uploadpack")
echo ${uplp:-git-upload-pack} echo ${uplp:-git-upload-pack}
;; ;;
*) *)

View File

@ -54,10 +54,10 @@ do
shift shift
done done


orig_head=$(git-rev-parse --verify HEAD 2>/dev/null) orig_head=$(git rev-parse --verify HEAD 2>/dev/null)
git-fetch --update-head-ok "$@" || exit 1 git-fetch --update-head-ok "$@" || exit 1


curr_head=$(git-rev-parse --verify HEAD 2>/dev/null) curr_head=$(git rev-parse --verify HEAD 2>/dev/null)
if test "$curr_head" != "$orig_head" if test "$curr_head" != "$orig_head"
then then
# The fetch involved updating the current branch. # The fetch involved updating the current branch.
@ -69,8 +69,8 @@ then
echo >&2 "Warning: fetch updated the current branch head." echo >&2 "Warning: fetch updated the current branch head."
echo >&2 "Warning: fast forwarding your working tree from" echo >&2 "Warning: fast forwarding your working tree from"
echo >&2 "Warning: commit $orig_head." echo >&2 "Warning: commit $orig_head."
git-update-index --refresh 2>/dev/null git update-index --refresh 2>/dev/null
git-read-tree -u -m "$orig_head" "$curr_head" || git read-tree -u -m "$orig_head" "$curr_head" ||
die 'Cannot fast-forward your working tree. die 'Cannot fast-forward your working tree.
After making sure that you saved anything precious from After making sure that you saved anything precious from
$ git diff '$orig_head' $ git diff '$orig_head'
@ -86,7 +86,7 @@ merge_head=$(sed -e '/ not-for-merge /d' \


case "$merge_head" in case "$merge_head" in
'') '')
curr_branch=$(git-symbolic-ref -q HEAD) curr_branch=$(git symbolic-ref -q HEAD)
case $? in case $? in
0) ;; 0) ;;
1) echo >&2 "You are not currently on a branch; you must explicitly" 1) echo >&2 "You are not currently on a branch; you must explicitly"
@ -113,11 +113,11 @@ esac


if test -z "$orig_head" if test -z "$orig_head"
then then
git-update-ref -m "initial pull" HEAD $merge_head "" && git update-ref -m "initial pull" HEAD $merge_head "" &&
git-read-tree --reset -u HEAD || exit 1 git read-tree --reset -u HEAD || exit 1
exit exit
fi fi


merge_name=$(git-fmt-merge-msg <"$GIT_DIR/FETCH_HEAD") || exit merge_name=$(git fmt-merge-msg <"$GIT_DIR/FETCH_HEAD") || exit
exec git-merge $no_summary $no_commit $squash $strategy_args \ exec git-merge $no_summary $no_commit $squash $strategy_args \
"$merge_name" HEAD $merge_head "$merge_name" HEAD $merge_head

View File

@ -67,12 +67,12 @@ tmp_info="$tmp_dir/info"




# Find the intial commit # Find the intial commit
commit=$(git-rev-parse HEAD) commit=$(git rev-parse HEAD)


mkdir $tmp_dir || exit 2 mkdir $tmp_dir || exit 2
for patch_name in $(cat "$QUILT_PATCHES/series" | grep -v '^#'); do for patch_name in $(cat "$QUILT_PATCHES/series" | grep -v '^#'); do
echo $patch_name echo $patch_name
(cat $QUILT_PATCHES/$patch_name | git-mailinfo "$tmp_msg" "$tmp_patch" > "$tmp_info") || exit 3 (cat $QUILT_PATCHES/$patch_name | git mailinfo "$tmp_msg" "$tmp_patch" > "$tmp_info") || exit 3
test -s .dotest/patch || { test -s .dotest/patch || {
echo "Patch is empty. Was it split wrong?" echo "Patch is empty. Was it split wrong?"
exit 1 exit 1
@ -113,10 +113,10 @@ for patch_name in $(cat "$QUILT_PATCHES/series" | grep -v '^#'); do
fi fi


if [ -z "$dry_run" ] ; then if [ -z "$dry_run" ] ; then
git-apply --index -C1 "$tmp_patch" && git apply --index -C1 "$tmp_patch" &&
tree=$(git-write-tree) && tree=$(git write-tree) &&
commit=$( (echo "$SUBJECT"; echo; cat "$tmp_msg") | git-commit-tree $tree -p $commit) && commit=$( (echo "$SUBJECT"; echo; cat "$tmp_msg") | git commit-tree $tree -p $commit) &&
git-update-ref -m "quiltimport: $patch_name" HEAD $commit || exit 4 git update-ref -m "quiltimport: $patch_name" HEAD $commit || exit 4
fi fi
done done
rm -rf $tmp_dir || exit 5 rm -rf $tmp_dir || exit 5

View File

@ -51,7 +51,7 @@ continue_merge () {
test -n "$prev_head" || die "prev_head must be defined" test -n "$prev_head" || die "prev_head must be defined"
test -d "$dotest" || die "$dotest directory does not exist" test -d "$dotest" || die "$dotest directory does not exist"


unmerged=$(git-ls-files -u) unmerged=$(git ls-files -u)
if test -n "$unmerged" if test -n "$unmerged"
then then
echo "You still have unmerged paths in your index" echo "You still have unmerged paths in your index"
@ -59,7 +59,7 @@ continue_merge () {
die "$RESOLVEMSG" die "$RESOLVEMSG"
fi fi


if ! git-diff-index --quiet HEAD if ! git diff-index --quiet HEAD
then then
if ! git-commit -C "`cat $dotest/current`" if ! git-commit -C "`cat $dotest/current`"
then then
@ -71,10 +71,10 @@ continue_merge () {
else else
printf "Already applied: %0${prec}d" $msgnum printf "Already applied: %0${prec}d" $msgnum
fi fi
echo ' '`git-rev-list --pretty=oneline -1 HEAD | \ echo ' '`git rev-list --pretty=oneline -1 HEAD | \
sed 's/^[a-f0-9]\+ //'` sed 's/^[a-f0-9]\+ //'`


prev_head=`git-rev-parse HEAD^0` prev_head=`git rev-parse HEAD^0`
# save the resulting commit so we can read-tree on it later # save the resulting commit so we can read-tree on it later
echo "$prev_head" > "$dotest/prev_head" echo "$prev_head" > "$dotest/prev_head"


@ -86,8 +86,8 @@ continue_merge () {
call_merge () { call_merge () {
cmt="$(cat $dotest/cmt.$1)" cmt="$(cat $dotest/cmt.$1)"
echo "$cmt" > "$dotest/current" echo "$cmt" > "$dotest/current"
hd=$(git-rev-parse --verify HEAD) hd=$(git rev-parse --verify HEAD)
cmt_name=$(git-symbolic-ref HEAD) cmt_name=$(git symbolic-ref HEAD)
msgnum=$(cat $dotest/msgnum) msgnum=$(cat $dotest/msgnum)
end=$(cat $dotest/end) end=$(cat $dotest/end)
eval GITHEAD_$cmt='"${cmt_name##refs/heads/}~$(($end - $msgnum))"' eval GITHEAD_$cmt='"${cmt_name##refs/heads/}~$(($end - $msgnum))"'
@ -101,7 +101,7 @@ call_merge () {
return return
;; ;;
1) 1)
test -d "$GIT_DIR/rr-cache" && git-rerere test -d "$GIT_DIR/rr-cache" && git rerere
die "$RESOLVEMSG" die "$RESOLVEMSG"
;; ;;
2) 2)
@ -134,7 +134,7 @@ while case "$#" in 0) break ;; esac
do do
case "$1" in case "$1" in
--continue) --continue)
git-diff-files --quiet || { git diff-files --quiet || {
echo "You must edit all merge conflicts and then" echo "You must edit all merge conflicts and then"
echo "mark them as resolved using git add" echo "mark them as resolved using git add"
exit 1 exit 1
@ -162,7 +162,7 @@ do
then then
if test -d "$GIT_DIR/rr-cache" if test -d "$GIT_DIR/rr-cache"
then then
git-rerere clear git rerere clear
fi fi
prev_head="`cat $dotest/prev_head`" prev_head="`cat $dotest/prev_head`"
end="`cat $dotest/end`" end="`cat $dotest/end`"
@ -183,7 +183,7 @@ do
--abort) --abort)
if test -d "$GIT_DIR/rr-cache" if test -d "$GIT_DIR/rr-cache"
then then
git-rerere clear git rerere clear
fi fi
if test -d "$dotest" if test -d "$dotest"
then then
@ -259,8 +259,8 @@ else
fi fi


# The tree must be really really clean. # The tree must be really really clean.
git-update-index --refresh || exit git update-index --refresh || exit
diff=$(git-diff-index --cached --name-status -r HEAD) diff=$(git diff-index --cached --name-status -r HEAD)
case "$diff" in case "$diff" in
?*) echo "cannot rebase: your index is not up-to-date" ?*) echo "cannot rebase: your index is not up-to-date"
echo "$diff" echo "$diff"
@ -275,7 +275,7 @@ upstream=`git rev-parse --verify "${upstream_name}^0"` ||


# Make sure the branch to rebase onto is valid. # Make sure the branch to rebase onto is valid.
onto_name=${newbase-"$upstream_name"} onto_name=${newbase-"$upstream_name"}
onto=$(git-rev-parse --verify "${onto_name}^0") || exit onto=$(git rev-parse --verify "${onto_name}^0") || exit


# If a hook exists, give it a chance to interrupt # If a hook exists, give it a chance to interrupt
if test -x "$GIT_DIR/hooks/pre-rebase" if test -x "$GIT_DIR/hooks/pre-rebase"
@ -301,13 +301,13 @@ case "$#" in
fi fi
;; ;;
esac esac
branch=$(git-rev-parse --verify "${branch_name}^0") || exit branch=$(git rev-parse --verify "${branch_name}^0") || exit


# Now we are rebasing commits $upstream..$branch on top of $onto # Now we are rebasing commits $upstream..$branch on top of $onto


# Check if we are already based on $onto, but this should be # Check if we are already based on $onto, but this should be
# done only when upstream and onto are the same. # done only when upstream and onto are the same.
mb=$(git-merge-base "$onto" "$branch") mb=$(git merge-base "$onto" "$branch")
if test "$upstream" = "$onto" && test "$mb" = "$onto" if test "$upstream" = "$onto" && test "$mb" = "$onto"
then then
echo >&2 "Current branch $branch_name is up to date." echo >&2 "Current branch $branch_name is up to date."
@ -318,7 +318,7 @@ if test -n "$verbose"
then then
echo "Changes from $mb to $onto:" echo "Changes from $mb to $onto:"
# We want color (if set), but no pager # We want color (if set), but no pager
GIT_PAGER='' git-diff --stat --summary "$mb" "$onto" GIT_PAGER='' git diff --stat --summary "$mb" "$onto"
fi fi


# Rewind the head to "$onto"; this saves our current head in ORIG_HEAD. # Rewind the head to "$onto"; this saves our current head in ORIG_HEAD.
@ -335,7 +335,7 @@ fi


if test -z "$do_merge" if test -z "$do_merge"
then then
git-format-patch -k --stdout --full-index --ignore-if-in-upstream "$upstream"..ORIG_HEAD | git format-patch -k --stdout --full-index --ignore-if-in-upstream "$upstream"..ORIG_HEAD |
git am $git_am_opt --binary -3 -k --resolvemsg="$RESOLVEMSG" git am $git_am_opt --binary -3 -k --resolvemsg="$RESOLVEMSG"
exit $? exit $?
fi fi
@ -346,11 +346,11 @@ fi
mkdir -p "$dotest" mkdir -p "$dotest"
echo "$onto" > "$dotest/onto" echo "$onto" > "$dotest/onto"
echo "$onto_name" > "$dotest/onto_name" echo "$onto_name" > "$dotest/onto_name"
prev_head=`git-rev-parse HEAD^0` prev_head=`git rev-parse HEAD^0`
echo "$prev_head" > "$dotest/prev_head" echo "$prev_head" > "$dotest/prev_head"


msgnum=0 msgnum=0
for cmt in `git-rev-list --reverse --no-merges "$upstream"..ORIG_HEAD` for cmt in `git rev-list --reverse --no-merges "$upstream"..ORIG_HEAD`
do do
msgnum=$(($msgnum + 1)) msgnum=$(($msgnum + 1))
echo "$cmt" > "$dotest/cmt.$msgnum" echo "$cmt" > "$dotest/cmt.$msgnum"

View File

@ -63,7 +63,7 @@ case ",$all_into_one," in
esac esac


args="$args $local $quiet $no_reuse$extra" args="$args $local $quiet $no_reuse$extra"
names=$(git-pack-objects --non-empty --all --reflog $args </dev/null "$PACKTMP") || names=$(git pack-objects --non-empty --all --reflog $args </dev/null "$PACKTMP") ||
exit 1 exit 1
if [ -z "$names" ]; then if [ -z "$names" ]; then
echo Nothing new to pack. echo Nothing new to pack.
@ -113,7 +113,7 @@ then
done done
) )
fi fi
git-prune-packed $quiet git prune-packed $quiet
fi fi


case "$no_update_info" in case "$no_update_info" in

View File

@ -18,8 +18,8 @@ head=${3-HEAD}
[ "$base" ] || usage [ "$base" ] || usage
[ "$url" ] || usage [ "$url" ] || usage


baserev=`git-rev-parse --verify "$base"^0` && baserev=`git rev-parse --verify "$base"^0` &&
headrev=`git-rev-parse --verify "$head"^0` || exit headrev=`git rev-parse --verify "$head"^0` || exit


merge_base=`git merge-base $baserev $headrev` || merge_base=`git merge-base $baserev $headrev` ||
die "fatal: No commits in common between $base and $head" die "fatal: No commits in common between $base and $head"

View File

@ -24,7 +24,7 @@ do
usage usage
;; ;;
*) *)
rev=$(git-rev-parse --verify "$1") || exit rev=$(git rev-parse --verify "$1") || exit
shift shift
break break
;; ;;
@ -33,7 +33,7 @@ do
done done


: ${rev=HEAD} : ${rev=HEAD}
rev=$(git-rev-parse --verify $rev^0) || exit rev=$(git rev-parse --verify $rev^0) || exit


# Skip -- in "git reset HEAD -- foo" and "git reset -- foo". # Skip -- in "git reset HEAD -- foo" and "git reset -- foo".
case "$1" in --) shift ;; esac case "$1" in --) shift ;; esac
@ -46,7 +46,7 @@ then
test "$reset_type" = "--mixed" || test "$reset_type" = "--mixed" ||
die "Cannot do partial $reset_type reset." die "Cannot do partial $reset_type reset."


git-diff-index --cached $rev -- "$@" | git diff-index --cached $rev -- "$@" |
sed -e 's/^:\([0-7][0-7]*\) [0-7][0-7]* \([0-9a-f][0-9a-f]*\) [0-9a-f][0-9a-f]* [A-Z] \(.*\)$/\1 \2 \3/' | sed -e 's/^:\([0-7][0-7]*\) [0-7][0-7]* \([0-9a-f][0-9a-f]*\) [0-9a-f][0-9a-f]* [A-Z] \(.*\)$/\1 \2 \3/' |
git update-index --add --remove --index-info || exit git update-index --add --remove --index-info || exit
git update-index --refresh git update-index --refresh
@ -66,22 +66,22 @@ fi
if test "$reset_type" = "--soft" if test "$reset_type" = "--soft"
then then
if test -f "$GIT_DIR/MERGE_HEAD" || if test -f "$GIT_DIR/MERGE_HEAD" ||
test "" != "$(git-ls-files --unmerged)" test "" != "$(git ls-files --unmerged)"
then then
die "Cannot do a soft reset in the middle of a merge." die "Cannot do a soft reset in the middle of a merge."
fi fi
else else
git-read-tree -v --reset $update "$rev" || exit git read-tree -v --reset $update "$rev" || exit
fi fi


# Any resets update HEAD to the head being switched to. # Any resets update HEAD to the head being switched to.
if orig=$(git-rev-parse --verify HEAD 2>/dev/null) if orig=$(git rev-parse --verify HEAD 2>/dev/null)
then then
echo "$orig" >"$GIT_DIR/ORIG_HEAD" echo "$orig" >"$GIT_DIR/ORIG_HEAD"
else else
rm -f "$GIT_DIR/ORIG_HEAD" rm -f "$GIT_DIR/ORIG_HEAD"
fi fi
git-update-ref -m "$GIT_REFLOG_ACTION" HEAD "$rev" git update-ref -m "$GIT_REFLOG_ACTION" HEAD "$rev"
update_ref_status=$? update_ref_status=$?


case "$reset_type" in case "$reset_type" in
@ -96,7 +96,7 @@ case "$reset_type" in
;; # Nothing else to do ;; # Nothing else to do
--mixed ) --mixed )
# Report what has not been updated. # Report what has not been updated.
git-update-index --refresh git update-index --refresh
;; ;;
esac esac



View File

@ -29,11 +29,11 @@ set_reflog_action() {
} }


is_bare_repository () { is_bare_repository () {
git-rev-parse --is-bare-repository git rev-parse --is-bare-repository
} }


cd_to_toplevel () { cd_to_toplevel () {
cdup=$(git-rev-parse --show-cdup) cdup=$(git rev-parse --show-cdup)
if test ! -z "$cdup" if test ! -z "$cdup"
then then
cd "$cdup" || { cd "$cdup" || {
@ -44,8 +44,8 @@ cd_to_toplevel () {
} }


require_work_tree () { require_work_tree () {
test $(git-rev-parse --is-inside-work-tree) = true && test $(git rev-parse --is-inside-work-tree) = true &&
test $(git-rev-parse --is-inside-git-dir) = false || test $(git rev-parse --is-inside-git-dir) = false ||
die "fatal: $0 cannot be used without a working tree." die "fatal: $0 cannot be used without a working tree."
} }


@ -95,12 +95,12 @@ esac
if [ -z "$SUBDIRECTORY_OK" ] if [ -z "$SUBDIRECTORY_OK" ]
then then
: ${GIT_DIR=.git} : ${GIT_DIR=.git}
GIT_DIR=$(GIT_DIR="$GIT_DIR" git-rev-parse --git-dir) || { GIT_DIR=$(GIT_DIR="$GIT_DIR" git rev-parse --git-dir) || {
exit=$? exit=$?
echo >&2 "You need to run this command from the toplevel of the working tree." echo >&2 "You need to run this command from the toplevel of the working tree."
exit $exit exit $exit
} }
else else
GIT_DIR=$(git-rev-parse --git-dir) || exit GIT_DIR=$(git rev-parse --git-dir) || exit
fi fi
: ${GIT_OBJECT_DIRECTORY="$GIT_DIR/objects"} : ${GIT_OBJECT_DIRECTORY="$GIT_DIR/objects"}

View File

@ -12,8 +12,8 @@ trap 'rm -f "$TMP-*"' 0
ref_stash=refs/stash ref_stash=refs/stash


no_changes () { no_changes () {
git-diff-index --quiet --cached HEAD && git diff-index --quiet --cached HEAD &&
git-diff-files --quiet git diff-files --quiet
} }


clear_stash () { clear_stash () {
@ -32,14 +32,14 @@ save_stash () {
clear_stash || die "Cannot initialize stash" clear_stash || die "Cannot initialize stash"


# state of the base commit # state of the base commit
if b_commit=$(git-rev-parse --verify HEAD) if b_commit=$(git rev-parse --verify HEAD)
then then
head=$(git-log --abbrev-commit --pretty=oneline -n 1 HEAD) head=$(git log --abbrev-commit --pretty=oneline -n 1 HEAD)
else else
die "You do not have the initial commit yet" die "You do not have the initial commit yet"
fi fi


if branch=$(git-symbolic-ref -q HEAD) if branch=$(git symbolic-ref -q HEAD)
then then
branch=${branch#refs/heads/} branch=${branch#refs/heads/}
else else
@ -48,9 +48,9 @@ save_stash () {
msg=$(printf '%s: %s' "$branch" "$head") msg=$(printf '%s: %s' "$branch" "$head")


# state of the index # state of the index
i_tree=$(git-write-tree) && i_tree=$(git write-tree) &&
i_commit=$(printf 'index on %s' "$msg" | i_commit=$(printf 'index on %s' "$msg" |
git-commit-tree $i_tree -p $b_commit) || git commit-tree $i_tree -p $b_commit) ||
die "Cannot save the current index state" die "Cannot save the current index state"


# state of the working tree # state of the working tree
@ -59,57 +59,57 @@ save_stash () {
export GIT_INDEX_FILE && export GIT_INDEX_FILE &&


rm -f "$TMP-index" && rm -f "$TMP-index" &&
git-read-tree $i_tree && git read-tree $i_tree &&
git-add -u && git add -u &&
git-write-tree && git write-tree &&
rm -f "$TMP-index" rm -f "$TMP-index"
) ) || ) ) ||
die "Cannot save the current worktree state" die "Cannot save the current worktree state"


# create the stash # create the stash
w_commit=$(printf 'WIP on %s' "$msg" | w_commit=$(printf 'WIP on %s' "$msg" |
git-commit-tree $w_tree -p $b_commit -p $i_commit) || git commit-tree $w_tree -p $b_commit -p $i_commit) ||
die "Cannot record working tree state" die "Cannot record working tree state"


git-update-ref -m "$msg" $ref_stash $w_commit || git update-ref -m "$msg" $ref_stash $w_commit ||
die "Cannot save the current status" die "Cannot save the current status"
printf >&2 'Saved WIP on %s\n' "$msg" printf >&2 'Saved WIP on %s\n' "$msg"
} }


have_stash () { have_stash () {
git-rev-parse --verify $ref_stash >/dev/null 2>&1 git rev-parse --verify $ref_stash >/dev/null 2>&1
} }


list_stash () { list_stash () {
have_stash || return 0 have_stash || return 0
git-log --pretty=oneline -g "$@" $ref_stash | git log --pretty=oneline -g "$@" $ref_stash |
sed -n -e 's/^[.0-9a-f]* refs\///p' sed -n -e 's/^[.0-9a-f]* refs\///p'
} }


show_stash () { show_stash () {
flags=$(git-rev-parse --no-revs --flags "$@") flags=$(git rev-parse --no-revs --flags "$@")
if test -z "$flags" if test -z "$flags"
then then
flags=--stat flags=--stat
fi fi
s=$(git-rev-parse --revs-only --no-flags --default $ref_stash "$@") s=$(git rev-parse --revs-only --no-flags --default $ref_stash "$@")


w_commit=$(git-rev-parse --verify "$s") && w_commit=$(git rev-parse --verify "$s") &&
b_commit=$(git-rev-parse --verify "$s^") && b_commit=$(git rev-parse --verify "$s^") &&
git-diff $flags $b_commit $w_commit git diff $flags $b_commit $w_commit
} }


apply_stash () { apply_stash () {
git-diff-files --quiet || git diff-files --quiet ||
die 'Cannot restore on top of a dirty state' die 'Cannot restore on top of a dirty state'


# current index state # current index state
c_tree=$(git-write-tree) || c_tree=$(git write-tree) ||
die 'Cannot apply a stash in the middle of a merge' die 'Cannot apply a stash in the middle of a merge'


s=$(git-rev-parse --revs-only --no-flags --default $ref_stash "$@") && s=$(git rev-parse --revs-only --no-flags --default $ref_stash "$@") &&
w_tree=$(git-rev-parse --verify "$s:") && w_tree=$(git rev-parse --verify "$s:") &&
b_tree=$(git-rev-parse --verify "$s^:") || b_tree=$(git rev-parse --verify "$s^:") ||
die "$*: no valid stashed state found" die "$*: no valid stashed state found"


eval " eval "
@ -123,9 +123,9 @@ apply_stash () {
then then
# No conflict # No conflict
a="$TMP-added" && a="$TMP-added" &&
git-diff --cached --name-only --diff-filter=A $c_tree >"$a" && git diff --cached --name-only --diff-filter=A $c_tree >"$a" &&
git-read-tree --reset $c_tree && git read-tree --reset $c_tree &&
git-update-index --add --stdin <"$a" || git update-index --add --stdin <"$a" ||
die "Cannot unstage modified files" die "Cannot unstage modified files"
git-status git-status
rm -f "$a" rm -f "$a"

View File

@ -46,7 +46,7 @@ get_repo_base() {
# #
module_name() module_name()
{ {
name=$(GIT_CONFIG=.gitmodules git-config --get-regexp '^submodule\..*\.path$' "$1" | name=$(GIT_CONFIG=.gitmodules git config --get-regexp '^submodule\..*\.path$' "$1" |
sed -nre 's/^submodule\.(.+)\.path .+$/\1/p') sed -nre 's/^submodule\.(.+)\.path .+$/\1/p')
test -z "$name" && test -z "$name" &&
die "No submodule mapping found in .gitmodules for path '$path'" die "No submodule mapping found in .gitmodules for path '$path'"
@ -116,7 +116,7 @@ module_add()
test -e "$path" && test -e "$path" &&
die "'$path' already exists" die "'$path' already exists"


git-ls-files --error-unmatch "$path" > /dev/null 2>&1 && git ls-files --error-unmatch "$path" > /dev/null 2>&1 &&
die "'$path' already exists in the index" die "'$path' already exists in the index"


module_clone "$path" "$repo" || exit module_clone "$path" "$repo" || exit
@ -143,14 +143,14 @@ modules_init()
do do
# Skip already registered paths # Skip already registered paths
name=$(module_name "$path") || exit name=$(module_name "$path") || exit
url=$(git-config submodule."$name".url) url=$(git config submodule."$name".url)
test -z "$url" || continue test -z "$url" || continue


url=$(GIT_CONFIG=.gitmodules git-config submodule."$name".url) url=$(GIT_CONFIG=.gitmodules git config submodule."$name".url)
test -z "$url" && test -z "$url" &&
die "No url found for submodule path '$path' in .gitmodules" die "No url found for submodule path '$path' in .gitmodules"


git-config submodule."$name".url "$url" || git config submodule."$name".url "$url" ||
die "Failed to register url for submodule path '$path'" die "Failed to register url for submodule path '$path'"


say "Submodule '$name' ($url) registered for path '$path'" say "Submodule '$name' ($url) registered for path '$path'"
@ -168,7 +168,7 @@ modules_update()
while read mode sha1 stage path while read mode sha1 stage path
do do
name=$(module_name "$path") || exit name=$(module_name "$path") || exit
url=$(git-config submodule."$name".url) url=$(git config submodule."$name".url)
if test -z "$url" if test -z "$url"
then then
# Only mention uninitialized submodules when its # Only mention uninitialized submodules when its
@ -184,7 +184,7 @@ modules_update()
subsha1= subsha1=
else else
subsha1=$(unset GIT_DIR && cd "$path" && subsha1=$(unset GIT_DIR && cd "$path" &&
git-rev-parse --verify HEAD) || git rev-parse --verify HEAD) ||
die "Unable to find current revision in submodule path '$path'" die "Unable to find current revision in submodule path '$path'"
fi fi


@ -203,9 +203,9 @@ set_name_rev () {
revname=$( ( revname=$( (
unset GIT_DIR && unset GIT_DIR &&
cd "$1" && { cd "$1" && {
git-describe "$2" 2>/dev/null || git describe "$2" 2>/dev/null ||
git-describe --tags "$2" 2>/dev/null || git describe --tags "$2" 2>/dev/null ||
git-describe --contains --tags "$2" git describe --contains --tags "$2"
} }
) ) ) )
test -z "$revname" || revname=" ($revname)" test -z "$revname" || revname=" ($revname)"
@ -227,13 +227,13 @@ modules_list()
while read mode sha1 stage path while read mode sha1 stage path
do do
name=$(module_name "$path") || exit name=$(module_name "$path") || exit
url=$(git-config submodule."$name".url) url=$(git config submodule."$name".url)
if test -z "url" || ! test -d "$path"/.git if test -z "url" || ! test -d "$path"/.git
then then
say "-$sha1 $path" say "-$sha1 $path"
continue; continue;
fi fi
revname=$(unset GIT_DIR && cd "$path" && git-describe --tags $sha1) revname=$(unset GIT_DIR && cd "$path" && git describe --tags $sha1)
set_name_rev "$path" $"sha1" set_name_rev "$path" $"sha1"
if git diff-files --quiet -- "$path" if git diff-files --quiet -- "$path"
then then
@ -241,7 +241,7 @@ modules_list()
else else
if test -z "$cached" if test -z "$cached"
then then
sha1=$(unset GIT_DIR && cd "$path" && git-rev-parse --verify HEAD) sha1=$(unset GIT_DIR && cd "$path" && git rev-parse --verify HEAD)
set_name_rev "$path" $"sha1" set_name_rev "$path" $"sha1"
fi fi
say "+$sha1 $path$revname" say "+$sha1 $path$revname"

View File

@ -118,12 +118,12 @@ do
had_error=0 had_error=0
for tag for tag
do do
cur=$(git-show-ref --verify --hash -- "refs/tags/$tag") || { cur=$(git show-ref --verify --hash -- "refs/tags/$tag") || {
echo >&2 "Seriously, what tag are you talking about?" echo >&2 "Seriously, what tag are you talking about?"
had_error=1 had_error=1
continue continue
} }
git-update-ref -m 'tag: delete' -d "refs/tags/$tag" "$cur" || { git update-ref -m 'tag: delete' -d "refs/tags/$tag" "$cur" || {
had_error=1 had_error=1
continue continue
} }
@ -134,7 +134,7 @@ do
-v) -v)
shift shift
tag_name="$1" tag_name="$1"
tag=$(git-show-ref --verify --hash -- "refs/tags/$tag_name") || tag=$(git show-ref --verify --hash -- "refs/tags/$tag_name") ||
die "Seriously, what tag are you talking about?" die "Seriously, what tag are you talking about?"
git-verify-tag -v "$tag" git-verify-tag -v "$tag"
exit $? exit $?
@ -153,21 +153,21 @@ done
name="$1" name="$1"
[ "$name" ] || usage [ "$name" ] || usage
prev=0000000000000000000000000000000000000000 prev=0000000000000000000000000000000000000000
if git-show-ref --verify --quiet -- "refs/tags/$name" if git show-ref --verify --quiet -- "refs/tags/$name"
then then
test -n "$force" || die "tag '$name' already exists" test -n "$force" || die "tag '$name' already exists"
prev=`git rev-parse "refs/tags/$name"` prev=`git rev-parse "refs/tags/$name"`
fi fi
shift shift
git-check-ref-format "tags/$name" || git check-ref-format "tags/$name" ||
die "we do not like '$name' as a tag name." die "we do not like '$name' as a tag name."


object=$(git-rev-parse --verify --default HEAD "$@") || exit 1 object=$(git rev-parse --verify --default HEAD "$@") || exit 1
type=$(git-cat-file -t $object) || exit 1 type=$(git cat-file -t $object) || exit 1
tagger=$(git-var GIT_COMMITTER_IDENT) || exit 1 tagger=$(git-var GIT_COMMITTER_IDENT) || exit 1


test -n "$username" || test -n "$username" ||
username=$(git-repo-config user.signingkey) || username=$(git repo-config user.signingkey) ||
username=$(expr "z$tagger" : 'z\(.*>\)') username=$(expr "z$tagger" : 'z\(.*>\)')


trap 'rm -f "$GIT_DIR"/TAG_TMP* "$GIT_DIR"/TAG_FINALMSG "$GIT_DIR"/TAG_EDITMSG' 0 trap 'rm -f "$GIT_DIR"/TAG_TMP* "$GIT_DIR"/TAG_FINALMSG "$GIT_DIR"/TAG_EDITMSG' 0
@ -183,7 +183,7 @@ if [ "$annotate" ]; then
fi fi


grep -v '^#' <"$GIT_DIR"/TAG_EDITMSG | grep -v '^#' <"$GIT_DIR"/TAG_EDITMSG |
git-stripspace >"$GIT_DIR"/TAG_FINALMSG git stripspace >"$GIT_DIR"/TAG_FINALMSG


[ -s "$GIT_DIR"/TAG_FINALMSG -o -n "$message_given" ] || { [ -s "$GIT_DIR"/TAG_FINALMSG -o -n "$message_given" ] || {
echo >&2 "No tag message?" echo >&2 "No tag message?"

View File

@ -21,7 +21,7 @@ then
usage usage
fi fi


type="$(git-cat-file -t "$1" 2>/dev/null)" || type="$(git cat-file -t "$1" 2>/dev/null)" ||
die "$1: no such object." die "$1: no such object."


test "$type" = tag || test "$type" = tag ||
@ -29,14 +29,14 @@ test "$type" = tag ||


case "$verbose" in case "$verbose" in
t) t)
git-cat-file -p "$1" | git cat-file -p "$1" |
sed -n -e '/^-----BEGIN PGP SIGNATURE-----/q' -e p sed -n -e '/^-----BEGIN PGP SIGNATURE-----/q' -e p
;; ;;
esac esac


trap 'rm -f "$GIT_DIR/.tmp-vtag"' 0 trap 'rm -f "$GIT_DIR/.tmp-vtag"' 0


git-cat-file tag "$1" >"$GIT_DIR/.tmp-vtag" || exit 1 git cat-file tag "$1" >"$GIT_DIR/.tmp-vtag" || exit 1
sed -n -e ' sed -n -e '
/^-----BEGIN PGP SIGNATURE-----$/q /^-----BEGIN PGP SIGNATURE-----$/q
p p

View File

@ -10,14 +10,14 @@ do
echo This is Z/$p from the original tree. >Z/$p echo This is Z/$p from the original tree. >Z/$p
test_expect_success \ test_expect_success \
"adding test file $p and Z/$p" \ "adding test file $p and Z/$p" \
'git-update-index --add $p && 'git update-index --add $p &&
git-update-index --add Z/$p' git update-index --add Z/$p'
done done
done done
echo This is SS from the original tree. >SS echo This is SS from the original tree. >SS
test_expect_success \ test_expect_success \
'adding test file SS' \ 'adding test file SS' \
'git-update-index --add SS' 'git update-index --add SS'
cat >TT <<\EOF cat >TT <<\EOF
This is a trivial merge sample text. This is a trivial merge sample text.
Branch A is expected to upcase this word, here. Branch A is expected to upcase this word, here.
@ -32,10 +32,10 @@ This concludes the trivial merge sample file.
EOF EOF
test_expect_success \ test_expect_success \
'adding test file TT' \ 'adding test file TT' \
'git-update-index --add TT' 'git update-index --add TT'
test_expect_success \ test_expect_success \
'prepare initial tree' \ 'prepare initial tree' \
'tree_O=$(git-write-tree)' 'tree_O=$(git write-tree)'


################################################################ ################################################################
# Branch A and B makes the changes according to the above matrix. # Branch A and B makes the changes according to the above matrix.
@ -47,14 +47,14 @@ to_remove=$(echo D? Z/D?)
rm -f $to_remove rm -f $to_remove
test_expect_success \ test_expect_success \
'change in branch A (removal)' \ 'change in branch A (removal)' \
'git-update-index --remove $to_remove' 'git update-index --remove $to_remove'


for p in M? Z/M? for p in M? Z/M?
do do
echo This is modified $p in the branch A. >$p echo This is modified $p in the branch A. >$p
test_expect_success \ test_expect_success \
'change in branch A (modification)' \ 'change in branch A (modification)' \
"git-update-index $p" "git update-index $p"
done done


for p in AN AA Z/AN Z/AA for p in AN AA Z/AN Z/AA
@ -62,31 +62,31 @@ do
echo This is added $p in the branch A. >$p echo This is added $p in the branch A. >$p
test_expect_success \ test_expect_success \
'change in branch A (addition)' \ 'change in branch A (addition)' \
"git-update-index --add $p" "git update-index --add $p"
done done


echo This is SS from the modified tree. >SS echo This is SS from the modified tree. >SS
echo This is LL from the modified tree. >LL echo This is LL from the modified tree. >LL
test_expect_success \ test_expect_success \
'change in branch A (addition)' \ 'change in branch A (addition)' \
'git-update-index --add LL && 'git update-index --add LL &&
git-update-index SS' git update-index SS'
mv TT TT- mv TT TT-
sed -e '/Branch A/s/word/WORD/g' <TT- >TT sed -e '/Branch A/s/word/WORD/g' <TT- >TT
rm -f TT- rm -f TT-
test_expect_success \ test_expect_success \
'change in branch A (edit)' \ 'change in branch A (edit)' \
'git-update-index TT' 'git update-index TT'


mkdir DF mkdir DF
echo Branch A makes a file at DF/DF, creating a directory DF. >DF/DF echo Branch A makes a file at DF/DF, creating a directory DF. >DF/DF
test_expect_success \ test_expect_success \
'change in branch A (change file to directory)' \ 'change in branch A (change file to directory)' \
'git-update-index --add DF/DF' 'git update-index --add DF/DF'


test_expect_success \ test_expect_success \
'recording branch A tree' \ 'recording branch A tree' \
'tree_A=$(git-write-tree)' 'tree_A=$(git write-tree)'


################################################################ ################################################################
# Branch B # Branch B
@ -96,21 +96,21 @@ rm -rf [NDMASLT][NDMASLT] Z DF
mkdir Z mkdir Z
test_expect_success \ test_expect_success \
'reading original tree and checking out' \ 'reading original tree and checking out' \
'git-read-tree $tree_O && 'git read-tree $tree_O &&
git-checkout-index -a' git checkout-index -a'


to_remove=$(echo ?D Z/?D) to_remove=$(echo ?D Z/?D)
rm -f $to_remove rm -f $to_remove
test_expect_success \ test_expect_success \
'change in branch B (removal)' \ 'change in branch B (removal)' \
"git-update-index --remove $to_remove" "git update-index --remove $to_remove"


for p in ?M Z/?M for p in ?M Z/?M
do do
echo This is modified $p in the branch B. >$p echo This is modified $p in the branch B. >$p
test_expect_success \ test_expect_success \
'change in branch B (modification)' \ 'change in branch B (modification)' \
"git-update-index $p" "git update-index $p"
done done


for p in NA AA Z/NA Z/AA for p in NA AA Z/NA Z/AA
@ -118,41 +118,41 @@ do
echo This is added $p in the branch B. >$p echo This is added $p in the branch B. >$p
test_expect_success \ test_expect_success \
'change in branch B (addition)' \ 'change in branch B (addition)' \
"git-update-index --add $p" "git update-index --add $p"
done done
echo This is SS from the modified tree. >SS echo This is SS from the modified tree. >SS
echo This is LL from the modified tree. >LL echo This is LL from the modified tree. >LL
test_expect_success \ test_expect_success \
'change in branch B (addition and modification)' \ 'change in branch B (addition and modification)' \
'git-update-index --add LL && 'git update-index --add LL &&
git-update-index SS' git update-index SS'
mv TT TT- mv TT TT-
sed -e '/Branch B/s/word/WORD/g' <TT- >TT sed -e '/Branch B/s/word/WORD/g' <TT- >TT
rm -f TT- rm -f TT-
test_expect_success \ test_expect_success \
'change in branch B (modification)' \ 'change in branch B (modification)' \
'git-update-index TT' 'git update-index TT'


echo Branch B makes a file at DF. >DF echo Branch B makes a file at DF. >DF
test_expect_success \ test_expect_success \
'change in branch B (addition of a file to conflict with directory)' \ 'change in branch B (addition of a file to conflict with directory)' \
'git-update-index --add DF' 'git update-index --add DF'


test_expect_success \ test_expect_success \
'recording branch B tree' \ 'recording branch B tree' \
'tree_B=$(git-write-tree)' 'tree_B=$(git write-tree)'


test_expect_success \ test_expect_success \
'keep contents of 3 trees for easy access' \ 'keep contents of 3 trees for easy access' \
'rm -f .git/index && 'rm -f .git/index &&
git-read-tree $tree_O && git read-tree $tree_O &&
mkdir .orig-O && mkdir .orig-O &&
git-checkout-index --prefix=.orig-O/ -f -q -a && git checkout-index --prefix=.orig-O/ -f -q -a &&
rm -f .git/index && rm -f .git/index &&
git-read-tree $tree_A && git read-tree $tree_A &&
mkdir .orig-A && mkdir .orig-A &&
git-checkout-index --prefix=.orig-A/ -f -q -a && git checkout-index --prefix=.orig-A/ -f -q -a &&
rm -f .git/index && rm -f .git/index &&
git-read-tree $tree_B && git read-tree $tree_B &&
mkdir .orig-B && mkdir .orig-B &&
git-checkout-index --prefix=.orig-B/ -f -q -a' git checkout-index --prefix=.orig-B/ -f -q -a'

View File

@ -31,12 +31,12 @@ fi
. ./test-lib.sh . ./test-lib.sh


################################################################ ################################################################
# git-init has been done in an empty repository. # git init has been done in an empty repository.
# make sure it is empty. # make sure it is empty.


find .git/objects -type f -print >should-be-empty find .git/objects -type f -print >should-be-empty
test_expect_success \ test_expect_success \
'.git/objects should be empty after git-init in an empty repo.' \ '.git/objects should be empty after git init in an empty repo.' \
'cmp -s /dev/null should-be-empty' 'cmp -s /dev/null should-be-empty'


# also it should have 2 subdirectories; no fan-out anymore, pack, and info. # also it should have 2 subdirectories; no fan-out anymore, pack, and info.
@ -51,17 +51,17 @@ test_expect_success \


# updating a new file without --add should fail. # updating a new file without --add should fail.
test_expect_failure \ test_expect_failure \
'git-update-index without --add should fail adding.' \ 'git update-index without --add should fail adding.' \
'git-update-index should-be-empty' 'git update-index should-be-empty'


# and with --add it should succeed, even if it is empty (it used to fail). # and with --add it should succeed, even if it is empty (it used to fail).
test_expect_success \ test_expect_success \
'git-update-index with --add should succeed.' \ 'git update-index with --add should succeed.' \
'git-update-index --add should-be-empty' 'git update-index --add should-be-empty'


test_expect_success \ test_expect_success \
'writing tree out with git-write-tree' \ 'writing tree out with git write-tree' \
'tree=$(git-write-tree)' 'tree=$(git write-tree)'


# we know the shape and contents of the tree and know the object ID for it. # we know the shape and contents of the tree and know the object ID for it.
test_expect_success \ test_expect_success \
@ -71,17 +71,17 @@ test_expect_success \
# Removing paths. # Removing paths.
rm -f should-be-empty full-of-directories rm -f should-be-empty full-of-directories
test_expect_failure \ test_expect_failure \
'git-update-index without --remove should fail removing.' \ 'git update-index without --remove should fail removing.' \
'git-update-index should-be-empty' 'git update-index should-be-empty'


test_expect_success \ test_expect_success \
'git-update-index with --remove should be able to remove.' \ 'git update-index with --remove should be able to remove.' \
'git-update-index --remove should-be-empty' 'git update-index --remove should-be-empty'


# Empty tree can be written with recent write-tree. # Empty tree can be written with recent write-tree.
test_expect_success \ test_expect_success \
'git-write-tree should be able to write an empty tree.' \ 'git write-tree should be able to write an empty tree.' \
'tree=$(git-write-tree)' 'tree=$(git write-tree)'


test_expect_success \ test_expect_success \
'validate object ID of a known tree.' \ 'validate object ID of a known tree.' \
@ -95,13 +95,13 @@ do
ln -s "hello $p" ${p}sym ln -s "hello $p" ${p}sym
done done
test_expect_success \ test_expect_success \
'adding various types of objects with git-update-index --add.' \ 'adding various types of objects with git update-index --add.' \
'find path* ! -type d -print | xargs git-update-index --add' 'find path* ! -type d -print | xargs git update-index --add'


# Show them and see that matches what we expect. # Show them and see that matches what we expect.
test_expect_success \ test_expect_success \
'showing stage with git-ls-files --stage' \ 'showing stage with git ls-files --stage' \
'git-ls-files --stage >current' 'git ls-files --stage >current'


cat >expected <<\EOF cat >expected <<\EOF
100644 f87290f8eb2cbbea7857214459a0739927eab154 0 path0 100644 f87290f8eb2cbbea7857214459a0739927eab154 0 path0
@ -114,19 +114,19 @@ cat >expected <<\EOF
120000 6649a1ebe9e9f1c553b66f5a6e74136a07ccc57c 0 path3/subp3/file3sym 120000 6649a1ebe9e9f1c553b66f5a6e74136a07ccc57c 0 path3/subp3/file3sym
EOF EOF
test_expect_success \ test_expect_success \
'validate git-ls-files output for a known tree.' \ 'validate git ls-files output for a known tree.' \
'diff current expected' 'diff current expected'


test_expect_success \ test_expect_success \
'writing tree out with git-write-tree.' \ 'writing tree out with git write-tree.' \
'tree=$(git-write-tree)' 'tree=$(git write-tree)'
test_expect_success \ test_expect_success \
'validate object ID for a known tree.' \ 'validate object ID for a known tree.' \
'test "$tree" = 087704a96baf1c2d1c869a8b084481e121c88b5b' 'test "$tree" = 087704a96baf1c2d1c869a8b084481e121c88b5b'


test_expect_success \ test_expect_success \
'showing tree with git-ls-tree' \ 'showing tree with git ls-tree' \
'git-ls-tree $tree >current' 'git ls-tree $tree >current'
cat >expected <<\EOF cat >expected <<\EOF
100644 blob f87290f8eb2cbbea7857214459a0739927eab154 path0 100644 blob f87290f8eb2cbbea7857214459a0739927eab154 path0
120000 blob 15a98433ae33114b085f3eb3bb03b832b3180a01 path0sym 120000 blob 15a98433ae33114b085f3eb3bb03b832b3180a01 path0sym
@ -134,14 +134,14 @@ cat >expected <<\EOF
040000 tree 21ae8269cacbe57ae09138dcc3a2887f904d02b3 path3 040000 tree 21ae8269cacbe57ae09138dcc3a2887f904d02b3 path3
EOF EOF
test_expect_success \ test_expect_success \
'git-ls-tree output for a known tree.' \ 'git ls-tree output for a known tree.' \
'diff current expected' 'diff current expected'


# This changed in ls-tree pathspec change -- recursive does # This changed in ls-tree pathspec change -- recursive does
# not show tree nodes anymore. # not show tree nodes anymore.
test_expect_success \ test_expect_success \
'showing tree with git-ls-tree -r' \ 'showing tree with git ls-tree -r' \
'git-ls-tree -r $tree >current' 'git ls-tree -r $tree >current'
cat >expected <<\EOF cat >expected <<\EOF
100644 blob f87290f8eb2cbbea7857214459a0739927eab154 path0 100644 blob f87290f8eb2cbbea7857214459a0739927eab154 path0
120000 blob 15a98433ae33114b085f3eb3bb03b832b3180a01 path0sym 120000 blob 15a98433ae33114b085f3eb3bb03b832b3180a01 path0sym
@ -153,13 +153,13 @@ cat >expected <<\EOF
120000 blob 6649a1ebe9e9f1c553b66f5a6e74136a07ccc57c path3/subp3/file3sym 120000 blob 6649a1ebe9e9f1c553b66f5a6e74136a07ccc57c path3/subp3/file3sym
EOF EOF
test_expect_success \ test_expect_success \
'git-ls-tree -r output for a known tree.' \ 'git ls-tree -r output for a known tree.' \
'diff current expected' 'diff current expected'


# But with -r -t we can have both. # But with -r -t we can have both.
test_expect_success \ test_expect_success \
'showing tree with git-ls-tree -r -t' \ 'showing tree with git ls-tree -r -t' \
'git-ls-tree -r -t $tree >current' 'git ls-tree -r -t $tree >current'
cat >expected <<\EOF cat >expected <<\EOF
100644 blob f87290f8eb2cbbea7857214459a0739927eab154 path0 100644 blob f87290f8eb2cbbea7857214459a0739927eab154 path0
120000 blob 15a98433ae33114b085f3eb3bb03b832b3180a01 path0sym 120000 blob 15a98433ae33114b085f3eb3bb03b832b3180a01 path0sym
@ -174,19 +174,19 @@ cat >expected <<\EOF
120000 blob 6649a1ebe9e9f1c553b66f5a6e74136a07ccc57c path3/subp3/file3sym 120000 blob 6649a1ebe9e9f1c553b66f5a6e74136a07ccc57c path3/subp3/file3sym
EOF EOF
test_expect_success \ test_expect_success \
'git-ls-tree -r output for a known tree.' \ 'git ls-tree -r output for a known tree.' \
'diff current expected' 'diff current expected'


test_expect_success \ test_expect_success \
'writing partial tree out with git-write-tree --prefix.' \ 'writing partial tree out with git write-tree --prefix.' \
'ptree=$(git-write-tree --prefix=path3)' 'ptree=$(git write-tree --prefix=path3)'
test_expect_success \ test_expect_success \
'validate object ID for a known tree.' \ 'validate object ID for a known tree.' \
'test "$ptree" = 21ae8269cacbe57ae09138dcc3a2887f904d02b3' 'test "$ptree" = 21ae8269cacbe57ae09138dcc3a2887f904d02b3'


test_expect_success \ test_expect_success \
'writing partial tree out with git-write-tree --prefix.' \ 'writing partial tree out with git write-tree --prefix.' \
'ptree=$(git-write-tree --prefix=path3/subp3)' 'ptree=$(git write-tree --prefix=path3/subp3)'
test_expect_success \ test_expect_success \
'validate object ID for a known tree.' \ 'validate object ID for a known tree.' \
'test "$ptree" = 3c5e5399f3a333eddecce7a9b9465b63f65f51e2' 'test "$ptree" = 3c5e5399f3a333eddecce7a9b9465b63f65f51e2'
@ -202,24 +202,24 @@ EOF
rm .git/index rm .git/index
test_expect_success \ test_expect_success \
'put invalid objects into the index.' \ 'put invalid objects into the index.' \
'git-update-index --index-info < badobjects' 'git update-index --index-info < badobjects'


test_expect_failure \ test_expect_failure \
'writing this tree without --missing-ok.' \ 'writing this tree without --missing-ok.' \
'git-write-tree' 'git write-tree'


test_expect_success \ test_expect_success \
'writing this tree with --missing-ok.' \ 'writing this tree with --missing-ok.' \
'git-write-tree --missing-ok' 'git write-tree --missing-ok'




################################################################ ################################################################
rm .git/index rm .git/index
test_expect_success \ test_expect_success \
'git-read-tree followed by write-tree should be idempotent.' \ 'git read-tree followed by write-tree should be idempotent.' \
'git-read-tree $tree && 'git read-tree $tree &&
test -f .git/index && test -f .git/index &&
newtree=$(git-write-tree) && newtree=$(git write-tree) &&
test "$newtree" = "$tree"' test "$newtree" = "$tree"'


cat >expected <<\EOF cat >expected <<\EOF
@ -233,36 +233,36 @@ cat >expected <<\EOF
:120000 120000 6649a1ebe9e9f1c553b66f5a6e74136a07ccc57c 0000000000000000000000000000000000000000 M path3/subp3/file3sym :120000 120000 6649a1ebe9e9f1c553b66f5a6e74136a07ccc57c 0000000000000000000000000000000000000000 M path3/subp3/file3sym
EOF EOF
test_expect_success \ test_expect_success \
'validate git-diff-files output for a know cache/work tree state.' \ 'validate git diff-files output for a know cache/work tree state.' \
'git-diff-files >current && diff >/dev/null -b current expected' 'git diff-files >current && diff >/dev/null -b current expected'


test_expect_success \ test_expect_success \
'git-update-index --refresh should succeed.' \ 'git update-index --refresh should succeed.' \
'git-update-index --refresh' 'git update-index --refresh'


test_expect_success \ test_expect_success \
'no diff after checkout and git-update-index --refresh.' \ 'no diff after checkout and git update-index --refresh.' \
'git-diff-files >current && cmp -s current /dev/null' 'git diff-files >current && cmp -s current /dev/null'


################################################################ ################################################################
P=087704a96baf1c2d1c869a8b084481e121c88b5b P=087704a96baf1c2d1c869a8b084481e121c88b5b
test_expect_success \ test_expect_success \
'git-commit-tree records the correct tree in a commit.' \ 'git commit-tree records the correct tree in a commit.' \
'commit0=$(echo NO | git-commit-tree $P) && 'commit0=$(echo NO | git commit-tree $P) &&
tree=$(git show --pretty=raw $commit0 | tree=$(git show --pretty=raw $commit0 |
sed -n -e "s/^tree //p" -e "/^author /q") && sed -n -e "s/^tree //p" -e "/^author /q") &&
test "z$tree" = "z$P"' test "z$tree" = "z$P"'


test_expect_success \ test_expect_success \
'git-commit-tree records the correct parent in a commit.' \ 'git commit-tree records the correct parent in a commit.' \
'commit1=$(echo NO | git-commit-tree $P -p $commit0) && 'commit1=$(echo NO | git commit-tree $P -p $commit0) &&
parent=$(git show --pretty=raw $commit1 | parent=$(git show --pretty=raw $commit1 |
sed -n -e "s/^parent //p" -e "/^author /q") && sed -n -e "s/^parent //p" -e "/^author /q") &&
test "z$commit0" = "z$parent"' test "z$commit0" = "z$parent"'


test_expect_success \ test_expect_success \
'git-commit-tree omits duplicated parent in a commit.' \ 'git commit-tree omits duplicated parent in a commit.' \
'commit2=$(echo NO | git-commit-tree $P -p $commit0 -p $commit0) && 'commit2=$(echo NO | git commit-tree $P -p $commit0 -p $commit0) &&
parent=$(git show --pretty=raw $commit2 | parent=$(git show --pretty=raw $commit2 |
sed -n -e "s/^parent //p" -e "/^author /q" | sed -n -e "s/^parent //p" -e "/^author /q" |
sort -u) && sort -u) &&

View File

@ -3,7 +3,7 @@
# Copyright (c) 2007 Carlos Rica # Copyright (c) 2007 Carlos Rica
# #


test_description='git-stripspace' test_description='git stripspace'


. ./test-lib.sh . ./test-lib.sh


@ -15,292 +15,292 @@ ttt="$t40$t40$t40$t40$t40$t40$t40$t40$t40$t40" # 400
test_expect_success \ test_expect_success \
'long lines without spaces should be unchanged' ' 'long lines without spaces should be unchanged' '
echo "$ttt" >expect && echo "$ttt" >expect &&
git-stripspace <expect >actual && git stripspace <expect >actual &&
git diff expect actual && git diff expect actual &&


echo "$ttt$ttt" >expect && echo "$ttt$ttt" >expect &&
git-stripspace <expect >actual && git stripspace <expect >actual &&
git diff expect actual && git diff expect actual &&


echo "$ttt$ttt$ttt" >expect && echo "$ttt$ttt$ttt" >expect &&
git-stripspace <expect >actual && git stripspace <expect >actual &&
git diff expect actual && git diff expect actual &&


echo "$ttt$ttt$ttt$ttt" >expect && echo "$ttt$ttt$ttt$ttt" >expect &&
git-stripspace <expect >actual && git stripspace <expect >actual &&
git diff expect actual git diff expect actual
' '


test_expect_success \ test_expect_success \
'lines with spaces at the beginning should be unchanged' ' 'lines with spaces at the beginning should be unchanged' '
echo "$sss$ttt" >expect && echo "$sss$ttt" >expect &&
git-stripspace <expect >actual && git stripspace <expect >actual &&
git diff expect actual && git diff expect actual &&


echo "$sss$sss$ttt" >expect && echo "$sss$sss$ttt" >expect &&
git-stripspace <expect >actual && git stripspace <expect >actual &&
git diff expect actual && git diff expect actual &&


echo "$sss$sss$sss$ttt" >expect && echo "$sss$sss$sss$ttt" >expect &&
git-stripspace <expect >actual && git stripspace <expect >actual &&
git diff expect actual git diff expect actual
' '


test_expect_success \ test_expect_success \
'lines with intermediate spaces should be unchanged' ' 'lines with intermediate spaces should be unchanged' '
echo "$ttt$sss$ttt" >expect && echo "$ttt$sss$ttt" >expect &&
git-stripspace <expect >actual && git stripspace <expect >actual &&
git diff expect actual && git diff expect actual &&


echo "$ttt$sss$sss$ttt" >expect && echo "$ttt$sss$sss$ttt" >expect &&
git-stripspace <expect >actual && git stripspace <expect >actual &&
git diff expect actual git diff expect actual
' '


test_expect_success \ test_expect_success \
'consecutive blank lines should be unified' ' 'consecutive blank lines should be unified' '
printf "$ttt\n\n$ttt\n" > expect && printf "$ttt\n\n$ttt\n" > expect &&
printf "$ttt\n\n\n\n\n$ttt\n" | git-stripspace >actual && printf "$ttt\n\n\n\n\n$ttt\n" | git stripspace >actual &&
git diff expect actual && git diff expect actual &&


printf "$ttt$ttt\n\n$ttt\n" > expect && printf "$ttt$ttt\n\n$ttt\n" > expect &&
printf "$ttt$ttt\n\n\n\n\n$ttt\n" | git-stripspace >actual && printf "$ttt$ttt\n\n\n\n\n$ttt\n" | git stripspace >actual &&
git diff expect actual && git diff expect actual &&


printf "$ttt$ttt$ttt\n\n$ttt\n" > expect && printf "$ttt$ttt$ttt\n\n$ttt\n" > expect &&
printf "$ttt$ttt$ttt\n\n\n\n\n$ttt\n" | git-stripspace >actual && printf "$ttt$ttt$ttt\n\n\n\n\n$ttt\n" | git stripspace >actual &&
git diff expect actual && git diff expect actual &&


printf "$ttt\n\n$ttt\n" > expect && printf "$ttt\n\n$ttt\n" > expect &&
printf "$ttt\n\n\n\n\n$ttt\n" | git-stripspace >actual && printf "$ttt\n\n\n\n\n$ttt\n" | git stripspace >actual &&
git diff expect actual && git diff expect actual &&


printf "$ttt\n\n$ttt$ttt\n" > expect && printf "$ttt\n\n$ttt$ttt\n" > expect &&
printf "$ttt\n\n\n\n\n$ttt$ttt\n" | git-stripspace >actual && printf "$ttt\n\n\n\n\n$ttt$ttt\n" | git stripspace >actual &&
git diff expect actual && git diff expect actual &&


printf "$ttt\n\n$ttt$ttt$ttt\n" > expect && printf "$ttt\n\n$ttt$ttt$ttt\n" > expect &&
printf "$ttt\n\n\n\n\n$ttt$ttt$ttt\n" | git-stripspace >actual && printf "$ttt\n\n\n\n\n$ttt$ttt$ttt\n" | git stripspace >actual &&
git diff expect actual git diff expect actual
' '


test_expect_success \ test_expect_success \
'consecutive blank lines at the beginning should be removed' ' 'consecutive blank lines at the beginning should be removed' '
printf "" > expect && printf "" > expect &&
printf "\n" | git-stripspace >actual && printf "\n" | git stripspace >actual &&
git diff expect actual && git diff expect actual &&


printf "" > expect && printf "" > expect &&
printf "\n\n\n" | git-stripspace >actual && printf "\n\n\n" | git stripspace >actual &&
git diff expect actual && git diff expect actual &&


printf "" > expect && printf "" > expect &&
printf "$sss\n$sss\n$sss\n" | git-stripspace >actual && printf "$sss\n$sss\n$sss\n" | git stripspace >actual &&
git diff expect actual && git diff expect actual &&


printf "" > expect && printf "" > expect &&
printf "$sss$sss\n$sss\n\n" | git-stripspace >actual && printf "$sss$sss\n$sss\n\n" | git stripspace >actual &&
git diff expect actual && git diff expect actual &&


printf "" > expect && printf "" > expect &&
printf "\n$sss\n$sss$sss\n" | git-stripspace >actual && printf "\n$sss\n$sss$sss\n" | git stripspace >actual &&
git diff expect actual && git diff expect actual &&


printf "" > expect && printf "" > expect &&
printf "$sss$sss$sss$sss\n\n\n" | git-stripspace >actual && printf "$sss$sss$sss$sss\n\n\n" | git stripspace >actual &&
git diff expect actual && git diff expect actual &&


printf "" > expect && printf "" > expect &&
printf "\n$sss$sss$sss$sss\n\n" | git-stripspace >actual && printf "\n$sss$sss$sss$sss\n\n" | git stripspace >actual &&
git diff expect actual && git diff expect actual &&


printf "" > expect && printf "" > expect &&
printf "\n\n$sss$sss$sss$sss\n" | git-stripspace >actual && printf "\n\n$sss$sss$sss$sss\n" | git stripspace >actual &&
git diff expect actual && git diff expect actual &&


printf "$ttt\n" > expect && printf "$ttt\n" > expect &&
printf "\n$ttt\n" | git-stripspace >actual && printf "\n$ttt\n" | git stripspace >actual &&
git diff expect actual && git diff expect actual &&


printf "$ttt\n" > expect && printf "$ttt\n" > expect &&
printf "\n\n\n$ttt\n" | git-stripspace >actual && printf "\n\n\n$ttt\n" | git stripspace >actual &&
git diff expect actual && git diff expect actual &&


printf "$ttt$ttt\n" > expect && printf "$ttt$ttt\n" > expect &&
printf "\n\n\n$ttt$ttt\n" | git-stripspace >actual && printf "\n\n\n$ttt$ttt\n" | git stripspace >actual &&
git diff expect actual && git diff expect actual &&


printf "$ttt$ttt$ttt\n" > expect && printf "$ttt$ttt$ttt\n" > expect &&
printf "\n\n\n$ttt$ttt$ttt\n" | git-stripspace >actual && printf "\n\n\n$ttt$ttt$ttt\n" | git stripspace >actual &&
git diff expect actual && git diff expect actual &&


printf "$ttt$ttt$ttt$ttt\n" > expect && printf "$ttt$ttt$ttt$ttt\n" > expect &&
printf "\n\n\n$ttt$ttt$ttt$ttt\n" | git-stripspace >actual && printf "\n\n\n$ttt$ttt$ttt$ttt\n" | git stripspace >actual &&
git diff expect actual && git diff expect actual &&


printf "$ttt\n" > expect && printf "$ttt\n" > expect &&
printf "$sss\n$sss\n$sss\n$ttt\n" | git-stripspace >actual && printf "$sss\n$sss\n$sss\n$ttt\n" | git stripspace >actual &&
git diff expect actual && git diff expect actual &&


printf "$ttt\n" > expect && printf "$ttt\n" > expect &&
printf "\n$sss\n$sss$sss\n$ttt\n" | git-stripspace >actual && printf "\n$sss\n$sss$sss\n$ttt\n" | git stripspace >actual &&
git diff expect actual && git diff expect actual &&


printf "$ttt\n" > expect && printf "$ttt\n" > expect &&
printf "$sss$sss\n$sss\n\n$ttt\n" | git-stripspace >actual && printf "$sss$sss\n$sss\n\n$ttt\n" | git stripspace >actual &&
git diff expect actual && git diff expect actual &&


printf "$ttt\n" > expect && printf "$ttt\n" > expect &&
printf "$sss$sss$sss\n\n\n$ttt\n" | git-stripspace >actual && printf "$sss$sss$sss\n\n\n$ttt\n" | git stripspace >actual &&
git diff expect actual && git diff expect actual &&


printf "$ttt\n" > expect && printf "$ttt\n" > expect &&
printf "\n$sss$sss$sss\n\n$ttt\n" | git-stripspace >actual && printf "\n$sss$sss$sss\n\n$ttt\n" | git stripspace >actual &&
git diff expect actual && git diff expect actual &&


printf "$ttt\n" > expect && printf "$ttt\n" > expect &&
printf "\n\n$sss$sss$sss\n$ttt\n" | git-stripspace >actual && printf "\n\n$sss$sss$sss\n$ttt\n" | git stripspace >actual &&
git diff expect actual git diff expect actual
' '


test_expect_success \ test_expect_success \
'consecutive blank lines at the end should be removed' ' 'consecutive blank lines at the end should be removed' '
printf "$ttt\n" > expect && printf "$ttt\n" > expect &&
printf "$ttt\n\n" | git-stripspace >actual && printf "$ttt\n\n" | git stripspace >actual &&
git diff expect actual && git diff expect actual &&


printf "$ttt\n" > expect && printf "$ttt\n" > expect &&
printf "$ttt\n\n\n\n" | git-stripspace >actual && printf "$ttt\n\n\n\n" | git stripspace >actual &&
git diff expect actual && git diff expect actual &&


printf "$ttt$ttt\n" > expect && printf "$ttt$ttt\n" > expect &&
printf "$ttt$ttt\n\n\n\n" | git-stripspace >actual && printf "$ttt$ttt\n\n\n\n" | git stripspace >actual &&
git diff expect actual && git diff expect actual &&


printf "$ttt$ttt$ttt\n" > expect && printf "$ttt$ttt$ttt\n" > expect &&
printf "$ttt$ttt$ttt\n\n\n\n" | git-stripspace >actual && printf "$ttt$ttt$ttt\n\n\n\n" | git stripspace >actual &&
git diff expect actual && git diff expect actual &&


printf "$ttt$ttt$ttt$ttt\n" > expect && printf "$ttt$ttt$ttt$ttt\n" > expect &&
printf "$ttt$ttt$ttt$ttt\n\n\n\n" | git-stripspace >actual && printf "$ttt$ttt$ttt$ttt\n\n\n\n" | git stripspace >actual &&
git diff expect actual && git diff expect actual &&


printf "$ttt\n" > expect && printf "$ttt\n" > expect &&
printf "$ttt\n$sss\n$sss\n$sss\n" | git-stripspace >actual && printf "$ttt\n$sss\n$sss\n$sss\n" | git stripspace >actual &&
git diff expect actual && git diff expect actual &&


printf "$ttt\n" > expect && printf "$ttt\n" > expect &&
printf "$ttt\n\n$sss\n$sss$sss\n" | git-stripspace >actual && printf "$ttt\n\n$sss\n$sss$sss\n" | git stripspace >actual &&
git diff expect actual && git diff expect actual &&


printf "$ttt\n" > expect && printf "$ttt\n" > expect &&
printf "$ttt\n$sss$sss\n$sss\n\n" | git-stripspace >actual && printf "$ttt\n$sss$sss\n$sss\n\n" | git stripspace >actual &&
git diff expect actual && git diff expect actual &&


printf "$ttt\n" > expect && printf "$ttt\n" > expect &&
printf "$ttt\n$sss$sss$sss\n\n\n" | git-stripspace >actual && printf "$ttt\n$sss$sss$sss\n\n\n" | git stripspace >actual &&
git diff expect actual && git diff expect actual &&


printf "$ttt\n" > expect && printf "$ttt\n" > expect &&
printf "$ttt\n\n$sss$sss$sss\n\n" | git-stripspace >actual && printf "$ttt\n\n$sss$sss$sss\n\n" | git stripspace >actual &&
git diff expect actual && git diff expect actual &&


printf "$ttt\n" > expect && printf "$ttt\n" > expect &&
printf "$ttt\n\n\n$sss$sss$sss\n" | git-stripspace >actual && printf "$ttt\n\n\n$sss$sss$sss\n" | git stripspace >actual &&
git diff expect actual git diff expect actual
' '


test_expect_success \ test_expect_success \
'text without newline at end should end with newline' ' 'text without newline at end should end with newline' '
test `printf "$ttt" | git-stripspace | wc -l` -gt 0 && test `printf "$ttt" | git stripspace | wc -l` -gt 0 &&
test `printf "$ttt$ttt" | git-stripspace | wc -l` -gt 0 && test `printf "$ttt$ttt" | git stripspace | wc -l` -gt 0 &&
test `printf "$ttt$ttt$ttt" | git-stripspace | wc -l` -gt 0 && test `printf "$ttt$ttt$ttt" | git stripspace | wc -l` -gt 0 &&
test `printf "$ttt$ttt$ttt$ttt" | git-stripspace | wc -l` -gt 0 test `printf "$ttt$ttt$ttt$ttt" | git stripspace | wc -l` -gt 0
' '


# text plus spaces at the end: # text plus spaces at the end:


test_expect_success \ test_expect_success \
'text plus spaces without newline at end should end with newline' ' 'text plus spaces without newline at end should end with newline' '
test `printf "$ttt$sss" | git-stripspace | wc -l` -gt 0 && test `printf "$ttt$sss" | git stripspace | wc -l` -gt 0 &&
test `printf "$ttt$ttt$sss" | git-stripspace | wc -l` -gt 0 && test `printf "$ttt$ttt$sss" | git stripspace | wc -l` -gt 0 &&
test `printf "$ttt$ttt$ttt$sss" | git-stripspace | wc -l` -gt 0 test `printf "$ttt$ttt$ttt$sss" | git stripspace | wc -l` -gt 0
test `printf "$ttt$sss$sss" | git-stripspace | wc -l` -gt 0 && test `printf "$ttt$sss$sss" | git stripspace | wc -l` -gt 0 &&
test `printf "$ttt$ttt$sss$sss" | git-stripspace | wc -l` -gt 0 && test `printf "$ttt$ttt$sss$sss" | git stripspace | wc -l` -gt 0 &&
test `printf "$ttt$sss$sss$sss" | git-stripspace | wc -l` -gt 0 test `printf "$ttt$sss$sss$sss" | git stripspace | wc -l` -gt 0
' '


test_expect_failure \ test_expect_failure \
'text plus spaces without newline at end should not show spaces' ' 'text plus spaces without newline at end should not show spaces' '
printf "$ttt$sss" | git-stripspace | grep -q " " || printf "$ttt$sss" | git stripspace | grep -q " " ||
printf "$ttt$ttt$sss" | git-stripspace | grep -q " " || printf "$ttt$ttt$sss" | git stripspace | grep -q " " ||
printf "$ttt$ttt$ttt$sss" | git-stripspace | grep -q " " || printf "$ttt$ttt$ttt$sss" | git stripspace | grep -q " " ||
printf "$ttt$sss$sss" | git-stripspace | grep -q " " || printf "$ttt$sss$sss" | git stripspace | grep -q " " ||
printf "$ttt$ttt$sss$sss" | git-stripspace | grep -q " " || printf "$ttt$ttt$sss$sss" | git stripspace | grep -q " " ||
printf "$ttt$sss$sss$sss" | git-stripspace | grep -q " " printf "$ttt$sss$sss$sss" | git stripspace | grep -q " "
' '


test_expect_success \ test_expect_success \
'text plus spaces without newline should show the correct lines' ' 'text plus spaces without newline should show the correct lines' '
printf "$ttt\n" >expect && printf "$ttt\n" >expect &&
printf "$ttt$sss" | git-stripspace >actual && printf "$ttt$sss" | git stripspace >actual &&
git diff expect actual && git diff expect actual &&


printf "$ttt\n" >expect && printf "$ttt\n" >expect &&
printf "$ttt$sss$sss" | git-stripspace >actual && printf "$ttt$sss$sss" | git stripspace >actual &&
git diff expect actual && git diff expect actual &&


printf "$ttt\n" >expect && printf "$ttt\n" >expect &&
printf "$ttt$sss$sss$sss" | git-stripspace >actual && printf "$ttt$sss$sss$sss" | git stripspace >actual &&
git diff expect actual && git diff expect actual &&


printf "$ttt$ttt\n" >expect && printf "$ttt$ttt\n" >expect &&
printf "$ttt$ttt$sss" | git-stripspace >actual && printf "$ttt$ttt$sss" | git stripspace >actual &&
git diff expect actual && git diff expect actual &&


printf "$ttt$ttt\n" >expect && printf "$ttt$ttt\n" >expect &&
printf "$ttt$ttt$sss$sss" | git-stripspace >actual && printf "$ttt$ttt$sss$sss" | git stripspace >actual &&
git diff expect actual && git diff expect actual &&


printf "$ttt$ttt$ttt\n" >expect && printf "$ttt$ttt$ttt\n" >expect &&
printf "$ttt$ttt$ttt$sss" | git-stripspace >actual && printf "$ttt$ttt$ttt$sss" | git stripspace >actual &&
git diff expect actual git diff expect actual
' '


test_expect_failure \ test_expect_failure \
'text plus spaces at end should not show spaces' ' 'text plus spaces at end should not show spaces' '
echo "$ttt$sss" | git-stripspace | grep -q " " || echo "$ttt$sss" | git stripspace | grep -q " " ||
echo "$ttt$ttt$sss" | git-stripspace | grep -q " " || echo "$ttt$ttt$sss" | git stripspace | grep -q " " ||
echo "$ttt$ttt$ttt$sss" | git-stripspace | grep -q " " || echo "$ttt$ttt$ttt$sss" | git stripspace | grep -q " " ||
echo "$ttt$sss$sss" | git-stripspace | grep -q " " || echo "$ttt$sss$sss" | git stripspace | grep -q " " ||
echo "$ttt$ttt$sss$sss" | git-stripspace | grep -q " " || echo "$ttt$ttt$sss$sss" | git stripspace | grep -q " " ||
echo "$ttt$sss$sss$sss" | git-stripspace | grep -q " " echo "$ttt$sss$sss$sss" | git stripspace | grep -q " "
' '


test_expect_success \ test_expect_success \
'text plus spaces at end should be cleaned and newline must remain' ' 'text plus spaces at end should be cleaned and newline must remain' '
echo "$ttt" >expect && echo "$ttt" >expect &&
echo "$ttt$sss" | git-stripspace >actual && echo "$ttt$sss" | git stripspace >actual &&
git diff expect actual && git diff expect actual &&


echo "$ttt" >expect && echo "$ttt" >expect &&
echo "$ttt$sss$sss" | git-stripspace >actual && echo "$ttt$sss$sss" | git stripspace >actual &&
git diff expect actual && git diff expect actual &&


echo "$ttt" >expect && echo "$ttt" >expect &&
echo "$ttt$sss$sss$sss" | git-stripspace >actual && echo "$ttt$sss$sss$sss" | git stripspace >actual &&
git diff expect actual && git diff expect actual &&


echo "$ttt$ttt" >expect && echo "$ttt$ttt" >expect &&
echo "$ttt$ttt$sss" | git-stripspace >actual && echo "$ttt$ttt$sss" | git stripspace >actual &&
git diff expect actual && git diff expect actual &&


echo "$ttt$ttt" >expect && echo "$ttt$ttt" >expect &&
echo "$ttt$ttt$sss$sss" | git-stripspace >actual && echo "$ttt$ttt$sss$sss" | git stripspace >actual &&
git diff expect actual && git diff expect actual &&


echo "$ttt$ttt$ttt" >expect && echo "$ttt$ttt$ttt" >expect &&
echo "$ttt$ttt$ttt$sss" | git-stripspace >actual && echo "$ttt$ttt$ttt$sss" | git stripspace >actual &&
git diff expect actual git diff expect actual
' '


@ -310,45 +310,45 @@ test_expect_success \
'spaces with newline at end should be replaced with empty string' ' 'spaces with newline at end should be replaced with empty string' '
printf "" >expect && printf "" >expect &&


echo | git-stripspace >actual && echo | git stripspace >actual &&
git diff expect actual && git diff expect actual &&


echo "$sss" | git-stripspace >actual && echo "$sss" | git stripspace >actual &&
git diff expect actual && git diff expect actual &&


echo "$sss$sss" | git-stripspace >actual && echo "$sss$sss" | git stripspace >actual &&
git diff expect actual && git diff expect actual &&


echo "$sss$sss$sss" | git-stripspace >actual && echo "$sss$sss$sss" | git stripspace >actual &&
git diff expect actual && git diff expect actual &&


echo "$sss$sss$sss$sss" | git-stripspace >actual && echo "$sss$sss$sss$sss" | git stripspace >actual &&
git diff expect actual git diff expect actual
' '


test_expect_failure \ test_expect_failure \
'spaces without newline at end should not show spaces' ' 'spaces without newline at end should not show spaces' '
printf "" | git-stripspace | grep -q " " || printf "" | git stripspace | grep -q " " ||
printf "$sss" | git-stripspace | grep -q " " || printf "$sss" | git stripspace | grep -q " " ||
printf "$sss$sss" | git-stripspace | grep -q " " || printf "$sss$sss" | git stripspace | grep -q " " ||
printf "$sss$sss$sss" | git-stripspace | grep -q " " || printf "$sss$sss$sss" | git stripspace | grep -q " " ||
printf "$sss$sss$sss$sss" | git-stripspace | grep -q " " printf "$sss$sss$sss$sss" | git stripspace | grep -q " "
' '


test_expect_success \ test_expect_success \
'spaces without newline at end should be replaced with empty string' ' 'spaces without newline at end should be replaced with empty string' '
printf "" >expect && printf "" >expect &&


printf "" | git-stripspace >actual && printf "" | git stripspace >actual &&
git diff expect actual git diff expect actual


printf "$sss$sss" | git-stripspace >actual && printf "$sss$sss" | git stripspace >actual &&
git diff expect actual git diff expect actual


printf "$sss$sss$sss" | git-stripspace >actual && printf "$sss$sss$sss" | git stripspace >actual &&
git diff expect actual git diff expect actual


printf "$sss$sss$sss$sss" | git-stripspace >actual && printf "$sss$sss$sss$sss" | git stripspace >actual &&
git diff expect actual git diff expect actual
' '



View File

@ -130,28 +130,28 @@ _x40='[0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f]'
_x40="$_x40$_x40$_x40$_x40$_x40$_x40$_x40$_x40" _x40="$_x40$_x40$_x40$_x40$_x40$_x40$_x40$_x40"


check_result () { check_result () {
git-ls-files --stage | sed -e 's/ '"$_x40"' / X /' >current && git ls-files --stage | sed -e 's/ '"$_x40"' / X /' >current &&
git diff expected current git diff expected current
} }


# This is done on an empty work directory, which is the normal # This is done on an empty work directory, which is the normal
# merge person behaviour. # merge person behaviour.
test_expect_success \ test_expect_success \
'3-way merge with git-read-tree -m, empty cache' \ '3-way merge with git read-tree -m, empty cache' \
"rm -fr [NDMALTS][NDMALTSF] Z && "rm -fr [NDMALTS][NDMALTSF] Z &&
rm .git/index && rm .git/index &&
git-read-tree -m $tree_O $tree_A $tree_B && git read-tree -m $tree_O $tree_A $tree_B &&
check_result" check_result"


# This starts out with the first head, which is the normal # This starts out with the first head, which is the normal
# patch submitter behaviour. # patch submitter behaviour.
test_expect_success \ test_expect_success \
'3-way merge with git-read-tree -m, match H' \ '3-way merge with git read-tree -m, match H' \
"rm -fr [NDMALTS][NDMALTSF] Z && "rm -fr [NDMALTS][NDMALTSF] Z &&
rm .git/index && rm .git/index &&
git-read-tree $tree_A && git read-tree $tree_A &&
git-checkout-index -f -u -a && git checkout-index -f -u -a &&
git-read-tree -m $tree_O $tree_A $tree_B && git read-tree -m $tree_O $tree_A $tree_B &&
check_result" check_result"


: <<\END_OF_CASE_TABLE : <<\END_OF_CASE_TABLE
@ -160,7 +160,7 @@ We have so far tested only empty index and clean-and-matching-A index
case which are trivial. Make sure index requirements are also case which are trivial. Make sure index requirements are also
checked. checked.


"git-read-tree -m O A B" "git read-tree -m O A B"


O A B result index requirements O A B result index requirements
------------------------------------------------------------------- -------------------------------------------------------------------
@ -214,87 +214,87 @@ test_expect_failure \
'1 - must not have an entry not in A.' \ '1 - must not have an entry not in A.' \
"rm -f .git/index XX && "rm -f .git/index XX &&
echo XX >XX && echo XX >XX &&
git-update-index --add XX && git update-index --add XX &&
git-read-tree -m $tree_O $tree_A $tree_B" git read-tree -m $tree_O $tree_A $tree_B"


test_expect_success \ test_expect_success \
'2 - must match B in !O && !A && B case.' \ '2 - must match B in !O && !A && B case.' \
"rm -f .git/index NA && "rm -f .git/index NA &&
cp .orig-B/NA NA && cp .orig-B/NA NA &&
git-update-index --add NA && git update-index --add NA &&
git-read-tree -m $tree_O $tree_A $tree_B" git read-tree -m $tree_O $tree_A $tree_B"


test_expect_success \ test_expect_success \
'2 - matching B alone is OK in !O && !A && B case.' \ '2 - matching B alone is OK in !O && !A && B case.' \
"rm -f .git/index NA && "rm -f .git/index NA &&
cp .orig-B/NA NA && cp .orig-B/NA NA &&
git-update-index --add NA && git update-index --add NA &&
echo extra >>NA && echo extra >>NA &&
git-read-tree -m $tree_O $tree_A $tree_B" git read-tree -m $tree_O $tree_A $tree_B"


test_expect_success \ test_expect_success \
'3 - must match A in !O && A && !B case.' \ '3 - must match A in !O && A && !B case.' \
"rm -f .git/index AN && "rm -f .git/index AN &&
cp .orig-A/AN AN && cp .orig-A/AN AN &&
git-update-index --add AN && git update-index --add AN &&
git-read-tree -m $tree_O $tree_A $tree_B && git read-tree -m $tree_O $tree_A $tree_B &&
check_result" check_result"


test_expect_success \ test_expect_success \
'3 - matching A alone is OK in !O && A && !B case.' \ '3 - matching A alone is OK in !O && A && !B case.' \
"rm -f .git/index AN && "rm -f .git/index AN &&
cp .orig-A/AN AN && cp .orig-A/AN AN &&
git-update-index --add AN && git update-index --add AN &&
echo extra >>AN && echo extra >>AN &&
git-read-tree -m $tree_O $tree_A $tree_B" git read-tree -m $tree_O $tree_A $tree_B"


test_expect_failure \ test_expect_failure \
'3 (fail) - must match A in !O && A && !B case.' \ '3 (fail) - must match A in !O && A && !B case.' \
"rm -f .git/index AN && "rm -f .git/index AN &&
cp .orig-A/AN AN && cp .orig-A/AN AN &&
echo extra >>AN && echo extra >>AN &&
git-update-index --add AN && git update-index --add AN &&
git-read-tree -m $tree_O $tree_A $tree_B" git read-tree -m $tree_O $tree_A $tree_B"


test_expect_success \ test_expect_success \
'4 - must match and be up-to-date in !O && A && B && A!=B case.' \ '4 - must match and be up-to-date in !O && A && B && A!=B case.' \
"rm -f .git/index AA && "rm -f .git/index AA &&
cp .orig-A/AA AA && cp .orig-A/AA AA &&
git-update-index --add AA && git update-index --add AA &&
git-read-tree -m $tree_O $tree_A $tree_B && git read-tree -m $tree_O $tree_A $tree_B &&
check_result" check_result"


test_expect_failure \ test_expect_failure \
'4 (fail) - must match and be up-to-date in !O && A && B && A!=B case.' \ '4 (fail) - must match and be up-to-date in !O && A && B && A!=B case.' \
"rm -f .git/index AA && "rm -f .git/index AA &&
cp .orig-A/AA AA && cp .orig-A/AA AA &&
git-update-index --add AA && git update-index --add AA &&
echo extra >>AA && echo extra >>AA &&
git-read-tree -m $tree_O $tree_A $tree_B" git read-tree -m $tree_O $tree_A $tree_B"


test_expect_failure \ test_expect_failure \
'4 (fail) - must match and be up-to-date in !O && A && B && A!=B case.' \ '4 (fail) - must match and be up-to-date in !O && A && B && A!=B case.' \
"rm -f .git/index AA && "rm -f .git/index AA &&
cp .orig-A/AA AA && cp .orig-A/AA AA &&
echo extra >>AA && echo extra >>AA &&
git-update-index --add AA && git update-index --add AA &&
git-read-tree -m $tree_O $tree_A $tree_B" git read-tree -m $tree_O $tree_A $tree_B"


test_expect_success \ test_expect_success \
'5 - must match in !O && A && B && A==B case.' \ '5 - must match in !O && A && B && A==B case.' \
"rm -f .git/index LL && "rm -f .git/index LL &&
cp .orig-A/LL LL && cp .orig-A/LL LL &&
git-update-index --add LL && git update-index --add LL &&
git-read-tree -m $tree_O $tree_A $tree_B && git read-tree -m $tree_O $tree_A $tree_B &&
check_result" check_result"


test_expect_success \ test_expect_success \
'5 - must match in !O && A && B && A==B case.' \ '5 - must match in !O && A && B && A==B case.' \
"rm -f .git/index LL && "rm -f .git/index LL &&
cp .orig-A/LL LL && cp .orig-A/LL LL &&
git-update-index --add LL && git update-index --add LL &&
echo extra >>LL && echo extra >>LL &&
git-read-tree -m $tree_O $tree_A $tree_B && git read-tree -m $tree_O $tree_A $tree_B &&
check_result" check_result"


test_expect_failure \ test_expect_failure \
@ -302,117 +302,117 @@ test_expect_failure \
"rm -f .git/index LL && "rm -f .git/index LL &&
cp .orig-A/LL LL && cp .orig-A/LL LL &&
echo extra >>LL && echo extra >>LL &&
git-update-index --add LL && git update-index --add LL &&
git-read-tree -m $tree_O $tree_A $tree_B" git read-tree -m $tree_O $tree_A $tree_B"


test_expect_failure \ test_expect_failure \
'6 - must not exist in O && !A && !B case' \ '6 - must not exist in O && !A && !B case' \
"rm -f .git/index DD && "rm -f .git/index DD &&
echo DD >DD echo DD >DD
git-update-index --add DD && git update-index --add DD &&
git-read-tree -m $tree_O $tree_A $tree_B" git read-tree -m $tree_O $tree_A $tree_B"


test_expect_failure \ test_expect_failure \
'7 - must not exist in O && !A && B && O!=B case' \ '7 - must not exist in O && !A && B && O!=B case' \
"rm -f .git/index DM && "rm -f .git/index DM &&
cp .orig-B/DM DM && cp .orig-B/DM DM &&
git-update-index --add DM && git update-index --add DM &&
git-read-tree -m $tree_O $tree_A $tree_B" git read-tree -m $tree_O $tree_A $tree_B"


test_expect_failure \ test_expect_failure \
'8 - must not exist in O && !A && B && O==B case' \ '8 - must not exist in O && !A && B && O==B case' \
"rm -f .git/index DN && "rm -f .git/index DN &&
cp .orig-B/DN DN && cp .orig-B/DN DN &&
git-update-index --add DN && git update-index --add DN &&
git-read-tree -m $tree_O $tree_A $tree_B" git read-tree -m $tree_O $tree_A $tree_B"


test_expect_success \ test_expect_success \
'9 - must match and be up-to-date in O && A && !B && O!=A case' \ '9 - must match and be up-to-date in O && A && !B && O!=A case' \
"rm -f .git/index MD && "rm -f .git/index MD &&
cp .orig-A/MD MD && cp .orig-A/MD MD &&
git-update-index --add MD && git update-index --add MD &&
git-read-tree -m $tree_O $tree_A $tree_B && git read-tree -m $tree_O $tree_A $tree_B &&
check_result" check_result"


test_expect_failure \ test_expect_failure \
'9 (fail) - must match and be up-to-date in O && A && !B && O!=A case' \ '9 (fail) - must match and be up-to-date in O && A && !B && O!=A case' \
"rm -f .git/index MD && "rm -f .git/index MD &&
cp .orig-A/MD MD && cp .orig-A/MD MD &&
git-update-index --add MD && git update-index --add MD &&
echo extra >>MD && echo extra >>MD &&
git-read-tree -m $tree_O $tree_A $tree_B" git read-tree -m $tree_O $tree_A $tree_B"


test_expect_failure \ test_expect_failure \
'9 (fail) - must match and be up-to-date in O && A && !B && O!=A case' \ '9 (fail) - must match and be up-to-date in O && A && !B && O!=A case' \
"rm -f .git/index MD && "rm -f .git/index MD &&
cp .orig-A/MD MD && cp .orig-A/MD MD &&
echo extra >>MD && echo extra >>MD &&
git-update-index --add MD && git update-index --add MD &&
git-read-tree -m $tree_O $tree_A $tree_B" git read-tree -m $tree_O $tree_A $tree_B"


test_expect_success \ test_expect_success \
'10 - must match and be up-to-date in O && A && !B && O==A case' \ '10 - must match and be up-to-date in O && A && !B && O==A case' \
"rm -f .git/index ND && "rm -f .git/index ND &&
cp .orig-A/ND ND && cp .orig-A/ND ND &&
git-update-index --add ND && git update-index --add ND &&
git-read-tree -m $tree_O $tree_A $tree_B && git read-tree -m $tree_O $tree_A $tree_B &&
check_result" check_result"


test_expect_failure \ test_expect_failure \
'10 (fail) - must match and be up-to-date in O && A && !B && O==A case' \ '10 (fail) - must match and be up-to-date in O && A && !B && O==A case' \
"rm -f .git/index ND && "rm -f .git/index ND &&
cp .orig-A/ND ND && cp .orig-A/ND ND &&
git-update-index --add ND && git update-index --add ND &&
echo extra >>ND && echo extra >>ND &&
git-read-tree -m $tree_O $tree_A $tree_B" git read-tree -m $tree_O $tree_A $tree_B"


test_expect_failure \ test_expect_failure \
'10 (fail) - must match and be up-to-date in O && A && !B && O==A case' \ '10 (fail) - must match and be up-to-date in O && A && !B && O==A case' \
"rm -f .git/index ND && "rm -f .git/index ND &&
cp .orig-A/ND ND && cp .orig-A/ND ND &&
echo extra >>ND && echo extra >>ND &&
git-update-index --add ND && git update-index --add ND &&
git-read-tree -m $tree_O $tree_A $tree_B" git read-tree -m $tree_O $tree_A $tree_B"


test_expect_success \ test_expect_success \
'11 - must match and be up-to-date in O && A && B && O!=A && O!=B && A!=B case' \ '11 - must match and be up-to-date in O && A && B && O!=A && O!=B && A!=B case' \
"rm -f .git/index MM && "rm -f .git/index MM &&
cp .orig-A/MM MM && cp .orig-A/MM MM &&
git-update-index --add MM && git update-index --add MM &&
git-read-tree -m $tree_O $tree_A $tree_B && git read-tree -m $tree_O $tree_A $tree_B &&
check_result" check_result"


test_expect_failure \ test_expect_failure \
'11 (fail) - must match and be up-to-date in O && A && B && O!=A && O!=B && A!=B case' \ '11 (fail) - must match and be up-to-date in O && A && B && O!=A && O!=B && A!=B case' \
"rm -f .git/index MM && "rm -f .git/index MM &&
cp .orig-A/MM MM && cp .orig-A/MM MM &&
git-update-index --add MM && git update-index --add MM &&
echo extra >>MM && echo extra >>MM &&
git-read-tree -m $tree_O $tree_A $tree_B" git read-tree -m $tree_O $tree_A $tree_B"


test_expect_failure \ test_expect_failure \
'11 (fail) - must match and be up-to-date in O && A && B && O!=A && O!=B && A!=B case' \ '11 (fail) - must match and be up-to-date in O && A && B && O!=A && O!=B && A!=B case' \
"rm -f .git/index MM && "rm -f .git/index MM &&
cp .orig-A/MM MM && cp .orig-A/MM MM &&
echo extra >>MM && echo extra >>MM &&
git-update-index --add MM && git update-index --add MM &&
git-read-tree -m $tree_O $tree_A $tree_B" git read-tree -m $tree_O $tree_A $tree_B"


test_expect_success \ test_expect_success \
'12 - must match A in O && A && B && O!=A && A==B case' \ '12 - must match A in O && A && B && O!=A && A==B case' \
"rm -f .git/index SS && "rm -f .git/index SS &&
cp .orig-A/SS SS && cp .orig-A/SS SS &&
git-update-index --add SS && git update-index --add SS &&
git-read-tree -m $tree_O $tree_A $tree_B && git read-tree -m $tree_O $tree_A $tree_B &&
check_result" check_result"


test_expect_success \ test_expect_success \
'12 - must match A in O && A && B && O!=A && A==B case' \ '12 - must match A in O && A && B && O!=A && A==B case' \
"rm -f .git/index SS && "rm -f .git/index SS &&
cp .orig-A/SS SS && cp .orig-A/SS SS &&
git-update-index --add SS && git update-index --add SS &&
echo extra >>SS && echo extra >>SS &&
git-read-tree -m $tree_O $tree_A $tree_B && git read-tree -m $tree_O $tree_A $tree_B &&
check_result" check_result"


test_expect_failure \ test_expect_failure \
@ -420,74 +420,74 @@ test_expect_failure \
"rm -f .git/index SS && "rm -f .git/index SS &&
cp .orig-A/SS SS && cp .orig-A/SS SS &&
echo extra >>SS && echo extra >>SS &&
git-update-index --add SS && git update-index --add SS &&
git-read-tree -m $tree_O $tree_A $tree_B" git read-tree -m $tree_O $tree_A $tree_B"


test_expect_success \ test_expect_success \
'13 - must match A in O && A && B && O!=A && O==B case' \ '13 - must match A in O && A && B && O!=A && O==B case' \
"rm -f .git/index MN && "rm -f .git/index MN &&
cp .orig-A/MN MN && cp .orig-A/MN MN &&
git-update-index --add MN && git update-index --add MN &&
git-read-tree -m $tree_O $tree_A $tree_B && git read-tree -m $tree_O $tree_A $tree_B &&
check_result" check_result"


test_expect_success \ test_expect_success \
'13 - must match A in O && A && B && O!=A && O==B case' \ '13 - must match A in O && A && B && O!=A && O==B case' \
"rm -f .git/index MN && "rm -f .git/index MN &&
cp .orig-A/MN MN && cp .orig-A/MN MN &&
git-update-index --add MN && git update-index --add MN &&
echo extra >>MN && echo extra >>MN &&
git-read-tree -m $tree_O $tree_A $tree_B && git read-tree -m $tree_O $tree_A $tree_B &&
check_result" check_result"


test_expect_success \ test_expect_success \
'14 - must match and be up-to-date in O && A && B && O==A && O!=B case' \ '14 - must match and be up-to-date in O && A && B && O==A && O!=B case' \
"rm -f .git/index NM && "rm -f .git/index NM &&
cp .orig-A/NM NM && cp .orig-A/NM NM &&
git-update-index --add NM && git update-index --add NM &&
git-read-tree -m $tree_O $tree_A $tree_B && git read-tree -m $tree_O $tree_A $tree_B &&
check_result" check_result"


test_expect_success \ test_expect_success \
'14 - may match B in O && A && B && O==A && O!=B case' \ '14 - may match B in O && A && B && O==A && O!=B case' \
"rm -f .git/index NM && "rm -f .git/index NM &&
cp .orig-B/NM NM && cp .orig-B/NM NM &&
git-update-index --add NM && git update-index --add NM &&
echo extra >>NM && echo extra >>NM &&
git-read-tree -m $tree_O $tree_A $tree_B && git read-tree -m $tree_O $tree_A $tree_B &&
check_result" check_result"


test_expect_failure \ test_expect_failure \
'14 (fail) - must match and be up-to-date in O && A && B && O==A && O!=B case' \ '14 (fail) - must match and be up-to-date in O && A && B && O==A && O!=B case' \
"rm -f .git/index NM && "rm -f .git/index NM &&
cp .orig-A/NM NM && cp .orig-A/NM NM &&
git-update-index --add NM && git update-index --add NM &&
echo extra >>NM && echo extra >>NM &&
git-read-tree -m $tree_O $tree_A $tree_B" git read-tree -m $tree_O $tree_A $tree_B"


test_expect_failure \ test_expect_failure \
'14 (fail) - must match and be up-to-date in O && A && B && O==A && O!=B case' \ '14 (fail) - must match and be up-to-date in O && A && B && O==A && O!=B case' \
"rm -f .git/index NM && "rm -f .git/index NM &&
cp .orig-A/NM NM && cp .orig-A/NM NM &&
echo extra >>NM && echo extra >>NM &&
git-update-index --add NM && git update-index --add NM &&
git-read-tree -m $tree_O $tree_A $tree_B" git read-tree -m $tree_O $tree_A $tree_B"


test_expect_success \ test_expect_success \
'15 - must match A in O && A && B && O==A && O==B case' \ '15 - must match A in O && A && B && O==A && O==B case' \
"rm -f .git/index NN && "rm -f .git/index NN &&
cp .orig-A/NN NN && cp .orig-A/NN NN &&
git-update-index --add NN && git update-index --add NN &&
git-read-tree -m $tree_O $tree_A $tree_B && git read-tree -m $tree_O $tree_A $tree_B &&
check_result" check_result"


test_expect_success \ test_expect_success \
'15 - must match A in O && A && B && O==A && O==B case' \ '15 - must match A in O && A && B && O==A && O==B case' \
"rm -f .git/index NN && "rm -f .git/index NN &&
cp .orig-A/NN NN && cp .orig-A/NN NN &&
git-update-index --add NN && git update-index --add NN &&
echo extra >>NN && echo extra >>NN &&
git-read-tree -m $tree_O $tree_A $tree_B && git read-tree -m $tree_O $tree_A $tree_B &&
check_result" check_result"


test_expect_failure \ test_expect_failure \
@ -495,20 +495,20 @@ test_expect_failure \
"rm -f .git/index NN && "rm -f .git/index NN &&
cp .orig-A/NN NN && cp .orig-A/NN NN &&
echo extra >>NN && echo extra >>NN &&
git-update-index --add NN && git update-index --add NN &&
git-read-tree -m $tree_O $tree_A $tree_B" git read-tree -m $tree_O $tree_A $tree_B"


# #16 # #16
test_expect_success \ test_expect_success \
'16 - A matches in one and B matches in another.' \ '16 - A matches in one and B matches in another.' \
'rm -f .git/index F16 && 'rm -f .git/index F16 &&
echo F16 >F16 && echo F16 >F16 &&
git-update-index --add F16 && git update-index --add F16 &&
tree0=`git-write-tree` && tree0=`git write-tree` &&
echo E16 >F16 && echo E16 >F16 &&
git-update-index F16 && git update-index F16 &&
tree1=`git-write-tree` && tree1=`git write-tree` &&
git-read-tree -m $tree0 $tree1 $tree1 $tree0 && git read-tree -m $tree0 $tree1 $tree1 $tree0 &&
git-ls-files --stage' git ls-files --stage'


test_done test_done

View File

@ -11,7 +11,7 @@ There is the head (called H) and another commit (called M), which is
simply ahead of H. The index and the work tree contains a state that simply ahead of H. The index and the work tree contains a state that
is derived from H, but may also have local changes. This test checks is derived from H, but may also have local changes. This test checks
all the combinations described in the two-tree merge "carry forward" all the combinations described in the two-tree merge "carry forward"
rules, found in <Documentation/git-read-tree.txt>. rules, found in <Documentation/git read-tree.txt>.


In the test, these paths are used: In the test, these paths are used:
bozbar - in H, stays in M, modified from bozbar to gnusto bozbar - in H, stays in M, modified from bozbar to gnusto
@ -23,7 +23,7 @@ In the test, these paths are used:
. ./test-lib.sh . ./test-lib.sh


read_tree_twoway () { read_tree_twoway () {
git-read-tree -m "$1" "$2" && git-ls-files --stage git read-tree -m "$1" "$2" && git ls-files --stage
} }


_x40='[0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f]' _x40='[0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f]'
@ -37,7 +37,7 @@ compare_change () {
} }


check_cache_at () { check_cache_at () {
clean_if_empty=`git-diff-files -- "$1"` clean_if_empty=`git diff-files -- "$1"`
case "$clean_if_empty" in case "$clean_if_empty" in
'') echo "$1: clean" ;; '') echo "$1: clean" ;;
?*) echo "$1: dirty" ;; ?*) echo "$1: dirty" ;;
@ -68,24 +68,24 @@ test_expect_success \
cat bozbar-old >bozbar && cat bozbar-old >bozbar &&
echo rezrov >rezrov && echo rezrov >rezrov &&
echo yomin >yomin && echo yomin >yomin &&
git-update-index --add nitfol bozbar rezrov && git update-index --add nitfol bozbar rezrov &&
treeH=`git-write-tree` && treeH=`git write-tree` &&
echo treeH $treeH && echo treeH $treeH &&
git-ls-tree $treeH && git ls-tree $treeH &&


cat bozbar-new >bozbar && cat bozbar-new >bozbar &&
git-update-index --add frotz bozbar --force-remove rezrov && git update-index --add frotz bozbar --force-remove rezrov &&
git-ls-files --stage >M.out && git ls-files --stage >M.out &&
treeM=`git-write-tree` && treeM=`git write-tree` &&
echo treeM $treeM && echo treeM $treeM &&
git-ls-tree $treeM && git ls-tree $treeM &&
git-diff-tree $treeH $treeM' git diff-tree $treeH $treeM'


test_expect_success \ test_expect_success \
'1, 2, 3 - no carry forward' \ '1, 2, 3 - no carry forward' \
'rm -f .git/index && 'rm -f .git/index &&
read_tree_twoway $treeH $treeM && read_tree_twoway $treeH $treeM &&
git-ls-files --stage >1-3.out && git ls-files --stage >1-3.out &&
git diff M.out 1-3.out && git diff M.out 1-3.out &&
check_cache_at bozbar dirty && check_cache_at bozbar dirty &&
check_cache_at frotz dirty && check_cache_at frotz dirty &&
@ -96,11 +96,11 @@ echo '+100644 X 0 yomin' >expected
test_expect_success \ test_expect_success \
'4 - carry forward local addition.' \ '4 - carry forward local addition.' \
'rm -f .git/index && 'rm -f .git/index &&
git-read-tree $treeH && git read-tree $treeH &&
git-checkout-index -u -f -q -a && git checkout-index -u -f -q -a &&
git-update-index --add yomin && git update-index --add yomin &&
read_tree_twoway $treeH $treeM && read_tree_twoway $treeH $treeM &&
git-ls-files --stage >4.out || return 1 git ls-files --stage >4.out || return 1
git diff M.out 4.out >4diff.out git diff M.out 4.out >4diff.out
compare_change 4diff.out expected && compare_change 4diff.out expected &&
check_cache_at yomin clean' check_cache_at yomin clean'
@ -108,13 +108,13 @@ test_expect_success \
test_expect_success \ test_expect_success \
'5 - carry forward local addition.' \ '5 - carry forward local addition.' \
'rm -f .git/index && 'rm -f .git/index &&
git-read-tree $treeH && git read-tree $treeH &&
git-checkout-index -u -f -q -a && git checkout-index -u -f -q -a &&
echo yomin >yomin && echo yomin >yomin &&
git-update-index --add yomin && git update-index --add yomin &&
echo yomin yomin >yomin && echo yomin yomin >yomin &&
read_tree_twoway $treeH $treeM && read_tree_twoway $treeH $treeM &&
git-ls-files --stage >5.out || return 1 git ls-files --stage >5.out || return 1
git diff M.out 5.out >5diff.out git diff M.out 5.out >5diff.out
compare_change 5diff.out expected && compare_change 5diff.out expected &&
check_cache_at yomin dirty' check_cache_at yomin dirty'
@ -122,83 +122,83 @@ test_expect_success \
test_expect_success \ test_expect_success \
'6 - local addition already has the same.' \ '6 - local addition already has the same.' \
'rm -f .git/index && 'rm -f .git/index &&
git-read-tree $treeH && git read-tree $treeH &&
git-checkout-index -u -f -q -a && git checkout-index -u -f -q -a &&
git-update-index --add frotz && git update-index --add frotz &&
read_tree_twoway $treeH $treeM && read_tree_twoway $treeH $treeM &&
git-ls-files --stage >6.out && git ls-files --stage >6.out &&
git diff M.out 6.out && git diff M.out 6.out &&
check_cache_at frotz clean' check_cache_at frotz clean'


test_expect_success \ test_expect_success \
'7 - local addition already has the same.' \ '7 - local addition already has the same.' \
'rm -f .git/index && 'rm -f .git/index &&
git-read-tree $treeH && git read-tree $treeH &&
git-checkout-index -u -f -q -a && git checkout-index -u -f -q -a &&
echo frotz >frotz && echo frotz >frotz &&
git-update-index --add frotz && git update-index --add frotz &&
echo frotz frotz >frotz && echo frotz frotz >frotz &&
read_tree_twoway $treeH $treeM && read_tree_twoway $treeH $treeM &&
git-ls-files --stage >7.out && git ls-files --stage >7.out &&
git diff M.out 7.out && git diff M.out 7.out &&
check_cache_at frotz dirty' check_cache_at frotz dirty'


test_expect_success \ test_expect_success \
'8 - conflicting addition.' \ '8 - conflicting addition.' \
'rm -f .git/index && 'rm -f .git/index &&
git-read-tree $treeH && git read-tree $treeH &&
git-checkout-index -u -f -q -a && git checkout-index -u -f -q -a &&
echo frotz frotz >frotz && echo frotz frotz >frotz &&
git-update-index --add frotz && git update-index --add frotz &&
if read_tree_twoway $treeH $treeM; then false; else :; fi' if read_tree_twoway $treeH $treeM; then false; else :; fi'


test_expect_success \ test_expect_success \
'9 - conflicting addition.' \ '9 - conflicting addition.' \
'rm -f .git/index && 'rm -f .git/index &&
git-read-tree $treeH && git read-tree $treeH &&
git-checkout-index -u -f -q -a && git checkout-index -u -f -q -a &&
echo frotz frotz >frotz && echo frotz frotz >frotz &&
git-update-index --add frotz && git update-index --add frotz &&
echo frotz >frotz && echo frotz >frotz &&
if read_tree_twoway $treeH $treeM; then false; else :; fi' if read_tree_twoway $treeH $treeM; then false; else :; fi'


test_expect_success \ test_expect_success \
'10 - path removed.' \ '10 - path removed.' \
'rm -f .git/index && 'rm -f .git/index &&
git-read-tree $treeH && git read-tree $treeH &&
git-checkout-index -u -f -q -a && git checkout-index -u -f -q -a &&
echo rezrov >rezrov && echo rezrov >rezrov &&
git-update-index --add rezrov && git update-index --add rezrov &&
read_tree_twoway $treeH $treeM && read_tree_twoway $treeH $treeM &&
git-ls-files --stage >10.out && git ls-files --stage >10.out &&
git diff M.out 10.out' git diff M.out 10.out'


test_expect_success \ test_expect_success \
'11 - dirty path removed.' \ '11 - dirty path removed.' \
'rm -f .git/index && 'rm -f .git/index &&
git-read-tree $treeH && git read-tree $treeH &&
git-checkout-index -u -f -q -a && git checkout-index -u -f -q -a &&
echo rezrov >rezrov && echo rezrov >rezrov &&
git-update-index --add rezrov && git update-index --add rezrov &&
echo rezrov rezrov >rezrov && echo rezrov rezrov >rezrov &&
if read_tree_twoway $treeH $treeM; then false; else :; fi' if read_tree_twoway $treeH $treeM; then false; else :; fi'


test_expect_success \ test_expect_success \
'12 - unmatching local changes being removed.' \ '12 - unmatching local changes being removed.' \
'rm -f .git/index && 'rm -f .git/index &&
git-read-tree $treeH && git read-tree $treeH &&
git-checkout-index -u -f -q -a && git checkout-index -u -f -q -a &&
echo rezrov rezrov >rezrov && echo rezrov rezrov >rezrov &&
git-update-index --add rezrov && git update-index --add rezrov &&
if read_tree_twoway $treeH $treeM; then false; else :; fi' if read_tree_twoway $treeH $treeM; then false; else :; fi'


test_expect_success \ test_expect_success \
'13 - unmatching local changes being removed.' \ '13 - unmatching local changes being removed.' \
'rm -f .git/index && 'rm -f .git/index &&
git-read-tree $treeH && git read-tree $treeH &&
git-checkout-index -u -f -q -a && git checkout-index -u -f -q -a &&
echo rezrov rezrov >rezrov && echo rezrov rezrov >rezrov &&
git-update-index --add rezrov && git update-index --add rezrov &&
echo rezrov >rezrov && echo rezrov >rezrov &&
if read_tree_twoway $treeH $treeM; then false; else :; fi' if read_tree_twoway $treeH $treeM; then false; else :; fi'


@ -210,12 +210,12 @@ EOF
test_expect_success \ test_expect_success \
'14 - unchanged in two heads.' \ '14 - unchanged in two heads.' \
'rm -f .git/index && 'rm -f .git/index &&
git-read-tree $treeH && git read-tree $treeH &&
git-checkout-index -u -f -q -a && git checkout-index -u -f -q -a &&
echo nitfol nitfol >nitfol && echo nitfol nitfol >nitfol &&
git-update-index --add nitfol && git update-index --add nitfol &&
read_tree_twoway $treeH $treeM && read_tree_twoway $treeH $treeM &&
git-ls-files --stage >14.out || return 1 git ls-files --stage >14.out || return 1
git diff M.out 14.out >14diff.out git diff M.out 14.out >14diff.out
compare_change 14diff.out expected && compare_change 14diff.out expected &&
check_cache_at nitfol clean' check_cache_at nitfol clean'
@ -223,13 +223,13 @@ test_expect_success \
test_expect_success \ test_expect_success \
'15 - unchanged in two heads.' \ '15 - unchanged in two heads.' \
'rm -f .git/index && 'rm -f .git/index &&
git-read-tree $treeH && git read-tree $treeH &&
git-checkout-index -u -f -q -a && git checkout-index -u -f -q -a &&
echo nitfol nitfol >nitfol && echo nitfol nitfol >nitfol &&
git-update-index --add nitfol && git update-index --add nitfol &&
echo nitfol nitfol nitfol >nitfol && echo nitfol nitfol nitfol >nitfol &&
read_tree_twoway $treeH $treeM && read_tree_twoway $treeH $treeM &&
git-ls-files --stage >15.out || return 1 git ls-files --stage >15.out || return 1
git diff M.out 15.out >15diff.out git diff M.out 15.out >15diff.out
compare_change 15diff.out expected && compare_change 15diff.out expected &&
check_cache_at nitfol dirty' check_cache_at nitfol dirty'
@ -237,66 +237,66 @@ test_expect_success \
test_expect_success \ test_expect_success \
'16 - conflicting local change.' \ '16 - conflicting local change.' \
'rm -f .git/index && 'rm -f .git/index &&
git-read-tree $treeH && git read-tree $treeH &&
git-checkout-index -u -f -q -a && git checkout-index -u -f -q -a &&
echo bozbar bozbar >bozbar && echo bozbar bozbar >bozbar &&
git-update-index --add bozbar && git update-index --add bozbar &&
if read_tree_twoway $treeH $treeM; then false; else :; fi' if read_tree_twoway $treeH $treeM; then false; else :; fi'


test_expect_success \ test_expect_success \
'17 - conflicting local change.' \ '17 - conflicting local change.' \
'rm -f .git/index && 'rm -f .git/index &&
git-read-tree $treeH && git read-tree $treeH &&
git-checkout-index -u -f -q -a && git checkout-index -u -f -q -a &&
echo bozbar bozbar >bozbar && echo bozbar bozbar >bozbar &&
git-update-index --add bozbar && git update-index --add bozbar &&
echo bozbar bozbar bozbar >bozbar && echo bozbar bozbar bozbar >bozbar &&
if read_tree_twoway $treeH $treeM; then false; else :; fi' if read_tree_twoway $treeH $treeM; then false; else :; fi'


test_expect_success \ test_expect_success \
'18 - local change already having a good result.' \ '18 - local change already having a good result.' \
'rm -f .git/index && 'rm -f .git/index &&
git-read-tree $treeH && git read-tree $treeH &&
git-checkout-index -u -f -q -a && git checkout-index -u -f -q -a &&
cat bozbar-new >bozbar && cat bozbar-new >bozbar &&
git-update-index --add bozbar && git update-index --add bozbar &&
read_tree_twoway $treeH $treeM && read_tree_twoway $treeH $treeM &&
git-ls-files --stage >18.out && git ls-files --stage >18.out &&
git diff M.out 18.out && git diff M.out 18.out &&
check_cache_at bozbar clean' check_cache_at bozbar clean'


test_expect_success \ test_expect_success \
'19 - local change already having a good result, further modified.' \ '19 - local change already having a good result, further modified.' \
'rm -f .git/index && 'rm -f .git/index &&
git-read-tree $treeH && git read-tree $treeH &&
git-checkout-index -u -f -q -a && git checkout-index -u -f -q -a &&
cat bozbar-new >bozbar && cat bozbar-new >bozbar &&
git-update-index --add bozbar && git update-index --add bozbar &&
echo gnusto gnusto >bozbar && echo gnusto gnusto >bozbar &&
read_tree_twoway $treeH $treeM && read_tree_twoway $treeH $treeM &&
git-ls-files --stage >19.out && git ls-files --stage >19.out &&
git diff M.out 19.out && git diff M.out 19.out &&
check_cache_at bozbar dirty' check_cache_at bozbar dirty'


test_expect_success \ test_expect_success \
'20 - no local change, use new tree.' \ '20 - no local change, use new tree.' \
'rm -f .git/index && 'rm -f .git/index &&
git-read-tree $treeH && git read-tree $treeH &&
git-checkout-index -u -f -q -a && git checkout-index -u -f -q -a &&
cat bozbar-old >bozbar && cat bozbar-old >bozbar &&
git-update-index --add bozbar && git update-index --add bozbar &&
read_tree_twoway $treeH $treeM && read_tree_twoway $treeH $treeM &&
git-ls-files --stage >20.out && git ls-files --stage >20.out &&
git diff M.out 20.out && git diff M.out 20.out &&
check_cache_at bozbar dirty' check_cache_at bozbar dirty'


test_expect_success \ test_expect_success \
'21 - no local change, dirty cache.' \ '21 - no local change, dirty cache.' \
'rm -f .git/index && 'rm -f .git/index &&
git-read-tree $treeH && git read-tree $treeH &&
git-checkout-index -u -f -q -a && git checkout-index -u -f -q -a &&
cat bozbar-old >bozbar && cat bozbar-old >bozbar &&
git-update-index --add bozbar && git update-index --add bozbar &&
echo gnusto gnusto >bozbar && echo gnusto gnusto >bozbar &&
if read_tree_twoway $treeH $treeM; then false; else :; fi' if read_tree_twoway $treeH $treeM; then false; else :; fi'


@ -304,10 +304,10 @@ test_expect_success \
test_expect_success \ test_expect_success \
'22 - local change cache updated.' \ '22 - local change cache updated.' \
'rm -f .git/index && 'rm -f .git/index &&
git-read-tree $treeH && git read-tree $treeH &&
git-checkout-index -u -f -q -a && git checkout-index -u -f -q -a &&
sed -e "s/such as/SUCH AS/" bozbar-old >bozbar && sed -e "s/such as/SUCH AS/" bozbar-old >bozbar &&
git-update-index --add bozbar && git update-index --add bozbar &&
if read_tree_twoway $treeH $treeM; then false; else :; fi' if read_tree_twoway $treeH $treeM; then false; else :; fi'


# Also make sure we did not break DF vs DF/DF case. # Also make sure we did not break DF vs DF/DF case.
@ -315,28 +315,28 @@ test_expect_success \
'DF vs DF/DF case setup.' \ 'DF vs DF/DF case setup.' \
'rm -f .git/index && 'rm -f .git/index &&
echo DF >DF && echo DF >DF &&
git-update-index --add DF && git update-index --add DF &&
treeDF=`git-write-tree` && treeDF=`git write-tree` &&
echo treeDF $treeDF && echo treeDF $treeDF &&
git-ls-tree $treeDF && git ls-tree $treeDF &&


rm -f DF && rm -f DF &&
mkdir DF && mkdir DF &&
echo DF/DF >DF/DF && echo DF/DF >DF/DF &&
git-update-index --add --remove DF DF/DF && git update-index --add --remove DF DF/DF &&
treeDFDF=`git-write-tree` && treeDFDF=`git write-tree` &&
echo treeDFDF $treeDFDF && echo treeDFDF $treeDFDF &&
git-ls-tree $treeDFDF && git ls-tree $treeDFDF &&
git-ls-files --stage >DFDF.out' git ls-files --stage >DFDF.out'


test_expect_success \ test_expect_success \
'DF vs DF/DF case test.' \ 'DF vs DF/DF case test.' \
'rm -f .git/index && 'rm -f .git/index &&
rm -fr DF && rm -fr DF &&
echo DF >DF && echo DF >DF &&
git-update-index --add DF && git update-index --add DF &&
read_tree_twoway $treeDF $treeDFDF && read_tree_twoway $treeDF $treeDFDF &&
git-ls-files --stage >DFDFcheck.out && git ls-files --stage >DFDFcheck.out &&
git diff DFDF.out DFDFcheck.out && git diff DFDF.out DFDFcheck.out &&
check_cache_at DF/DF dirty && check_cache_at DF/DF dirty &&
:' :'

View File

@ -20,7 +20,7 @@ compare_change () {
} }


check_cache_at () { check_cache_at () {
clean_if_empty=`git-diff-files -- "$1"` clean_if_empty=`git diff-files -- "$1"`
case "$clean_if_empty" in case "$clean_if_empty" in
'') echo "$1: clean" ;; '') echo "$1: clean" ;;
?*) echo "$1: dirty" ;; ?*) echo "$1: dirty" ;;
@ -39,26 +39,26 @@ test_expect_success \
echo nitfol >nitfol && echo nitfol >nitfol &&
echo bozbar >bozbar && echo bozbar >bozbar &&
echo rezrov >rezrov && echo rezrov >rezrov &&
git-update-index --add nitfol bozbar rezrov && git update-index --add nitfol bozbar rezrov &&
treeH=`git-write-tree` && treeH=`git write-tree` &&
echo treeH $treeH && echo treeH $treeH &&
git-ls-tree $treeH && git ls-tree $treeH &&


echo gnusto >bozbar && echo gnusto >bozbar &&
git-update-index --add frotz bozbar --force-remove rezrov && git update-index --add frotz bozbar --force-remove rezrov &&
git-ls-files --stage >M.out && git ls-files --stage >M.out &&
treeM=`git-write-tree` && treeM=`git write-tree` &&
echo treeM $treeM && echo treeM $treeM &&
git-ls-tree $treeM && git ls-tree $treeM &&
sum bozbar frotz nitfol >M.sum && sum bozbar frotz nitfol >M.sum &&
git-diff-tree $treeH $treeM' git diff-tree $treeH $treeM'


test_expect_success \ test_expect_success \
'1, 2, 3 - no carry forward' \ '1, 2, 3 - no carry forward' \
'rm -f .git/index nitfol bozbar rezrov frotz && 'rm -f .git/index nitfol bozbar rezrov frotz &&
git-read-tree --reset -u $treeH && git read-tree --reset -u $treeH &&
git-read-tree -m -u $treeH $treeM && git read-tree -m -u $treeH $treeM &&
git-ls-files --stage >1-3.out && git ls-files --stage >1-3.out &&
cmp M.out 1-3.out && cmp M.out 1-3.out &&
sum bozbar frotz nitfol >actual3.sum && sum bozbar frotz nitfol >actual3.sum &&
cmp M.sum actual3.sum && cmp M.sum actual3.sum &&
@ -69,12 +69,12 @@ test_expect_success \
test_expect_success \ test_expect_success \
'4 - carry forward local addition.' \ '4 - carry forward local addition.' \
'rm -f .git/index nitfol bozbar rezrov frotz && 'rm -f .git/index nitfol bozbar rezrov frotz &&
git-read-tree --reset -u $treeH && git read-tree --reset -u $treeH &&
echo "+100644 X 0 yomin" >expected && echo "+100644 X 0 yomin" >expected &&
echo yomin >yomin && echo yomin >yomin &&
git-update-index --add yomin && git update-index --add yomin &&
git-read-tree -m -u $treeH $treeM && git read-tree -m -u $treeH $treeM &&
git-ls-files --stage >4.out || return 1 git ls-files --stage >4.out || return 1
diff -U0 M.out 4.out >4diff.out diff -U0 M.out 4.out >4diff.out
compare_change 4diff.out expected && compare_change 4diff.out expected &&
check_cache_at yomin clean && check_cache_at yomin clean &&
@ -87,13 +87,13 @@ test_expect_success \
test_expect_success \ test_expect_success \
'5 - carry forward local addition.' \ '5 - carry forward local addition.' \
'rm -f .git/index nitfol bozbar rezrov frotz && 'rm -f .git/index nitfol bozbar rezrov frotz &&
git-read-tree --reset -u $treeH && git read-tree --reset -u $treeH &&
git-read-tree -m -u $treeH && git read-tree -m -u $treeH &&
echo yomin >yomin && echo yomin >yomin &&
git-update-index --add yomin && git update-index --add yomin &&
echo yomin yomin >yomin && echo yomin yomin >yomin &&
git-read-tree -m -u $treeH $treeM && git read-tree -m -u $treeH $treeM &&
git-ls-files --stage >5.out || return 1 git ls-files --stage >5.out || return 1
diff -U0 M.out 5.out >5diff.out diff -U0 M.out 5.out >5diff.out
compare_change 5diff.out expected && compare_change 5diff.out expected &&
check_cache_at yomin dirty && check_cache_at yomin dirty &&
@ -107,11 +107,11 @@ test_expect_success \
test_expect_success \ test_expect_success \
'6 - local addition already has the same.' \ '6 - local addition already has the same.' \
'rm -f .git/index nitfol bozbar rezrov frotz && 'rm -f .git/index nitfol bozbar rezrov frotz &&
git-read-tree --reset -u $treeH && git read-tree --reset -u $treeH &&
echo frotz >frotz && echo frotz >frotz &&
git-update-index --add frotz && git update-index --add frotz &&
git-read-tree -m -u $treeH $treeM && git read-tree -m -u $treeH $treeM &&
git-ls-files --stage >6.out && git ls-files --stage >6.out &&
diff -U0 M.out 6.out && diff -U0 M.out 6.out &&
check_cache_at frotz clean && check_cache_at frotz clean &&
sum bozbar frotz nitfol >actual3.sum && sum bozbar frotz nitfol >actual3.sum &&
@ -123,12 +123,12 @@ test_expect_success \
test_expect_success \ test_expect_success \
'7 - local addition already has the same.' \ '7 - local addition already has the same.' \
'rm -f .git/index nitfol bozbar rezrov frotz && 'rm -f .git/index nitfol bozbar rezrov frotz &&
git-read-tree --reset -u $treeH && git read-tree --reset -u $treeH &&
echo frotz >frotz && echo frotz >frotz &&
git-update-index --add frotz && git update-index --add frotz &&
echo frotz frotz >frotz && echo frotz frotz >frotz &&
git-read-tree -m -u $treeH $treeM && git read-tree -m -u $treeH $treeM &&
git-ls-files --stage >7.out && git ls-files --stage >7.out &&
diff -U0 M.out 7.out && diff -U0 M.out 7.out &&
check_cache_at frotz dirty && check_cache_at frotz dirty &&
sum bozbar frotz nitfol >actual7.sum && sum bozbar frotz nitfol >actual7.sum &&
@ -141,28 +141,28 @@ test_expect_success \
test_expect_success \ test_expect_success \
'8 - conflicting addition.' \ '8 - conflicting addition.' \
'rm -f .git/index nitfol bozbar rezrov frotz && 'rm -f .git/index nitfol bozbar rezrov frotz &&
git-read-tree --reset -u $treeH && git read-tree --reset -u $treeH &&
echo frotz frotz >frotz && echo frotz frotz >frotz &&
git-update-index --add frotz && git update-index --add frotz &&
if git-read-tree -m -u $treeH $treeM; then false; else :; fi' if git read-tree -m -u $treeH $treeM; then false; else :; fi'


test_expect_success \ test_expect_success \
'9 - conflicting addition.' \ '9 - conflicting addition.' \
'rm -f .git/index nitfol bozbar rezrov frotz && 'rm -f .git/index nitfol bozbar rezrov frotz &&
git-read-tree --reset -u $treeH && git read-tree --reset -u $treeH &&
echo frotz frotz >frotz && echo frotz frotz >frotz &&
git-update-index --add frotz && git update-index --add frotz &&
echo frotz >frotz && echo frotz >frotz &&
if git-read-tree -m -u $treeH $treeM; then false; else :; fi' if git read-tree -m -u $treeH $treeM; then false; else :; fi'


test_expect_success \ test_expect_success \
'10 - path removed.' \ '10 - path removed.' \
'rm -f .git/index nitfol bozbar rezrov frotz && 'rm -f .git/index nitfol bozbar rezrov frotz &&
git-read-tree --reset -u $treeH && git read-tree --reset -u $treeH &&
echo rezrov >rezrov && echo rezrov >rezrov &&
git-update-index --add rezrov && git update-index --add rezrov &&
git-read-tree -m -u $treeH $treeM && git read-tree -m -u $treeH $treeM &&
git-ls-files --stage >10.out && git ls-files --stage >10.out &&
cmp M.out 10.out && cmp M.out 10.out &&
sum bozbar frotz nitfol >actual10.sum && sum bozbar frotz nitfol >actual10.sum &&
cmp M.sum actual10.sum' cmp M.sum actual10.sum'
@ -170,28 +170,28 @@ test_expect_success \
test_expect_success \ test_expect_success \
'11 - dirty path removed.' \ '11 - dirty path removed.' \
'rm -f .git/index nitfol bozbar rezrov frotz && 'rm -f .git/index nitfol bozbar rezrov frotz &&
git-read-tree --reset -u $treeH && git read-tree --reset -u $treeH &&
echo rezrov >rezrov && echo rezrov >rezrov &&
git-update-index --add rezrov && git update-index --add rezrov &&
echo rezrov rezrov >rezrov && echo rezrov rezrov >rezrov &&
if git-read-tree -m -u $treeH $treeM; then false; else :; fi' if git read-tree -m -u $treeH $treeM; then false; else :; fi'


test_expect_success \ test_expect_success \
'12 - unmatching local changes being removed.' \ '12 - unmatching local changes being removed.' \
'rm -f .git/index nitfol bozbar rezrov frotz && 'rm -f .git/index nitfol bozbar rezrov frotz &&
git-read-tree --reset -u $treeH && git read-tree --reset -u $treeH &&
echo rezrov rezrov >rezrov && echo rezrov rezrov >rezrov &&
git-update-index --add rezrov && git update-index --add rezrov &&
if git-read-tree -m -u $treeH $treeM; then false; else :; fi' if git read-tree -m -u $treeH $treeM; then false; else :; fi'


test_expect_success \ test_expect_success \
'13 - unmatching local changes being removed.' \ '13 - unmatching local changes being removed.' \
'rm -f .git/index nitfol bozbar rezrov frotz && 'rm -f .git/index nitfol bozbar rezrov frotz &&
git-read-tree --reset -u $treeH && git read-tree --reset -u $treeH &&
echo rezrov rezrov >rezrov && echo rezrov rezrov >rezrov &&
git-update-index --add rezrov && git update-index --add rezrov &&
echo rezrov >rezrov && echo rezrov >rezrov &&
if git-read-tree -m -u $treeH $treeM; then false; else :; fi' if git read-tree -m -u $treeH $treeM; then false; else :; fi'


cat >expected <<EOF cat >expected <<EOF
-100644 X 0 nitfol -100644 X 0 nitfol
@ -201,11 +201,11 @@ EOF
test_expect_success \ test_expect_success \
'14 - unchanged in two heads.' \ '14 - unchanged in two heads.' \
'rm -f .git/index nitfol bozbar rezrov frotz && 'rm -f .git/index nitfol bozbar rezrov frotz &&
git-read-tree --reset -u $treeH && git read-tree --reset -u $treeH &&
echo nitfol nitfol >nitfol && echo nitfol nitfol >nitfol &&
git-update-index --add nitfol && git update-index --add nitfol &&
git-read-tree -m -u $treeH $treeM && git read-tree -m -u $treeH $treeM &&
git-ls-files --stage >14.out || return 1 git ls-files --stage >14.out || return 1
diff -U0 M.out 14.out >14diff.out diff -U0 M.out 14.out >14diff.out
compare_change 14diff.out expected && compare_change 14diff.out expected &&
sum bozbar frotz >actual14.sum && sum bozbar frotz >actual14.sum &&
@ -221,12 +221,12 @@ test_expect_success \
test_expect_success \ test_expect_success \
'15 - unchanged in two heads.' \ '15 - unchanged in two heads.' \
'rm -f .git/index nitfol bozbar rezrov frotz && 'rm -f .git/index nitfol bozbar rezrov frotz &&
git-read-tree --reset -u $treeH && git read-tree --reset -u $treeH &&
echo nitfol nitfol >nitfol && echo nitfol nitfol >nitfol &&
git-update-index --add nitfol && git update-index --add nitfol &&
echo nitfol nitfol nitfol >nitfol && echo nitfol nitfol nitfol >nitfol &&
git-read-tree -m -u $treeH $treeM && git read-tree -m -u $treeH $treeM &&
git-ls-files --stage >15.out || return 1 git ls-files --stage >15.out || return 1
diff -U0 M.out 15.out >15diff.out diff -U0 M.out 15.out >15diff.out
compare_change 15diff.out expected && compare_change 15diff.out expected &&
check_cache_at nitfol dirty && check_cache_at nitfol dirty &&
@ -242,28 +242,28 @@ test_expect_success \
test_expect_success \ test_expect_success \
'16 - conflicting local change.' \ '16 - conflicting local change.' \
'rm -f .git/index nitfol bozbar rezrov frotz && 'rm -f .git/index nitfol bozbar rezrov frotz &&
git-read-tree --reset -u $treeH && git read-tree --reset -u $treeH &&
echo bozbar bozbar >bozbar && echo bozbar bozbar >bozbar &&
git-update-index --add bozbar && git update-index --add bozbar &&
if git-read-tree -m -u $treeH $treeM; then false; else :; fi' if git read-tree -m -u $treeH $treeM; then false; else :; fi'


test_expect_success \ test_expect_success \
'17 - conflicting local change.' \ '17 - conflicting local change.' \
'rm -f .git/index nitfol bozbar rezrov frotz && 'rm -f .git/index nitfol bozbar rezrov frotz &&
git-read-tree --reset -u $treeH && git read-tree --reset -u $treeH &&
echo bozbar bozbar >bozbar && echo bozbar bozbar >bozbar &&
git-update-index --add bozbar && git update-index --add bozbar &&
echo bozbar bozbar bozbar >bozbar && echo bozbar bozbar bozbar >bozbar &&
if git-read-tree -m -u $treeH $treeM; then false; else :; fi' if git read-tree -m -u $treeH $treeM; then false; else :; fi'


test_expect_success \ test_expect_success \
'18 - local change already having a good result.' \ '18 - local change already having a good result.' \
'rm -f .git/index nitfol bozbar rezrov frotz && 'rm -f .git/index nitfol bozbar rezrov frotz &&
git-read-tree --reset -u $treeH && git read-tree --reset -u $treeH &&
echo gnusto >bozbar && echo gnusto >bozbar &&
git-update-index --add bozbar && git update-index --add bozbar &&
git-read-tree -m -u $treeH $treeM && git read-tree -m -u $treeH $treeM &&
git-ls-files --stage >18.out && git ls-files --stage >18.out &&
diff -U0 M.out 18.out && diff -U0 M.out 18.out &&
check_cache_at bozbar clean && check_cache_at bozbar clean &&
sum bozbar frotz nitfol >actual18.sum && sum bozbar frotz nitfol >actual18.sum &&
@ -272,12 +272,12 @@ test_expect_success \
test_expect_success \ test_expect_success \
'19 - local change already having a good result, further modified.' \ '19 - local change already having a good result, further modified.' \
'rm -f .git/index nitfol bozbar rezrov frotz && 'rm -f .git/index nitfol bozbar rezrov frotz &&
git-read-tree --reset -u $treeH && git read-tree --reset -u $treeH &&
echo gnusto >bozbar && echo gnusto >bozbar &&
git-update-index --add bozbar && git update-index --add bozbar &&
echo gnusto gnusto >bozbar && echo gnusto gnusto >bozbar &&
git-read-tree -m -u $treeH $treeM && git read-tree -m -u $treeH $treeM &&
git-ls-files --stage >19.out && git ls-files --stage >19.out &&
diff -U0 M.out 19.out && diff -U0 M.out 19.out &&
check_cache_at bozbar dirty && check_cache_at bozbar dirty &&
sum frotz nitfol >actual19.sum && sum frotz nitfol >actual19.sum &&
@ -292,11 +292,11 @@ test_expect_success \
test_expect_success \ test_expect_success \
'20 - no local change, use new tree.' \ '20 - no local change, use new tree.' \
'rm -f .git/index nitfol bozbar rezrov frotz && 'rm -f .git/index nitfol bozbar rezrov frotz &&
git-read-tree --reset -u $treeH && git read-tree --reset -u $treeH &&
echo bozbar >bozbar && echo bozbar >bozbar &&
git-update-index --add bozbar && git update-index --add bozbar &&
git-read-tree -m -u $treeH $treeM && git read-tree -m -u $treeH $treeM &&
git-ls-files --stage >20.out && git ls-files --stage >20.out &&
diff -U0 M.out 20.out && diff -U0 M.out 20.out &&
check_cache_at bozbar clean && check_cache_at bozbar clean &&
sum bozbar frotz nitfol >actual20.sum && sum bozbar frotz nitfol >actual20.sum &&
@ -305,39 +305,39 @@ test_expect_success \
test_expect_success \ test_expect_success \
'21 - no local change, dirty cache.' \ '21 - no local change, dirty cache.' \
'rm -f .git/index nitfol bozbar rezrov frotz && 'rm -f .git/index nitfol bozbar rezrov frotz &&
git-read-tree --reset -u $treeH && git read-tree --reset -u $treeH &&
echo bozbar >bozbar && echo bozbar >bozbar &&
git-update-index --add bozbar && git update-index --add bozbar &&
echo gnusto gnusto >bozbar && echo gnusto gnusto >bozbar &&
if git-read-tree -m -u $treeH $treeM; then false; else :; fi' if git read-tree -m -u $treeH $treeM; then false; else :; fi'


# Also make sure we did not break DF vs DF/DF case. # Also make sure we did not break DF vs DF/DF case.
test_expect_success \ test_expect_success \
'DF vs DF/DF case setup.' \ 'DF vs DF/DF case setup.' \
'rm -f .git/index 'rm -f .git/index
echo DF >DF && echo DF >DF &&
git-update-index --add DF && git update-index --add DF &&
treeDF=`git-write-tree` && treeDF=`git write-tree` &&
echo treeDF $treeDF && echo treeDF $treeDF &&
git-ls-tree $treeDF && git ls-tree $treeDF &&


rm -f DF && rm -f DF &&
mkdir DF && mkdir DF &&
echo DF/DF >DF/DF && echo DF/DF >DF/DF &&
git-update-index --add --remove DF DF/DF && git update-index --add --remove DF DF/DF &&
treeDFDF=`git-write-tree` && treeDFDF=`git write-tree` &&
echo treeDFDF $treeDFDF && echo treeDFDF $treeDFDF &&
git-ls-tree $treeDFDF && git ls-tree $treeDFDF &&
git-ls-files --stage >DFDF.out' git ls-files --stage >DFDF.out'


test_expect_success \ test_expect_success \
'DF vs DF/DF case test.' \ 'DF vs DF/DF case test.' \
'rm -f .git/index && 'rm -f .git/index &&
rm -fr DF && rm -fr DF &&
echo DF >DF && echo DF >DF &&
git-update-index --add DF && git update-index --add DF &&
git-read-tree -m -u $treeDF $treeDFDF && git read-tree -m -u $treeDF $treeDFDF &&
git-ls-files --stage >DFDFcheck.out && git ls-files --stage >DFDFcheck.out &&
diff -U0 DFDF.out DFDFcheck.out && diff -U0 DFDF.out DFDFcheck.out &&
check_cache_at DF/DF clean' check_cache_at DF/DF clean'



View File

@ -3,15 +3,15 @@
# Copyright (c) 2006 Junio C Hamano # Copyright (c) 2006 Junio C Hamano
# #


test_description='git-read-tree --prefix test. test_description='git read-tree --prefix test.
' '


. ./test-lib.sh . ./test-lib.sh


test_expect_success setup ' test_expect_success setup '
echo hello >one && echo hello >one &&
git-update-index --add one && git update-index --add one &&
tree=`git-write-tree` && tree=`git write-tree` &&
echo tree is $tree echo tree is $tree
' '


@ -19,8 +19,8 @@ echo 'one
two/one' >expect two/one' >expect


test_expect_success 'read-tree --prefix' ' test_expect_success 'read-tree --prefix' '
git-read-tree --prefix=two/ $tree && git read-tree --prefix=two/ $tree &&
git-ls-files >actual && git ls-files >actual &&
cmp expect actual cmp expect actual
' '



View File

@ -84,7 +84,7 @@ test_expect_success 'three-way not complaining on an untracked path in both' '
echo >file2 file two is untracked on the master side && echo >file2 file two is untracked on the master side &&
echo >subdir/file2 file two is untracked on the master side && echo >subdir/file2 file two is untracked on the master side &&


git-read-tree -m -u branch-point master side git read-tree -m -u branch-point master side
' '


test_expect_success 'three-way not clobbering a working tree file' ' test_expect_success 'three-way not clobbering a working tree file' '

View File

@ -22,19 +22,19 @@ LF='


test_expect_success 'update-index and ls-files' ' test_expect_success 'update-index and ls-files' '
cd $HERE && cd $HERE &&
git-update-index --add one && git update-index --add one &&
case "`git-ls-files`" in case "`git ls-files`" in
one) echo ok one ;; one) echo ok one ;;
*) echo bad one; exit 1 ;; *) echo bad one; exit 1 ;;
esac && esac &&
cd dir && cd dir &&
git-update-index --add two && git update-index --add two &&
case "`git-ls-files`" in case "`git ls-files`" in
two) echo ok two ;; two) echo ok two ;;
*) echo bad two; exit 1 ;; *) echo bad two; exit 1 ;;
esac && esac &&
cd .. && cd .. &&
case "`git-ls-files`" in case "`git ls-files`" in
dir/two"$LF"one) echo ok both ;; dir/two"$LF"one) echo ok both ;;
*) echo bad; exit 1 ;; *) echo bad; exit 1 ;;
esac esac
@ -42,13 +42,13 @@ test_expect_success 'update-index and ls-files' '


test_expect_success 'cat-file' ' test_expect_success 'cat-file' '
cd $HERE && cd $HERE &&
two=`git-ls-files -s dir/two` && two=`git ls-files -s dir/two` &&
two=`expr "$two" : "[0-7]* \\([0-9a-f]*\\)"` && two=`expr "$two" : "[0-7]* \\([0-9a-f]*\\)"` &&
echo "$two" && echo "$two" &&
git-cat-file -p "$two" >actual && git cat-file -p "$two" >actual &&
cmp dir/two actual && cmp dir/two actual &&
cd dir && cd dir &&
git-cat-file -p "$two" >actual && git cat-file -p "$two" >actual &&
cmp two actual cmp two actual
' '
rm -f actual dir/actual rm -f actual dir/actual
@ -57,17 +57,17 @@ test_expect_success 'diff-files' '
cd $HERE && cd $HERE &&
echo a >>one && echo a >>one &&
echo d >>dir/two && echo d >>dir/two &&
case "`git-diff-files --name-only`" in case "`git diff-files --name-only`" in
dir/two"$LF"one) echo ok top ;; dir/two"$LF"one) echo ok top ;;
*) echo bad top; exit 1 ;; *) echo bad top; exit 1 ;;
esac && esac &&
# diff should not omit leading paths # diff should not omit leading paths
cd dir && cd dir &&
case "`git-diff-files --name-only`" in case "`git diff-files --name-only`" in
dir/two"$LF"one) echo ok subdir ;; dir/two"$LF"one) echo ok subdir ;;
*) echo bad subdir; exit 1 ;; *) echo bad subdir; exit 1 ;;
esac && esac &&
case "`git-diff-files --name-only .`" in case "`git diff-files --name-only .`" in
dir/two) echo ok subdir limited ;; dir/two) echo ok subdir limited ;;
*) echo bad subdir limited; exit 1 ;; *) echo bad subdir limited; exit 1 ;;
esac esac
@ -75,33 +75,33 @@ test_expect_success 'diff-files' '


test_expect_success 'write-tree' ' test_expect_success 'write-tree' '
cd $HERE && cd $HERE &&
top=`git-write-tree` && top=`git write-tree` &&
echo $top && echo $top &&
cd dir && cd dir &&
sub=`git-write-tree` && sub=`git write-tree` &&
echo $sub && echo $sub &&
test "z$top" = "z$sub" test "z$top" = "z$sub"
' '


test_expect_success 'checkout-index' ' test_expect_success 'checkout-index' '
cd $HERE && cd $HERE &&
git-checkout-index -f -u one && git checkout-index -f -u one &&
cmp one original.one && cmp one original.one &&
cd dir && cd dir &&
git-checkout-index -f -u two && git checkout-index -f -u two &&
cmp two ../original.two cmp two ../original.two
' '


test_expect_success 'read-tree' ' test_expect_success 'read-tree' '
cd $HERE && cd $HERE &&
rm -f one dir/two && rm -f one dir/two &&
tree=`git-write-tree` && tree=`git write-tree` &&
git-read-tree --reset -u "$tree" && git read-tree --reset -u "$tree" &&
cmp one original.one && cmp one original.one &&
cmp dir/two original.two && cmp dir/two original.two &&
cd dir && cd dir &&
rm -f two && rm -f two &&
git-read-tree --reset -u "$tree" && git read-tree --reset -u "$tree" &&
cmp two ../original.two && cmp two ../original.two &&
cmp ../one ../original.one cmp ../one ../original.one
' '

View File

@ -3,9 +3,9 @@
# Copyright (C) 2005 Rene Scharfe # Copyright (C) 2005 Rene Scharfe
# #


test_description='git-commit-tree options test test_description='git commit-tree options test


This test checks that git-commit-tree can create a specific commit This test checks that git commit-tree can create a specific commit
object by defining all environment variables that it understands. object by defining all environment variables that it understands.
' '


@ -21,7 +21,7 @@ EOF


test_expect_success \ test_expect_success \
'test preparation: write empty tree' \ 'test preparation: write empty tree' \
'git-write-tree >treeid' 'git write-tree >treeid'


test_expect_success \ test_expect_success \
'construct commit' \ 'construct commit' \
@ -32,11 +32,11 @@ test_expect_success \
GIT_COMMITTER_NAME="Committer Name" \ GIT_COMMITTER_NAME="Committer Name" \
GIT_COMMITTER_EMAIL="committer@email" \ GIT_COMMITTER_EMAIL="committer@email" \
GIT_COMMITTER_DATE="2005-05-26 23:30" \ GIT_COMMITTER_DATE="2005-05-26 23:30" \
TZ=GMT git-commit-tree `cat treeid` >commitid 2>/dev/null' TZ=GMT git commit-tree `cat treeid` >commitid 2>/dev/null'


test_expect_success \ test_expect_success \
'read commit' \ 'read commit' \
'git-cat-file commit `cat commitid` >commit' 'git cat-file commit `cat commitid` >commit'


test_expect_success \ test_expect_success \
'compare commit' \ 'compare commit' \

View File

@ -10,11 +10,11 @@ test_description='A simple turial in the form of a test case'
echo "Hello World" > hello echo "Hello World" > hello
echo "Silly example" > example echo "Silly example" > example


git-update-index --add hello example git update-index --add hello example


test_expect_success 'blob' "test blob = \"$(git-cat-file -t 557db03)\"" test_expect_success 'blob' "test blob = \"$(git cat-file -t 557db03)\""


test_expect_success 'blob 557db03' "test \"Hello World\" = \"$(git-cat-file blob 557db03)\"" test_expect_success 'blob 557db03' "test \"Hello World\" = \"$(git cat-file blob 557db03)\""


echo "It's a new day for git" >>hello echo "It's a new day for git" >>hello
cat > diff.expect << EOF cat > diff.expect << EOF
@ -26,25 +26,25 @@ index 557db03..263414f 100644
Hello World Hello World
+It's a new day for git +It's a new day for git
EOF EOF
git-diff-files -p > diff.output git diff-files -p > diff.output
test_expect_success 'git-diff-files -p' 'cmp diff.expect diff.output' test_expect_success 'git diff-files -p' 'cmp diff.expect diff.output'
git diff > diff.output git diff > diff.output
test_expect_success 'git diff' 'cmp diff.expect diff.output' test_expect_success 'git diff' 'cmp diff.expect diff.output'


tree=$(git-write-tree 2>/dev/null) tree=$(git write-tree 2>/dev/null)


test_expect_success 'tree' "test 8988da15d077d4829fc51d8544c097def6644dbb = $tree" test_expect_success 'tree' "test 8988da15d077d4829fc51d8544c097def6644dbb = $tree"


output="$(echo "Initial commit" | git-commit-tree $(git-write-tree) 2>&1 > .git/refs/heads/master)" output="$(echo "Initial commit" | git commit-tree $(git write-tree) 2>&1 > .git/refs/heads/master)"


git-diff-index -p HEAD > diff.output git diff-index -p HEAD > diff.output
test_expect_success 'git-diff-index -p HEAD' 'cmp diff.expect diff.output' test_expect_success 'git diff-index -p HEAD' 'cmp diff.expect diff.output'


git diff HEAD > diff.output git diff HEAD > diff.output
test_expect_success 'git diff HEAD' 'cmp diff.expect diff.output' test_expect_success 'git diff HEAD' 'cmp diff.expect diff.output'


#rm hello #rm hello
#test_expect_success 'git-read-tree --reset HEAD' "git-read-tree --reset HEAD ; test \"hello: needs update\" = \"$(git-update-index --refresh)\"" #test_expect_success 'git read-tree --reset HEAD' "git read-tree --reset HEAD ; test \"hello: needs update\" = \"$(git update-index --refresh)\""


cat > whatchanged.expect << EOF cat > whatchanged.expect << EOF
commit VARIABLE commit VARIABLE
@ -69,11 +69,11 @@ index 0000000..557db03
+Hello World +Hello World
EOF EOF


git-whatchanged -p --root | \ git whatchanged -p --root | \
sed -e "1s/^\(.\{7\}\).\{40\}/\1VARIABLE/" \ sed -e "1s/^\(.\{7\}\).\{40\}/\1VARIABLE/" \
-e "2,3s/^\(.\{8\}\).*$/\1VARIABLE/" \ -e "2,3s/^\(.\{8\}\).*$/\1VARIABLE/" \
> whatchanged.output > whatchanged.output
test_expect_success 'git-whatchanged -p --root' 'cmp whatchanged.expect whatchanged.output' test_expect_success 'git whatchanged -p --root' 'cmp whatchanged.expect whatchanged.output'


git tag my-first-tag git tag my-first-tag
test_expect_success 'git tag my-first-tag' 'cmp .git/refs/heads/master .git/refs/tags/my-first-tag' test_expect_success 'git tag my-first-tag' 'cmp .git/refs/heads/master .git/refs/tags/my-first-tag'

View File

@ -3,13 +3,13 @@
# Copyright (c) 2005 Johannes Schindelin # Copyright (c) 2005 Johannes Schindelin
# #


test_description='Test git-config in different settings' test_description='Test git config in different settings'


. ./test-lib.sh . ./test-lib.sh


test -f .git/config && rm .git/config test -f .git/config && rm .git/config


git-config core.penguin "little blue" git config core.penguin "little blue"


cat > expect << EOF cat > expect << EOF
[core] [core]
@ -18,7 +18,7 @@ EOF


test_expect_success 'initial' 'cmp .git/config expect' test_expect_success 'initial' 'cmp .git/config expect'


git-config Core.Movie BadPhysics git config Core.Movie BadPhysics


cat > expect << EOF cat > expect << EOF
[core] [core]
@ -28,7 +28,7 @@ EOF


test_expect_success 'mixed case' 'cmp .git/config expect' test_expect_success 'mixed case' 'cmp .git/config expect'


git-config Cores.WhatEver Second git config Cores.WhatEver Second


cat > expect << EOF cat > expect << EOF
[core] [core]
@ -40,7 +40,7 @@ EOF


test_expect_success 'similar section' 'cmp .git/config expect' test_expect_success 'similar section' 'cmp .git/config expect'


git-config CORE.UPPERCASE true git config CORE.UPPERCASE true


cat > expect << EOF cat > expect << EOF
[core] [core]
@ -54,10 +54,10 @@ EOF
test_expect_success 'similar section' 'cmp .git/config expect' test_expect_success 'similar section' 'cmp .git/config expect'


test_expect_success 'replace with non-match' \ test_expect_success 'replace with non-match' \
'git-config core.penguin kingpin !blue' 'git config core.penguin kingpin !blue'


test_expect_success 'replace with non-match (actually matching)' \ test_expect_success 'replace with non-match (actually matching)' \
'git-config core.penguin "very blue" !kingpin' 'git config core.penguin "very blue" !kingpin'


cat > expect << EOF cat > expect << EOF
[core] [core]
@ -86,7 +86,7 @@ EOF
cp .git/config .git/config2 cp .git/config .git/config2


test_expect_success 'multiple unset' \ test_expect_success 'multiple unset' \
'git-config --unset-all beta.haha' 'git config --unset-all beta.haha'


cat > expect << EOF cat > expect << EOF
[beta] ; silly comment # another comment [beta] ; silly comment # another comment
@ -102,7 +102,7 @@ test_expect_success 'multiple unset is correct' 'cmp .git/config expect'
mv .git/config2 .git/config mv .git/config2 .git/config


test_expect_success '--replace-all' \ test_expect_success '--replace-all' \
'git-config --replace-all beta.haha gamma' 'git config --replace-all beta.haha gamma'


cat > expect << EOF cat > expect << EOF
[beta] ; silly comment # another comment [beta] ; silly comment # another comment
@ -116,7 +116,7 @@ EOF


test_expect_success 'all replaced' 'cmp .git/config expect' test_expect_success 'all replaced' 'cmp .git/config expect'


git-config beta.haha alpha git config beta.haha alpha


cat > expect << EOF cat > expect << EOF
[beta] ; silly comment # another comment [beta] ; silly comment # another comment
@ -130,7 +130,7 @@ EOF


test_expect_success 'really mean test' 'cmp .git/config expect' test_expect_success 'really mean test' 'cmp .git/config expect'


git-config nextsection.nonewline wow git config nextsection.nonewline wow


cat > expect << EOF cat > expect << EOF
[beta] ; silly comment # another comment [beta] ; silly comment # another comment
@ -145,8 +145,8 @@ EOF


test_expect_success 'really really mean test' 'cmp .git/config expect' test_expect_success 'really really mean test' 'cmp .git/config expect'


test_expect_success 'get value' 'test alpha = $(git-config beta.haha)' test_expect_success 'get value' 'test alpha = $(git config beta.haha)'
git-config --unset beta.haha git config --unset beta.haha


cat > expect << EOF cat > expect << EOF
[beta] ; silly comment # another comment [beta] ; silly comment # another comment
@ -160,7 +160,7 @@ EOF


test_expect_success 'unset' 'cmp .git/config expect' test_expect_success 'unset' 'cmp .git/config expect'


git-config nextsection.NoNewLine "wow2 for me" "for me$" git config nextsection.NoNewLine "wow2 for me" "for me$"


cat > expect << EOF cat > expect << EOF
[beta] ; silly comment # another comment [beta] ; silly comment # another comment
@ -176,18 +176,18 @@ EOF
test_expect_success 'multivar' 'cmp .git/config expect' test_expect_success 'multivar' 'cmp .git/config expect'


test_expect_success 'non-match' \ test_expect_success 'non-match' \
'git-config --get nextsection.nonewline !for' 'git config --get nextsection.nonewline !for'


test_expect_success 'non-match value' \ test_expect_success 'non-match value' \
'test wow = $(git-config --get nextsection.nonewline !for)' 'test wow = $(git config --get nextsection.nonewline !for)'


test_expect_failure 'ambiguous get' \ test_expect_failure 'ambiguous get' \
'git-config --get nextsection.nonewline' 'git config --get nextsection.nonewline'


test_expect_success 'get multivar' \ test_expect_success 'get multivar' \
'git-config --get-all nextsection.nonewline' 'git config --get-all nextsection.nonewline'


git-config nextsection.nonewline "wow3" "wow$" git config nextsection.nonewline "wow3" "wow$"


cat > expect << EOF cat > expect << EOF
[beta] ; silly comment # another comment [beta] ; silly comment # another comment
@ -202,15 +202,15 @@ EOF


test_expect_success 'multivar replace' 'cmp .git/config expect' test_expect_success 'multivar replace' 'cmp .git/config expect'


test_expect_failure 'ambiguous value' 'git-config nextsection.nonewline' test_expect_failure 'ambiguous value' 'git config nextsection.nonewline'


test_expect_failure 'ambiguous unset' \ test_expect_failure 'ambiguous unset' \
'git-config --unset nextsection.nonewline' 'git config --unset nextsection.nonewline'


test_expect_failure 'invalid unset' \ test_expect_failure 'invalid unset' \
'git-config --unset somesection.nonewline' 'git config --unset somesection.nonewline'


git-config --unset nextsection.nonewline "wow3$" git config --unset nextsection.nonewline "wow3$"


cat > expect << EOF cat > expect << EOF
[beta] ; silly comment # another comment [beta] ; silly comment # another comment
@ -224,12 +224,12 @@ EOF


test_expect_success 'multivar unset' 'cmp .git/config expect' test_expect_success 'multivar unset' 'cmp .git/config expect'


test_expect_failure 'invalid key' 'git-config inval.2key blabla' test_expect_failure 'invalid key' 'git config inval.2key blabla'


test_expect_success 'correct key' 'git-config 123456.a123 987' test_expect_success 'correct key' 'git config 123456.a123 987'


test_expect_success 'hierarchical section' \ test_expect_success 'hierarchical section' \
'git-config Version.1.2.3eX.Alpha beta' 'git config Version.1.2.3eX.Alpha beta'


cat > expect << EOF cat > expect << EOF
[beta] ; silly comment # another comment [beta] ; silly comment # another comment
@ -255,7 +255,7 @@ version.1.2.3eX.alpha=beta
EOF EOF


test_expect_success 'working --list' \ test_expect_success 'working --list' \
'git-config --list > output && cmp output expect' 'git config --list > output && cmp output expect'


cat > expect << EOF cat > expect << EOF
beta.noindent sillyValue beta.noindent sillyValue
@ -263,9 +263,9 @@ nextsection.nonewline wow2 for me
EOF EOF


test_expect_success '--get-regexp' \ test_expect_success '--get-regexp' \
'git-config --get-regexp in > output && cmp output expect' 'git config --get-regexp in > output && cmp output expect'


git-config --add nextsection.nonewline "wow4 for you" git config --add nextsection.nonewline "wow4 for you"


cat > expect << EOF cat > expect << EOF
wow2 for me wow2 for me
@ -273,7 +273,7 @@ wow4 for you
EOF EOF


test_expect_success '--add' \ test_expect_success '--add' \
'git-config --get-all nextsection.nonewline > output && cmp output expect' 'git config --get-all nextsection.nonewline > output && cmp output expect'


cat > .git/config << EOF cat > .git/config << EOF
[novalue] [novalue]
@ -281,15 +281,15 @@ cat > .git/config << EOF
EOF EOF


test_expect_success 'get variable with no value' \ test_expect_success 'get variable with no value' \
'git-config --get novalue.variable ^$' 'git config --get novalue.variable ^$'


echo novalue.variable > expect echo novalue.variable > expect


test_expect_success 'get-regexp variable with no value' \ test_expect_success 'get-regexp variable with no value' \
'git-config --get-regexp novalue > output && 'git config --get-regexp novalue > output &&
cmp output expect' cmp output expect'


git-config > output 2>&1 git config > output 2>&1


test_expect_success 'no arguments, but no crash' \ test_expect_success 'no arguments, but no crash' \
"test $? = 129 && grep usage output" "test $? = 129 && grep usage output"
@ -299,7 +299,7 @@ cat > .git/config << EOF
c = d c = d
EOF EOF


git-config a.x y git config a.x y


cat > expect << EOF cat > expect << EOF
[a.b] [a.b]
@ -310,8 +310,8 @@ EOF


test_expect_success 'new section is partial match of another' 'cmp .git/config expect' test_expect_success 'new section is partial match of another' 'cmp .git/config expect'


git-config b.x y git config b.x y
git-config a.b c git config a.b c


cat > expect << EOF cat > expect << EOF
[a.b] [a.b]
@ -334,11 +334,11 @@ cat > expect << EOF
ein.bahn=strasse ein.bahn=strasse
EOF EOF


GIT_CONFIG=other-config git-config -l > output GIT_CONFIG=other-config git config -l > output


test_expect_success 'alternative GIT_CONFIG' 'cmp output expect' test_expect_success 'alternative GIT_CONFIG' 'cmp output expect'


GIT_CONFIG=other-config git-config anwohner.park ausweis GIT_CONFIG=other-config git config anwohner.park ausweis


cat > expect << EOF cat > expect << EOF
[ein] [ein]
@ -361,7 +361,7 @@ weird
EOF EOF


test_expect_success "rename section" \ test_expect_success "rename section" \
"git-config --rename-section branch.eins branch.zwei" "git config --rename-section branch.eins branch.zwei"


cat > expect << EOF cat > expect << EOF
# Hallo # Hallo
@ -377,12 +377,12 @@ EOF
test_expect_success "rename succeeded" "git diff expect .git/config" test_expect_success "rename succeeded" "git diff expect .git/config"


test_expect_failure "rename non-existing section" \ test_expect_failure "rename non-existing section" \
'git-config --rename-section branch."world domination" branch.drei' 'git config --rename-section branch."world domination" branch.drei'


test_expect_success "rename succeeded" "git diff expect .git/config" test_expect_success "rename succeeded" "git diff expect .git/config"


test_expect_success "rename another section" \ test_expect_success "rename another section" \
'git-config --rename-section branch."1 234 blabl/a" branch.drei' 'git config --rename-section branch."1 234 blabl/a" branch.drei'


cat > expect << EOF cat > expect << EOF
# Hallo # Hallo
@ -425,20 +425,20 @@ EOF


test_expect_success 'section ending' ' test_expect_success 'section ending' '


git-config gitcvs.enabled true && git config gitcvs.enabled true &&
git-config gitcvs.ext.dbname %Ggitcvs1.%a.%m.sqlite && git config gitcvs.ext.dbname %Ggitcvs1.%a.%m.sqlite &&
git-config gitcvs.dbname %Ggitcvs2.%a.%m.sqlite && git config gitcvs.dbname %Ggitcvs2.%a.%m.sqlite &&
cmp .git/config expect cmp .git/config expect


' '


test_expect_success numbers ' test_expect_success numbers '


git-config kilo.gram 1k && git config kilo.gram 1k &&
git-config mega.ton 1m && git config mega.ton 1m &&
k=$(git-config --int --get kilo.gram) && k=$(git config --int --get kilo.gram) &&
test z1024 = "z$k" && test z1024 = "z$k" &&
m=$(git-config --int --get mega.ton) && m=$(git config --int --get mega.ton) &&
test z1048576 = "z$m" test z1048576 = "z$m"
' '


@ -455,30 +455,30 @@ EOF


test_expect_success bool ' test_expect_success bool '


git-config bool.true1 01 && git config bool.true1 01 &&
git-config bool.true2 -1 && git config bool.true2 -1 &&
git-config bool.true3 YeS && git config bool.true3 YeS &&
git-config bool.true4 true && git config bool.true4 true &&
git-config bool.false1 000 && git config bool.false1 000 &&
git-config bool.false2 "" && git config bool.false2 "" &&
git-config bool.false3 nO && git config bool.false3 nO &&
git-config bool.false4 FALSE && git config bool.false4 FALSE &&
rm -f result && rm -f result &&
for i in 1 2 3 4 for i in 1 2 3 4
do do
git-config --bool --get bool.true$i >>result git config --bool --get bool.true$i >>result
git-config --bool --get bool.false$i >>result git config --bool --get bool.false$i >>result
done && done &&
cmp expect result' cmp expect result'


test_expect_failure 'invalid bool (--get)' ' test_expect_failure 'invalid bool (--get)' '


git-config bool.nobool foobar && git config bool.nobool foobar &&
git-config --bool --get bool.nobool' git config --bool --get bool.nobool'


test_expect_failure 'invalid bool (set)' ' test_expect_failure 'invalid bool (set)' '


git-config --bool bool.nobool foobar' git config --bool bool.nobool foobar'


rm .git/config rm .git/config


@ -496,14 +496,14 @@ EOF


test_expect_success 'set --bool' ' test_expect_success 'set --bool' '


git-config --bool bool.true1 01 && git config --bool bool.true1 01 &&
git-config --bool bool.true2 -1 && git config --bool bool.true2 -1 &&
git-config --bool bool.true3 YeS && git config --bool bool.true3 YeS &&
git-config --bool bool.true4 true && git config --bool bool.true4 true &&
git-config --bool bool.false1 000 && git config --bool bool.false1 000 &&
git-config --bool bool.false2 "" && git config --bool bool.false2 "" &&
git-config --bool bool.false3 nO && git config --bool bool.false3 nO &&
git-config --bool bool.false4 FALSE && git config --bool bool.false4 FALSE &&
cmp expect .git/config' cmp expect .git/config'


rm .git/config rm .git/config
@ -517,17 +517,17 @@ EOF


test_expect_success 'set --int' ' test_expect_success 'set --int' '


git-config --int int.val1 01 && git config --int int.val1 01 &&
git-config --int int.val2 -1 && git config --int int.val2 -1 &&
git-config --int int.val3 5m && git config --int int.val3 5m &&
cmp expect .git/config' cmp expect .git/config'


rm .git/config rm .git/config


git-config quote.leading " test" git config quote.leading " test"
git-config quote.ending "test " git config quote.ending "test "
git-config quote.semicolon "test;test" git config quote.semicolon "test;test"
git-config quote.hash "test#test" git config quote.hash "test#test"


cat > expect << EOF cat > expect << EOF
[quote] [quote]

View File

@ -3,7 +3,7 @@
# Copyright (c) 2006 Shawn Pearce # Copyright (c) 2006 Shawn Pearce
# #


test_description='Test git-update-ref and basic ref logging' test_description='Test git update-ref and basic ref logging'
. ./test-lib.sh . ./test-lib.sh


Z=0000000000000000000000000000000000000000 Z=0000000000000000000000000000000000000000
@ -19,34 +19,34 @@ n=$n_dir/fixes


test_expect_success \ test_expect_success \
"create $m" \ "create $m" \
"git-update-ref $m $A && "git update-ref $m $A &&
test $A"' = $(cat .git/'"$m"')' test $A"' = $(cat .git/'"$m"')'
test_expect_success \ test_expect_success \
"create $m" \ "create $m" \
"git-update-ref $m $B $A && "git update-ref $m $B $A &&
test $B"' = $(cat .git/'"$m"')' test $B"' = $(cat .git/'"$m"')'
rm -f .git/$m rm -f .git/$m


test_expect_success \ test_expect_success \
"fail to create $n" \ "fail to create $n" \
"touch .git/$n_dir "touch .git/$n_dir
git-update-ref $n $A >out 2>err"' git update-ref $n $A >out 2>err"'
test $? != 0' test $? != 0'
rm -f .git/$n_dir out err rm -f .git/$n_dir out err


test_expect_success \ test_expect_success \
"create $m (by HEAD)" \ "create $m (by HEAD)" \
"git-update-ref HEAD $A && "git update-ref HEAD $A &&
test $A"' = $(cat .git/'"$m"')' test $A"' = $(cat .git/'"$m"')'
test_expect_success \ test_expect_success \
"create $m (by HEAD)" \ "create $m (by HEAD)" \
"git-update-ref HEAD $B $A && "git update-ref HEAD $B $A &&
test $B"' = $(cat .git/'"$m"')' test $B"' = $(cat .git/'"$m"')'
rm -f .git/$m rm -f .git/$m


test_expect_failure \ test_expect_failure \
'(not) create HEAD with old sha1' \ '(not) create HEAD with old sha1' \
"git-update-ref HEAD $A $B" "git update-ref HEAD $A $B"
test_expect_failure \ test_expect_failure \
"(not) prior created .git/$m" \ "(not) prior created .git/$m" \
"test -f .git/$m" "test -f .git/$m"
@ -54,10 +54,10 @@ rm -f .git/$m


test_expect_success \ test_expect_success \
"create HEAD" \ "create HEAD" \
"git-update-ref HEAD $A" "git update-ref HEAD $A"
test_expect_failure \ test_expect_failure \
'(not) change HEAD with wrong SHA1' \ '(not) change HEAD with wrong SHA1' \
"git-update-ref HEAD $B $Z" "git update-ref HEAD $B $Z"
test_expect_failure \ test_expect_failure \
"(not) changed .git/$m" \ "(not) changed .git/$m" \
"test $B"' = $(cat .git/'"$m"')' "test $B"' = $(cat .git/'"$m"')'
@ -68,17 +68,17 @@ rm -f .git/$m
test_expect_success \ test_expect_success \
"create $m (logged by touch)" \ "create $m (logged by touch)" \
'GIT_COMMITTER_DATE="2005-05-26 23:30" \ 'GIT_COMMITTER_DATE="2005-05-26 23:30" \
git-update-ref HEAD '"$A"' -m "Initial Creation" && git update-ref HEAD '"$A"' -m "Initial Creation" &&
test '"$A"' = $(cat .git/'"$m"')' test '"$A"' = $(cat .git/'"$m"')'
test_expect_success \ test_expect_success \
"update $m (logged by touch)" \ "update $m (logged by touch)" \
'GIT_COMMITTER_DATE="2005-05-26 23:31" \ 'GIT_COMMITTER_DATE="2005-05-26 23:31" \
git-update-ref HEAD'" $B $A "'-m "Switch" && git update-ref HEAD'" $B $A "'-m "Switch" &&
test '"$B"' = $(cat .git/'"$m"')' test '"$B"' = $(cat .git/'"$m"')'
test_expect_success \ test_expect_success \
"set $m (logged by touch)" \ "set $m (logged by touch)" \
'GIT_COMMITTER_DATE="2005-05-26 23:41" \ 'GIT_COMMITTER_DATE="2005-05-26 23:41" \
git-update-ref HEAD'" $A && git update-ref HEAD'" $A &&
test $A"' = $(cat .git/'"$m"')' test $A"' = $(cat .git/'"$m"')'


cat >expect <<EOF cat >expect <<EOF
@ -93,23 +93,23 @@ rm -rf .git/$m .git/logs expect


test_expect_success \ test_expect_success \
'enable core.logAllRefUpdates' \ 'enable core.logAllRefUpdates' \
'git-config core.logAllRefUpdates true && 'git config core.logAllRefUpdates true &&
test true = $(git-config --bool --get core.logAllRefUpdates)' test true = $(git config --bool --get core.logAllRefUpdates)'


test_expect_success \ test_expect_success \
"create $m (logged by config)" \ "create $m (logged by config)" \
'GIT_COMMITTER_DATE="2005-05-26 23:32" \ 'GIT_COMMITTER_DATE="2005-05-26 23:32" \
git-update-ref HEAD'" $A "'-m "Initial Creation" && git update-ref HEAD'" $A "'-m "Initial Creation" &&
test '"$A"' = $(cat .git/'"$m"')' test '"$A"' = $(cat .git/'"$m"')'
test_expect_success \ test_expect_success \
"update $m (logged by config)" \ "update $m (logged by config)" \
'GIT_COMMITTER_DATE="2005-05-26 23:33" \ 'GIT_COMMITTER_DATE="2005-05-26 23:33" \
git-update-ref HEAD'" $B $A "'-m "Switch" && git update-ref HEAD'" $B $A "'-m "Switch" &&
test '"$B"' = $(cat .git/'"$m"')' test '"$B"' = $(cat .git/'"$m"')'
test_expect_success \ test_expect_success \
"set $m (logged by config)" \ "set $m (logged by config)" \
'GIT_COMMITTER_DATE="2005-05-26 23:43" \ 'GIT_COMMITTER_DATE="2005-05-26 23:43" \
git-update-ref HEAD '"$A && git update-ref HEAD '"$A &&
test $A"' = $(cat .git/'"$m"')' test $A"' = $(cat .git/'"$m"')'


cat >expect <<EOF cat >expect <<EOF
@ -122,7 +122,7 @@ test_expect_success \
'diff expect .git/logs/$m' 'diff expect .git/logs/$m'
rm -f .git/$m .git/logs/$m expect rm -f .git/$m .git/logs/$m expect


git-update-ref $m $D git update-ref $m $D
cat >.git/logs/$m <<EOF cat >.git/logs/$m <<EOF
$C $A $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1117150320 -0500 $C $A $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1117150320 -0500
$A $B $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1117150380 -0500 $A $B $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1117150380 -0500
@ -136,49 +136,49 @@ ld="Thu, 26 May 2005 18:43:00 -0500"
test_expect_success \ test_expect_success \
'Query "master@{May 25 2005}" (before history)' \ 'Query "master@{May 25 2005}" (before history)' \
'rm -f o e 'rm -f o e
git-rev-parse --verify "master@{May 25 2005}" >o 2>e && git rev-parse --verify "master@{May 25 2005}" >o 2>e &&
test '"$C"' = $(cat o) && test '"$C"' = $(cat o) &&
test "warning: Log for '\'master\'' only goes back to $ed." = "$(cat e)"' test "warning: Log for '\'master\'' only goes back to $ed." = "$(cat e)"'
test_expect_success \ test_expect_success \
"Query master@{2005-05-25} (before history)" \ "Query master@{2005-05-25} (before history)" \
'rm -f o e 'rm -f o e
git-rev-parse --verify master@{2005-05-25} >o 2>e && git rev-parse --verify master@{2005-05-25} >o 2>e &&
test '"$C"' = $(cat o) && test '"$C"' = $(cat o) &&
echo test "warning: Log for '\'master\'' only goes back to $ed." = "$(cat e)"' echo test "warning: Log for '\'master\'' only goes back to $ed." = "$(cat e)"'
test_expect_success \ test_expect_success \
'Query "master@{May 26 2005 23:31:59}" (1 second before history)' \ 'Query "master@{May 26 2005 23:31:59}" (1 second before history)' \
'rm -f o e 'rm -f o e
git-rev-parse --verify "master@{May 26 2005 23:31:59}" >o 2>e && git rev-parse --verify "master@{May 26 2005 23:31:59}" >o 2>e &&
test '"$C"' = $(cat o) && test '"$C"' = $(cat o) &&
test "warning: Log for '\''master'\'' only goes back to $ed." = "$(cat e)"' test "warning: Log for '\''master'\'' only goes back to $ed." = "$(cat e)"'
test_expect_success \ test_expect_success \
'Query "master@{May 26 2005 23:32:00}" (exactly history start)' \ 'Query "master@{May 26 2005 23:32:00}" (exactly history start)' \
'rm -f o e 'rm -f o e
git-rev-parse --verify "master@{May 26 2005 23:32:00}" >o 2>e && git rev-parse --verify "master@{May 26 2005 23:32:00}" >o 2>e &&
test '"$A"' = $(cat o) && test '"$A"' = $(cat o) &&
test "" = "$(cat e)"' test "" = "$(cat e)"'
test_expect_success \ test_expect_success \
'Query "master@{2005-05-26 23:33:01}" (middle of history with gap)' \ 'Query "master@{2005-05-26 23:33:01}" (middle of history with gap)' \
'rm -f o e 'rm -f o e
git-rev-parse --verify "master@{2005-05-26 23:33:01}" >o 2>e && git rev-parse --verify "master@{2005-05-26 23:33:01}" >o 2>e &&
test '"$B"' = $(cat o) && test '"$B"' = $(cat o) &&
test "warning: Log .git/logs/'"$m has gap after $gd"'." = "$(cat e)"' test "warning: Log .git/logs/'"$m has gap after $gd"'." = "$(cat e)"'
test_expect_success \ test_expect_success \
'Query "master@{2005-05-26 23:38:00}" (middle of history)' \ 'Query "master@{2005-05-26 23:38:00}" (middle of history)' \
'rm -f o e 'rm -f o e
git-rev-parse --verify "master@{2005-05-26 23:38:00}" >o 2>e && git rev-parse --verify "master@{2005-05-26 23:38:00}" >o 2>e &&
test '"$Z"' = $(cat o) && test '"$Z"' = $(cat o) &&
test "" = "$(cat e)"' test "" = "$(cat e)"'
test_expect_success \ test_expect_success \
'Query "master@{2005-05-26 23:43:00}" (exact end of history)' \ 'Query "master@{2005-05-26 23:43:00}" (exact end of history)' \
'rm -f o e 'rm -f o e
git-rev-parse --verify "master@{2005-05-26 23:43:00}" >o 2>e && git rev-parse --verify "master@{2005-05-26 23:43:00}" >o 2>e &&
test '"$E"' = $(cat o) && test '"$E"' = $(cat o) &&
test "" = "$(cat e)"' test "" = "$(cat e)"'
test_expect_success \ test_expect_success \
'Query "master@{2005-05-28}" (past end of history)' \ 'Query "master@{2005-05-28}" (past end of history)' \
'rm -f o e 'rm -f o e
git-rev-parse --verify "master@{2005-05-28}" >o 2>e && git rev-parse --verify "master@{2005-05-28}" >o 2>e &&
test '"$D"' = $(cat o) && test '"$D"' = $(cat o) &&
test "warning: Log .git/logs/'"$m unexpectedly ended on $ld"'." = "$(cat e)"' test "warning: Log .git/logs/'"$m unexpectedly ended on $ld"'." = "$(cat e)"'


@ -188,26 +188,26 @@ rm -f .git/$m .git/logs/$m expect
test_expect_success \ test_expect_success \
'creating initial files' \ 'creating initial files' \
'echo TEST >F && 'echo TEST >F &&
git-add F && git add F &&
GIT_AUTHOR_DATE="2005-05-26 23:30" \ GIT_AUTHOR_DATE="2005-05-26 23:30" \
GIT_COMMITTER_DATE="2005-05-26 23:30" git-commit -m add -a && GIT_COMMITTER_DATE="2005-05-26 23:30" git-commit -m add -a &&
h_TEST=$(git-rev-parse --verify HEAD) h_TEST=$(git rev-parse --verify HEAD)
echo The other day this did not work. >M && echo The other day this did not work. >M &&
echo And then Bob told me how to fix it. >>M && echo And then Bob told me how to fix it. >>M &&
echo OTHER >F && echo OTHER >F &&
GIT_AUTHOR_DATE="2005-05-26 23:41" \ GIT_AUTHOR_DATE="2005-05-26 23:41" \
GIT_COMMITTER_DATE="2005-05-26 23:41" git-commit -F M -a && GIT_COMMITTER_DATE="2005-05-26 23:41" git-commit -F M -a &&
h_OTHER=$(git-rev-parse --verify HEAD) && h_OTHER=$(git rev-parse --verify HEAD) &&
echo FIXED >F && echo FIXED >F &&
GIT_AUTHOR_DATE="2005-05-26 23:44" \ GIT_AUTHOR_DATE="2005-05-26 23:44" \
GIT_COMMITTER_DATE="2005-05-26 23:44" git-commit --amend && GIT_COMMITTER_DATE="2005-05-26 23:44" git-commit --amend &&
h_FIXED=$(git-rev-parse --verify HEAD) && h_FIXED=$(git rev-parse --verify HEAD) &&
echo TEST+FIXED >F && echo TEST+FIXED >F &&
echo Merged initial commit and a later commit. >M && echo Merged initial commit and a later commit. >M &&
echo $h_TEST >.git/MERGE_HEAD && echo $h_TEST >.git/MERGE_HEAD &&
GIT_AUTHOR_DATE="2005-05-26 23:45" \ GIT_AUTHOR_DATE="2005-05-26 23:45" \
GIT_COMMITTER_DATE="2005-05-26 23:45" git-commit -F M && GIT_COMMITTER_DATE="2005-05-26 23:45" git-commit -F M &&
h_MERGED=$(git-rev-parse --verify HEAD) h_MERGED=$(git rev-parse --verify HEAD)
rm -f M' rm -f M'


cat >expect <<EOF cat >expect <<EOF
@ -222,13 +222,13 @@ test_expect_success \
unset h_TEST h_OTHER h_FIXED h_MERGED unset h_TEST h_OTHER h_FIXED h_MERGED


test_expect_success \ test_expect_success \
'git-cat-file blob master:F (expect OTHER)' \ 'git cat-file blob master:F (expect OTHER)' \
'test OTHER = $(git-cat-file blob master:F)' 'test OTHER = $(git cat-file blob master:F)'
test_expect_success \ test_expect_success \
'git-cat-file blob master@{2005-05-26 23:30}:F (expect TEST)' \ 'git cat-file blob master@{2005-05-26 23:30}:F (expect TEST)' \
'test TEST = $(git-cat-file blob "master@{2005-05-26 23:30}:F")' 'test TEST = $(git cat-file blob "master@{2005-05-26 23:30}:F")'
test_expect_success \ test_expect_success \
'git-cat-file blob master@{2005-05-26 23:42}:F (expect OTHER)' \ 'git cat-file blob master@{2005-05-26 23:42}:F (expect OTHER)' \
'test OTHER = $(git-cat-file blob "master@{2005-05-26 23:42}:F")' 'test OTHER = $(git cat-file blob "master@{2005-05-26 23:42}:F")'


test_done test_done

View File

@ -3,7 +3,7 @@
# Copyright (c) 2005 Junio C Hamano # Copyright (c) 2005 Junio C Hamano
# #


test_description='git-checkout-index test. test_description='git checkout-index test.


This test registers the following filesystem structure in the This test registers the following filesystem structure in the
cache: cache:
@ -16,7 +16,7 @@ And then tries to checkout in a work tree that has the following:
path0/file0 - a file in a directory path0/file0 - a file in a directory
path1 - a file path1 - a file


The git-checkout-index command should fail when attempting to checkout The git checkout-index command should fail when attempting to checkout
path0, finding it is occupied by a directory, and path1/file1, finding path0, finding it is occupied by a directory, and path1/file1, finding
path1 is occupied by a non-directory. With "-f" flag, it should remove path1 is occupied by a non-directory. With "-f" flag, it should remove
the conflicting paths and succeed. the conflicting paths and succeed.
@ -28,8 +28,8 @@ mkdir path1
date >path1/file1 date >path1/file1


test_expect_success \ test_expect_success \
'git-update-index --add various paths.' \ 'git update-index --add various paths.' \
'git-update-index --add path0 path1/file1' 'git update-index --add path0 path1/file1'


rm -fr path0 path1 rm -fr path0 path1
mkdir path0 mkdir path0
@ -37,15 +37,15 @@ date >path0/file0
date >path1 date >path1


test_expect_failure \ test_expect_failure \
'git-checkout-index without -f should fail on conflicting work tree.' \ 'git checkout-index without -f should fail on conflicting work tree.' \
'git-checkout-index -a' 'git checkout-index -a'


test_expect_success \ test_expect_success \
'git-checkout-index with -f should succeed.' \ 'git checkout-index with -f should succeed.' \
'git-checkout-index -f -a' 'git checkout-index -f -a'


test_expect_success \ test_expect_success \
'git-checkout-index conflicting paths.' \ 'git checkout-index conflicting paths.' \
'test -f path0 && test -d path1 && test -f path1/file1' 'test -f path0 && test -d path1 && test -f path1/file1'


test_done test_done

View File

@ -3,7 +3,7 @@
# Copyright (c) 2005 Junio C Hamano # Copyright (c) 2005 Junio C Hamano
# #


test_description='git-checkout-index test. test_description='git checkout-index test.


This test registers the following filesystem structure in the cache: This test registers the following filesystem structure in the cache:


@ -26,46 +26,46 @@ show_files() {
find path? -ls | find path? -ls |
sed -e 's/^[0-9]* * [0-9]* * \([-bcdl]\)[^ ]* *[0-9]* *[^ ]* *[^ ]* *[0-9]* [A-Z][a-z][a-z] [0-9][0-9] [^ ]* /fs: \1 /' sed -e 's/^[0-9]* * [0-9]* * \([-bcdl]\)[^ ]* *[0-9]* *[^ ]* *[^ ]* *[0-9]* [A-Z][a-z][a-z] [0-9][0-9] [^ ]* /fs: \1 /'
# what's in the cache, just mode and name # what's in the cache, just mode and name
git-ls-files --stage | git ls-files --stage |
sed -e 's/^\([0-9]*\) [0-9a-f]* [0-3] /ca: \1 /' sed -e 's/^\([0-9]*\) [0-9a-f]* [0-3] /ca: \1 /'
# what's in the tree, just mode and name. # what's in the tree, just mode and name.
git-ls-tree -r "$1" | git ls-tree -r "$1" |
sed -e 's/^\([0-9]*\) [^ ]* [0-9a-f]* /tr: \1 /' sed -e 's/^\([0-9]*\) [^ ]* [0-9a-f]* /tr: \1 /'
} }


mkdir path0 mkdir path0
date >path0/file0 date >path0/file0
test_expect_success \ test_expect_success \
'git-update-index --add path0/file0' \ 'git update-index --add path0/file0' \
'git-update-index --add path0/file0' 'git update-index --add path0/file0'
test_expect_success \ test_expect_success \
'writing tree out with git-write-tree' \ 'writing tree out with git write-tree' \
'tree1=$(git-write-tree)' 'tree1=$(git write-tree)'
test_debug 'show_files $tree1' test_debug 'show_files $tree1'


mkdir path1 mkdir path1
date >path1/file1 date >path1/file1
test_expect_success \ test_expect_success \
'git-update-index --add path1/file1' \ 'git update-index --add path1/file1' \
'git-update-index --add path1/file1' 'git update-index --add path1/file1'
test_expect_success \ test_expect_success \
'writing tree out with git-write-tree' \ 'writing tree out with git write-tree' \
'tree2=$(git-write-tree)' 'tree2=$(git write-tree)'
test_debug 'show_files $tree2' test_debug 'show_files $tree2'


rm -fr path1 rm -fr path1
test_expect_success \ test_expect_success \
'read previously written tree and checkout.' \ 'read previously written tree and checkout.' \
'git-read-tree -m $tree1 && git-checkout-index -f -a' 'git read-tree -m $tree1 && git checkout-index -f -a'
test_debug 'show_files $tree1' test_debug 'show_files $tree1'


ln -s path0 path1 ln -s path0 path1
test_expect_success \ test_expect_success \
'git-update-index --add a symlink.' \ 'git update-index --add a symlink.' \
'git-update-index --add path1' 'git update-index --add path1'
test_expect_success \ test_expect_success \
'writing tree out with git-write-tree' \ 'writing tree out with git write-tree' \
'tree3=$(git-write-tree)' 'tree3=$(git write-tree)'
test_debug 'show_files $tree3' test_debug 'show_files $tree3'


# Morten says "Got that?" here. # Morten says "Got that?" here.
@ -73,7 +73,7 @@ test_debug 'show_files $tree3'


test_expect_success \ test_expect_success \
'read previously written tree and checkout.' \ 'read previously written tree and checkout.' \
'git-read-tree $tree2 && git-checkout-index -f -a' 'git read-tree $tree2 && git checkout-index -f -a'
test_debug 'show_files $tree2' test_debug 'show_files $tree2'


test_expect_success \ test_expect_success \

View File

@ -3,31 +3,31 @@
# Copyright (c) 2005 Junio C Hamano # Copyright (c) 2005 Junio C Hamano
# #


test_description='git-checkout-index -u test. test_description='git checkout-index -u test.


With -u flag, git-checkout-index internally runs the equivalent of With -u flag, git checkout-index internally runs the equivalent of
git-update-index --refresh on the checked out entry.' git update-index --refresh on the checked out entry.'


. ./test-lib.sh . ./test-lib.sh


test_expect_success \ test_expect_success \
'preparation' ' 'preparation' '
echo frotz >path0 && echo frotz >path0 &&
git-update-index --add path0 && git update-index --add path0 &&
t=$(git-write-tree)' t=$(git write-tree)'


test_expect_failure \ test_expect_failure \
'without -u, git-checkout-index smudges stat information.' ' 'without -u, git checkout-index smudges stat information.' '
rm -f path0 && rm -f path0 &&
git-read-tree $t && git read-tree $t &&
git-checkout-index -f -a && git checkout-index -f -a &&
git-diff-files | diff - /dev/null' git diff-files | diff - /dev/null'


test_expect_success \ test_expect_success \
'with -u, git-checkout-index picks up stat information from new files.' ' 'with -u, git checkout-index picks up stat information from new files.' '
rm -f path0 && rm -f path0 &&
git-read-tree $t && git read-tree $t &&
git-checkout-index -u -f -a && git checkout-index -u -f -a &&
git-diff-files | diff - /dev/null' git diff-files | diff - /dev/null'


test_done test_done

View File

@ -3,7 +3,7 @@
# Copyright (c) 2005 Junio C Hamano # Copyright (c) 2005 Junio C Hamano
# #


test_description='git-checkout-index --prefix test. test_description='git checkout-index --prefix test.


This test makes sure that --prefix option works as advertised, and This test makes sure that --prefix option works as advertised, and
also verifies that such leading path may contain symlinks, unlike also verifies that such leading path may contain symlinks, unlike
@ -17,14 +17,14 @@ test_expect_success \
'mkdir path1 && 'mkdir path1 &&
echo frotz >path0 && echo frotz >path0 &&
echo rezrov >path1/file1 && echo rezrov >path1/file1 &&
git-update-index --add path0 path1/file1' git update-index --add path0 path1/file1'


test_expect_success \ test_expect_success \
'have symlink in place where dir is expected.' \ 'have symlink in place where dir is expected.' \
'rm -fr path0 path1 && 'rm -fr path0 path1 &&
mkdir path2 && mkdir path2 &&
ln -s path2 path1 && ln -s path2 path1 &&
git-checkout-index -f -a && git checkout-index -f -a &&
test ! -h path1 && test -d path1 && test ! -h path1 && test -d path1 &&
test -f path1/file1 && test ! -f path2/file1' test -f path1/file1 && test ! -f path2/file1'


@ -32,7 +32,7 @@ test_expect_success \
'use --prefix=path2/' \ 'use --prefix=path2/' \
'rm -fr path0 path1 path2 && 'rm -fr path0 path1 path2 &&
mkdir path2 && mkdir path2 &&
git-checkout-index --prefix=path2/ -f -a && git checkout-index --prefix=path2/ -f -a &&
test -f path2/path0 && test -f path2/path0 &&
test -f path2/path1/file1 && test -f path2/path1/file1 &&
test ! -f path0 && test ! -f path0 &&
@ -41,7 +41,7 @@ test_expect_success \
test_expect_success \ test_expect_success \
'use --prefix=tmp-' \ 'use --prefix=tmp-' \
'rm -fr path0 path1 path2 tmp* && 'rm -fr path0 path1 path2 tmp* &&
git-checkout-index --prefix=tmp- -f -a && git checkout-index --prefix=tmp- -f -a &&
test -f tmp-path0 && test -f tmp-path0 &&
test -f tmp-path1/file1 && test -f tmp-path1/file1 &&
test ! -f path0 && test ! -f path0 &&
@ -52,7 +52,7 @@ test_expect_success \
'rm -fr path0 path1 path2 tmp* && 'rm -fr path0 path1 path2 tmp* &&
echo nitfol >tmp-path1 && echo nitfol >tmp-path1 &&
mkdir tmp-path0 && mkdir tmp-path0 &&
git-checkout-index --prefix=tmp- -f -a && git checkout-index --prefix=tmp- -f -a &&
test -f tmp-path0 && test -f tmp-path0 &&
test -f tmp-path1/file1 && test -f tmp-path1/file1 &&
test ! -f path0 && test ! -f path0 &&
@ -64,7 +64,7 @@ test_expect_success \
'rm -fr path0 path1 path2 tmp* && 'rm -fr path0 path1 path2 tmp* &&
mkdir tmp1 tmp1/orary && mkdir tmp1 tmp1/orary &&
ln -s tmp1 tmp && ln -s tmp1 tmp &&
git-checkout-index --prefix=tmp/orary/ -f -a && git checkout-index --prefix=tmp/orary/ -f -a &&
test -d tmp1/orary && test -d tmp1/orary &&
test -f tmp1/orary/path0 && test -f tmp1/orary/path0 &&
test -f tmp1/orary/path1/file1 && test -f tmp1/orary/path1/file1 &&
@ -76,7 +76,7 @@ test_expect_success \
'rm -fr path0 path1 path2 tmp* && 'rm -fr path0 path1 path2 tmp* &&
mkdir tmp1 && mkdir tmp1 &&
ln -s tmp1 tmp && ln -s tmp1 tmp &&
git-checkout-index --prefix=tmp/orary- -f -a && git checkout-index --prefix=tmp/orary- -f -a &&
test -f tmp1/orary-path0 && test -f tmp1/orary-path0 &&
test -f tmp1/orary-path1/file1 && test -f tmp1/orary-path1/file1 &&
test -h tmp' test -h tmp'
@ -87,7 +87,7 @@ test_expect_success \
'rm -fr path0 path1 path2 tmp* && 'rm -fr path0 path1 path2 tmp* &&
mkdir tmp1 && mkdir tmp1 &&
ln -s tmp1 tmp-path1 && ln -s tmp1 tmp-path1 &&
git-checkout-index --prefix=tmp- -f -a && git checkout-index --prefix=tmp- -f -a &&
test -f tmp-path0 && test -f tmp-path0 &&
test ! -h tmp-path1 && test ! -h tmp-path1 &&
test -d tmp-path1 && test -d tmp-path1 &&

View File

@ -3,9 +3,9 @@
# Copyright (c) 2006 Shawn Pearce # Copyright (c) 2006 Shawn Pearce
# #


test_description='git-checkout-index --temp test. test_description='git checkout-index --temp test.


With --temp flag, git-checkout-index writes to temporary merge files With --temp flag, git checkout-index writes to temporary merge files
rather than the tracked path.' rather than the tracked path.'


. ./test-lib.sh . ./test-lib.sh
@ -18,28 +18,28 @@ echo tree1path1 >path1 &&
echo tree1path3 >path3 && echo tree1path3 >path3 &&
echo tree1path4 >path4 && echo tree1path4 >path4 &&
echo tree1asubdir/path5 >asubdir/path5 && echo tree1asubdir/path5 >asubdir/path5 &&
git-update-index --add path0 path1 path3 path4 asubdir/path5 && git update-index --add path0 path1 path3 path4 asubdir/path5 &&
t1=$(git-write-tree) && t1=$(git write-tree) &&
rm -f path* .merge_* out .git/index && rm -f path* .merge_* out .git/index &&
echo tree2path0 >path0 && echo tree2path0 >path0 &&
echo tree2path1 >path1 && echo tree2path1 >path1 &&
echo tree2path2 >path2 && echo tree2path2 >path2 &&
echo tree2path4 >path4 && echo tree2path4 >path4 &&
git-update-index --add path0 path1 path2 path4 && git update-index --add path0 path1 path2 path4 &&
t2=$(git-write-tree) && t2=$(git write-tree) &&
rm -f path* .merge_* out .git/index && rm -f path* .merge_* out .git/index &&
echo tree2path0 >path0 && echo tree2path0 >path0 &&
echo tree3path1 >path1 && echo tree3path1 >path1 &&
echo tree3path2 >path2 && echo tree3path2 >path2 &&
echo tree3path3 >path3 && echo tree3path3 >path3 &&
git-update-index --add path0 path1 path2 path3 && git update-index --add path0 path1 path2 path3 &&
t3=$(git-write-tree)' t3=$(git write-tree)'


test_expect_success \ test_expect_success \
'checkout one stage 0 to temporary file' ' 'checkout one stage 0 to temporary file' '
rm -f path* .merge_* out .git/index && rm -f path* .merge_* out .git/index &&
git-read-tree $t1 && git read-tree $t1 &&
git-checkout-index --temp -- path1 >out && git checkout-index --temp -- path1 >out &&
test $(wc -l <out) = 1 && test $(wc -l <out) = 1 &&
test $(cut "-d " -f2 out) = path1 && test $(cut "-d " -f2 out) = path1 &&
p=$(cut "-d " -f1 out) && p=$(cut "-d " -f1 out) &&
@ -49,8 +49,8 @@ test $(cat $p) = tree1path1'
test_expect_success \ test_expect_success \
'checkout all stage 0 to temporary files' ' 'checkout all stage 0 to temporary files' '
rm -f path* .merge_* out .git/index && rm -f path* .merge_* out .git/index &&
git-read-tree $t1 && git read-tree $t1 &&
git-checkout-index -a --temp >out && git checkout-index -a --temp >out &&
test $(wc -l <out) = 5 && test $(wc -l <out) = 5 &&
for f in path0 path1 path3 path4 asubdir/path5 for f in path0 path1 path3 path4 asubdir/path5
do do
@ -63,12 +63,12 @@ done'
test_expect_success \ test_expect_success \
'prepare 3-way merge' ' 'prepare 3-way merge' '
rm -f path* .merge_* out .git/index && rm -f path* .merge_* out .git/index &&
git-read-tree -m $t1 $t2 $t3' git read-tree -m $t1 $t2 $t3'


test_expect_success \ test_expect_success \
'checkout one stage 2 to temporary file' ' 'checkout one stage 2 to temporary file' '
rm -f path* .merge_* out && rm -f path* .merge_* out &&
git-checkout-index --stage=2 --temp -- path1 >out && git checkout-index --stage=2 --temp -- path1 >out &&
test $(wc -l <out) = 1 && test $(wc -l <out) = 1 &&
test $(cut "-d " -f2 out) = path1 && test $(cut "-d " -f2 out) = path1 &&
p=$(cut "-d " -f1 out) && p=$(cut "-d " -f1 out) &&
@ -78,7 +78,7 @@ test $(cat $p) = tree2path1'
test_expect_success \ test_expect_success \
'checkout all stage 2 to temporary files' ' 'checkout all stage 2 to temporary files' '
rm -f path* .merge_* out && rm -f path* .merge_* out &&
git-checkout-index --all --stage=2 --temp >out && git checkout-index --all --stage=2 --temp >out &&
test $(wc -l <out) = 3 && test $(wc -l <out) = 3 &&
for f in path1 path2 path4 for f in path1 path2 path4
do do
@ -91,13 +91,13 @@ done'
test_expect_success \ test_expect_success \
'checkout all stages/one file to nothing' ' 'checkout all stages/one file to nothing' '
rm -f path* .merge_* out && rm -f path* .merge_* out &&
git-checkout-index --stage=all --temp -- path0 >out && git checkout-index --stage=all --temp -- path0 >out &&
test $(wc -l <out) = 0' test $(wc -l <out) = 0'


test_expect_success \ test_expect_success \
'checkout all stages/one file to temporary files' ' 'checkout all stages/one file to temporary files' '
rm -f path* .merge_* out && rm -f path* .merge_* out &&
git-checkout-index --stage=all --temp -- path1 >out && git checkout-index --stage=all --temp -- path1 >out &&
test $(wc -l <out) = 1 && test $(wc -l <out) = 1 &&
test $(cut "-d " -f2 out) = path1 && test $(cut "-d " -f2 out) = path1 &&
cut "-d " -f1 out | (read s1 s2 s3 && cut "-d " -f1 out | (read s1 s2 s3 &&
@ -111,7 +111,7 @@ test $(cat $s3) = tree3path1)'
test_expect_success \ test_expect_success \
'checkout some stages/one file to temporary files' ' 'checkout some stages/one file to temporary files' '
rm -f path* .merge_* out && rm -f path* .merge_* out &&
git-checkout-index --stage=all --temp -- path2 >out && git checkout-index --stage=all --temp -- path2 >out &&
test $(wc -l <out) = 1 && test $(wc -l <out) = 1 &&
test $(cut "-d " -f2 out) = path2 && test $(cut "-d " -f2 out) = path2 &&
cut "-d " -f1 out | (read s1 s2 s3 && cut "-d " -f1 out | (read s1 s2 s3 &&
@ -124,7 +124,7 @@ test $(cat $s3) = tree3path2)'
test_expect_success \ test_expect_success \
'checkout all stages/all files to temporary files' ' 'checkout all stages/all files to temporary files' '
rm -f path* .merge_* out && rm -f path* .merge_* out &&
git-checkout-index -a --stage=all --temp >out && git checkout-index -a --stage=all --temp >out &&
test $(wc -l <out) = 5' test $(wc -l <out) = 5'


test_expect_success \ test_expect_success \
@ -184,7 +184,7 @@ test $(cat $s1) = tree1asubdir/path5)'
test_expect_success \ test_expect_success \
'checkout --temp within subdir' ' 'checkout --temp within subdir' '
(cd asubdir && (cd asubdir &&
git-checkout-index -a --stage=all >out && git checkout-index -a --stage=all >out &&
test $(wc -l <out) = 1 && test $(wc -l <out) = 1 &&
test $(grep path5 out | cut "-d " -f2) = path5 && test $(grep path5 out | cut "-d " -f2) = path5 &&
grep path5 out | cut "-d " -f1 | (read s1 s2 s3 && grep path5 out | cut "-d " -f1 | (read s1 s2 s3 &&
@ -198,11 +198,11 @@ test_expect_success \
'checkout --temp symlink' ' 'checkout --temp symlink' '
rm -f path* .merge_* out .git/index && rm -f path* .merge_* out .git/index &&
ln -s b a && ln -s b a &&
git-update-index --add a && git update-index --add a &&
t4=$(git-write-tree) && t4=$(git write-tree) &&
rm -f .git/index && rm -f .git/index &&
git-read-tree $t4 && git read-tree $t4 &&
git-checkout-index --temp -a >out && git checkout-index --temp -a >out &&
test $(wc -l <out) = 1 && test $(wc -l <out) = 1 &&
test $(cut "-d " -f2 out) = a && test $(cut "-d " -f2 out) = a &&
p=$(cut "-d " -f1 out) && p=$(cut "-d " -f1 out) &&

View File

@ -3,22 +3,22 @@
# Copyright (c) 2007 Johannes Sixt # Copyright (c) 2007 Johannes Sixt
# #


test_description='git-checkout-index on filesystem w/o symlinks test. test_description='git checkout-index on filesystem w/o symlinks test.


This tests that git-checkout-index creates a symbolic link as a plain This tests that git checkout-index creates a symbolic link as a plain
file if core.symlinks is false.' file if core.symlinks is false.'


. ./test-lib.sh . ./test-lib.sh


test_expect_success \ test_expect_success \
'preparation' ' 'preparation' '
git-config core.symlinks false && git config core.symlinks false &&
l=$(echo -n file | git-hash-object -t blob -w --stdin) && l=$(echo -n file | git-hash-object -t blob -w --stdin) &&
echo "120000 $l symlink" | git-update-index --index-info' echo "120000 $l symlink" | git update-index --index-info'


test_expect_success \ test_expect_success \
'the checked-out symlink must be a file' ' 'the checked-out symlink must be a file' '
git-checkout-index symlink && git checkout-index symlink &&
test -f symlink' test -f symlink'


test_expect_success \ test_expect_success \

View File

@ -3,7 +3,7 @@
# Copyright (c) 2005 Junio C Hamano # Copyright (c) 2005 Junio C Hamano
# #


test_description='git-update-index nonsense-path test. test_description='git update-index nonsense-path test.


This test creates the following structure in the cache: This test creates the following structure in the cache:


@ -12,7 +12,7 @@ This test creates the following structure in the cache:
path2/file2 - a file in a directory path2/file2 - a file in a directory
path3/file3 - a file in a directory path3/file3 - a file in a directory


and tries to git-update-index --add the following: and tries to git update-index --add the following:


path0/file0 - a file in a directory path0/file0 - a file in a directory
path1/file1 - a file in a directory path1/file1 - a file in a directory
@ -31,8 +31,8 @@ date >path2/file2
date >path3/file3 date >path3/file3


test_expect_success \ test_expect_success \
'git-update-index --add to add various paths.' \ 'git update-index --add to add various paths.' \
'git-update-index --add -- path0 path1 path2/file2 path3/file3' 'git update-index --add -- path0 path1 path2/file2 path3/file3'


rm -fr path? rm -fr path?


@ -45,7 +45,7 @@ date >path1/file1
for p in path0/file0 path1/file1 path2 path3 for p in path0/file0 path1/file1 path2 path3
do do
test_expect_failure \ test_expect_failure \
"git-update-index to add conflicting path $p should fail." \ "git update-index to add conflicting path $p should fail." \
"git-update-index --add -- $p" "git update-index --add -- $p"
done done
test_done test_done

View File

@ -3,7 +3,7 @@
# Copyright (c) 2006 Junio C Hamano # Copyright (c) 2006 Junio C Hamano
# #


test_description='git-update-index --again test. test_description='git update-index --again test.
' '


. ./test-lib.sh . ./test-lib.sh
@ -15,29 +15,29 @@ EOF
test_expect_success 'update-index --add' \ test_expect_success 'update-index --add' \
'echo hello world >file1 && 'echo hello world >file1 &&
echo goodbye people >file2 && echo goodbye people >file2 &&
git-update-index --add file1 file2 && git update-index --add file1 file2 &&
git-ls-files -s >current && git ls-files -s >current &&
cmp current expected' cmp current expected'


test_expect_success 'update-index --again' \ test_expect_success 'update-index --again' \
'rm -f file1 && 'rm -f file1 &&
echo hello everybody >file2 && echo hello everybody >file2 &&
if git-update-index --again if git update-index --again
then then
echo should have refused to remove file1 echo should have refused to remove file1
exit 1 exit 1
else else
echo happy - failed as expected echo happy - failed as expected
fi && fi &&
git-ls-files -s >current && git ls-files -s >current &&
cmp current expected' cmp current expected'


cat > expected <<\EOF cat > expected <<\EOF
100644 0f1ae1422c2bf43f117d3dbd715c988a9ed2103f 0 file2 100644 0f1ae1422c2bf43f117d3dbd715c988a9ed2103f 0 file2
EOF EOF
test_expect_success 'update-index --remove --again' \ test_expect_success 'update-index --remove --again' \
'git-update-index --remove --again && 'git update-index --remove --again &&
git-ls-files -s >current && git ls-files -s >current &&
cmp current expected' cmp current expected'


test_expect_success 'first commit' 'git-commit -m initial' test_expect_success 'first commit' 'git-commit -m initial'
@ -50,11 +50,11 @@ test_expect_success 'update-index again' \
'mkdir -p dir1 && 'mkdir -p dir1 &&
echo hello world >dir1/file3 && echo hello world >dir1/file3 &&
echo goodbye people >file2 && echo goodbye people >file2 &&
git-update-index --add file2 dir1/file3 && git update-index --add file2 dir1/file3 &&
echo hello everybody >file2 echo hello everybody >file2
echo happy >dir1/file3 && echo happy >dir1/file3 &&
git-update-index --again && git update-index --again &&
git-ls-files -s >current && git ls-files -s >current &&
cmp current expected' cmp current expected'


cat > expected <<\EOF cat > expected <<\EOF
@ -65,9 +65,9 @@ test_expect_success 'update-index --update from subdir' \
'echo not so happy >file2 && 'echo not so happy >file2 &&
cd dir1 && cd dir1 &&
cat ../file2 >file3 && cat ../file2 >file3 &&
git-update-index --again && git update-index --again &&
cd .. && cd .. &&
git-ls-files -s >current && git ls-files -s >current &&
cmp current expected' cmp current expected'


cat > expected <<\EOF cat > expected <<\EOF
@ -77,8 +77,8 @@ EOF
test_expect_success 'update-index --update with pathspec' \ test_expect_success 'update-index --update with pathspec' \
'echo very happy >file2 && 'echo very happy >file2 &&
cat file2 >dir1/file3 && cat file2 >dir1/file3 &&
git-update-index --again dir1/ && git update-index --again dir1/ &&
git-ls-files -s >current && git ls-files -s >current &&
cmp current expected' cmp current expected'


test_done test_done

View File

@ -3,29 +3,29 @@
# Copyright (c) 2007 Johannes Sixt # Copyright (c) 2007 Johannes Sixt
# #


test_description='git-update-index on filesystem w/o symlinks test. test_description='git update-index on filesystem w/o symlinks test.


This tests that git-update-index keeps the symbolic link property This tests that git update-index keeps the symbolic link property
even if a plain file is in the working tree if core.symlinks is false.' even if a plain file is in the working tree if core.symlinks is false.'


. ./test-lib.sh . ./test-lib.sh


test_expect_success \ test_expect_success \
'preparation' ' 'preparation' '
git-config core.symlinks false && git config core.symlinks false &&
l=$(echo -n file | git-hash-object -t blob -w --stdin) && l=$(echo -n file | git-hash-object -t blob -w --stdin) &&
echo "120000 $l symlink" | git-update-index --index-info' echo "120000 $l symlink" | git update-index --index-info'


test_expect_success \ test_expect_success \
'modify the symbolic link' ' 'modify the symbolic link' '
echo -n new-file > symlink && echo -n new-file > symlink &&
git-update-index symlink' git update-index symlink'


test_expect_success \ test_expect_success \
'the index entry must still be a symbolic link' ' 'the index entry must still be a symbolic link' '
case "`git-ls-files --stage --cached symlink`" in case "`git ls-files --stage --cached symlink`" in
120000" "*symlink) echo ok;; 120000" "*symlink) echo ok;;
*) echo fail; git-ls-files --stage --cached symlink; (exit 1);; *) echo fail; git ls-files --stage --cached symlink; (exit 1);;
esac' esac'


test_done test_done

View File

@ -1,6 +1,6 @@
#!/bin/sh #!/bin/sh


test_description='git-add -u with path limiting test_description='git add -u with path limiting


This test creates a working tree state with three files: This test creates a working tree state with three files:


@ -8,7 +8,7 @@ This test creates a working tree state with three files:
dir/sub (previously committed, modified) dir/sub (previously committed, modified)
dir/other (untracked) dir/other (untracked)


and issues a git-add -u with path limiting on "dir" to add and issues a git add -u with path limiting on "dir" to add
only the updates to dir/sub.' only the updates to dir/sub.'


. ./test-lib.sh . ./test-lib.sh
@ -17,22 +17,22 @@ test_expect_success 'setup' '
echo initial >top && echo initial >top &&
mkdir dir && mkdir dir &&
echo initial >dir/sub && echo initial >dir/sub &&
git-add dir/sub top && git add dir/sub top &&
git-commit -m initial && git-commit -m initial &&
echo changed >top && echo changed >top &&
echo changed >dir/sub && echo changed >dir/sub &&
echo other >dir/other echo other >dir/other
' '


test_expect_success 'update' 'git-add -u dir' test_expect_success 'update' 'git add -u dir'


test_expect_success 'update touched correct path' \ test_expect_success 'update touched correct path' \
'test "`git-diff-files --name-status dir/sub`" = ""' 'test "`git diff-files --name-status dir/sub`" = ""'


test_expect_success 'update did not touch other tracked files' \ test_expect_success 'update did not touch other tracked files' \
'test "`git-diff-files --name-status top`" = "M top"' 'test "`git diff-files --name-status top`" = "M top"'


test_expect_success 'update did not touch untracked files' \ test_expect_success 'update did not touch untracked files' \
'test "`git-diff-files --name-status dir/other`" = ""' 'test "`git diff-files --name-status dir/other`" = ""'


test_done test_done

View File

@ -3,9 +3,9 @@
# Copyright (c) 2005 Junio C Hamano # Copyright (c) 2005 Junio C Hamano
# #


test_description='git-ls-files test (--others should pick up symlinks). test_description='git ls-files test (--others should pick up symlinks).


This test runs git-ls-files --others with the following on the This test runs git ls-files --others with the following on the
filesystem. filesystem.


path0 - a file path0 - a file
@ -23,7 +23,7 @@ date >path2/file2
date >path2-junk date >path2-junk
date >path3/file3 date >path3/file3
date >path3-junk date >path3-junk
git-update-index --add path3-junk path3/file3 git update-index --add path3-junk path3/file3


cat >expected1 <<EOF cat >expected1 <<EOF
expected1 expected1
@ -37,20 +37,20 @@ EOF
sed -e 's|path2/file2|path2/|' <expected1 >expected2 sed -e 's|path2/file2|path2/|' <expected1 >expected2


test_expect_success \ test_expect_success \
'git-ls-files --others to show output.' \ 'git ls-files --others to show output.' \
'git-ls-files --others >output' 'git ls-files --others >output'


test_expect_success \ test_expect_success \
'git-ls-files --others should pick up symlinks.' \ 'git ls-files --others should pick up symlinks.' \
'diff output expected1' 'diff output expected1'


test_expect_success \ test_expect_success \
'git-ls-files --others --directory to show output.' \ 'git ls-files --others --directory to show output.' \
'git-ls-files --others --directory >output' 'git ls-files --others --directory >output'




test_expect_success \ test_expect_success \
'git-ls-files --others --directory should not get confused.' \ 'git ls-files --others --directory should not get confused.' \
'diff output expected2' 'diff output expected2'


test_done test_done

View File

@ -3,9 +3,9 @@
# Copyright (c) 2005 Junio C Hamano # Copyright (c) 2005 Junio C Hamano
# #


test_description='git-ls-files --others --exclude test_description='git ls-files --others --exclude


This test runs git-ls-files --others and tests --exclude patterns. This test runs git ls-files --others and tests --exclude patterns.
' '


. ./test-lib.sh . ./test-lib.sh
@ -59,8 +59,8 @@ echo '!*.2
!*.8' >one/two/.gitignore !*.8' >one/two/.gitignore


test_expect_success \ test_expect_success \
'git-ls-files --others with various exclude options.' \ 'git ls-files --others with various exclude options.' \
'git-ls-files --others \ 'git ls-files --others \
--exclude=\*.6 \ --exclude=\*.6 \
--exclude-per-directory=.gitignore \ --exclude-per-directory=.gitignore \
--exclude-from=.git/ignore \ --exclude-from=.git/ignore \
@ -71,8 +71,8 @@ test_expect_success \
printf '*.1\r\n/*.3\r\n!*.6\r\n' >.gitignore printf '*.1\r\n/*.3\r\n!*.6\r\n' >.gitignore


test_expect_success \ test_expect_success \
'git-ls-files --others with \r\n line endings.' \ 'git ls-files --others with \r\n line endings.' \
'git-ls-files --others \ 'git ls-files --others \
--exclude=\*.6 \ --exclude=\*.6 \
--exclude-per-directory=.gitignore \ --exclude-per-directory=.gitignore \
--exclude-from=.git/ignore \ --exclude-from=.git/ignore \
@ -84,9 +84,9 @@ cat > excludes-file << EOF
e* e*
EOF EOF


git-config core.excludesFile excludes-file git config core.excludesFile excludes-file


git-runstatus | grep "^# " > output git runstatus | grep "^# " > output


cat > expect << EOF cat > expect << EOF
# .gitignore # .gitignore

View File

@ -3,9 +3,9 @@
# Copyright (c) 2005 Junio C Hamano # Copyright (c) 2005 Junio C Hamano
# #


test_description='git-ls-files test (-- to terminate the path list). test_description='git ls-files test (-- to terminate the path list).


This test runs git-ls-files --others with the following on the This test runs git ls-files --others with the following on the
filesystem. filesystem.


path0 - a file path0 - a file
@ -21,8 +21,8 @@ test_expect_success \
echo frotz >./--' echo frotz >./--'


test_expect_success \ test_expect_success \
'git-ls-files without path restriction.' \ 'git ls-files without path restriction.' \
'git-ls-files --others >output && 'git ls-files --others >output &&
git diff output - <<EOF git diff output - <<EOF
-- --
-foo -foo
@ -32,32 +32,32 @@ EOF
' '


test_expect_success \ test_expect_success \
'git-ls-files with path restriction.' \ 'git ls-files with path restriction.' \
'git-ls-files --others path0 >output && 'git ls-files --others path0 >output &&
git diff output - <<EOF git diff output - <<EOF
path0 path0
EOF EOF
' '


test_expect_success \ test_expect_success \
'git-ls-files with path restriction with --.' \ 'git ls-files with path restriction with --.' \
'git-ls-files --others -- path0 >output && 'git ls-files --others -- path0 >output &&
git diff output - <<EOF git diff output - <<EOF
path0 path0
EOF EOF
' '


test_expect_success \ test_expect_success \
'git-ls-files with path restriction with -- --.' \ 'git ls-files with path restriction with -- --.' \
'git-ls-files --others -- -- >output && 'git ls-files --others -- -- >output &&
git diff output - <<EOF git diff output - <<EOF
-- --
EOF EOF
' '


test_expect_success \ test_expect_success \
'git-ls-files with no path restriction.' \ 'git ls-files with no path restriction.' \
'git-ls-files --others -- >output && 'git ls-files --others -- >output &&
git diff output - <<EOF git diff output - <<EOF
-- --
-foo -foo

View File

@ -3,7 +3,7 @@
# Copyright (c) 2005 Junio C Hamano # Copyright (c) 2005 Junio C Hamano
# #


test_description='git-ls-files -k and -m flags test. test_description='git ls-files -k and -m flags test.


This test prepares the following in the cache: This test prepares the following in the cache:


@ -22,7 +22,7 @@ and the following on the filesystem:
path5 - a symlink path5 - a symlink
path6/file6 - a file in a directory path6/file6 - a file in a directory


git-ls-files -k should report that existing filesystem git ls-files -k should report that existing filesystem
objects except path4, path5 and path6/file6 to be killed. objects except path4, path5 and path6/file6 to be killed.


Also for modification test, the cache and working tree have: Also for modification test, the cache and working tree have:
@ -47,8 +47,8 @@ date >path8
: >path9 : >path9
date >path10 date >path10
test_expect_success \ test_expect_success \
'git-update-index --add to add various paths.' \ 'git update-index --add to add various paths.' \
"git-update-index --add -- path0 path1 path?/file? path7 path8 path9 path10" "git update-index --add -- path0 path1 path?/file? path7 path8 path9 path10"


rm -fr path? ;# leave path10 alone rm -fr path? ;# leave path10 alone
date >path2 date >path2
@ -64,8 +64,8 @@ date >path7
touch path10 touch path10


test_expect_success \ test_expect_success \
'git-ls-files -k to show killed files.' \ 'git ls-files -k to show killed files.' \
'git-ls-files -k >.output' 'git ls-files -k >.output'
cat >.expected <<EOF cat >.expected <<EOF
path0/file0 path0/file0
path1/file1 path1/file1
@ -74,12 +74,12 @@ path3
EOF EOF


test_expect_success \ test_expect_success \
'validate git-ls-files -k output.' \ 'validate git ls-files -k output.' \
'diff .output .expected' 'diff .output .expected'


test_expect_success \ test_expect_success \
'git-ls-files -m to show modified files.' \ 'git ls-files -m to show modified files.' \
'git-ls-files -m >.output' 'git ls-files -m >.output'
cat >.expected <<EOF cat >.expected <<EOF
path0 path0
path1 path1
@ -90,7 +90,7 @@ path8
EOF EOF


test_expect_success \ test_expect_success \
'validate git-ls-files -m output.' \ 'validate git ls-files -m output.' \
'diff .output .expected' 'diff .output .expected'


test_done test_done

View File

@ -3,25 +3,25 @@
# Copyright (c) 2006 Carl D. Worth # Copyright (c) 2006 Carl D. Worth
# #


test_description='git-ls-files test for --error-unmatch option test_description='git ls-files test for --error-unmatch option


This test runs git-ls-files --error-unmatch to ensure it correctly This test runs git ls-files --error-unmatch to ensure it correctly
returns an error when a non-existent path is provided on the command returns an error when a non-existent path is provided on the command
line. line.
' '
. ./test-lib.sh . ./test-lib.sh


touch foo bar touch foo bar
git-update-index --add foo bar git update-index --add foo bar
git-commit -m "add foo bar" git-commit -m "add foo bar"


test_expect_failure \ test_expect_failure \
'git-ls-files --error-unmatch should fail with unmatched path.' \ 'git ls-files --error-unmatch should fail with unmatched path.' \
'git-ls-files --error-unmatch foo bar-does-not-match' 'git ls-files --error-unmatch foo bar-does-not-match'


test_expect_success \ test_expect_success \
'git-ls-files --error-unmatch should succeed eith matched paths.' \ 'git ls-files --error-unmatch should succeed eith matched paths.' \
'git-ls-files --error-unmatch foo bar' 'git ls-files --error-unmatch foo bar'


test_done test_done
1 1

View File

@ -3,9 +3,9 @@
# Copyright (c) 2005 Junio C Hamano # Copyright (c) 2005 Junio C Hamano
# #


test_description='git-ls-tree test. test_description='git ls-tree test.


This test runs git-ls-tree with the following in a tree. This test runs git ls-tree with the following in a tree.


path0 - a file path0 - a file
path1 - a symlink path1 - a symlink
@ -27,8 +27,8 @@ test_expect_success \
ln -s ../path1 path2/bazbo && ln -s ../path1 path2/bazbo &&
echo Mi >path2/baz/b && echo Mi >path2/baz/b &&
find path? \( -type f -o -type l \) -print | find path? \( -type f -o -type l \) -print |
xargs git-update-index --add && xargs git update-index --add &&
tree=`git-write-tree` && tree=`git write-tree` &&
echo $tree' echo $tree'


_x40='[0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f]' _x40='[0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f]'
@ -40,7 +40,7 @@ test_output () {


test_expect_success \ test_expect_success \
'ls-tree plain' \ 'ls-tree plain' \
'git-ls-tree $tree >current && 'git ls-tree $tree >current &&
cat >expected <<\EOF && cat >expected <<\EOF &&
100644 blob X path0 100644 blob X path0
120000 blob X path1 120000 blob X path1
@ -50,7 +50,7 @@ EOF


test_expect_success \ test_expect_success \
'ls-tree recursive' \ 'ls-tree recursive' \
'git-ls-tree -r $tree >current && 'git ls-tree -r $tree >current &&
cat >expected <<\EOF && cat >expected <<\EOF &&
100644 blob X path0 100644 blob X path0
120000 blob X path1 120000 blob X path1
@ -62,7 +62,7 @@ EOF


test_expect_success \ test_expect_success \
'ls-tree recursive with -t' \ 'ls-tree recursive with -t' \
'git-ls-tree -r -t $tree >current && 'git ls-tree -r -t $tree >current &&
cat >expected <<\EOF && cat >expected <<\EOF &&
100644 blob X path0 100644 blob X path0
120000 blob X path1 120000 blob X path1
@ -76,7 +76,7 @@ EOF


test_expect_success \ test_expect_success \
'ls-tree recursive with -d' \ 'ls-tree recursive with -d' \
'git-ls-tree -r -d $tree >current && 'git ls-tree -r -d $tree >current &&
cat >expected <<\EOF && cat >expected <<\EOF &&
040000 tree X path2 040000 tree X path2
040000 tree X path2/baz 040000 tree X path2/baz
@ -85,7 +85,7 @@ EOF


test_expect_success \ test_expect_success \
'ls-tree filtered with path' \ 'ls-tree filtered with path' \
'git-ls-tree $tree path >current && 'git ls-tree $tree path >current &&
cat >expected <<\EOF && cat >expected <<\EOF &&
EOF EOF
test_output' test_output'
@ -95,7 +95,7 @@ EOF
# they are shown in canonical order. # they are shown in canonical order.
test_expect_success \ test_expect_success \
'ls-tree filtered with path1 path0' \ 'ls-tree filtered with path1 path0' \
'git-ls-tree $tree path1 path0 >current && 'git ls-tree $tree path1 path0 >current &&
cat >expected <<\EOF && cat >expected <<\EOF &&
100644 blob X path0 100644 blob X path0
120000 blob X path1 120000 blob X path1
@ -104,7 +104,7 @@ EOF


test_expect_success \ test_expect_success \
'ls-tree filtered with path0/' \ 'ls-tree filtered with path0/' \
'git-ls-tree $tree path0/ >current && 'git ls-tree $tree path0/ >current &&
cat >expected <<\EOF && cat >expected <<\EOF &&
EOF EOF
test_output' test_output'
@ -113,7 +113,7 @@ EOF
# with pathspec semantics it shows only path2 # with pathspec semantics it shows only path2
test_expect_success \ test_expect_success \
'ls-tree filtered with path2' \ 'ls-tree filtered with path2' \
'git-ls-tree $tree path2 >current && 'git ls-tree $tree path2 >current &&
cat >expected <<\EOF && cat >expected <<\EOF &&
040000 tree X path2 040000 tree X path2
EOF EOF
@ -122,7 +122,7 @@ EOF
# ... and path2/ shows the children. # ... and path2/ shows the children.
test_expect_success \ test_expect_success \
'ls-tree filtered with path2/' \ 'ls-tree filtered with path2/' \
'git-ls-tree $tree path2/ >current && 'git ls-tree $tree path2/ >current &&
cat >expected <<\EOF && cat >expected <<\EOF &&
040000 tree X path2/baz 040000 tree X path2/baz
120000 blob X path2/bazbo 120000 blob X path2/bazbo
@ -134,7 +134,7 @@ EOF
# path2/baz # path2/baz
test_expect_success \ test_expect_success \
'ls-tree filtered with path2/baz' \ 'ls-tree filtered with path2/baz' \
'git-ls-tree $tree path2/baz >current && 'git ls-tree $tree path2/baz >current &&
cat >expected <<\EOF && cat >expected <<\EOF &&
040000 tree X path2/baz 040000 tree X path2/baz
EOF EOF
@ -142,14 +142,14 @@ EOF


test_expect_success \ test_expect_success \
'ls-tree filtered with path2/bak' \ 'ls-tree filtered with path2/bak' \
'git-ls-tree $tree path2/bak >current && 'git ls-tree $tree path2/bak >current &&
cat >expected <<\EOF && cat >expected <<\EOF &&
EOF EOF
test_output' test_output'


test_expect_success \ test_expect_success \
'ls-tree -t filtered with path2/bak' \ 'ls-tree -t filtered with path2/bak' \
'git-ls-tree -t $tree path2/bak >current && 'git ls-tree -t $tree path2/bak >current &&
cat >expected <<\EOF && cat >expected <<\EOF &&
040000 tree X path2 040000 tree X path2
EOF EOF

View File

@ -4,9 +4,9 @@
# Copyright (c) 2005 Robert Fitzsimons # Copyright (c) 2005 Robert Fitzsimons
# #


test_description='git-ls-tree directory and filenames handling. test_description='git ls-tree directory and filenames handling.


This test runs git-ls-tree with the following in a tree. This test runs git ls-tree with the following in a tree.


1.txt - a file 1.txt - a file
2.txt - a file 2.txt - a file
@ -35,8 +35,8 @@ test_expect_success \
echo 111 >path3/1.txt && echo 111 >path3/1.txt &&
echo 222 >path3/2.txt && echo 222 >path3/2.txt &&
find *.txt path* \( -type f -o -type l \) -print | find *.txt path* \( -type f -o -type l \) -print |
xargs git-update-index --add && xargs git update-index --add &&
tree=`git-write-tree` && tree=`git write-tree` &&
echo $tree' echo $tree'


_x40='[0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f]' _x40='[0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f]'
@ -48,7 +48,7 @@ test_output () {


test_expect_success \ test_expect_success \
'ls-tree plain' \ 'ls-tree plain' \
'git-ls-tree $tree >current && 'git ls-tree $tree >current &&
cat >expected <<\EOF && cat >expected <<\EOF &&
100644 blob X 1.txt 100644 blob X 1.txt
100644 blob X 2.txt 100644 blob X 2.txt
@ -62,7 +62,7 @@ EOF
# Recursive does not show tree nodes anymore... # Recursive does not show tree nodes anymore...
test_expect_success \ test_expect_success \
'ls-tree recursive' \ 'ls-tree recursive' \
'git-ls-tree -r $tree >current && 'git ls-tree -r $tree >current &&
cat >expected <<\EOF && cat >expected <<\EOF &&
100644 blob X 1.txt 100644 blob X 1.txt
100644 blob X 2.txt 100644 blob X 2.txt
@ -76,7 +76,7 @@ EOF


test_expect_success \ test_expect_success \
'ls-tree filter 1.txt' \ 'ls-tree filter 1.txt' \
'git-ls-tree $tree 1.txt >current && 'git ls-tree $tree 1.txt >current &&
cat >expected <<\EOF && cat >expected <<\EOF &&
100644 blob X 1.txt 100644 blob X 1.txt
EOF EOF
@ -84,7 +84,7 @@ EOF


test_expect_success \ test_expect_success \
'ls-tree filter path1/b/c/1.txt' \ 'ls-tree filter path1/b/c/1.txt' \
'git-ls-tree $tree path1/b/c/1.txt >current && 'git ls-tree $tree path1/b/c/1.txt >current &&
cat >expected <<\EOF && cat >expected <<\EOF &&
100644 blob X path1/b/c/1.txt 100644 blob X path1/b/c/1.txt
EOF EOF
@ -92,7 +92,7 @@ EOF


test_expect_success \ test_expect_success \
'ls-tree filter all 1.txt files' \ 'ls-tree filter all 1.txt files' \
'git-ls-tree $tree 1.txt path0/a/b/c/1.txt path1/b/c/1.txt path2/1.txt path3/1.txt >current && 'git ls-tree $tree 1.txt path0/a/b/c/1.txt path1/b/c/1.txt path2/1.txt path3/1.txt >current &&
cat >expected <<\EOF && cat >expected <<\EOF &&
100644 blob X 1.txt 100644 blob X 1.txt
100644 blob X path0/a/b/c/1.txt 100644 blob X path0/a/b/c/1.txt
@ -107,7 +107,7 @@ EOF
# it behaves as if path0/a/b/c, path1/b/c, path2 and path3 are specified. # it behaves as if path0/a/b/c, path1/b/c, path2 and path3 are specified.
test_expect_success \ test_expect_success \
'ls-tree filter directories' \ 'ls-tree filter directories' \
'git-ls-tree $tree path3 path2 path0/a/b/c path1/b/c path0/a >current && 'git ls-tree $tree path3 path2 path0/a/b/c path1/b/c path0/a >current &&
cat >expected <<\EOF && cat >expected <<\EOF &&
040000 tree X path0/a/b/c 040000 tree X path0/a/b/c
040000 tree X path1/b/c 040000 tree X path1/b/c
@ -120,7 +120,7 @@ EOF
# having 1.txt and path3 # having 1.txt and path3
test_expect_success \ test_expect_success \
'ls-tree filter odd names' \ 'ls-tree filter odd names' \
'git-ls-tree $tree 1.txt /1.txt //1.txt path3/1.txt /path3/1.txt //path3//1.txt path3 /path3/ path3// >current && 'git ls-tree $tree 1.txt /1.txt //1.txt path3/1.txt /path3/1.txt //path3//1.txt path3 /path3/ path3// >current &&
cat >expected <<\EOF && cat >expected <<\EOF &&
100644 blob X 1.txt 100644 blob X 1.txt
100644 blob X path3/1.txt 100644 blob X path3/1.txt
@ -130,7 +130,7 @@ EOF


test_expect_success \ test_expect_success \
'ls-tree filter missing files and extra slashes' \ 'ls-tree filter missing files and extra slashes' \
'git-ls-tree $tree 1.txt/ abc.txt path3//23.txt path3/2.txt/// >current && 'git ls-tree $tree 1.txt/ abc.txt path3//23.txt path3/2.txt/// >current &&
cat >expected <<\EOF && cat >expected <<\EOF &&
EOF EOF
test_output' test_output'

View File

@ -13,22 +13,22 @@ handled. Specifically, that a bogus branch is not created.
test_expect_success \ test_expect_success \
'prepare a trivial repository' \ 'prepare a trivial repository' \
'echo Hello > A && 'echo Hello > A &&
git-update-index --add A && git update-index --add A &&
git-commit -m "Initial commit." && git-commit -m "Initial commit." &&
HEAD=$(git-rev-parse --verify HEAD)' HEAD=$(git rev-parse --verify HEAD)'


test_expect_failure \ test_expect_failure \
'git branch --help should not have created a bogus branch' \ 'git branch --help should not have created a bogus branch' \
'git-branch --help </dev/null >/dev/null 2>/dev/null || : 'git branch --help </dev/null >/dev/null 2>/dev/null || :
test -f .git/refs/heads/--help' test -f .git/refs/heads/--help'


test_expect_success \ test_expect_success \
'git branch abc should create a branch' \ 'git branch abc should create a branch' \
'git-branch abc && test -f .git/refs/heads/abc' 'git branch abc && test -f .git/refs/heads/abc'


test_expect_success \ test_expect_success \
'git branch a/b/c should create a branch' \ 'git branch a/b/c should create a branch' \
'git-branch a/b/c && test -f .git/refs/heads/a/b/c' 'git branch a/b/c && test -f .git/refs/heads/a/b/c'


cat >expect <<EOF cat >expect <<EOF
0000000000000000000000000000000000000000 $HEAD $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1117150200 +0000 branch: Created from master 0000000000000000000000000000000000000000 $HEAD $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1117150200 +0000 branch: Created from master
@ -36,149 +36,149 @@ EOF
test_expect_success \ test_expect_success \
'git branch -l d/e/f should create a branch and a log' \ 'git branch -l d/e/f should create a branch and a log' \
'GIT_COMMITTER_DATE="2005-05-26 23:30" \ 'GIT_COMMITTER_DATE="2005-05-26 23:30" \
git-branch -l d/e/f && git branch -l d/e/f &&
test -f .git/refs/heads/d/e/f && test -f .git/refs/heads/d/e/f &&
test -f .git/logs/refs/heads/d/e/f && test -f .git/logs/refs/heads/d/e/f &&
diff expect .git/logs/refs/heads/d/e/f' diff expect .git/logs/refs/heads/d/e/f'


test_expect_success \ test_expect_success \
'git branch -d d/e/f should delete a branch and a log' \ 'git branch -d d/e/f should delete a branch and a log' \
'git-branch -d d/e/f && 'git branch -d d/e/f &&
test ! -f .git/refs/heads/d/e/f && test ! -f .git/refs/heads/d/e/f &&
test ! -f .git/logs/refs/heads/d/e/f' test ! -f .git/logs/refs/heads/d/e/f'


test_expect_success \ test_expect_success \
'git branch j/k should work after branch j has been deleted' \ 'git branch j/k should work after branch j has been deleted' \
'git-branch j && 'git branch j &&
git-branch -d j && git branch -d j &&
git-branch j/k' git branch j/k'


test_expect_success \ test_expect_success \
'git branch l should work after branch l/m has been deleted' \ 'git branch l should work after branch l/m has been deleted' \
'git-branch l/m && 'git branch l/m &&
git-branch -d l/m && git branch -d l/m &&
git-branch l' git branch l'


test_expect_success \ test_expect_success \
'git branch -m m m/m should work' \ 'git branch -m m m/m should work' \
'git-branch -l m && 'git branch -l m &&
git-branch -m m m/m && git branch -m m m/m &&
test -f .git/logs/refs/heads/m/m' test -f .git/logs/refs/heads/m/m'


test_expect_success \ test_expect_success \
'git branch -m n/n n should work' \ 'git branch -m n/n n should work' \
'git-branch -l n/n && 'git branch -l n/n &&
git-branch -m n/n n git branch -m n/n n
test -f .git/logs/refs/heads/n' test -f .git/logs/refs/heads/n'


test_expect_failure \ test_expect_failure \
'git branch -m o/o o should fail when o/p exists' \ 'git branch -m o/o o should fail when o/p exists' \
'git-branch o/o && 'git branch o/o &&
git-branch o/p && git branch o/p &&
git-branch -m o/o o' git branch -m o/o o'


test_expect_failure \ test_expect_failure \
'git branch -m q r/q should fail when r exists' \ 'git branch -m q r/q should fail when r exists' \
'git-branch q && 'git branch q &&
git-branch r && git branch r &&
git-branch -m q r/q' git branch -m q r/q'


mv .git/config .git/config-saved mv .git/config .git/config-saved


test_expect_success 'git branch -m q q2 without config should succeed' ' test_expect_success 'git branch -m q q2 without config should succeed' '
git-branch -m q q2 && git branch -m q q2 &&
git-branch -m q2 q git branch -m q2 q
' '


mv .git/config-saved .git/config mv .git/config-saved .git/config


git-config branch.s/s.dummy Hello git config branch.s/s.dummy Hello


test_expect_success \ test_expect_success \
'git branch -m s/s s should work when s/t is deleted' \ 'git branch -m s/s s should work when s/t is deleted' \
'git-branch -l s/s && 'git branch -l s/s &&
test -f .git/logs/refs/heads/s/s && test -f .git/logs/refs/heads/s/s &&
git-branch -l s/t && git branch -l s/t &&
test -f .git/logs/refs/heads/s/t && test -f .git/logs/refs/heads/s/t &&
git-branch -d s/t && git branch -d s/t &&
git-branch -m s/s s && git branch -m s/s s &&
test -f .git/logs/refs/heads/s' test -f .git/logs/refs/heads/s'


test_expect_success 'config information was renamed, too' \ test_expect_success 'config information was renamed, too' \
"test $(git-config branch.s.dummy) = Hello && "test $(git config branch.s.dummy) = Hello &&
! git-config branch.s/s/dummy" ! git config branch.s/s/dummy"


test_expect_failure \ test_expect_failure \
'git-branch -m u v should fail when the reflog for u is a symlink' \ 'git branch -m u v should fail when the reflog for u is a symlink' \
'git-branch -l u && 'git branch -l u &&
mv .git/logs/refs/heads/u real-u && mv .git/logs/refs/heads/u real-u &&
ln -s real-u .git/logs/refs/heads/u && ln -s real-u .git/logs/refs/heads/u &&
git-branch -m u v' git branch -m u v'


test_expect_success 'test tracking setup via --track' \ test_expect_success 'test tracking setup via --track' \
'git-config remote.local.url . && 'git config remote.local.url . &&
git-config remote.local.fetch refs/heads/*:refs/remotes/local/* && git config remote.local.fetch refs/heads/*:refs/remotes/local/* &&
(git-show-ref -q refs/remotes/local/master || git-fetch local) && (git show-ref -q refs/remotes/local/master || git-fetch local) &&
git-branch --track my1 local/master && git branch --track my1 local/master &&
test $(git-config branch.my1.remote) = local && test $(git config branch.my1.remote) = local &&
test $(git-config branch.my1.merge) = refs/heads/master' test $(git config branch.my1.merge) = refs/heads/master'


test_expect_success 'test tracking setup (non-wildcard, matching)' \ test_expect_success 'test tracking setup (non-wildcard, matching)' \
'git-config remote.local.url . && 'git config remote.local.url . &&
git-config remote.local.fetch refs/heads/master:refs/remotes/local/master && git config remote.local.fetch refs/heads/master:refs/remotes/local/master &&
(git-show-ref -q refs/remotes/local/master || git-fetch local) && (git show-ref -q refs/remotes/local/master || git-fetch local) &&
git-branch --track my4 local/master && git branch --track my4 local/master &&
test $(git-config branch.my4.remote) = local && test $(git config branch.my4.remote) = local &&
test $(git-config branch.my4.merge) = refs/heads/master' test $(git config branch.my4.merge) = refs/heads/master'


test_expect_success 'test tracking setup (non-wildcard, not matching)' \ test_expect_success 'test tracking setup (non-wildcard, not matching)' \
'git-config remote.local.url . && 'git config remote.local.url . &&
git-config remote.local.fetch refs/heads/s:refs/remotes/local/s && git config remote.local.fetch refs/heads/s:refs/remotes/local/s &&
(git-show-ref -q refs/remotes/local/master || git-fetch local) && (git show-ref -q refs/remotes/local/master || git-fetch local) &&
git-branch --track my5 local/master && git branch --track my5 local/master &&
! test "$(git-config branch.my5.remote)" = local && ! test "$(git config branch.my5.remote)" = local &&
! test "$(git-config branch.my5.merge)" = refs/heads/master' ! test "$(git config branch.my5.merge)" = refs/heads/master'


test_expect_success 'test tracking setup via config' \ test_expect_success 'test tracking setup via config' \
'git-config branch.autosetupmerge true && 'git config branch.autosetupmerge true &&
git-config remote.local.url . && git config remote.local.url . &&
git-config remote.local.fetch refs/heads/*:refs/remotes/local/* && git config remote.local.fetch refs/heads/*:refs/remotes/local/* &&
(git-show-ref -q refs/remotes/local/master || git-fetch local) && (git show-ref -q refs/remotes/local/master || git-fetch local) &&
git-branch my3 local/master && git branch my3 local/master &&
test $(git-config branch.my3.remote) = local && test $(git config branch.my3.remote) = local &&
test $(git-config branch.my3.merge) = refs/heads/master' test $(git config branch.my3.merge) = refs/heads/master'


test_expect_success 'test overriding tracking setup via --no-track' \ test_expect_success 'test overriding tracking setup via --no-track' \
'git-config branch.autosetupmerge true && 'git config branch.autosetupmerge true &&
git-config remote.local.url . && git config remote.local.url . &&
git-config remote.local.fetch refs/heads/*:refs/remotes/local/* && git config remote.local.fetch refs/heads/*:refs/remotes/local/* &&
(git-show-ref -q refs/remotes/local/master || git-fetch local) && (git show-ref -q refs/remotes/local/master || git-fetch local) &&
git-branch --no-track my2 local/master && git branch --no-track my2 local/master &&
git-config branch.autosetupmerge false && git config branch.autosetupmerge false &&
! test "$(git-config branch.my2.remote)" = local && ! test "$(git config branch.my2.remote)" = local &&
! test "$(git-config branch.my2.merge)" = refs/heads/master' ! test "$(git config branch.my2.merge)" = refs/heads/master'


test_expect_success 'test local tracking setup' \ test_expect_success 'test local tracking setup' \
'git branch --track my6 s && 'git branch --track my6 s &&
test $(git-config branch.my6.remote) = . && test $(git config branch.my6.remote) = . &&
test $(git-config branch.my6.merge) = refs/heads/s' test $(git config branch.my6.merge) = refs/heads/s'


test_expect_success 'test tracking setup via --track but deeper' \ test_expect_success 'test tracking setup via --track but deeper' \
'git-config remote.local.url . && 'git config remote.local.url . &&
git-config remote.local.fetch refs/heads/*:refs/remotes/local/* && git config remote.local.fetch refs/heads/*:refs/remotes/local/* &&
(git-show-ref -q refs/remotes/local/o/o || git-fetch local) && (git show-ref -q refs/remotes/local/o/o || git-fetch local) &&
git-branch --track my7 local/o/o && git branch --track my7 local/o/o &&
test "$(git-config branch.my7.remote)" = local && test "$(git config branch.my7.remote)" = local &&
test "$(git-config branch.my7.merge)" = refs/heads/o/o' test "$(git config branch.my7.merge)" = refs/heads/o/o'


test_expect_success 'test deleting branch deletes branch config' \ test_expect_success 'test deleting branch deletes branch config' \
'git-branch -d my7 && 'git branch -d my7 &&
test "$(git-config branch.my7.remote)" = "" && test "$(git config branch.my7.remote)" = "" &&
test "$(git-config branch.my7.merge)" = ""' test "$(git config branch.my7.merge)" = ""'


test_expect_success 'test deleting branch without config' \ test_expect_success 'test deleting branch without config' \
'git-branch my7 s && 'git branch my7 s &&
test "$(git-branch -d my7 2>&1)" = "Deleted branch my7."' test "$(git branch -d my7 2>&1)" = "Deleted branch my7."'


# Keep this test last, as it changes the current branch # Keep this test last, as it changes the current branch
cat >expect <<EOF cat >expect <<EOF

View File

@ -16,92 +16,92 @@ echo '[core] logallrefupdates = true' >>.git/config
test_expect_success \ test_expect_success \
'prepare a trivial repository' \ 'prepare a trivial repository' \
'echo Hello > A && 'echo Hello > A &&
git-update-index --add A && git update-index --add A &&
git-commit -m "Initial commit." && git-commit -m "Initial commit." &&
HEAD=$(git-rev-parse --verify HEAD)' HEAD=$(git rev-parse --verify HEAD)'


SHA1= SHA1=


test_expect_success \ test_expect_success \
'see if git show-ref works as expected' \ 'see if git show-ref works as expected' \
'git-branch a && 'git branch a &&
SHA1=`cat .git/refs/heads/a` && SHA1=`cat .git/refs/heads/a` &&
echo "$SHA1 refs/heads/a" >expect && echo "$SHA1 refs/heads/a" >expect &&
git-show-ref a >result && git show-ref a >result &&
diff expect result' diff expect result'


test_expect_success \ test_expect_success \
'see if a branch still exists when packed' \ 'see if a branch still exists when packed' \
'git-branch b && 'git branch b &&
git-pack-refs --all && git pack-refs --all &&
rm -f .git/refs/heads/b && rm -f .git/refs/heads/b &&
echo "$SHA1 refs/heads/b" >expect && echo "$SHA1 refs/heads/b" >expect &&
git-show-ref b >result && git show-ref b >result &&
diff expect result' diff expect result'


test_expect_failure \ test_expect_failure \
'git branch c/d should barf if branch c exists' \ 'git branch c/d should barf if branch c exists' \
'git-branch c && 'git branch c &&
git-pack-refs --all && git pack-refs --all &&
rm .git/refs/heads/c && rm .git/refs/heads/c &&
git-branch c/d' git branch c/d'


test_expect_success \ test_expect_success \
'see if a branch still exists after git pack-refs --prune' \ 'see if a branch still exists after git pack-refs --prune' \
'git-branch e && 'git branch e &&
git-pack-refs --all --prune && git pack-refs --all --prune &&
echo "$SHA1 refs/heads/e" >expect && echo "$SHA1 refs/heads/e" >expect &&
git-show-ref e >result && git show-ref e >result &&
diff expect result' diff expect result'


test_expect_failure \ test_expect_failure \
'see if git pack-refs --prune remove ref files' \ 'see if git pack-refs --prune remove ref files' \
'git-branch f && 'git branch f &&
git-pack-refs --all --prune && git pack-refs --all --prune &&
ls .git/refs/heads/f' ls .git/refs/heads/f'


test_expect_success \ test_expect_success \
'git branch g should work when git branch g/h has been deleted' \ 'git branch g should work when git branch g/h has been deleted' \
'git-branch g/h && 'git branch g/h &&
git-pack-refs --all --prune && git pack-refs --all --prune &&
git-branch -d g/h && git branch -d g/h &&
git-branch g && git branch g &&
git-pack-refs --all && git pack-refs --all &&
git-branch -d g' git branch -d g'


test_expect_failure \ test_expect_failure \
'git branch i/j/k should barf if branch i exists' \ 'git branch i/j/k should barf if branch i exists' \
'git-branch i && 'git branch i &&
git-pack-refs --all --prune && git pack-refs --all --prune &&
git-branch i/j/k' git branch i/j/k'


test_expect_success \ test_expect_success \
'test git branch k after branch k/l/m and k/lm have been deleted' \ 'test git branch k after branch k/l/m and k/lm have been deleted' \
'git-branch k/l && 'git branch k/l &&
git-branch k/lm && git branch k/lm &&
git-branch -d k/l && git branch -d k/l &&
git-branch k/l/m && git branch k/l/m &&
git-branch -d k/l/m && git branch -d k/l/m &&
git-branch -d k/lm && git branch -d k/lm &&
git-branch k' git branch k'


test_expect_success \ test_expect_success \
'test git branch n after some branch deletion and pruning' \ 'test git branch n after some branch deletion and pruning' \
'git-branch n/o && 'git branch n/o &&
git-branch n/op && git branch n/op &&
git-branch -d n/o && git branch -d n/o &&
git-branch n/o/p && git branch n/o/p &&
git-branch -d n/op && git branch -d n/op &&
git-pack-refs --all --prune && git pack-refs --all --prune &&
git-branch -d n/o/p && git branch -d n/o/p &&
git-branch n' git branch n'


test_expect_success 'pack, prune and repack' ' test_expect_success 'pack, prune and repack' '
git-tag foo && git-tag foo &&
git-pack-refs --all --prune && git pack-refs --all --prune &&
git-show-ref >all-of-them && git show-ref >all-of-them &&
git-pack-refs && git pack-refs &&
git-show-ref >again && git show-ref >again &&
diff all-of-them again diff all-of-them again
' '



View File

@ -32,12 +32,12 @@ test -f "$p1" && cmp "$p0" "$p1" || {


echo 'just space echo 'just space
no-funny' >expected no-funny' >expected
test_expect_success 'git-ls-files no-funny' \ test_expect_success 'git ls-files no-funny' \
'git-update-index --add "$p0" "$p2" && 'git update-index --add "$p0" "$p2" &&
git-ls-files >current && git ls-files >current &&
git diff expected current' git diff expected current'


t0=`git-write-tree` t0=`git write-tree`
echo "$t0" >t0 echo "$t0" >t0


cat > expected <<\EOF cat > expected <<\EOF
@ -45,19 +45,19 @@ just space
no-funny no-funny
"tabs\t,\" (dq) and spaces" "tabs\t,\" (dq) and spaces"
EOF EOF
test_expect_success 'git-ls-files with-funny' \ test_expect_success 'git ls-files with-funny' \
'git-update-index --add "$p1" && 'git update-index --add "$p1" &&
git-ls-files >current && git ls-files >current &&
git diff expected current' git diff expected current'


echo 'just space echo 'just space
no-funny no-funny
tabs ," (dq) and spaces' >expected tabs ," (dq) and spaces' >expected
test_expect_success 'git-ls-files -z with-funny' \ test_expect_success 'git ls-files -z with-funny' \
'git-ls-files -z | tr \\0 \\012 >current && 'git ls-files -z | tr \\0 \\012 >current &&
git diff expected current' git diff expected current'


t1=`git-write-tree` t1=`git write-tree`
echo "$t1" >t1 echo "$t1" >t1


cat > expected <<\EOF cat > expected <<\EOF
@ -65,45 +65,45 @@ just space
no-funny no-funny
"tabs\t,\" (dq) and spaces" "tabs\t,\" (dq) and spaces"
EOF EOF
test_expect_success 'git-ls-tree with funny' \ test_expect_success 'git ls-tree with funny' \
'git-ls-tree -r $t1 | sed -e "s/^[^ ]* //" >current && 'git ls-tree -r $t1 | sed -e "s/^[^ ]* //" >current &&
git diff expected current' git diff expected current'


cat > expected <<\EOF cat > expected <<\EOF
A "tabs\t,\" (dq) and spaces" A "tabs\t,\" (dq) and spaces"
EOF EOF
test_expect_success 'git-diff-index with-funny' \ test_expect_success 'git diff-index with-funny' \
'git-diff-index --name-status $t0 >current && 'git diff-index --name-status $t0 >current &&
git diff expected current' git diff expected current'


test_expect_success 'git-diff-tree with-funny' \ test_expect_success 'git diff-tree with-funny' \
'git-diff-tree --name-status $t0 $t1 >current && 'git diff-tree --name-status $t0 $t1 >current &&
git diff expected current' git diff expected current'


echo 'A echo 'A
tabs ," (dq) and spaces' >expected tabs ," (dq) and spaces' >expected
test_expect_success 'git-diff-index -z with-funny' \ test_expect_success 'git diff-index -z with-funny' \
'git-diff-index -z --name-status $t0 | tr \\0 \\012 >current && 'git diff-index -z --name-status $t0 | tr \\0 \\012 >current &&
git diff expected current' git diff expected current'


test_expect_success 'git-diff-tree -z with-funny' \ test_expect_success 'git diff-tree -z with-funny' \
'git-diff-tree -z --name-status $t0 $t1 | tr \\0 \\012 >current && 'git diff-tree -z --name-status $t0 $t1 | tr \\0 \\012 >current &&
git diff expected current' git diff expected current'


cat > expected <<\EOF cat > expected <<\EOF
CNUM no-funny "tabs\t,\" (dq) and spaces" CNUM no-funny "tabs\t,\" (dq) and spaces"
EOF EOF
test_expect_success 'git-diff-tree -C with-funny' \ test_expect_success 'git diff-tree -C with-funny' \
'git-diff-tree -C --find-copies-harder --name-status \ 'git diff-tree -C --find-copies-harder --name-status \
$t0 $t1 | sed -e 's/^C[0-9]*/CNUM/' >current && $t0 $t1 | sed -e 's/^C[0-9]*/CNUM/' >current &&
git diff expected current' git diff expected current'


cat > expected <<\EOF cat > expected <<\EOF
RNUM no-funny "tabs\t,\" (dq) and spaces" RNUM no-funny "tabs\t,\" (dq) and spaces"
EOF EOF
test_expect_success 'git-diff-tree delete with-funny' \ test_expect_success 'git diff-tree delete with-funny' \
'git-update-index --force-remove "$p0" && 'git update-index --force-remove "$p0" &&
git-diff-index -M --name-status \ git diff-index -M --name-status \
$t0 | sed -e 's/^R[0-9]*/RNUM/' >current && $t0 | sed -e 's/^R[0-9]*/RNUM/' >current &&
git diff expected current' git diff expected current'


@ -113,8 +113,8 @@ similarity index NUM%
rename from no-funny rename from no-funny
rename to "tabs\t,\" (dq) and spaces" rename to "tabs\t,\" (dq) and spaces"
EOF EOF
test_expect_success 'git-diff-tree delete with-funny' \ test_expect_success 'git diff-tree delete with-funny' \
'git-diff-index -M -p $t0 | 'git diff-index -M -p $t0 |
sed -e "s/index [0-9]*%/index NUM%/" >current && sed -e "s/index [0-9]*%/index NUM%/" >current &&
git diff expected current' git diff expected current'


@ -127,8 +127,8 @@ similarity index NUM%
rename from no-funny rename from no-funny
rename to "tabs\t,\" (dq) and spaces" rename to "tabs\t,\" (dq) and spaces"
EOF EOF
test_expect_success 'git-diff-tree delete with-funny' \ test_expect_success 'git diff-tree delete with-funny' \
'git-diff-index -M -p $t0 | 'git diff-index -M -p $t0 |
sed -e "s/index [0-9]*%/index NUM%/" >current && sed -e "s/index [0-9]*%/index NUM%/" >current &&
git diff expected current' git diff expected current'


@ -136,9 +136,9 @@ cat >expected <<\EOF
"tabs\t,\" (dq) and spaces" "tabs\t,\" (dq) and spaces"
1 files changed, 0 insertions(+), 0 deletions(-) 1 files changed, 0 insertions(+), 0 deletions(-)
EOF EOF
test_expect_success 'git-diff-tree rename with-funny applied' \ test_expect_success 'git diff-tree rename with-funny applied' \
'git-diff-index -M -p $t0 | 'git diff-index -M -p $t0 |
git-apply --stat | sed -e "s/|.*//" -e "s/ *\$//" >current && git apply --stat | sed -e "s/|.*//" -e "s/ *\$//" >current &&
git diff expected current' git diff expected current'


cat > expected <<\EOF cat > expected <<\EOF
@ -146,15 +146,15 @@ cat > expected <<\EOF
"tabs\t,\" (dq) and spaces" "tabs\t,\" (dq) and spaces"
2 files changed, 3 insertions(+), 3 deletions(-) 2 files changed, 3 insertions(+), 3 deletions(-)
EOF EOF
test_expect_success 'git-diff-tree delete with-funny applied' \ test_expect_success 'git diff-tree delete with-funny applied' \
'git-diff-index -p $t0 | 'git diff-index -p $t0 |
git-apply --stat | sed -e "s/|.*//" -e "s/ *\$//" >current && git apply --stat | sed -e "s/|.*//" -e "s/ *\$//" >current &&
git diff expected current' git diff expected current'


test_expect_success 'git-apply non-git diff' \ test_expect_success 'git apply non-git diff' \
'git-diff-index -p $t0 | 'git diff-index -p $t0 |
sed -ne "/^[-+@]/p" | sed -ne "/^[-+@]/p" |
git-apply --stat | sed -e "s/|.*//" -e "s/ *\$//" >current && git apply --stat | sed -e "s/|.*//" -e "s/ *\$//" >current &&
git diff expected current' git diff expected current'


test_done test_done

View File

@ -14,15 +14,15 @@ export GIT_AUTHOR_EMAIL=bogus_email_address
test_expect_success \ test_expect_success \
'prepare repository with topic branch, then rebase against master' \ 'prepare repository with topic branch, then rebase against master' \
'echo First > A && 'echo First > A &&
git-update-index --add A && git update-index --add A &&
git-commit -m "Add A." && git-commit -m "Add A." &&
git checkout -b my-topic-branch && git checkout -b my-topic-branch &&
echo Second > B && echo Second > B &&
git-update-index --add B && git update-index --add B &&
git-commit -m "Add B." && git-commit -m "Add B." &&
git checkout -f master && git checkout -f master &&
echo Third >> A && echo Third >> A &&
git-update-index A && git update-index A &&
git-commit -m "Modify A." && git-commit -m "Modify A." &&
git checkout -f my-topic-branch && git checkout -f my-topic-branch &&
git rebase master' git rebase master'

View File

@ -14,37 +14,37 @@ local branch.
test_expect_success \ test_expect_success \
'prepare repository with topic branch' \ 'prepare repository with topic branch' \
'echo First > A && 'echo First > A &&
git-update-index --add A && git update-index --add A &&
git-commit -m "Add A." && git-commit -m "Add A." &&


git-checkout -b my-topic-branch && git-checkout -b my-topic-branch &&


echo Second > B && echo Second > B &&
git-update-index --add B && git update-index --add B &&
git-commit -m "Add B." && git-commit -m "Add B." &&


echo AnotherSecond > C && echo AnotherSecond > C &&
git-update-index --add C && git update-index --add C &&
git-commit -m "Add C." && git-commit -m "Add C." &&


git-checkout -f master && git-checkout -f master &&


echo Third >> A && echo Third >> A &&
git-update-index A && git update-index A &&
git-commit -m "Modify A." git-commit -m "Modify A."
' '


test_expect_success \ test_expect_success \
'pick top patch from topic branch into master' \ 'pick top patch from topic branch into master' \
'git-cherry-pick my-topic-branch^0 && 'git cherry-pick my-topic-branch^0 &&
git-checkout -f my-topic-branch && git-checkout -f my-topic-branch &&
git-branch master-merge master && git branch master-merge master &&
git-branch my-topic-branch-merge my-topic-branch git branch my-topic-branch-merge my-topic-branch
' '


test_debug \ test_debug \
'git-cherry master && 'git cherry master &&
git-format-patch -k --stdout --full-index master >/dev/null && git format-patch -k --stdout --full-index master >/dev/null &&
gitk --all & sleep 1 gitk --all & sleep 1
' '



View File

@ -49,7 +49,7 @@ test_expect_success 'rebase --skip with --merge' '
' '


test_expect_success 'merge and reference trees equal' \ test_expect_success 'merge and reference trees equal' \
'test -z "`git-diff-tree skip-merge skip-reference`"' 'test -z "`git diff-tree skip-merge skip-reference`"'


test_debug 'gitk --all & sleep 1' test_debug 'gitk --all & sleep 1'



View File

@ -3,10 +3,10 @@
# Copyright (c) 2006 Yann Dirson, based on t3400 by Amos Waterland # Copyright (c) 2006 Yann Dirson, based on t3400 by Amos Waterland
# #


test_description='git-cherry should detect patches integrated upstream test_description='git cherry should detect patches integrated upstream


This test cherry-picks one local change of two into master branch, and This test cherry-picks one local change of two into master branch, and
checks that git-cherry only returns the second patch in the local branch checks that git cherry only returns the second patch in the local branch
' '
. ./test-lib.sh . ./test-lib.sh


@ -15,40 +15,40 @@ export GIT_AUTHOR_EMAIL=bogus_email_address
test_expect_success \ test_expect_success \
'prepare repository with topic branch, and check cherry finds the 2 patches from there' \ 'prepare repository with topic branch, and check cherry finds the 2 patches from there' \
'echo First > A && 'echo First > A &&
git-update-index --add A && git update-index --add A &&
git-commit -m "Add A." && git-commit -m "Add A." &&


git-checkout -b my-topic-branch && git-checkout -b my-topic-branch &&


echo Second > B && echo Second > B &&
git-update-index --add B && git update-index --add B &&
git-commit -m "Add B." && git-commit -m "Add B." &&


sleep 2 && sleep 2 &&
echo AnotherSecond > C && echo AnotherSecond > C &&
git-update-index --add C && git update-index --add C &&
git-commit -m "Add C." && git-commit -m "Add C." &&


git-checkout -f master && git-checkout -f master &&
rm -f B C && rm -f B C &&


echo Third >> A && echo Third >> A &&
git-update-index A && git update-index A &&
git-commit -m "Modify A." && git-commit -m "Modify A." &&


expr "$(echo $(git-cherry master my-topic-branch) )" : "+ [^ ]* + .*" expr "$(echo $(git cherry master my-topic-branch) )" : "+ [^ ]* + .*"
' '


test_expect_success \ test_expect_success \
'check that cherry with limit returns only the top patch'\ 'check that cherry with limit returns only the top patch'\
'expr "$(echo $(git-cherry master my-topic-branch my-topic-branch^1) )" : "+ [^ ]*" 'expr "$(echo $(git cherry master my-topic-branch my-topic-branch^1) )" : "+ [^ ]*"
' '


test_expect_success \ test_expect_success \
'cherry-pick one of the 2 patches, and check cherry recognized one and only one as new' \ 'cherry-pick one of the 2 patches, and check cherry recognized one and only one as new' \
'git-cherry-pick my-topic-branch^0 && 'git cherry-pick my-topic-branch^0 &&
echo $(git-cherry master my-topic-branch) && echo $(git cherry master my-topic-branch) &&
expr "$(echo $(git-cherry master my-topic-branch) )" : "+ [^ ]* - .*" expr "$(echo $(git cherry master my-topic-branch) )" : "+ [^ ]* - .*"
' '


test_done test_done

View File

@ -3,7 +3,7 @@
# Copyright (c) 2006 Carl D. Worth # Copyright (c) 2006 Carl D. Worth
# #


test_description='Test of the various options to git-rm.' test_description='Test of the various options to git rm.'


. ./test-lib.sh . ./test-lib.sh


@ -11,13 +11,13 @@ test_description='Test of the various options to git-rm.'
test_expect_success \ test_expect_success \
'Initialize test directory' \ 'Initialize test directory' \
"touch -- foo bar baz 'space embedded' -q && "touch -- foo bar baz 'space embedded' -q &&
git-add -- foo bar baz 'space embedded' -q && git add -- foo bar baz 'space embedded' -q &&
git-commit -m 'add normal files' && git-commit -m 'add normal files' &&
test_tabs=y && test_tabs=y &&
if touch -- 'tab embedded' 'newline if touch -- 'tab embedded' 'newline
embedded' embedded'
then then
git-add -- 'tab embedded' 'newline git add -- 'tab embedded' 'newline
embedded' && embedded' &&
git-commit -m 'add files with tabs and newlines' git-commit -m 'add files with tabs and newlines'
else else
@ -26,7 +26,7 @@ embedded' &&
fi" fi"


# Later we will try removing an unremovable path to make sure # Later we will try removing an unremovable path to make sure
# git-rm barfs, but if the test is run as root that cannot be # git rm barfs, but if the test is run as root that cannot be
# arranged. # arranged.
test_expect_success \ test_expect_success \
'Determine rm behavior' \ 'Determine rm behavior' \
@ -38,51 +38,51 @@ test_expect_success \
rm -f test-file' rm -f test-file'


test_expect_success \ test_expect_success \
'Pre-check that foo exists and is in index before git-rm foo' \ 'Pre-check that foo exists and is in index before git rm foo' \
'[ -f foo ] && git-ls-files --error-unmatch foo' '[ -f foo ] && git ls-files --error-unmatch foo'


test_expect_success \ test_expect_success \
'Test that git-rm foo succeeds' \ 'Test that git rm foo succeeds' \
'git-rm --cached foo' 'git rm --cached foo'


test_expect_success \ test_expect_success \
'Post-check that foo exists but is not in index after git-rm foo' \ 'Post-check that foo exists but is not in index after git rm foo' \
'[ -f foo ] && ! git-ls-files --error-unmatch foo' '[ -f foo ] && ! git ls-files --error-unmatch foo'


test_expect_success \ test_expect_success \
'Pre-check that bar exists and is in index before "git-rm bar"' \ 'Pre-check that bar exists and is in index before "git rm bar"' \
'[ -f bar ] && git-ls-files --error-unmatch bar' '[ -f bar ] && git ls-files --error-unmatch bar'


test_expect_success \ test_expect_success \
'Test that "git-rm bar" succeeds' \ 'Test that "git rm bar" succeeds' \
'git-rm bar' 'git rm bar'


test_expect_success \ test_expect_success \
'Post-check that bar does not exist and is not in index after "git-rm -f bar"' \ 'Post-check that bar does not exist and is not in index after "git rm -f bar"' \
'! [ -f bar ] && ! git-ls-files --error-unmatch bar' '! [ -f bar ] && ! git ls-files --error-unmatch bar'


test_expect_success \ test_expect_success \
'Test that "git-rm -- -q" succeeds (remove a file that looks like an option)' \ 'Test that "git rm -- -q" succeeds (remove a file that looks like an option)' \
'git-rm -- -q' 'git rm -- -q'


test "$test_tabs" = y && test_expect_success \ test "$test_tabs" = y && test_expect_success \
"Test that \"git-rm -f\" succeeds with embedded space, tab, or newline characters." \ "Test that \"git rm -f\" succeeds with embedded space, tab, or newline characters." \
"git-rm -f 'space embedded' 'tab embedded' 'newline "git rm -f 'space embedded' 'tab embedded' 'newline
embedded'" embedded'"


if test "$test_failed_remove" = y; then if test "$test_failed_remove" = y; then
chmod a-w . chmod a-w .
test_expect_failure \ test_expect_failure \
'Test that "git-rm -f" fails if its rm fails' \ 'Test that "git rm -f" fails if its rm fails' \
'git-rm -f baz' 'git rm -f baz'
chmod 775 . chmod 775 .
else else
test_expect_success 'skipping removal failure (perhaps running as root?)' : test_expect_success 'skipping removal failure (perhaps running as root?)' :
fi fi


test_expect_success \ test_expect_success \
'When the rm in "git-rm -f" fails, it should not remove the file from the index' \ 'When the rm in "git rm -f" fails, it should not remove the file from the index' \
'git-ls-files --error-unmatch baz' 'git ls-files --error-unmatch baz'


test_expect_success 'Remove nonexistent file with --ignore-unmatch' ' test_expect_success 'Remove nonexistent file with --ignore-unmatch' '
git rm --ignore-unmatch nonexistent git rm --ignore-unmatch nonexistent

View File

@ -3,72 +3,72 @@
# Copyright (c) 2006 Carl D. Worth # Copyright (c) 2006 Carl D. Worth
# #


test_description='Test of git-add, including the -- option.' test_description='Test of git add, including the -- option.'


. ./test-lib.sh . ./test-lib.sh


test_expect_success \ test_expect_success \
'Test of git-add' \ 'Test of git add' \
'touch foo && git-add foo' 'touch foo && git add foo'


test_expect_success \ test_expect_success \
'Post-check that foo is in the index' \ 'Post-check that foo is in the index' \
'git-ls-files foo | grep foo' 'git ls-files foo | grep foo'


test_expect_success \ test_expect_success \
'Test that "git-add -- -q" works' \ 'Test that "git add -- -q" works' \
'touch -- -q && git-add -- -q' 'touch -- -q && git add -- -q'


test_expect_success \ test_expect_success \
'git-add: Test that executable bit is not used if core.filemode=0' \ 'git add: Test that executable bit is not used if core.filemode=0' \
'git config core.filemode 0 && 'git config core.filemode 0 &&
echo foo >xfoo1 && echo foo >xfoo1 &&
chmod 755 xfoo1 && chmod 755 xfoo1 &&
git-add xfoo1 && git add xfoo1 &&
case "`git-ls-files --stage xfoo1`" in case "`git ls-files --stage xfoo1`" in
100644" "*xfoo1) echo ok;; 100644" "*xfoo1) echo ok;;
*) echo fail; git-ls-files --stage xfoo1; (exit 1);; *) echo fail; git ls-files --stage xfoo1; (exit 1);;
esac' esac'


test_expect_success 'git-add: filemode=0 should not get confused by symlink' ' test_expect_success 'git add: filemode=0 should not get confused by symlink' '
rm -f xfoo1 && rm -f xfoo1 &&
ln -s foo xfoo1 && ln -s foo xfoo1 &&
git-add xfoo1 && git add xfoo1 &&
case "`git-ls-files --stage xfoo1`" in case "`git ls-files --stage xfoo1`" in
120000" "*xfoo1) echo ok;; 120000" "*xfoo1) echo ok;;
*) echo fail; git-ls-files --stage xfoo1; (exit 1);; *) echo fail; git ls-files --stage xfoo1; (exit 1);;
esac esac
' '


test_expect_success \ test_expect_success \
'git-update-index --add: Test that executable bit is not used...' \ 'git update-index --add: Test that executable bit is not used...' \
'git config core.filemode 0 && 'git config core.filemode 0 &&
echo foo >xfoo2 && echo foo >xfoo2 &&
chmod 755 xfoo2 && chmod 755 xfoo2 &&
git-update-index --add xfoo2 && git update-index --add xfoo2 &&
case "`git-ls-files --stage xfoo2`" in case "`git ls-files --stage xfoo2`" in
100644" "*xfoo2) echo ok;; 100644" "*xfoo2) echo ok;;
*) echo fail; git-ls-files --stage xfoo2; (exit 1);; *) echo fail; git ls-files --stage xfoo2; (exit 1);;
esac' esac'


test_expect_success 'git-add: filemode=0 should not get confused by symlink' ' test_expect_success 'git add: filemode=0 should not get confused by symlink' '
rm -f xfoo2 && rm -f xfoo2 &&
ln -s foo xfoo2 && ln -s foo xfoo2 &&
git update-index --add xfoo2 && git update-index --add xfoo2 &&
case "`git-ls-files --stage xfoo2`" in case "`git ls-files --stage xfoo2`" in
120000" "*xfoo2) echo ok;; 120000" "*xfoo2) echo ok;;
*) echo fail; git-ls-files --stage xfoo2; (exit 1);; *) echo fail; git ls-files --stage xfoo2; (exit 1);;
esac esac
' '


test_expect_success \ test_expect_success \
'git-update-index --add: Test that executable bit is not used...' \ 'git update-index --add: Test that executable bit is not used...' \
'git config core.filemode 0 && 'git config core.filemode 0 &&
ln -s xfoo2 xfoo3 && ln -s xfoo2 xfoo3 &&
git-update-index --add xfoo3 && git update-index --add xfoo3 &&
case "`git-ls-files --stage xfoo3`" in case "`git ls-files --stage xfoo3`" in
120000" "*xfoo3) echo ok;; 120000" "*xfoo3) echo ok;;
*) echo fail; git-ls-files --stage xfoo3; (exit 1);; *) echo fail; git ls-files --stage xfoo3; (exit 1);;
esac' esac'


test_expect_success '.gitignore test setup' ' test_expect_success '.gitignore test setup' '
@ -80,28 +80,28 @@ test_expect_success '.gitignore test setup' '
' '


test_expect_success '.gitignore is honored' ' test_expect_success '.gitignore is honored' '
git-add . && git add . &&
! git-ls-files | grep "\\.ig" ! git ls-files | grep "\\.ig"
' '


test_expect_success 'error out when attempting to add ignored ones without -f' ' test_expect_success 'error out when attempting to add ignored ones without -f' '
! git-add a.?? && ! git add a.?? &&
! git-ls-files | grep "\\.ig" ! git ls-files | grep "\\.ig"
' '


test_expect_success 'error out when attempting to add ignored ones without -f' ' test_expect_success 'error out when attempting to add ignored ones without -f' '
! git-add d.?? && ! git add d.?? &&
! git-ls-files | grep "\\.ig" ! git ls-files | grep "\\.ig"
' '


test_expect_success 'add ignored ones with -f' ' test_expect_success 'add ignored ones with -f' '
git-add -f a.?? && git add -f a.?? &&
git-ls-files --error-unmatch a.ig git ls-files --error-unmatch a.ig
' '


test_expect_success 'add ignored ones with -f' ' test_expect_success 'add ignored ones with -f' '
git-add -f d.??/* && git add -f d.??/* &&
git-ls-files --error-unmatch d.ig/d.if d.ig/d.ig git ls-files --error-unmatch d.ig/d.if d.ig/d.ig
' '


mkdir 1 1/2 1/3 mkdir 1 1/2 1/3

View File

@ -22,9 +22,9 @@ check_verify_failure () {
# first create a commit, so we have a valid object/type # first create a commit, so we have a valid object/type
# for the tag. # for the tag.
echo Hello >A echo Hello >A
git-update-index --add A git update-index --add A
git-commit -m "Initial commit" git-commit -m "Initial commit"
head=$(git-rev-parse --verify HEAD) head=$(git rev-parse --verify HEAD)


############################################################ ############################################################
# 1. length check # 1. length check

View File

@ -8,28 +8,28 @@ test_description='commit and log output encodings'
. ./test-lib.sh . ./test-lib.sh


compare_with () { compare_with () {
git-show -s $1 | sed -e '1,/^$/d' -e 's/^ //' -e '$d' >current && git show -s $1 | sed -e '1,/^$/d' -e 's/^ //' -e '$d' >current &&
git diff current "$2" git diff current "$2"
} }


test_expect_success setup ' test_expect_success setup '
: >F && : >F &&
git-add F && git add F &&
T=$(git-write-tree) && T=$(git write-tree) &&
C=$(git-commit-tree $T <../t3900/1-UTF-8.txt) && C=$(git commit-tree $T <../t3900/1-UTF-8.txt) &&
git-update-ref HEAD $C && git update-ref HEAD $C &&
git-tag C0 git-tag C0
' '


test_expect_success 'no encoding header for base case' ' test_expect_success 'no encoding header for base case' '
E=$(git-cat-file commit C0 | sed -ne "s/^encoding //p") && E=$(git cat-file commit C0 | sed -ne "s/^encoding //p") &&
test z = "z$E" test z = "z$E"
' '


for H in ISO-8859-1 EUCJP ISO-2022-JP for H in ISO-8859-1 EUCJP ISO-2022-JP
do do
test_expect_success "$H setup" ' test_expect_success "$H setup" '
git-config i18n.commitencoding $H && git config i18n.commitencoding $H &&
git-checkout -b $H C0 && git-checkout -b $H C0 &&
echo $H >F && echo $H >F &&
git-commit -a -F ../t3900/$H.txt git-commit -a -F ../t3900/$H.txt
@ -39,21 +39,21 @@ done
for H in ISO-8859-1 EUCJP ISO-2022-JP for H in ISO-8859-1 EUCJP ISO-2022-JP
do do
test_expect_success "check encoding header for $H" ' test_expect_success "check encoding header for $H" '
E=$(git-cat-file commit '$H' | sed -ne "s/^encoding //p") && E=$(git cat-file commit '$H' | sed -ne "s/^encoding //p") &&
test "z$E" = "z'$H'" test "z$E" = "z'$H'"
' '
done done


test_expect_success 'config to remove customization' ' test_expect_success 'config to remove customization' '
git-config --unset-all i18n.commitencoding && git config --unset-all i18n.commitencoding &&
if Z=$(git-config --get-all i18n.commitencoding) if Z=$(git config --get-all i18n.commitencoding)
then then
echo Oops, should have failed. echo Oops, should have failed.
false false
else else
test z = "z$Z" test z = "z$Z"
fi && fi &&
git-config i18n.commitencoding utf-8 git config i18n.commitencoding utf-8
' '


test_expect_success 'ISO-8859-1 should be shown in UTF-8 now' ' test_expect_success 'ISO-8859-1 should be shown in UTF-8 now' '
@ -68,8 +68,8 @@ do
done done


test_expect_success 'config to add customization' ' test_expect_success 'config to add customization' '
git-config --unset-all i18n.commitencoding && git config --unset-all i18n.commitencoding &&
if Z=$(git-config --get-all i18n.commitencoding) if Z=$(git config --get-all i18n.commitencoding)
then then
echo Oops, should have failed. echo Oops, should have failed.
false false
@ -81,13 +81,13 @@ test_expect_success 'config to add customization' '
for H in ISO-8859-1 EUCJP ISO-2022-JP for H in ISO-8859-1 EUCJP ISO-2022-JP
do do
test_expect_success "$H should be shown in itself now" ' test_expect_success "$H should be shown in itself now" '
git-config i18n.commitencoding '$H' && git config i18n.commitencoding '$H' &&
compare_with '$H' ../t3900/'$H'.txt compare_with '$H' ../t3900/'$H'.txt
' '
done done


test_expect_success 'config to tweak customization' ' test_expect_success 'config to tweak customization' '
git-config i18n.logoutputencoding utf-8 git config i18n.logoutputencoding utf-8
' '


test_expect_success 'ISO-8859-1 should be shown in UTF-8 now' ' test_expect_success 'ISO-8859-1 should be shown in UTF-8 now' '
@ -103,7 +103,7 @@ done


for J in EUCJP ISO-2022-JP for J in EUCJP ISO-2022-JP
do do
git-config i18n.logoutputencoding $J git config i18n.logoutputencoding $J
for H in EUCJP ISO-2022-JP for H in EUCJP ISO-2022-JP
do do
test_expect_success "$H should be shown in $J now" ' test_expect_success "$H should be shown in $J now" '

View File

@ -14,7 +14,7 @@ check_encoding () {
do do
git format-patch --encoding=UTF-8 --stdout HEAD~$i..HEAD~$j | git format-patch --encoding=UTF-8 --stdout HEAD~$i..HEAD~$j |
grep "^From: =?UTF-8?q?=C3=81=C3=A9=C3=AD=20=C3=B3=C3=BA?=" && grep "^From: =?UTF-8?q?=C3=81=C3=A9=C3=AD=20=C3=B3=C3=BA?=" &&
git-cat-file commit HEAD~$j | git cat-file commit HEAD~$j |
case "$header" in case "$header" in
8859) 8859)
grep "^encoding ISO-8859-1" ;; grep "^encoding ISO-8859-1" ;;
@ -31,7 +31,7 @@ check_encoding () {
} }


test_expect_success setup ' test_expect_success setup '
git-config i18n.commitencoding UTF-8 && git config i18n.commitencoding UTF-8 &&


# use UTF-8 in author and committer name to match the # use UTF-8 in author and committer name to match the
# i18n.commitencoding settings # i18n.commitencoding settings
@ -55,7 +55,7 @@ test_expect_success setup '
git commit -s -m "Second on side" && git commit -s -m "Second on side" &&


# the second one on the side branch is ISO-8859-1 # the second one on the side branch is ISO-8859-1
git-config i18n.commitencoding ISO-8859-1 && git config i18n.commitencoding ISO-8859-1 &&
# use author and committer name in ISO-8859-1 to match it. # use author and committer name in ISO-8859-1 to match it.
. ../t3901-8859-1.txt && . ../t3901-8859-1.txt &&
test_tick && test_tick &&
@ -64,11 +64,11 @@ test_expect_success setup '
git commit -s -m "Third on side" && git commit -s -m "Third on side" &&


# Back to default # Back to default
git-config i18n.commitencoding UTF-8 git config i18n.commitencoding UTF-8
' '


test_expect_success 'format-patch output (ISO-8859-1)' ' test_expect_success 'format-patch output (ISO-8859-1)' '
git-config i18n.logoutputencoding ISO-8859-1 && git config i18n.logoutputencoding ISO-8859-1 &&


git format-patch --stdout master..HEAD^ >out-l1 && git format-patch --stdout master..HEAD^ >out-l1 &&
git format-patch --stdout HEAD^ >out-l2 && git format-patch --stdout HEAD^ >out-l2 &&
@ -91,7 +91,7 @@ test_expect_success 'format-patch output (UTF-8)' '


test_expect_success 'rebase (U/U)' ' test_expect_success 'rebase (U/U)' '
# We want the result of rebase in UTF-8 # We want the result of rebase in UTF-8
git-config i18n.commitencoding UTF-8 && git config i18n.commitencoding UTF-8 &&


# The test is about logoutputencoding not affecting the # The test is about logoutputencoding not affecting the
# final outcome -- it is used internally to generate the # final outcome -- it is used internally to generate the
@ -109,7 +109,7 @@ test_expect_success 'rebase (U/U)' '
' '


test_expect_success 'rebase (U/L)' ' test_expect_success 'rebase (U/L)' '
git-config i18n.commitencoding UTF-8 && git config i18n.commitencoding UTF-8 &&
git config i18n.logoutputencoding ISO-8859-1 && git config i18n.logoutputencoding ISO-8859-1 &&
. ../t3901-utf8.txt && . ../t3901-utf8.txt &&


@ -121,7 +121,7 @@ test_expect_success 'rebase (U/L)' '


test_expect_success 'rebase (L/L)' ' test_expect_success 'rebase (L/L)' '
# In this test we want ISO-8859-1 encoded commits as the result # In this test we want ISO-8859-1 encoded commits as the result
git-config i18n.commitencoding ISO-8859-1 && git config i18n.commitencoding ISO-8859-1 &&
git config i18n.logoutputencoding ISO-8859-1 && git config i18n.logoutputencoding ISO-8859-1 &&
. ../t3901-8859-1.txt && . ../t3901-8859-1.txt &&


@ -134,7 +134,7 @@ test_expect_success 'rebase (L/L)' '
test_expect_success 'rebase (L/U)' ' test_expect_success 'rebase (L/U)' '
# This is pathological -- use UTF-8 as intermediate form # This is pathological -- use UTF-8 as intermediate form
# to get ISO-8859-1 results. # to get ISO-8859-1 results.
git-config i18n.commitencoding ISO-8859-1 && git config i18n.commitencoding ISO-8859-1 &&
git config i18n.logoutputencoding UTF-8 && git config i18n.logoutputencoding UTF-8 &&
. ../t3901-8859-1.txt && . ../t3901-8859-1.txt &&


@ -147,7 +147,7 @@ test_expect_success 'rebase (L/U)' '
test_expect_success 'cherry-pick(U/U)' ' test_expect_success 'cherry-pick(U/U)' '
# Both the commitencoding and logoutputencoding is set to UTF-8. # Both the commitencoding and logoutputencoding is set to UTF-8.


git-config i18n.commitencoding UTF-8 && git config i18n.commitencoding UTF-8 &&
git config i18n.logoutputencoding UTF-8 && git config i18n.logoutputencoding UTF-8 &&
. ../t3901-utf8.txt && . ../t3901-utf8.txt &&


@ -162,7 +162,7 @@ test_expect_success 'cherry-pick(U/U)' '
test_expect_success 'cherry-pick(L/L)' ' test_expect_success 'cherry-pick(L/L)' '
# Both the commitencoding and logoutputencoding is set to ISO-8859-1 # Both the commitencoding and logoutputencoding is set to ISO-8859-1


git-config i18n.commitencoding ISO-8859-1 && git config i18n.commitencoding ISO-8859-1 &&
git config i18n.logoutputencoding ISO-8859-1 && git config i18n.logoutputencoding ISO-8859-1 &&
. ../t3901-8859-1.txt && . ../t3901-8859-1.txt &&


@ -177,7 +177,7 @@ test_expect_success 'cherry-pick(L/L)' '
test_expect_success 'cherry-pick(U/L)' ' test_expect_success 'cherry-pick(U/L)' '
# Commitencoding is set to UTF-8 but logoutputencoding is ISO-8859-1 # Commitencoding is set to UTF-8 but logoutputencoding is ISO-8859-1


git-config i18n.commitencoding UTF-8 && git config i18n.commitencoding UTF-8 &&
git config i18n.logoutputencoding ISO-8859-1 && git config i18n.logoutputencoding ISO-8859-1 &&
. ../t3901-utf8.txt && . ../t3901-utf8.txt &&


@ -193,7 +193,7 @@ test_expect_success 'cherry-pick(L/U)' '
# Again, the commitencoding is set to ISO-8859-1 but # Again, the commitencoding is set to ISO-8859-1 but
# logoutputencoding is set to UTF-8. # logoutputencoding is set to UTF-8.


git-config i18n.commitencoding ISO-8859-1 && git config i18n.commitencoding ISO-8859-1 &&
git config i18n.logoutputencoding UTF-8 && git config i18n.logoutputencoding UTF-8 &&
. ../t3901-8859-1.txt && . ../t3901-8859-1.txt &&


@ -206,7 +206,7 @@ test_expect_success 'cherry-pick(L/U)' '
' '


test_expect_success 'rebase --merge (U/U)' ' test_expect_success 'rebase --merge (U/U)' '
git-config i18n.commitencoding UTF-8 && git config i18n.commitencoding UTF-8 &&
git config i18n.logoutputencoding UTF-8 && git config i18n.logoutputencoding UTF-8 &&
. ../t3901-utf8.txt && . ../t3901-utf8.txt &&


@ -217,7 +217,7 @@ test_expect_success 'rebase --merge (U/U)' '
' '


test_expect_success 'rebase --merge (U/L)' ' test_expect_success 'rebase --merge (U/L)' '
git-config i18n.commitencoding UTF-8 && git config i18n.commitencoding UTF-8 &&
git config i18n.logoutputencoding ISO-8859-1 && git config i18n.logoutputencoding ISO-8859-1 &&
. ../t3901-utf8.txt && . ../t3901-utf8.txt &&


@ -229,7 +229,7 @@ test_expect_success 'rebase --merge (U/L)' '


test_expect_success 'rebase --merge (L/L)' ' test_expect_success 'rebase --merge (L/L)' '
# In this test we want ISO-8859-1 encoded commits as the result # In this test we want ISO-8859-1 encoded commits as the result
git-config i18n.commitencoding ISO-8859-1 && git config i18n.commitencoding ISO-8859-1 &&
git config i18n.logoutputencoding ISO-8859-1 && git config i18n.logoutputencoding ISO-8859-1 &&
. ../t3901-8859-1.txt && . ../t3901-8859-1.txt &&


@ -242,7 +242,7 @@ test_expect_success 'rebase --merge (L/L)' '
test_expect_success 'rebase --merge (L/U)' ' test_expect_success 'rebase --merge (L/U)' '
# This is pathological -- use UTF-8 as intermediate form # This is pathological -- use UTF-8 as intermediate form
# to get ISO-8859-1 results. # to get ISO-8859-1 results.
git-config i18n.commitencoding ISO-8859-1 && git config i18n.commitencoding ISO-8859-1 &&
git config i18n.logoutputencoding UTF-8 && git config i18n.logoutputencoding UTF-8 &&
. ../t3901-8859-1.txt && . ../t3901-8859-1.txt &&



View File

@ -17,15 +17,15 @@ chmod +x path1


test_expect_success \ test_expect_success \
'update-cache --add two files with and without +x.' \ 'update-cache --add two files with and without +x.' \
'git-update-index --add path0 path1' 'git update-index --add path0 path1'


mv path0 path0- mv path0 path0-
sed -e 's/line/Line/' <path0- >path0 sed -e 's/line/Line/' <path0- >path0
chmod +x path0 chmod +x path0
rm -f path1 rm -f path1
test_expect_success \ test_expect_success \
'git-diff-files -p after editing work tree.' \ 'git diff-files -p after editing work tree.' \
'git-diff-files -p >current' 'git diff-files -p >current'


# that's as far as it comes # that's as far as it comes
if [ "$(git config --get core.filemode)" = false ] if [ "$(git config --get core.filemode)" = false ]
@ -56,7 +56,7 @@ deleted file mode 100755
EOF EOF


test_expect_success \ test_expect_success \
'validate git-diff-files -p output.' \ 'validate git diff-files -p output.' \
'compare_diff_patch current expected' 'compare_diff_patch current expected'


test_done test_done

View File

@ -28,21 +28,21 @@ Line 15


test_expect_success \ test_expect_success \
'update-cache --add a file.' \ 'update-cache --add a file.' \
'git-update-index --add path0' 'git update-index --add path0'


test_expect_success \ test_expect_success \
'write that tree.' \ 'write that tree.' \
'tree=$(git-write-tree) && echo $tree' 'tree=$(git write-tree) && echo $tree'


sed -e 's/line/Line/' <path0 >path1 sed -e 's/line/Line/' <path0 >path1
rm -f path0 rm -f path0
test_expect_success \ test_expect_success \
'renamed and edited the file.' \ 'renamed and edited the file.' \
'git-update-index --add --remove path0 path1' 'git update-index --add --remove path0 path1'


test_expect_success \ test_expect_success \
'git-diff-index -p -M after rename and editing.' \ 'git diff-index -p -M after rename and editing.' \
'git-diff-index -p -M $tree >current' 'git diff-index -p -M $tree >current'
cat >expected <<\EOF cat >expected <<\EOF
diff --git a/path0 b/path1 diff --git a/path0 b/path1
rename from path0 rename from path0

View File

@ -140,80 +140,80 @@ cmp_diff_files_output () {


test_expect_success \ test_expect_success \
'diff-tree of known trees.' \ 'diff-tree of known trees.' \
'git-diff-tree $tree_O $tree_A >.test-a && 'git diff-tree $tree_O $tree_A >.test-a &&
cmp -s .test-a .test-plain-OA' cmp -s .test-a .test-plain-OA'


test_expect_success \ test_expect_success \
'diff-tree of known trees.' \ 'diff-tree of known trees.' \
'git-diff-tree -r $tree_O $tree_A >.test-a && 'git diff-tree -r $tree_O $tree_A >.test-a &&
cmp -s .test-a .test-recursive-OA' cmp -s .test-a .test-recursive-OA'


test_expect_success \ test_expect_success \
'diff-tree of known trees.' \ 'diff-tree of known trees.' \
'git-diff-tree $tree_O $tree_B >.test-a && 'git diff-tree $tree_O $tree_B >.test-a &&
cmp -s .test-a .test-plain-OB' cmp -s .test-a .test-plain-OB'


test_expect_success \ test_expect_success \
'diff-tree of known trees.' \ 'diff-tree of known trees.' \
'git-diff-tree -r $tree_O $tree_B >.test-a && 'git diff-tree -r $tree_O $tree_B >.test-a &&
cmp -s .test-a .test-recursive-OB' cmp -s .test-a .test-recursive-OB'


test_expect_success \ test_expect_success \
'diff-tree of known trees.' \ 'diff-tree of known trees.' \
'git-diff-tree $tree_A $tree_B >.test-a && 'git diff-tree $tree_A $tree_B >.test-a &&
cmp -s .test-a .test-plain-AB' cmp -s .test-a .test-plain-AB'


test_expect_success \ test_expect_success \
'diff-tree of known trees.' \ 'diff-tree of known trees.' \
'git-diff-tree -r $tree_A $tree_B >.test-a && 'git diff-tree -r $tree_A $tree_B >.test-a &&
cmp -s .test-a .test-recursive-AB' cmp -s .test-a .test-recursive-AB'


test_expect_success \ test_expect_success \
'diff-cache O with A in cache' \ 'diff-cache O with A in cache' \
'git-read-tree $tree_A && 'git read-tree $tree_A &&
git-diff-index --cached $tree_O >.test-a && git diff-index --cached $tree_O >.test-a &&
cmp -s .test-a .test-recursive-OA' cmp -s .test-a .test-recursive-OA'


test_expect_success \ test_expect_success \
'diff-cache O with B in cache' \ 'diff-cache O with B in cache' \
'git-read-tree $tree_B && 'git read-tree $tree_B &&
git-diff-index --cached $tree_O >.test-a && git diff-index --cached $tree_O >.test-a &&
cmp -s .test-a .test-recursive-OB' cmp -s .test-a .test-recursive-OB'


test_expect_success \ test_expect_success \
'diff-cache A with B in cache' \ 'diff-cache A with B in cache' \
'git-read-tree $tree_B && 'git read-tree $tree_B &&
git-diff-index --cached $tree_A >.test-a && git diff-index --cached $tree_A >.test-a &&
cmp -s .test-a .test-recursive-AB' cmp -s .test-a .test-recursive-AB'


test_expect_success \ test_expect_success \
'diff-files with O in cache and A checked out' \ 'diff-files with O in cache and A checked out' \
'rm -fr Z [A-Z][A-Z] && 'rm -fr Z [A-Z][A-Z] &&
git-read-tree $tree_A && git read-tree $tree_A &&
git-checkout-index -f -a && git checkout-index -f -a &&
git-read-tree --reset $tree_O || return 1 git read-tree --reset $tree_O || return 1
git-update-index --refresh >/dev/null ;# this can exit non-zero git update-index --refresh >/dev/null ;# this can exit non-zero
git-diff-files >.test-a && git diff-files >.test-a &&
cmp_diff_files_output .test-a .test-recursive-OA' cmp_diff_files_output .test-a .test-recursive-OA'


test_expect_success \ test_expect_success \
'diff-files with O in cache and B checked out' \ 'diff-files with O in cache and B checked out' \
'rm -fr Z [A-Z][A-Z] && 'rm -fr Z [A-Z][A-Z] &&
git-read-tree $tree_B && git read-tree $tree_B &&
git-checkout-index -f -a && git checkout-index -f -a &&
git-read-tree --reset $tree_O || return 1 git read-tree --reset $tree_O || return 1
git-update-index --refresh >/dev/null ;# this can exit non-zero git update-index --refresh >/dev/null ;# this can exit non-zero
git-diff-files >.test-a && git diff-files >.test-a &&
cmp_diff_files_output .test-a .test-recursive-OB' cmp_diff_files_output .test-a .test-recursive-OB'


test_expect_success \ test_expect_success \
'diff-files with A in cache and B checked out' \ 'diff-files with A in cache and B checked out' \
'rm -fr Z [A-Z][A-Z] && 'rm -fr Z [A-Z][A-Z] &&
git-read-tree $tree_B && git read-tree $tree_B &&
git-checkout-index -f -a && git checkout-index -f -a &&
git-read-tree --reset $tree_A || return 1 git read-tree --reset $tree_A || return 1
git-update-index --refresh >/dev/null ;# this can exit non-zero git update-index --refresh >/dev/null ;# this can exit non-zero
git-diff-files >.test-a && git diff-files >.test-a &&
cmp_diff_files_output .test-a .test-recursive-AB' cmp_diff_files_output .test-a .test-recursive-AB'


################################################################ ################################################################
@ -222,26 +222,26 @@ test_expect_success \


test_expect_success \ test_expect_success \
'diff-tree O A == diff-tree -R A O' \ 'diff-tree O A == diff-tree -R A O' \
'git-diff-tree $tree_O $tree_A >.test-a && 'git diff-tree $tree_O $tree_A >.test-a &&
git-diff-tree -R $tree_A $tree_O >.test-b && git diff-tree -R $tree_A $tree_O >.test-b &&
cmp -s .test-a .test-b' cmp -s .test-a .test-b'


test_expect_success \ test_expect_success \
'diff-tree -r O A == diff-tree -r -R A O' \ 'diff-tree -r O A == diff-tree -r -R A O' \
'git-diff-tree -r $tree_O $tree_A >.test-a && 'git diff-tree -r $tree_O $tree_A >.test-a &&
git-diff-tree -r -R $tree_A $tree_O >.test-b && git diff-tree -r -R $tree_A $tree_O >.test-b &&
cmp -s .test-a .test-b' cmp -s .test-a .test-b'


test_expect_success \ test_expect_success \
'diff-tree B A == diff-tree -R A B' \ 'diff-tree B A == diff-tree -R A B' \
'git-diff-tree $tree_B $tree_A >.test-a && 'git diff-tree $tree_B $tree_A >.test-a &&
git-diff-tree -R $tree_A $tree_B >.test-b && git diff-tree -R $tree_A $tree_B >.test-b &&
cmp -s .test-a .test-b' cmp -s .test-a .test-b'


test_expect_success \ test_expect_success \
'diff-tree -r B A == diff-tree -r -R A B' \ 'diff-tree -r B A == diff-tree -r -R A B' \
'git-diff-tree -r $tree_B $tree_A >.test-a && 'git diff-tree -r $tree_B $tree_A >.test-a &&
git-diff-tree -r -R $tree_A $tree_B >.test-b && git diff-tree -r -R $tree_A $tree_B >.test-b &&
cmp -s .test-a .test-b' cmp -s .test-a .test-b'


test_done test_done

View File

@ -13,8 +13,8 @@ test_expect_success \
'prepare reference tree' \ 'prepare reference tree' \
'cat ../../COPYING >COPYING && 'cat ../../COPYING >COPYING &&
echo frotz >rezrov && echo frotz >rezrov &&
git-update-index --add COPYING rezrov && git update-index --add COPYING rezrov &&
tree=$(git-write-tree) && tree=$(git write-tree) &&
echo $tree' echo $tree'


test_expect_success \ test_expect_success \
@ -22,14 +22,14 @@ test_expect_success \
'sed -e 's/HOWEVER/However/' <COPYING >COPYING.1 && 'sed -e 's/HOWEVER/However/' <COPYING >COPYING.1 &&
sed -e 's/GPL/G.P.L/g' <COPYING >COPYING.2 && sed -e 's/GPL/G.P.L/g' <COPYING >COPYING.2 &&
rm -f COPYING && rm -f COPYING &&
git-update-index --add --remove COPYING COPYING.?' git update-index --add --remove COPYING COPYING.?'


# tree has COPYING and rezrov. work tree has COPYING.1 and COPYING.2, # tree has COPYING and rezrov. work tree has COPYING.1 and COPYING.2,
# both are slightly edited, and unchanged rezrov. So we say you # both are slightly edited, and unchanged rezrov. So we say you
# copy-and-edit one, and rename-and-edit the other. We do not say # copy-and-edit one, and rename-and-edit the other. We do not say
# anything about rezrov. # anything about rezrov.


GIT_DIFF_OPTS=--unified=0 git-diff-index -M -p $tree >current GIT_DIFF_OPTS=--unified=0 git diff-index -M -p $tree >current
cat >expected <<\EOF cat >expected <<\EOF
diff --git a/COPYING b/COPYING.1 diff --git a/COPYING b/COPYING.1
copy from COPYING copy from COPYING
@ -62,14 +62,14 @@ test_expect_success \
test_expect_success \ test_expect_success \
'prepare work tree again' \ 'prepare work tree again' \
'mv COPYING.2 COPYING && 'mv COPYING.2 COPYING &&
git-update-index --add --remove COPYING COPYING.1 COPYING.2' git update-index --add --remove COPYING COPYING.1 COPYING.2'


# tree has COPYING and rezrov. work tree has COPYING and COPYING.1, # tree has COPYING and rezrov. work tree has COPYING and COPYING.1,
# both are slightly edited, and unchanged rezrov. So we say you # both are slightly edited, and unchanged rezrov. So we say you
# edited one, and copy-and-edit the other. We do not say # edited one, and copy-and-edit the other. We do not say
# anything about rezrov. # anything about rezrov.


GIT_DIFF_OPTS=--unified=0 git-diff-index -C -p $tree >current GIT_DIFF_OPTS=--unified=0 git diff-index -C -p $tree >current
cat >expected <<\EOF cat >expected <<\EOF
diff --git a/COPYING b/COPYING diff --git a/COPYING b/COPYING
--- a/COPYING --- a/COPYING
@ -100,16 +100,16 @@ test_expect_success \
test_expect_success \ test_expect_success \
'prepare work tree once again' \ 'prepare work tree once again' \
'cat ../../COPYING >COPYING && 'cat ../../COPYING >COPYING &&
git-update-index --add --remove COPYING COPYING.1' git update-index --add --remove COPYING COPYING.1'


# tree has COPYING and rezrov. work tree has COPYING and COPYING.1, # tree has COPYING and rezrov. work tree has COPYING and COPYING.1,
# but COPYING is not edited. We say you copy-and-edit COPYING.1; this # but COPYING is not edited. We say you copy-and-edit COPYING.1; this
# is only possible because -C mode now reports the unmodified file to # is only possible because -C mode now reports the unmodified file to
# the diff-core. Unchanged rezrov, although being fed to # the diff-core. Unchanged rezrov, although being fed to
# git-diff-index as well, should not be mentioned. # git diff-index as well, should not be mentioned.


GIT_DIFF_OPTS=--unified=0 \ GIT_DIFF_OPTS=--unified=0 \
git-diff-index -C --find-copies-harder -p $tree >current git diff-index -C --find-copies-harder -p $tree >current
cat >expected <<\EOF cat >expected <<\EOF
diff --git a/COPYING b/COPYING.1 diff --git a/COPYING b/COPYING.1
copy from COPYING copy from COPYING

View File

@ -16,8 +16,8 @@ test_expect_success \
'prepare reference tree' \ 'prepare reference tree' \
'echo xyzzy | tr -d '\\\\'012 >yomin && 'echo xyzzy | tr -d '\\\\'012 >yomin &&
ln -s xyzzy frotz && ln -s xyzzy frotz &&
git-update-index --add frotz yomin && git update-index --add frotz yomin &&
tree=$(git-write-tree) && tree=$(git write-tree) &&
echo $tree' echo $tree'


test_expect_success \ test_expect_success \
@ -26,7 +26,7 @@ test_expect_success \
rm -f yomin && rm -f yomin &&
ln -s xyzzy nitfol && ln -s xyzzy nitfol &&
ln -s xzzzy bozbar && ln -s xzzzy bozbar &&
git-update-index --add --remove frotz rezrov nitfol bozbar yomin' git update-index --add --remove frotz rezrov nitfol bozbar yomin'


# tree has frotz pointing at xyzzy, and yomin that contains xyzzy to # tree has frotz pointing at xyzzy, and yomin that contains xyzzy to
# confuse things. work tree has rezrov (xyzzy) nitfol (xyzzy) and # confuse things. work tree has rezrov (xyzzy) nitfol (xyzzy) and
@ -34,7 +34,7 @@ test_expect_success \
# rezrov and nitfol are rename/copy of frotz and bozbar should be # rezrov and nitfol are rename/copy of frotz and bozbar should be
# a new creation. # a new creation.


GIT_DIFF_OPTS=--unified=0 git-diff-index -M -p $tree >current GIT_DIFF_OPTS=--unified=0 git diff-index -M -p $tree >current
cat >expected <<\EOF cat >expected <<\EOF
diff --git a/bozbar b/bozbar diff --git a/bozbar b/bozbar
new file mode 120000 new file mode 120000

View File

@ -13,8 +13,8 @@ test_expect_success \
'prepare reference tree' \ 'prepare reference tree' \
'cat ../../COPYING >COPYING && 'cat ../../COPYING >COPYING &&
echo frotz >rezrov && echo frotz >rezrov &&
git-update-index --add COPYING rezrov && git update-index --add COPYING rezrov &&
tree=$(git-write-tree) && tree=$(git write-tree) &&
echo $tree' echo $tree'


test_expect_success \ test_expect_success \
@ -22,14 +22,14 @@ test_expect_success \
'sed -e 's/HOWEVER/However/' <COPYING >COPYING.1 && 'sed -e 's/HOWEVER/However/' <COPYING >COPYING.1 &&
sed -e 's/GPL/G.P.L/g' <COPYING >COPYING.2 && sed -e 's/GPL/G.P.L/g' <COPYING >COPYING.2 &&
rm -f COPYING && rm -f COPYING &&
git-update-index --add --remove COPYING COPYING.?' git update-index --add --remove COPYING COPYING.?'


# tree has COPYING and rezrov. work tree has COPYING.1 and COPYING.2, # tree has COPYING and rezrov. work tree has COPYING.1 and COPYING.2,
# both are slightly edited, and unchanged rezrov. We say COPYING.1 # both are slightly edited, and unchanged rezrov. We say COPYING.1
# and COPYING.2 are based on COPYING, and do not say anything about # and COPYING.2 are based on COPYING, and do not say anything about
# rezrov. # rezrov.


git-diff-index -M $tree >current git diff-index -M $tree >current


cat >expected <<\EOF cat >expected <<\EOF
:100644 100644 6ff87c4664981e4397625791c8ea3bbb5f2279a3 0603b3238a076dc6c8022aedc6648fa523a17178 C1234 COPYING COPYING.1 :100644 100644 6ff87c4664981e4397625791c8ea3bbb5f2279a3 0603b3238a076dc6c8022aedc6648fa523a17178 C1234 COPYING COPYING.1
@ -45,14 +45,14 @@ test_expect_success \
test_expect_success \ test_expect_success \
'prepare work tree again' \ 'prepare work tree again' \
'mv COPYING.2 COPYING && 'mv COPYING.2 COPYING &&
git-update-index --add --remove COPYING COPYING.1 COPYING.2' git update-index --add --remove COPYING COPYING.1 COPYING.2'


# tree has COPYING and rezrov. work tree has COPYING and COPYING.1, # tree has COPYING and rezrov. work tree has COPYING and COPYING.1,
# both are slightly edited, and unchanged rezrov. We say COPYING.1 # both are slightly edited, and unchanged rezrov. We say COPYING.1
# is based on COPYING and COPYING is still there, and do not say anything # is based on COPYING and COPYING is still there, and do not say anything
# about rezrov. # about rezrov.


git-diff-index -C $tree >current git diff-index -C $tree >current
cat >expected <<\EOF cat >expected <<\EOF
:100644 100644 6ff87c4664981e4397625791c8ea3bbb5f2279a3 06c67961bbaed34a127f76d261f4c0bf73eda471 M COPYING :100644 100644 6ff87c4664981e4397625791c8ea3bbb5f2279a3 06c67961bbaed34a127f76d261f4c0bf73eda471 M COPYING
:100644 100644 6ff87c4664981e4397625791c8ea3bbb5f2279a3 0603b3238a076dc6c8022aedc6648fa523a17178 C1234 COPYING COPYING.1 :100644 100644 6ff87c4664981e4397625791c8ea3bbb5f2279a3 0603b3238a076dc6c8022aedc6648fa523a17178 C1234 COPYING COPYING.1
@ -72,9 +72,9 @@ test_expect_success \
test_expect_success \ test_expect_success \
'prepare work tree once again' \ 'prepare work tree once again' \
'cat ../../COPYING >COPYING && 'cat ../../COPYING >COPYING &&
git-update-index --add --remove COPYING COPYING.1' git update-index --add --remove COPYING COPYING.1'


git-diff-index -C --find-copies-harder $tree >current git diff-index -C --find-copies-harder $tree >current
cat >expected <<\EOF cat >expected <<\EOF
:100644 100644 6ff87c4664981e4397625791c8ea3bbb5f2279a3 0603b3238a076dc6c8022aedc6648fa523a17178 C1234 COPYING COPYING.1 :100644 100644 6ff87c4664981e4397625791c8ea3bbb5f2279a3 0603b3238a076dc6c8022aedc6648fa523a17178 C1234 COPYING COPYING.1
EOF EOF

View File

@ -11,24 +11,24 @@ test_description='Test mode change diffs.
test_expect_success \ test_expect_success \
'setup' \ 'setup' \
'echo frotz >rezrov && 'echo frotz >rezrov &&
git-update-index --add rezrov && git update-index --add rezrov &&
tree=`git-write-tree` && tree=`git write-tree` &&
echo $tree' echo $tree'


if [ "$(git config --get core.filemode)" = false ] if [ "$(git config --get core.filemode)" = false ]
then then
say 'filemode disabled on the filesystem, using update-index --chmod=+x' say 'filemode disabled on the filesystem, using update-index --chmod=+x'
test_expect_success \ test_expect_success \
'git-update-index --chmod=+x' \ 'git update-index --chmod=+x' \
'git-update-index rezrov && 'git update-index rezrov &&
git-update-index --chmod=+x rezrov && git update-index --chmod=+x rezrov &&
git-diff-index $tree >current' git diff-index $tree >current'
else else
test_expect_success \ test_expect_success \
'chmod' \ 'chmod' \
'chmod +x rezrov && 'chmod +x rezrov &&
git-update-index rezrov && git update-index rezrov &&
git-diff-index $tree >current' git diff-index $tree >current'
fi fi


_x40='[0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f]' _x40='[0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f]'

View File

@ -13,20 +13,20 @@ test_expect_success \
'prepare reference tree' \ 'prepare reference tree' \
'mkdir path0 path1 && 'mkdir path0 path1 &&
cp ../../COPYING path0/COPYING && cp ../../COPYING path0/COPYING &&
git-update-index --add path0/COPYING && git update-index --add path0/COPYING &&
tree=$(git-write-tree) && tree=$(git write-tree) &&
echo $tree' echo $tree'


test_expect_success \ test_expect_success \
'prepare work tree' \ 'prepare work tree' \
'cp path0/COPYING path1/COPYING && 'cp path0/COPYING path1/COPYING &&
git-update-index --add --remove path0/COPYING path1/COPYING' git update-index --add --remove path0/COPYING path1/COPYING'


# In the tree, there is only path0/COPYING. In the cache, path0 and # In the tree, there is only path0/COPYING. In the cache, path0 and
# path1 both have COPYING and the latter is a copy of path0/COPYING. # path1 both have COPYING and the latter is a copy of path0/COPYING.
# Comparing the full tree with cache should tell us so. # Comparing the full tree with cache should tell us so.


git-diff-index -C --find-copies-harder $tree >current git diff-index -C --find-copies-harder $tree >current


cat >expected <<\EOF cat >expected <<\EOF
:100644 100644 6ff87c4664981e4397625791c8ea3bbb5f2279a3 6ff87c4664981e4397625791c8ea3bbb5f2279a3 C100 path0/COPYING path1/COPYING :100644 100644 6ff87c4664981e4397625791c8ea3bbb5f2279a3 6ff87c4664981e4397625791c8ea3bbb5f2279a3 C100 path0/COPYING path1/COPYING
@ -42,7 +42,7 @@ test_expect_success \
# path1/COPYING suddenly appearing from nowhere, not detected as # path1/COPYING suddenly appearing from nowhere, not detected as
# a copy from path0/COPYING. # a copy from path0/COPYING.


git-diff-index -C $tree path1 >current git diff-index -C $tree path1 >current


cat >expected <<\EOF cat >expected <<\EOF
:000000 100644 0000000000000000000000000000000000000000 6ff87c4664981e4397625791c8ea3bbb5f2279a3 A path1/COPYING :000000 100644 0000000000000000000000000000000000000000 6ff87c4664981e4397625791c8ea3bbb5f2279a3 A path1/COPYING
@ -55,14 +55,14 @@ test_expect_success \
test_expect_success \ test_expect_success \
'tweak work tree' \ 'tweak work tree' \
'rm -f path0/COPYING && 'rm -f path0/COPYING &&
git-update-index --remove path0/COPYING' git update-index --remove path0/COPYING'


# In the tree, there is only path0/COPYING. In the cache, path0 does # In the tree, there is only path0/COPYING. In the cache, path0 does
# not have COPYING anymore and path1 has COPYING which is a copy of # not have COPYING anymore and path1 has COPYING which is a copy of
# path0/COPYING. Showing the full tree with cache should tell us about # path0/COPYING. Showing the full tree with cache should tell us about
# the rename. # the rename.


git-diff-index -C $tree >current git diff-index -C $tree >current


cat >expected <<\EOF cat >expected <<\EOF
:100644 100644 6ff87c4664981e4397625791c8ea3bbb5f2279a3 6ff87c4664981e4397625791c8ea3bbb5f2279a3 R100 path0/COPYING path1/COPYING :100644 100644 6ff87c4664981e4397625791c8ea3bbb5f2279a3 6ff87c4664981e4397625791c8ea3bbb5f2279a3 R100 path0/COPYING path1/COPYING
@ -77,7 +77,7 @@ test_expect_success \
# path0/COPYING. When we say we care only about path1, we should just # path0/COPYING. When we say we care only about path1, we should just
# see path1/COPYING appearing from nowhere. # see path1/COPYING appearing from nowhere.


git-diff-index -C $tree path1 >current git diff-index -C $tree path1 >current


cat >expected <<\EOF cat >expected <<\EOF
:000000 100644 0000000000000000000000000000000000000000 6ff87c4664981e4397625791c8ea3bbb5f2279a3 A path1/COPYING :000000 100644 0000000000000000000000000000000000000000 6ff87c4664981e4397625791c8ea3bbb5f2279a3 A path1/COPYING

View File

@ -28,19 +28,19 @@ test_expect_success \
setup \ setup \
'cat ../../README >file0 && 'cat ../../README >file0 &&
cat ../../COPYING >file1 && cat ../../COPYING >file1 &&
git-update-index --add file0 file1 && git update-index --add file0 file1 &&
tree=$(git-write-tree) && tree=$(git write-tree) &&
echo "$tree"' echo "$tree"'


test_expect_success \ test_expect_success \
'change file1 with copy-edit of file0 and remove file0' \ 'change file1 with copy-edit of file0 and remove file0' \
'sed -e "s/git/GIT/" file0 >file1 && 'sed -e "s/git/GIT/" file0 >file1 &&
rm -f file0 && rm -f file0 &&
git-update-index --remove file0 file1' git update-index --remove file0 file1'


test_expect_success \ test_expect_success \
'run diff with -B' \ 'run diff with -B' \
'git-diff-index -B --cached "$tree" >current' 'git diff-index -B --cached "$tree" >current'


cat >expected <<\EOF cat >expected <<\EOF
:100644 000000 f5deac7be59e7eeab8657fd9ae706fd6a57daed2 0000000000000000000000000000000000000000 D file0 :100644 000000 f5deac7be59e7eeab8657fd9ae706fd6a57daed2 0000000000000000000000000000000000000000 D file0
@ -53,7 +53,7 @@ test_expect_success \


test_expect_success \ test_expect_success \
'run diff with -B and -M' \ 'run diff with -B and -M' \
'git-diff-index -B -M "$tree" >current' 'git diff-index -B -M "$tree" >current'


cat >expected <<\EOF cat >expected <<\EOF
:100644 100644 f5deac7be59e7eeab8657fd9ae706fd6a57daed2 08bb2fb671deff4c03a4d4a0a1315dff98d5732c R100 file0 file1 :100644 100644 f5deac7be59e7eeab8657fd9ae706fd6a57daed2 08bb2fb671deff4c03a4d4a0a1315dff98d5732c R100 file0 file1
@ -66,16 +66,16 @@ test_expect_success \
test_expect_success \ test_expect_success \
'swap file0 and file1' \ 'swap file0 and file1' \
'rm -f file0 file1 && 'rm -f file0 file1 &&
git-read-tree -m $tree && git read-tree -m $tree &&
git-checkout-index -f -u -a && git checkout-index -f -u -a &&
mv file0 tmp && mv file0 tmp &&
mv file1 file0 && mv file1 file0 &&
mv tmp file1 && mv tmp file1 &&
git-update-index file0 file1' git update-index file0 file1'


test_expect_success \ test_expect_success \
'run diff with -B' \ 'run diff with -B' \
'git-diff-index -B "$tree" >current' 'git diff-index -B "$tree" >current'


cat >expected <<\EOF cat >expected <<\EOF
:100644 100644 f5deac7be59e7eeab8657fd9ae706fd6a57daed2 6ff87c4664981e4397625791c8ea3bbb5f2279a3 M100 file0 :100644 100644 f5deac7be59e7eeab8657fd9ae706fd6a57daed2 6ff87c4664981e4397625791c8ea3bbb5f2279a3 M100 file0
@ -88,7 +88,7 @@ test_expect_success \


test_expect_success \ test_expect_success \
'run diff with -B and -M' \ 'run diff with -B and -M' \
'git-diff-index -B -M "$tree" >current' 'git diff-index -B -M "$tree" >current'


cat >expected <<\EOF cat >expected <<\EOF
:100644 100644 6ff87c4664981e4397625791c8ea3bbb5f2279a3 6ff87c4664981e4397625791c8ea3bbb5f2279a3 R100 file1 file0 :100644 100644 6ff87c4664981e4397625791c8ea3bbb5f2279a3 6ff87c4664981e4397625791c8ea3bbb5f2279a3 R100 file1 file0
@ -103,11 +103,11 @@ test_expect_success \
'make file0 into something completely different' \ 'make file0 into something completely different' \
'rm -f file0 && 'rm -f file0 &&
ln -s frotz file0 && ln -s frotz file0 &&
git-update-index file0 file1' git update-index file0 file1'


test_expect_success \ test_expect_success \
'run diff with -B' \ 'run diff with -B' \
'git-diff-index -B "$tree" >current' 'git diff-index -B "$tree" >current'


cat >expected <<\EOF cat >expected <<\EOF
:100644 120000 f5deac7be59e7eeab8657fd9ae706fd6a57daed2 67be421f88824578857624f7b3dc75e99a8a1481 T file0 :100644 120000 f5deac7be59e7eeab8657fd9ae706fd6a57daed2 67be421f88824578857624f7b3dc75e99a8a1481 T file0
@ -120,7 +120,7 @@ test_expect_success \


test_expect_success \ test_expect_success \
'run diff with -B' \ 'run diff with -B' \
'git-diff-index -B -M "$tree" >current' 'git diff-index -B -M "$tree" >current'


# This should not mistake file0 as the copy source of new file1 # This should not mistake file0 as the copy source of new file1
# due to type differences. # due to type differences.
@ -135,7 +135,7 @@ test_expect_success \


test_expect_success \ test_expect_success \
'run diff with -M' \ 'run diff with -M' \
'git-diff-index -M "$tree" >current' 'git diff-index -M "$tree" >current'


# This should not mistake file0 as the copy source of new file1 # This should not mistake file0 as the copy source of new file1
# due to type differences. # due to type differences.
@ -151,16 +151,16 @@ test_expect_success \
test_expect_success \ test_expect_success \
'file1 edited to look like file0 and file0 rename-edited to file2' \ 'file1 edited to look like file0 and file0 rename-edited to file2' \
'rm -f file0 file1 && 'rm -f file0 file1 &&
git-read-tree -m $tree && git read-tree -m $tree &&
git-checkout-index -f -u -a && git checkout-index -f -u -a &&
sed -e "s/git/GIT/" file0 >file1 && sed -e "s/git/GIT/" file0 >file1 &&
sed -e "s/git/GET/" file0 >file2 && sed -e "s/git/GET/" file0 >file2 &&
rm -f file0 rm -f file0
git-update-index --add --remove file0 file1 file2' git update-index --add --remove file0 file1 file2'


test_expect_success \ test_expect_success \
'run diff with -B' \ 'run diff with -B' \
'git-diff-index -B "$tree" >current' 'git diff-index -B "$tree" >current'


cat >expected <<\EOF cat >expected <<\EOF
:100644 000000 f5deac7be59e7eeab8657fd9ae706fd6a57daed2 0000000000000000000000000000000000000000 D file0 :100644 000000 f5deac7be59e7eeab8657fd9ae706fd6a57daed2 0000000000000000000000000000000000000000 D file0
@ -174,7 +174,7 @@ test_expect_success \


test_expect_success \ test_expect_success \
'run diff with -B -M' \ 'run diff with -B -M' \
'git-diff-index -B -M "$tree" >current' 'git diff-index -B -M "$tree" >current'


cat >expected <<\EOF cat >expected <<\EOF
:100644 100644 f5deac7be59e7eeab8657fd9ae706fd6a57daed2 08bb2fb671deff4c03a4d4a0a1315dff98d5732c C095 file0 file1 :100644 100644 f5deac7be59e7eeab8657fd9ae706fd6a57daed2 08bb2fb671deff4c03a4d4a0a1315dff98d5732c C095 file0 file1

View File

@ -13,8 +13,8 @@ test_expect_success \
'prepare reference tree' \ 'prepare reference tree' \
'cat ../../COPYING >COPYING && 'cat ../../COPYING >COPYING &&
echo frotz >rezrov && echo frotz >rezrov &&
git-update-index --add COPYING rezrov && git update-index --add COPYING rezrov &&
tree=$(git-write-tree) && tree=$(git write-tree) &&
echo $tree' echo $tree'


test_expect_success \ test_expect_success \
@ -22,14 +22,14 @@ test_expect_success \
'sed -e 's/HOWEVER/However/' <COPYING >COPYING.1 && 'sed -e 's/HOWEVER/However/' <COPYING >COPYING.1 &&
sed -e 's/GPL/G.P.L/g' <COPYING >COPYING.2 && sed -e 's/GPL/G.P.L/g' <COPYING >COPYING.2 &&
rm -f COPYING && rm -f COPYING &&
git-update-index --add --remove COPYING COPYING.?' git update-index --add --remove COPYING COPYING.?'


# tree has COPYING and rezrov. work tree has COPYING.1 and COPYING.2, # tree has COPYING and rezrov. work tree has COPYING.1 and COPYING.2,
# both are slightly edited, and unchanged rezrov. We say COPYING.1 # both are slightly edited, and unchanged rezrov. We say COPYING.1
# and COPYING.2 are based on COPYING, and do not say anything about # and COPYING.2 are based on COPYING, and do not say anything about
# rezrov. # rezrov.


git-diff-index -z -M $tree >current git diff-index -z -M $tree >current


cat >expected <<\EOF cat >expected <<\EOF
:100644 100644 6ff87c4664981e4397625791c8ea3bbb5f2279a3 0603b3238a076dc6c8022aedc6648fa523a17178 C1234 :100644 100644 6ff87c4664981e4397625791c8ea3bbb5f2279a3 0603b3238a076dc6c8022aedc6648fa523a17178 C1234
@ -49,14 +49,14 @@ test_expect_success \
test_expect_success \ test_expect_success \
'prepare work tree again' \ 'prepare work tree again' \
'mv COPYING.2 COPYING && 'mv COPYING.2 COPYING &&
git-update-index --add --remove COPYING COPYING.1 COPYING.2' git update-index --add --remove COPYING COPYING.1 COPYING.2'


# tree has COPYING and rezrov. work tree has COPYING and COPYING.1, # tree has COPYING and rezrov. work tree has COPYING and COPYING.1,
# both are slightly edited, and unchanged rezrov. We say COPYING.1 # both are slightly edited, and unchanged rezrov. We say COPYING.1
# is based on COPYING and COPYING is still there, and do not say anything # is based on COPYING and COPYING is still there, and do not say anything
# about rezrov. # about rezrov.


git-diff-index -z -C $tree >current git diff-index -z -C $tree >current
cat >expected <<\EOF cat >expected <<\EOF
:100644 100644 6ff87c4664981e4397625791c8ea3bbb5f2279a3 06c67961bbaed34a127f76d261f4c0bf73eda471 M :100644 100644 6ff87c4664981e4397625791c8ea3bbb5f2279a3 06c67961bbaed34a127f76d261f4c0bf73eda471 M
COPYING COPYING
@ -79,9 +79,9 @@ test_expect_success \
test_expect_success \ test_expect_success \
'prepare work tree once again' \ 'prepare work tree once again' \
'cat ../../COPYING >COPYING && 'cat ../../COPYING >COPYING &&
git-update-index --add --remove COPYING COPYING.1' git update-index --add --remove COPYING COPYING.1'


git-diff-index -z -C --find-copies-harder $tree >current git diff-index -z -C --find-copies-harder $tree >current
cat >expected <<\EOF cat >expected <<\EOF
:100644 100644 6ff87c4664981e4397625791c8ea3bbb5f2279a3 0603b3238a076dc6c8022aedc6648fa523a17178 C1234 :100644 100644 6ff87c4664981e4397625791c8ea3bbb5f2279a3 0603b3238a076dc6c8022aedc6648fa523a17178 C1234
COPYING COPYING

View File

@ -17,18 +17,18 @@ test_expect_success \
'echo frotz >file0 && 'echo frotz >file0 &&
mkdir path1 && mkdir path1 &&
echo rezrov >path1/file1 && echo rezrov >path1/file1 &&
git-update-index --add file0 path1/file1 && git update-index --add file0 path1/file1 &&
tree=`git-write-tree` && tree=`git write-tree` &&
echo "$tree" && echo "$tree" &&
echo nitfol >file0 && echo nitfol >file0 &&
echo yomin >path1/file1 && echo yomin >path1/file1 &&
git-update-index file0 path1/file1' git update-index file0 path1/file1'


cat >expected <<\EOF cat >expected <<\EOF
EOF EOF
test_expect_success \ test_expect_success \
'limit to path should show nothing' \ 'limit to path should show nothing' \
'git-diff-index --cached $tree -- path >current && 'git diff-index --cached $tree -- path >current &&
compare_diff_raw current expected' compare_diff_raw current expected'


cat >expected <<\EOF cat >expected <<\EOF
@ -36,7 +36,7 @@ cat >expected <<\EOF
EOF EOF
test_expect_success \ test_expect_success \
'limit to path1 should show path1/file1' \ 'limit to path1 should show path1/file1' \
'git-diff-index --cached $tree -- path1 >current && 'git diff-index --cached $tree -- path1 >current &&
compare_diff_raw current expected' compare_diff_raw current expected'


cat >expected <<\EOF cat >expected <<\EOF
@ -44,7 +44,7 @@ cat >expected <<\EOF
EOF EOF
test_expect_success \ test_expect_success \
'limit to path1/ should show path1/file1' \ 'limit to path1/ should show path1/file1' \
'git-diff-index --cached $tree -- path1/ >current && 'git diff-index --cached $tree -- path1/ >current &&
compare_diff_raw current expected' compare_diff_raw current expected'


cat >expected <<\EOF cat >expected <<\EOF
@ -52,14 +52,14 @@ cat >expected <<\EOF
EOF EOF
test_expect_success \ test_expect_success \
'limit to file0 should show file0' \ 'limit to file0 should show file0' \
'git-diff-index --cached $tree -- file0 >current && 'git diff-index --cached $tree -- file0 >current &&
compare_diff_raw current expected' compare_diff_raw current expected'


cat >expected <<\EOF cat >expected <<\EOF
EOF EOF
test_expect_success \ test_expect_success \
'limit to file0/ should emit nothing.' \ 'limit to file0/ should emit nothing.' \
'git-diff-index --cached $tree -- file0/ >current && 'git diff-index --cached $tree -- file0/ >current &&
compare_diff_raw current expected' compare_diff_raw current expected'


test_done test_done

View File

@ -23,17 +23,17 @@ EOF
test_expect_success \ test_expect_success \
'diff new symlink' \ 'diff new symlink' \
'ln -s xyzzy frotz && 'ln -s xyzzy frotz &&
git-update-index && git update-index &&
tree=$(git-write-tree) && tree=$(git write-tree) &&
git-update-index --add frotz && git update-index --add frotz &&
GIT_DIFF_OPTS=--unified=0 git-diff-index -M -p $tree > current && GIT_DIFF_OPTS=--unified=0 git diff-index -M -p $tree > current &&
compare_diff_patch current expected' compare_diff_patch current expected'


test_expect_success \ test_expect_success \
'diff unchanged symlink' \ 'diff unchanged symlink' \
'tree=$(git-write-tree) && 'tree=$(git write-tree) &&
git-update-index frotz && git update-index frotz &&
test -z "$(git-diff-index --name-only $tree)"' test -z "$(git diff-index --name-only $tree)"'


cat > expected << EOF cat > expected << EOF
diff --git a/frotz b/frotz diff --git a/frotz b/frotz
@ -49,7 +49,7 @@ EOF
test_expect_success \ test_expect_success \
'diff removed symlink' \ 'diff removed symlink' \
'rm frotz && 'rm frotz &&
git-diff-index -M -p $tree > current && git diff-index -M -p $tree > current &&
compare_diff_patch current expected' compare_diff_patch current expected'


cat > expected << EOF cat > expected << EOF
@ -60,7 +60,7 @@ test_expect_success \
'diff identical, but newly created symlink' \ 'diff identical, but newly created symlink' \
'sleep 3 && 'sleep 3 &&
ln -s xyzzy frotz && ln -s xyzzy frotz &&
git-diff-index -M -p $tree > current && git diff-index -M -p $tree > current &&
compare_diff_patch current expected' compare_diff_patch current expected'


cat > expected << EOF cat > expected << EOF
@ -79,7 +79,7 @@ test_expect_success \
'diff different symlink' \ 'diff different symlink' \
'rm frotz && 'rm frotz &&
ln -s yxyyz frotz && ln -s yxyyz frotz &&
git-diff-index -M -p $tree > current && git diff-index -M -p $tree > current &&
compare_diff_patch current expected' compare_diff_patch current expected'


test_done test_done

View File

@ -10,7 +10,7 @@ test_description='Binary diff and apply


test_expect_success 'prepare repository' \ test_expect_success 'prepare repository' \
'echo AIT >a && echo BIT >b && echo CIT >c && echo DIT >d && 'echo AIT >a && echo BIT >b && echo CIT >c && echo DIT >d &&
git-update-index --add a b c d && git update-index --add a b c d &&
echo git >a && echo git >a &&
cat ../test4012.png >b && cat ../test4012.png >b &&
echo git >c && echo git >c &&
@ -24,18 +24,18 @@ cat > expected <<\EOF
4 files changed, 2 insertions(+), 2 deletions(-) 4 files changed, 2 insertions(+), 2 deletions(-)
EOF EOF
test_expect_success 'diff without --binary' \ test_expect_success 'diff without --binary' \
'git-diff | git-apply --stat --summary >current && 'git diff | git apply --stat --summary >current &&
cmp current expected' cmp current expected'


test_expect_success 'diff with --binary' \ test_expect_success 'diff with --binary' \
'git-diff --binary | git-apply --stat --summary >current && 'git diff --binary | git apply --stat --summary >current &&
cmp current expected' cmp current expected'


# apply needs to be able to skip the binary material correctly # apply needs to be able to skip the binary material correctly
# in order to report the line number of a corrupt patch. # in order to report the line number of a corrupt patch.
test_expect_success 'apply detecting corrupt patch correctly' \ test_expect_success 'apply detecting corrupt patch correctly' \
'git-diff | sed -e 's/-CIT/xCIT/' >broken && 'git diff | sed -e 's/-CIT/xCIT/' >broken &&
if git-apply --stat --summary broken 2>detected if git apply --stat --summary broken 2>detected
then then
echo unhappy - should have detected an error echo unhappy - should have detected an error
(exit 1) (exit 1)
@ -48,8 +48,8 @@ test_expect_success 'apply detecting corrupt patch correctly' \
test "$detected" = xCIT' test "$detected" = xCIT'


test_expect_success 'apply detecting corrupt patch correctly' \ test_expect_success 'apply detecting corrupt patch correctly' \
'git-diff --binary | sed -e 's/-CIT/xCIT/' >broken && 'git diff --binary | sed -e 's/-CIT/xCIT/' >broken &&
if git-apply --stat --summary broken 2>detected if git apply --stat --summary broken 2>detected
then then
echo unhappy - should have detected an error echo unhappy - should have detected an error
(exit 1) (exit 1)
@ -66,15 +66,15 @@ test_expect_success 'initial commit' 'git-commit -a -m initial'
# Try removal (b), modification (d), and creation (e). # Try removal (b), modification (d), and creation (e).
test_expect_success 'diff-index with --binary' \ test_expect_success 'diff-index with --binary' \
'echo AIT >a && mv b e && echo CIT >c && cat e >d && 'echo AIT >a && mv b e && echo CIT >c && cat e >d &&
git-update-index --add --remove a b c d e && git update-index --add --remove a b c d e &&
tree0=`git-write-tree` && tree0=`git write-tree` &&
git-diff --cached --binary >current && git diff --cached --binary >current &&
git-apply --stat --summary current' git apply --stat --summary current'


test_expect_success 'apply binary patch' \ test_expect_success 'apply binary patch' \
'git-reset --hard && 'git-reset --hard &&
git-apply --binary --index <current && git apply --binary --index <current &&
tree1=`git-write-tree` && tree1=`git write-tree` &&
test "$tree1" = "$tree0"' test "$tree1" = "$tree0"'


test_done test_done

View File

@ -17,7 +17,7 @@ do {
} while (0); } while (0);
EOF EOF


git-update-index --add x git update-index --add x


cat << EOF > x cat << EOF > x
do do
@ -42,13 +42,13 @@ index adf3937..6edc172 100644
+while (0); +while (0);
EOF EOF


git-diff > out git diff > out
test_expect_success "Ray's example without options" 'git diff expect out' test_expect_success "Ray's example without options" 'git diff expect out'


git-diff -w > out git diff -w > out
test_expect_success "Ray's example with -w" 'git diff expect out' test_expect_success "Ray's example with -w" 'git diff expect out'


git-diff -b > out git diff -b > out
test_expect_success "Ray's example with -b" 'git diff expect out' test_expect_success "Ray's example with -b" 'git diff expect out'


tr 'Q' '\015' << EOF > x tr 'Q' '\015' << EOF > x
@ -60,7 +60,7 @@ unchanged line
CR at endQ CR at endQ
EOF EOF


git-update-index x git update-index x


cat << EOF > x cat << EOF > x
whitespace at beginning whitespace at beginning
@ -89,14 +89,14 @@ index d99af23..8b32fb5 100644
-CR at endQ -CR at endQ
+CR at end +CR at end
EOF EOF
git-diff > out git diff > out
test_expect_success 'another test, without options' 'git diff expect out' test_expect_success 'another test, without options' 'git diff expect out'


cat << EOF > expect cat << EOF > expect
diff --git a/x b/x diff --git a/x b/x
index d99af23..8b32fb5 100644 index d99af23..8b32fb5 100644
EOF EOF
git-diff -w > out git diff -w > out
test_expect_success 'another test, with -w' 'git diff expect out' test_expect_success 'another test, with -w' 'git diff expect out'


tr 'Q' '\015' << EOF > expect tr 'Q' '\015' << EOF > expect
@ -114,7 +114,7 @@ index d99af23..8b32fb5 100644
unchanged line unchanged line
CR at endQ CR at endQ
EOF EOF
git-diff -b > out git diff -b > out
test_expect_success 'another test, with -b' 'git diff expect out' test_expect_success 'another test, with -b' 'git diff expect out'


test_done test_done

View File

@ -3,44 +3,44 @@
# Copyright (c) 2005 Junio C Hamano # Copyright (c) 2005 Junio C Hamano
# #


test_description='git-apply --stat --summary test. test_description='git apply --stat --summary test.


' '
. ./test-lib.sh . ./test-lib.sh


test_expect_success \ test_expect_success \
'rename' \ 'rename' \
'git-apply --stat --summary <../t4100/t-apply-1.patch >current && 'git apply --stat --summary <../t4100/t-apply-1.patch >current &&
git diff ../t4100/t-apply-1.expect current' git diff ../t4100/t-apply-1.expect current'


test_expect_success \ test_expect_success \
'copy' \ 'copy' \
'git-apply --stat --summary <../t4100/t-apply-2.patch >current && 'git apply --stat --summary <../t4100/t-apply-2.patch >current &&
git diff ../t4100/t-apply-2.expect current' git diff ../t4100/t-apply-2.expect current'


test_expect_success \ test_expect_success \
'rewrite' \ 'rewrite' \
'git-apply --stat --summary <../t4100/t-apply-3.patch >current && 'git apply --stat --summary <../t4100/t-apply-3.patch >current &&
git diff ../t4100/t-apply-3.expect current' git diff ../t4100/t-apply-3.expect current'


test_expect_success \ test_expect_success \
'mode' \ 'mode' \
'git-apply --stat --summary <../t4100/t-apply-4.patch >current && 'git apply --stat --summary <../t4100/t-apply-4.patch >current &&
git diff ../t4100/t-apply-4.expect current' git diff ../t4100/t-apply-4.expect current'


test_expect_success \ test_expect_success \
'non git' \ 'non git' \
'git-apply --stat --summary <../t4100/t-apply-5.patch >current && 'git apply --stat --summary <../t4100/t-apply-5.patch >current &&
git diff ../t4100/t-apply-5.expect current' git diff ../t4100/t-apply-5.expect current'


test_expect_success \ test_expect_success \
'non git' \ 'non git' \
'git-apply --stat --summary <../t4100/t-apply-6.patch >current && 'git apply --stat --summary <../t4100/t-apply-6.patch >current &&
git diff ../t4100/t-apply-6.expect current' git diff ../t4100/t-apply-6.expect current'


test_expect_success \ test_expect_success \
'non git' \ 'non git' \
'git-apply --stat --summary <../t4100/t-apply-7.patch >current && 'git apply --stat --summary <../t4100/t-apply-7.patch >current &&
git diff ../t4100/t-apply-7.expect current' git diff ../t4100/t-apply-7.expect current'


test_done test_done

View File

@ -3,7 +3,7 @@
# Copyright (c) 2005 Junio C Hamano # Copyright (c) 2005 Junio C Hamano
# #


test_description='git-apply should handle files with incomplete lines. test_description='git apply should handle files with incomplete lines.


' '
. ./test-lib.sh . ./test-lib.sh
@ -23,7 +23,7 @@ do
cat frotz.$i >frotz cat frotz.$i >frotz
test_expect_success \ test_expect_success \
"apply diff between $i and $j" \ "apply diff between $i and $j" \
"git-apply <../t4101/diff.$i-$j && diff frotz.$j frotz" "git apply <../t4101/diff.$i-$j && diff frotz.$j frotz"
done done
done done



View File

@ -3,7 +3,7 @@
# Copyright (c) 2005 Junio C Hamano # Copyright (c) 2005 Junio C Hamano
# #


test_description='git-apply handling copy/rename patch. test_description='git apply handling copy/rename patch.


' '
. ./test-lib.sh . ./test-lib.sh
@ -26,10 +26,10 @@ echo 'This is foo' >foo
chmod +x foo chmod +x foo


test_expect_success setup \ test_expect_success setup \
'git-update-index --add foo' 'git update-index --add foo'


test_expect_success apply \ test_expect_success apply \
'git-apply --index --stat --summary --apply test-patch' 'git apply --index --stat --summary --apply test-patch'


if [ "$(git config --get core.filemode)" = false ] if [ "$(git config --get core.filemode)" = false ]
then then
@ -40,7 +40,7 @@ else
fi fi


test_expect_success 'apply reverse' \ test_expect_success 'apply reverse' \
'git-apply -R --index --stat --summary --apply test-patch && 'git apply -R --index --stat --summary --apply test-patch &&
test "$(cat foo)" = "This is foo"' test "$(cat foo)" = "This is foo"'


cat >test-patch <<\EOF cat >test-patch <<\EOF
@ -56,7 +56,7 @@ copy to bar
EOF EOF


test_expect_success 'apply copy' \ test_expect_success 'apply copy' \
'git-apply --index --stat --summary --apply test-patch && 'git apply --index --stat --summary --apply test-patch &&
test "$(cat bar)" = "This is bar" -a "$(cat foo)" = "This is foo"' test "$(cat bar)" = "This is bar" -a "$(cat foo)" = "This is foo"'


test_done test_done

View File

@ -3,7 +3,7 @@
# Copyright (c) 2005 Junio C Hamano # Copyright (c) 2005 Junio C Hamano
# #


test_description='git-apply handling binary patches test_description='git apply handling binary patches


' '
. ./test-lib.sh . ./test-lib.sh
@ -20,55 +20,55 @@ EOF
cat file1 >file2 cat file1 >file2
cat file1 >file4 cat file1 >file4


git-update-index --add --remove file1 file2 file4 git update-index --add --remove file1 file2 file4
git-commit -m 'Initial Version' 2>/dev/null git-commit -m 'Initial Version' 2>/dev/null


git-checkout -b binary git-checkout -b binary
tr 'x' '\0' <file1 >file3 tr 'x' '\0' <file1 >file3
cat file3 >file4 cat file3 >file4
git-add file2 git add file2
tr '\0' 'v' <file3 >file1 tr '\0' 'v' <file3 >file1
rm -f file2 rm -f file2
git-update-index --add --remove file1 file2 file3 file4 git update-index --add --remove file1 file2 file3 file4
git-commit -m 'Second Version' git-commit -m 'Second Version'


git-diff-tree -p master binary >B.diff git diff-tree -p master binary >B.diff
git-diff-tree -p -C master binary >C.diff git diff-tree -p -C master binary >C.diff


git-diff-tree -p --binary master binary >BF.diff git diff-tree -p --binary master binary >BF.diff
git-diff-tree -p --binary -C master binary >CF.diff git diff-tree -p --binary -C master binary >CF.diff


test_expect_success 'stat binary diff -- should not fail.' \ test_expect_success 'stat binary diff -- should not fail.' \
'git-checkout master 'git-checkout master
git-apply --stat --summary B.diff' git apply --stat --summary B.diff'


test_expect_success 'stat binary diff (copy) -- should not fail.' \ test_expect_success 'stat binary diff (copy) -- should not fail.' \
'git-checkout master 'git-checkout master
git-apply --stat --summary C.diff' git apply --stat --summary C.diff'


test_expect_failure 'check binary diff -- should fail.' \ test_expect_failure 'check binary diff -- should fail.' \
'git-checkout master 'git-checkout master
git-apply --check B.diff' git apply --check B.diff'


test_expect_failure 'check binary diff (copy) -- should fail.' \ test_expect_failure 'check binary diff (copy) -- should fail.' \
'git-checkout master 'git-checkout master
git-apply --check C.diff' git apply --check C.diff'


test_expect_failure 'check incomplete binary diff with replacement -- should fail.' \ test_expect_failure 'check incomplete binary diff with replacement -- should fail.' \
'git-checkout master 'git-checkout master
git-apply --check --allow-binary-replacement B.diff' git apply --check --allow-binary-replacement B.diff'


test_expect_failure 'check incomplete binary diff with replacement (copy) -- should fail.' \ test_expect_failure 'check incomplete binary diff with replacement (copy) -- should fail.' \
'git-checkout master 'git-checkout master
git-apply --check --allow-binary-replacement C.diff' git apply --check --allow-binary-replacement C.diff'


test_expect_success 'check binary diff with replacement.' \ test_expect_success 'check binary diff with replacement.' \
'git-checkout master 'git-checkout master
git-apply --check --allow-binary-replacement BF.diff' git apply --check --allow-binary-replacement BF.diff'


test_expect_success 'check binary diff with replacement (copy).' \ test_expect_success 'check binary diff with replacement (copy).' \
'git-checkout master 'git-checkout master
git-apply --check --allow-binary-replacement CF.diff' git apply --check --allow-binary-replacement CF.diff'


# Now we start applying them. # Now we start applying them.


@ -80,36 +80,36 @@ do_reset () {


test_expect_failure 'apply binary diff -- should fail.' \ test_expect_failure 'apply binary diff -- should fail.' \
'do_reset 'do_reset
git-apply B.diff' git apply B.diff'


test_expect_failure 'apply binary diff -- should fail.' \ test_expect_failure 'apply binary diff -- should fail.' \
'do_reset 'do_reset
git-apply --index B.diff' git apply --index B.diff'


test_expect_failure 'apply binary diff (copy) -- should fail.' \ test_expect_failure 'apply binary diff (copy) -- should fail.' \
'do_reset 'do_reset
git-apply C.diff' git apply C.diff'


test_expect_failure 'apply binary diff (copy) -- should fail.' \ test_expect_failure 'apply binary diff (copy) -- should fail.' \
'do_reset 'do_reset
git-apply --index C.diff' git apply --index C.diff'


test_expect_success 'apply binary diff without replacement.' \ test_expect_success 'apply binary diff without replacement.' \
'do_reset 'do_reset
git-apply BF.diff' git apply BF.diff'


test_expect_success 'apply binary diff without replacement (copy).' \ test_expect_success 'apply binary diff without replacement (copy).' \
'do_reset 'do_reset
git-apply CF.diff' git apply CF.diff'


test_expect_success 'apply binary diff.' \ test_expect_success 'apply binary diff.' \
'do_reset 'do_reset
git-apply --allow-binary-replacement --index BF.diff && git apply --allow-binary-replacement --index BF.diff &&
test -z "$(git-diff --name-status binary)"' test -z "$(git diff --name-status binary)"'


test_expect_success 'apply binary diff (copy).' \ test_expect_success 'apply binary diff (copy).' \
'do_reset 'do_reset
git-apply --allow-binary-replacement --index CF.diff && git apply --allow-binary-replacement --index CF.diff &&
test -z "$(git-diff --name-status binary)"' test -z "$(git diff --name-status binary)"'


test_done test_done

View File

@ -3,7 +3,7 @@
# Copyright (c) 2005 Junio C Hamano # Copyright (c) 2005 Junio C Hamano
# #


test_description='git-apply boundary tests test_description='git apply boundary tests


' '
. ./test-lib.sh . ./test-lib.sh

View File

@ -4,7 +4,7 @@
# Copyright (c) 2005 Robert Fitzsimons # Copyright (c) 2005 Robert Fitzsimons
# #


test_description='git-apply test patches with multiple fragments. test_description='git apply test patches with multiple fragments.


' '
. ./test-lib.sh . ./test-lib.sh
@ -138,8 +138,8 @@ diff --git a/main.c b/main.c
EOF EOF


test_expect_success "S = git-apply (1)" \ test_expect_success "S = git apply (1)" \
'git-apply patch1.patch patch2.patch' 'git apply patch1.patch patch2.patch'
mv main.c main.c.git mv main.c main.c.git


test_expect_success "S = patch (1)" \ test_expect_success "S = patch (1)" \
@ -150,8 +150,8 @@ test_expect_success "S = cmp (1)" \


rm -f main.c main.c.git rm -f main.c main.c.git


test_expect_success "S = git-apply (2)" \ test_expect_success "S = git apply (2)" \
'git-apply patch1.patch patch2.patch patch3.patch' 'git apply patch1.patch patch2.patch patch3.patch'
mv main.c main.c.git mv main.c main.c.git


test_expect_success "S = patch (2)" \ test_expect_success "S = patch (2)" \
@ -162,8 +162,8 @@ test_expect_success "S = cmp (2)" \


rm -f main.c main.c.git rm -f main.c main.c.git


test_expect_success "S = git-apply (3)" \ test_expect_success "S = git apply (3)" \
'git-apply patch1.patch patch4.patch' 'git apply patch1.patch patch4.patch'
mv main.c main.c.git mv main.c main.c.git


test_expect_success "S = patch (3)" \ test_expect_success "S = patch (3)" \

View File

@ -4,7 +4,7 @@
# Copyright (c) 2005 Robert Fitzsimons # Copyright (c) 2005 Robert Fitzsimons
# #


test_description='git-apply test for patches which require scanning forwards and backwards. test_description='git apply test for patches which require scanning forwards and backwards.


' '
. ./test-lib.sh . ./test-lib.sh
@ -86,8 +86,8 @@ diff --git a/new.txt b/new.txt
+c2222 +c2222
EOF EOF


test_expect_success "S = git-apply scan" \ test_expect_success "S = git apply scan" \
'git-apply patch1.patch patch2.patch patch3.patch patch4.patch patch5.patch' 'git apply patch1.patch patch2.patch patch3.patch patch4.patch patch5.patch'
mv new.txt apply.txt mv new.txt apply.txt


test_expect_success "S = patch scan" \ test_expect_success "S = patch scan" \

View File

@ -3,7 +3,7 @@
# Copyright (c) 2005 Junio C Hamano # Copyright (c) 2005 Junio C Hamano
# #


test_description='git-apply should not get confused with rename/copy. test_description='git apply should not get confused with rename/copy.


' '


@ -115,10 +115,10 @@ rename to include/arch/m32r/klibc/archsetjmp.h
+#endif /* _KLIBC_ARCHSETJMP_H */ +#endif /* _KLIBC_ARCHSETJMP_H */
EOF EOF


find klibc -type f -print | xargs git-update-index --add -- find klibc -type f -print | xargs git update-index --add --


test_expect_success 'check rename/copy patch' 'git-apply --check patch' test_expect_success 'check rename/copy patch' 'git apply --check patch'


test_expect_success 'apply rename/copy patch' 'git-apply --index patch' test_expect_success 'apply rename/copy patch' 'git apply --index patch'


test_done test_done

View File

@ -3,7 +3,7 @@
# Copyright (c) 2006 Catalin Marinas # Copyright (c) 2006 Catalin Marinas
# #


test_description='git-apply trying to add an ending line. test_description='git apply trying to add an ending line.


' '
. ./test-lib.sh . ./test-lib.sh
@ -25,12 +25,12 @@ echo 'b' >>file
echo 'c' >>file echo 'c' >>file


test_expect_success setup \ test_expect_success setup \
'git-update-index --add file' 'git update-index --add file'


# test # test


test_expect_failure 'apply at the end' \ test_expect_failure 'apply at the end' \
'git-apply --index test-patch' 'git apply --index test-patch'


cat >test-patch <<\EOF cat >test-patch <<\EOF
diff a/file b/file diff a/file b/file
@ -45,9 +45,9 @@ EOF
echo >file 'a echo >file 'a
b b
c' c'
git-update-index file git update-index file


test_expect_failure 'apply at the beginning' \ test_expect_failure 'apply at the beginning' \
'git-apply --index test-patch' 'git apply --index test-patch'


test_done test_done

View File

@ -3,7 +3,7 @@
# Copyright (c) 2006 Eric Wong # Copyright (c) 2006 Eric Wong
# #


test_description='git-apply should not get confused with type changes. test_description='git apply should not get confused with type changes.


' '



View File

@ -3,7 +3,7 @@
# Copyright (c) 2005 Junio C Hamano # Copyright (c) 2005 Junio C Hamano
# #


test_description='git-apply symlinks and partial files test_description='git apply symlinks and partial files


' '



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