diff options
Diffstat (limited to 't')
47 files changed, 2592 insertions, 1127 deletions
diff --git a/t/lib-git-p4.sh b/t/lib-git-p4.sh index 2098b9ba05..ccd918e79e 100644 --- a/t/lib-git-p4.sh +++ b/t/lib-git-p4.sh @@ -48,7 +48,8 @@ P4DPORT=$((10669 + ($testid - $git_p4_test_start))) P4PORT=localhost:$P4DPORT P4CLIENT=client P4EDITOR=: -export P4PORT P4CLIENT P4EDITOR +unset P4CHARSET +export P4PORT P4CLIENT P4EDITOR P4CHARSET db="$TRASH_DIRECTORY/db" cli="$TRASH_DIRECTORY/cli" diff --git a/t/lib-httpd.sh b/t/lib-httpd.sh index dab405d574..54dbbfe5ce 100644 --- a/t/lib-httpd.sh +++ b/t/lib-httpd.sh @@ -169,7 +169,7 @@ test_http_push_nonff () { test_i18ngrep "Updates were rejected because" output ' - test_expect_failure 'force with lease aka cas' ' + test_expect_${EXPECT_CAS_RESULT} 'force with lease aka cas' ' HEAD=$( cd "$REMOTE_REPO" && git rev-parse --verify HEAD ) && test_when_finished '\'' (cd "$REMOTE_REPO" && git update-ref HEAD "$HEAD") diff --git a/t/lib-pack.sh b/t/lib-pack.sh new file mode 100644 index 0000000000..7e8685b44c --- /dev/null +++ b/t/lib-pack.sh @@ -0,0 +1,100 @@ +#!/bin/sh +# +# Support routines for hand-crafting weird or malicious packs. +# +# You can make a complete pack like: +# +# pack_header 2 >foo.pack && +# pack_obj e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 >>foo.pack && +# pack_obj e68fe8129b546b101aee9510c5328e7f21ca1d18 >>foo.pack && +# pack_trailer foo.pack + +# Print the big-endian 4-byte octal representation of $1 +uint32_octal () { + n=$1 + printf '\%o' $(($n / 16777216)); n=$((n % 16777216)) + printf '\%o' $(($n / 65536)); n=$((n % 65536)) + printf '\%o' $(($n / 256)); n=$((n % 256)) + printf '\%o' $(($n )); +} + +# Print the big-endian 4-byte binary representation of $1 +uint32_binary () { + printf "$(uint32_octal "$1")" +} + +# Print a pack header, version 2, for a pack with $1 objects +pack_header () { + printf 'PACK' && + printf '\0\0\0\2' && + uint32_binary "$1" +} + +# Print the pack data for object $1, as a delta against object $2 (or as a full +# object if $2 is missing or empty). The output is suitable for including +# directly in the packfile, and represents the entirety of the object entry. +# Doing this on the fly (especially picking your deltas) is quite tricky, so we +# have hardcoded some well-known objects. See the case statements below for the +# complete list. +pack_obj () { + case "$1" in + # empty blob + e69de29bb2d1d6434b8b29ae775ad8c2e48c5391) + case "$2" in + '') + printf '\060\170\234\003\0\0\0\0\1' + return + ;; + esac + ;; + + # blob containing "\7\76" + e68fe8129b546b101aee9510c5328e7f21ca1d18) + case "$2" in + '') + printf '\062\170\234\143\267\3\0\0\116\0\106' + return + ;; + 01d7713666f4de822776c7622c10f1b07de280dc) + printf '\165\1\327\161\66\146\364\336\202\47\166' && + printf '\307\142\54\20\361\260\175\342\200\334\170' && + printf '\234\143\142\142\142\267\003\0\0\151\0\114' + return + ;; + esac + ;; + + # blob containing "\7\0" + 01d7713666f4de822776c7622c10f1b07de280dc) + case "$2" in + '') + printf '\062\170\234\143\147\0\0\0\20\0\10' + return + ;; + e68fe8129b546b101aee9510c5328e7f21ca1d18) + printf '\165\346\217\350\22\233\124\153\20\32\356' && + printf '\225\20\305\62\216\177\41\312\35\30\170\234' && + printf '\143\142\142\142\147\0\0\0\53\0\16' + return + ;; + esac + ;; + esac + + echo >&2 "BUG: don't know how to print $1${2:+ (from $2)}" + return 1 +} + +# Compute and append pack trailer to "$1" +pack_trailer () { + test-sha1 -b <"$1" >trailer.tmp && + cat trailer.tmp >>"$1" && + rm -f trailer.tmp +} + +# Remove any existing packs to make sure that +# whatever we index next will be the pack that we +# actually use. +clear_packs () { + rm -f .git/objects/pack/* +} diff --git a/t/t0001-init.sh b/t/t0001-init.sh index ad66410564..9fb582b192 100755 --- a/t/t0001-init.sh +++ b/t/t0001-init.sh @@ -379,6 +379,10 @@ test_expect_success 'init with separate gitdir' ' test -d realgitdir/refs ' +test_expect_success 're-init on .git file' ' + ( cd newdir && git init ) +' + test_expect_success 're-init to update git link' ' ( cd newdir && diff --git a/t/t0008-ignores.sh b/t/t0008-ignores.sh index 96f40fedfb..181513ab4f 100755 --- a/t/t0008-ignores.sh +++ b/t/t0008-ignores.sh @@ -66,11 +66,11 @@ test_check_ignore () { init_vars && rm -f "$HOME/stdout" "$HOME/stderr" "$HOME/cmd" && - echo git $global_args check-ignore $quiet_opt $verbose_opt $non_matching_opt $args \ + echo git $global_args check-ignore $quiet_opt $verbose_opt $non_matching_opt $no_index_opt $args \ >"$HOME/cmd" && echo "$expect_code" >"$HOME/expected-exit-code" && test_expect_code "$expect_code" \ - git $global_args check-ignore $quiet_opt $verbose_opt $non_matching_opt $args \ + git $global_args check-ignore $quiet_opt $verbose_opt $non_matching_opt $no_index_opt $args \ >"$HOME/stdout" 2>"$HOME/stderr" && test_cmp "$HOME/expected-stdout" "$HOME/stdout" && stderr_empty_on_success "$expect_code" @@ -87,6 +87,9 @@ test_check_ignore () { # check-ignore --verbose output is the same as normal output except # for the extra first column. # +# A parameter is used to determine if the tests are run with the +# normal case (using the index), or with the --no-index option. +# # Arguments: # - (optional) prereqs for this test, e.g. 'SYMLINKS' # - test name @@ -94,19 +97,26 @@ test_check_ignore () { # from the other verbosity modes is automatically inferred # from this value) # - code to run (should invoke test_check_ignore) -test_expect_success_multi () { +# - index option: --index or --no-index +test_expect_success_multiple () { prereq= - if test $# -eq 4 + if test $# -eq 5 then prereq=$1 shift fi + if test "$4" = "--index" + then + no_index_opt= + else + no_index_opt=$4 + fi testname="$1" expect_all="$2" code="$3" expect_verbose=$( echo "$expect_all" | grep -v '^:: ' ) expect=$( echo "$expect_verbose" | sed -e 's/.* //' ) - test_expect_success $prereq "$testname" ' + test_expect_success $prereq "$testname${no_index_opt:+ with $no_index_opt}" ' expect "$expect" && eval "$code" ' @@ -116,7 +126,8 @@ test_expect_success_multi () { then for quiet_opt in '-q' '--quiet' do - test_expect_success $prereq "$testname${quiet_opt:+ with $quiet_opt}" " + opts="${no_index_opt:+$no_index_opt }$quiet_opt" + test_expect_success $prereq "$testname${opts:+ with $opts}" " expect '' && $code " @@ -126,7 +137,7 @@ test_expect_success_multi () { for verbose_opt in '-v' '--verbose' do - for non_matching_opt in '' ' -n' ' --non-matching' + for non_matching_opt in '' '-n' '--non-matching' do if test -n "$non_matching_opt" then @@ -139,12 +150,21 @@ test_expect_success_multi () { expect '$my_expect' && $code " - opts="$verbose_opt$non_matching_opt" + opts="${no_index_opt:+$no_index_opt }$verbose_opt${non_matching_opt:+ $non_matching_opt}" test_expect_success $prereq "$testname${opts:+ with $opts}" "$test_code" done done verbose_opt= non_matching_opt= + no_index_opt= +} + +test_expect_success_multi () { + test_expect_success_multiple "$@" "--index" +} + +test_expect_success_no_index_multi () { + test_expect_success_multiple "$@" "--no-index" } test_expect_success 'setup' ' @@ -288,7 +308,7 @@ test_expect_success_multi 'needs work tree' '' ' # First make sure that the presence of a file in the working tree # does not impact results, but that the presence of a file in the -# index does. +# index does unless the --no-index option is used. for subdir in '' 'a/' do @@ -303,22 +323,42 @@ do ":: ${subdir}non-existent" \ "test_check_ignore '${subdir}non-existent' 1" + test_expect_success_no_index_multi "non-existent file $where not ignored" \ + ":: ${subdir}non-existent" \ + "test_check_ignore '${subdir}non-existent' 1" + test_expect_success_multi "non-existent file $where ignored" \ ".gitignore:1:one ${subdir}one" \ "test_check_ignore '${subdir}one'" + test_expect_success_no_index_multi "non-existent file $where ignored" \ + ".gitignore:1:one ${subdir}one" \ + "test_check_ignore '${subdir}one'" + test_expect_success_multi "existing untracked file $where not ignored" \ ":: ${subdir}not-ignored" \ "test_check_ignore '${subdir}not-ignored' 1" + test_expect_success_no_index_multi "existing untracked file $where not ignored" \ + ":: ${subdir}not-ignored" \ + "test_check_ignore '${subdir}not-ignored' 1" + test_expect_success_multi "existing tracked file $where not ignored" \ ":: ${subdir}ignored-but-in-index" \ "test_check_ignore '${subdir}ignored-but-in-index' 1" + test_expect_success_no_index_multi "existing tracked file $where shown as ignored" \ + ".gitignore:2:ignored-* ${subdir}ignored-but-in-index" \ + "test_check_ignore '${subdir}ignored-but-in-index'" + test_expect_success_multi "existing untracked file $where ignored" \ ".gitignore:2:ignored-* ${subdir}ignored-and-untracked" \ "test_check_ignore '${subdir}ignored-and-untracked'" + test_expect_success_no_index_multi "existing untracked file $where ignored" \ + ".gitignore:2:ignored-* ${subdir}ignored-and-untracked" \ + "test_check_ignore '${subdir}ignored-and-untracked'" + test_expect_success_multi "mix of file types $where" \ ":: ${subdir}non-existent .gitignore:1:one ${subdir}one @@ -332,6 +372,20 @@ do ${subdir}ignored-but-in-index ${subdir}ignored-and-untracked' " + + test_expect_success_no_index_multi "mix of file types $where" \ +":: ${subdir}non-existent +.gitignore:1:one ${subdir}one +:: ${subdir}not-ignored +.gitignore:2:ignored-* ${subdir}ignored-but-in-index +.gitignore:2:ignored-* ${subdir}ignored-and-untracked" \ + "test_check_ignore ' + ${subdir}non-existent + ${subdir}one + ${subdir}not-ignored + ${subdir}ignored-but-in-index + ${subdir}ignored-and-untracked' + " done # Having established the above, from now on we mostly test against diff --git a/t/t0050-filesystem.sh b/t/t0050-filesystem.sh index 05d78d22a6..6b3cedcf24 100755 --- a/t/t0050-filesystem.sh +++ b/t/t0050-filesystem.sh @@ -91,6 +91,7 @@ test_expect_failure CASE_INSENSITIVE_FS 'add (with different case)' ' test_expect_success "setup unicode normalization tests" ' test_create_repo unicode && cd unicode && + git config core.precomposeunicode false && touch "$aumlcdiar" && git add "$aumlcdiar" && git commit -m initial && diff --git a/t/t0056-git-C.sh b/t/t0056-git-C.sh new file mode 100755 index 0000000000..99c037703a --- /dev/null +++ b/t/t0056-git-C.sh @@ -0,0 +1,84 @@ +#!/bin/sh + +test_description='"-C <path>" option and its effects on other path-related options' + +. ./test-lib.sh + +test_expect_success '"git -C <path>" runs git from the directory <path>' ' + test_create_repo dir1 && + echo 1 >dir1/a.txt && + msg="initial in dir1" && + (cd dir1 && git add a.txt && git commit -m "$msg") && + echo "$msg" >expected && + git -C dir1 log --format=%s >actual && + test_cmp expected actual +' + +test_expect_success 'Multiple -C options: "-C dir1 -C dir2" is equivalent to "-C dir1/dir2"' ' + test_create_repo dir1/dir2 && + echo 1 >dir1/dir2/b.txt && + git -C dir1/dir2 add b.txt && + msg="initial in dir1/dir2" && + echo "$msg" >expected && + git -C dir1/dir2 commit -m "$msg" && + git -C dir1 -C dir2 log --format=%s >actual && + test_cmp expected actual +' + +test_expect_success 'Effect on --git-dir option: "-C c --git-dir=a.git" is equivalent to "--git-dir c/a.git"' ' + mkdir c && + mkdir c/a && + mkdir c/a.git && + (cd c/a.git && git init --bare) && + echo 1 >c/a/a.txt && + git --git-dir c/a.git --work-tree=c/a add a.txt && + git --git-dir c/a.git --work-tree=c/a commit -m "initial" && + git --git-dir=c/a.git log -1 --format=%s >expected && + git -C c --git-dir=a.git log -1 --format=%s >actual && + test_cmp expected actual +' + +test_expect_success 'Order should not matter: "--git-dir=a.git -C c" is equivalent to "-C c --git-dir=a.git"' ' + git -C c --git-dir=a.git log -1 --format=%s >expected && + git --git-dir=a.git -C c log -1 --format=%s >actual && + test_cmp expected actual +' + +test_expect_success 'Effect on --work-tree option: "-C c/a.git --work-tree=../a" is equivalent to "--work-tree=c/a --git-dir=c/a.git"' ' + rm c/a/a.txt && + git --git-dir=c/a.git --work-tree=c/a status >expected && + git -C c/a.git --work-tree=../a status >actual && + test_cmp expected actual +' + +test_expect_success 'Order should not matter: "--work-tree=../a -C c/a.git" is equivalent to "-C c/a.git --work-tree=../a"' ' + git -C c/a.git --work-tree=../a status >expected && + git --work-tree=../a -C c/a.git status >actual && + test_cmp expected actual +' + +test_expect_success 'Effect on --git-dir and --work-tree options - "-C c --git-dir=a.git --work-tree=a" is equivalent to "--git-dir=c/a.git --work-tree=c/a"' ' + git --git-dir=c/a.git --work-tree=c/a status >expected && + git -C c --git-dir=a.git --work-tree=a status >actual && + test_cmp expected actual +' + +test_expect_success 'Order should not matter: "-C c --git-dir=a.git --work-tree=a" is equivalent to "--git-dir=a.git -C c --work-tree=a"' ' + git -C c --git-dir=a.git --work-tree=a status >expected && + git --git-dir=a.git -C c --work-tree=a status >actual && + test_cmp expected actual +' + +test_expect_success 'Order should not matter: "-C c --git-dir=a.git --work-tree=a" is equivalent to "--git-dir=a.git --work-tree=a -C c"' ' + git -C c --git-dir=a.git --work-tree=a status >expected && + git --git-dir=a.git --work-tree=a -C c status >actual && + test_cmp expected actual +' + +test_expect_success 'Relative followed by fullpath: "-C ./here -C /there" is equivalent to "-C /there"' ' + echo "initial in dir1/dir2" >expected && + git -C dir1 -C "$(pwd)/dir1/dir2" log --format=%s >actual && + test_cmp expected actual +' + +test_done diff --git a/t/t1300-repo-config.sh b/t/t1300-repo-config.sh index c23f4781e1..967359344d 100755 --- a/t/t1300-repo-config.sh +++ b/t/t1300-repo-config.sh @@ -652,16 +652,23 @@ test_expect_success numbers ' test_cmp expect actual ' +test_expect_success '--int is at least 64 bits' ' + git config giga.watts 121g && + echo 129922760704 >expect && + git config --int --get giga.watts >actual && + test_cmp expect actual +' + test_expect_success 'invalid unit' ' git config aninvalid.unit "1auto" && echo 1auto >expect && git config aninvalid.unit >actual && test_cmp expect actual && - cat > expect <<-\EOF - fatal: bad config value for '\''aninvalid.unit'\'' in .git/config + cat >expect <<-\EOF + fatal: bad numeric config value '\''1auto'\'' for '\''aninvalid.unit'\'' in .git/config: invalid unit EOF test_must_fail git config --int --get aninvalid.unit 2>actual && - test_cmp actual expect + test_i18ncmp expect actual ' cat > expect << EOF diff --git a/t/t1400-update-ref.sh b/t/t1400-update-ref.sh index e415ee0bbf..6ffd82fe32 100755 --- a/t/t1400-update-ref.sh +++ b/t/t1400-update-ref.sh @@ -302,4 +302,636 @@ test_expect_success \ '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")' +a=refs/heads/a +b=refs/heads/b +c=refs/heads/c +E='""' +F='%s\0' +pws='path with space' + +test_expect_success 'stdin test setup' ' + echo "$pws" >"$pws" && + git add -- "$pws" && + git commit -m "$pws" +' + +test_expect_success '-z fails without --stdin' ' + test_must_fail git update-ref -z $m $m $m 2>err && + grep "usage: git update-ref" err +' + +test_expect_success 'stdin works with no input' ' + >stdin && + git update-ref --stdin <stdin && + git rev-parse --verify -q $m +' + +test_expect_success 'stdin fails on empty line' ' + echo "" >stdin && + test_must_fail git update-ref --stdin <stdin 2>err && + grep "fatal: empty command in input" err +' + +test_expect_success 'stdin fails on only whitespace' ' + echo " " >stdin && + test_must_fail git update-ref --stdin <stdin 2>err && + grep "fatal: whitespace before command: " err +' + +test_expect_success 'stdin fails on leading whitespace' ' + echo " create $a $m" >stdin && + test_must_fail git update-ref --stdin <stdin 2>err && + grep "fatal: whitespace before command: create $a $m" err +' + +test_expect_success 'stdin fails on unknown command' ' + echo "unknown $a" >stdin && + test_must_fail git update-ref --stdin <stdin 2>err && + grep "fatal: unknown command: unknown $a" err +' + +test_expect_success 'stdin fails on badly quoted input' ' + echo "create $a \"master" >stdin && + test_must_fail git update-ref --stdin <stdin 2>err && + grep "fatal: badly quoted argument: \\\"master" err +' + +test_expect_success 'stdin fails on arguments not separated by space' ' + echo "create \"$a\"master" >stdin && + test_must_fail git update-ref --stdin <stdin 2>err && + grep "fatal: expected SP but got: master" err +' + +test_expect_success 'stdin fails create with no ref' ' + echo "create " >stdin && + test_must_fail git update-ref --stdin <stdin 2>err && + grep "fatal: create line missing <ref>" err +' + +test_expect_success 'stdin fails create with bad ref name' ' + echo "create ~a $m" >stdin && + test_must_fail git update-ref --stdin <stdin 2>err && + grep "fatal: invalid ref format: ~a" err +' + +test_expect_success 'stdin fails create with no new value' ' + echo "create $a" >stdin && + test_must_fail git update-ref --stdin <stdin 2>err && + grep "fatal: create $a missing <newvalue>" err +' + +test_expect_success 'stdin fails create with too many arguments' ' + echo "create $a $m $m" >stdin && + test_must_fail git update-ref --stdin <stdin 2>err && + grep "fatal: create $a has extra input: $m" err +' + +test_expect_success 'stdin fails update with no ref' ' + echo "update " >stdin && + test_must_fail git update-ref --stdin <stdin 2>err && + grep "fatal: update line missing <ref>" err +' + +test_expect_success 'stdin fails update with bad ref name' ' + echo "update ~a $m" >stdin && + test_must_fail git update-ref --stdin <stdin 2>err && + grep "fatal: invalid ref format: ~a" err +' + +test_expect_success 'stdin fails update with no new value' ' + echo "update $a" >stdin && + test_must_fail git update-ref --stdin <stdin 2>err && + grep "fatal: update $a missing <newvalue>" err +' + +test_expect_success 'stdin fails update with too many arguments' ' + echo "update $a $m $m $m" >stdin && + test_must_fail git update-ref --stdin <stdin 2>err && + grep "fatal: update $a has extra input: $m" err +' + +test_expect_success 'stdin fails delete with no ref' ' + echo "delete " >stdin && + test_must_fail git update-ref --stdin <stdin 2>err && + grep "fatal: delete line missing <ref>" err +' + +test_expect_success 'stdin fails delete with bad ref name' ' + echo "delete ~a $m" >stdin && + test_must_fail git update-ref --stdin <stdin 2>err && + grep "fatal: invalid ref format: ~a" err +' + +test_expect_success 'stdin fails delete with too many arguments' ' + echo "delete $a $m $m" >stdin && + test_must_fail git update-ref --stdin <stdin 2>err && + grep "fatal: delete $a has extra input: $m" err +' + +test_expect_success 'stdin fails verify with too many arguments' ' + echo "verify $a $m $m" >stdin && + test_must_fail git update-ref --stdin <stdin 2>err && + grep "fatal: verify $a has extra input: $m" err +' + +test_expect_success 'stdin fails option with unknown name' ' + echo "option unknown" >stdin && + test_must_fail git update-ref --stdin <stdin 2>err && + grep "fatal: option unknown: unknown" err +' + +test_expect_success 'stdin fails with duplicate refs' ' + cat >stdin <<-EOF && + create $a $m + create $b $m + create $a $m + EOF + test_must_fail git update-ref --stdin <stdin 2>err && + grep "fatal: Multiple updates for ref '"'"'$a'"'"' not allowed." err +' + +test_expect_success 'stdin create ref works' ' + echo "create $a $m" >stdin && + git update-ref --stdin <stdin && + git rev-parse $m >expect && + git rev-parse $a >actual && + test_cmp expect actual +' + +test_expect_success 'stdin update ref creates with zero old value' ' + echo "update $b $m $Z" >stdin && + git update-ref --stdin <stdin && + git rev-parse $m >expect && + git rev-parse $b >actual && + test_cmp expect actual && + git update-ref -d $b +' + +test_expect_success 'stdin update ref creates with empty old value' ' + echo "update $b $m $E" >stdin && + git update-ref --stdin <stdin && + git rev-parse $m >expect && + git rev-parse $b >actual && + test_cmp expect actual +' + +test_expect_success 'stdin create ref works with path with space to blob' ' + echo "create refs/blobs/pws \"$m:$pws\"" >stdin && + git update-ref --stdin <stdin && + git rev-parse "$m:$pws" >expect && + git rev-parse refs/blobs/pws >actual && + test_cmp expect actual && + git update-ref -d refs/blobs/pws +' + +test_expect_success 'stdin update ref fails with wrong old value' ' + echo "update $c $m $m~1" >stdin && + test_must_fail git update-ref --stdin <stdin 2>err && + grep "fatal: Cannot lock the ref '"'"'$c'"'"'" err && + test_must_fail git rev-parse --verify -q $c +' + +test_expect_success 'stdin update ref fails with bad old value' ' + echo "update $c $m does-not-exist" >stdin && + test_must_fail git update-ref --stdin <stdin 2>err && + grep "fatal: invalid old value for ref $c: does-not-exist" err && + test_must_fail git rev-parse --verify -q $c +' + +test_expect_success 'stdin create ref fails with bad new value' ' + echo "create $c does-not-exist" >stdin && + test_must_fail git update-ref --stdin <stdin 2>err && + grep "fatal: invalid new value for ref $c: does-not-exist" err && + test_must_fail git rev-parse --verify -q $c +' + +test_expect_success 'stdin create ref fails with zero new value' ' + echo "create $c " >stdin && + test_must_fail git update-ref --stdin <stdin 2>err && + grep "fatal: create $c given zero new value" err && + test_must_fail git rev-parse --verify -q $c +' + +test_expect_success 'stdin update ref works with right old value' ' + echo "update $b $m~1 $m" >stdin && + git update-ref --stdin <stdin && + git rev-parse $m~1 >expect && + git rev-parse $b >actual && + test_cmp expect actual +' + +test_expect_success 'stdin delete ref fails with wrong old value' ' + echo "delete $a $m~1" >stdin && + test_must_fail git update-ref --stdin <stdin 2>err && + grep "fatal: Cannot lock the ref '"'"'$a'"'"'" err && + git rev-parse $m >expect && + git rev-parse $a >actual && + test_cmp expect actual +' + +test_expect_success 'stdin delete ref fails with zero old value' ' + echo "delete $a " >stdin && + test_must_fail git update-ref --stdin <stdin 2>err && + grep "fatal: delete $a given zero old value" err && + git rev-parse $m >expect && + git rev-parse $a >actual && + test_cmp expect actual +' + +test_expect_success 'stdin update symref works option no-deref' ' + git symbolic-ref TESTSYMREF $b && + cat >stdin <<-EOF && + option no-deref + update TESTSYMREF $a $b + EOF + git update-ref --stdin <stdin && + git rev-parse TESTSYMREF >expect && + git rev-parse $a >actual && + test_cmp expect actual && + git rev-parse $m~1 >expect && + git rev-parse $b >actual && + test_cmp expect actual +' + +test_expect_success 'stdin delete symref works option no-deref' ' + git symbolic-ref TESTSYMREF $b && + cat >stdin <<-EOF && + option no-deref + delete TESTSYMREF $b + EOF + git update-ref --stdin <stdin && + test_must_fail git rev-parse --verify -q TESTSYMREF && + git rev-parse $m~1 >expect && + git rev-parse $b >actual && + test_cmp expect actual +' + +test_expect_success 'stdin delete ref works with right old value' ' + echo "delete $b $m~1" >stdin && + git update-ref --stdin <stdin && + test_must_fail git rev-parse --verify -q $b +' + +test_expect_success 'stdin update/create/verify combination works' ' + cat >stdin <<-EOF && + update $a $m + create $b $m + verify $c + EOF + git update-ref --stdin <stdin && + git rev-parse $m >expect && + git rev-parse $a >actual && + test_cmp expect actual && + git rev-parse $b >actual && + test_cmp expect actual && + test_must_fail git rev-parse --verify -q $c +' + +test_expect_success 'stdin update refs works with identity updates' ' + cat >stdin <<-EOF && + update $a $m $m + update $b $m $m + update $c $Z $E + EOF + git update-ref --stdin <stdin && + git rev-parse $m >expect && + git rev-parse $a >actual && + test_cmp expect actual && + git rev-parse $b >actual && + test_cmp expect actual && + test_must_fail git rev-parse --verify -q $c +' + +test_expect_success 'stdin update refs fails with wrong old value' ' + git update-ref $c $m && + cat >stdin <<-EOF && + update $a $m $m + update $b $m $m + update $c '' + EOF + test_must_fail git update-ref --stdin <stdin 2>err && + grep "fatal: Cannot lock the ref '"'"'$c'"'"'" err && + git rev-parse $m >expect && + git rev-parse $a >actual && + test_cmp expect actual && + git rev-parse $b >actual && + test_cmp expect actual && + git rev-parse $c >actual && + test_cmp expect actual +' + +test_expect_success 'stdin delete refs works with packed and loose refs' ' + git pack-refs --all && + git update-ref $c $m~1 && + cat >stdin <<-EOF && + delete $a $m + update $b $Z $m + update $c $E $m~1 + EOF + git update-ref --stdin <stdin && + test_must_fail git rev-parse --verify -q $a && + test_must_fail git rev-parse --verify -q $b && + test_must_fail git rev-parse --verify -q $c +' + +test_expect_success 'stdin -z works on empty input' ' + >stdin && + git update-ref -z --stdin <stdin && + git rev-parse --verify -q $m +' + +test_expect_success 'stdin -z fails on empty line' ' + echo "" >stdin && + test_must_fail git update-ref -z --stdin <stdin 2>err && + grep "fatal: whitespace before command: " err +' + +test_expect_success 'stdin -z fails on empty command' ' + printf $F "" >stdin && + test_must_fail git update-ref -z --stdin <stdin 2>err && + grep "fatal: empty command in input" err +' + +test_expect_success 'stdin -z fails on only whitespace' ' + printf $F " " >stdin && + test_must_fail git update-ref -z --stdin <stdin 2>err && + grep "fatal: whitespace before command: " err +' + +test_expect_success 'stdin -z fails on leading whitespace' ' + printf $F " create $a" "$m" >stdin && + test_must_fail git update-ref -z --stdin <stdin 2>err && + grep "fatal: whitespace before command: create $a" err +' + +test_expect_success 'stdin -z fails on unknown command' ' + printf $F "unknown $a" >stdin && + test_must_fail git update-ref -z --stdin <stdin 2>err && + grep "fatal: unknown command: unknown $a" err +' + +test_expect_success 'stdin -z fails create with no ref' ' + printf $F "create " >stdin && + test_must_fail git update-ref -z --stdin <stdin 2>err && + grep "fatal: create line missing <ref>" err +' + +test_expect_success 'stdin -z fails create with bad ref name' ' + printf $F "create ~a " "$m" >stdin && + test_must_fail git update-ref -z --stdin <stdin 2>err && + grep "fatal: invalid ref format: ~a " err +' + +test_expect_success 'stdin -z fails create with no new value' ' + printf $F "create $a" >stdin && + test_must_fail git update-ref -z --stdin <stdin 2>err && + grep "fatal: create $a missing <newvalue>" err +' + +test_expect_success 'stdin -z fails create with too many arguments' ' + printf $F "create $a" "$m" "$m" >stdin && + test_must_fail git update-ref -z --stdin <stdin 2>err && + grep "fatal: unknown command: $m" err +' + +test_expect_success 'stdin -z fails update with no ref' ' + printf $F "update " >stdin && + test_must_fail git update-ref -z --stdin <stdin 2>err && + grep "fatal: update line missing <ref>" err +' + +test_expect_success 'stdin -z fails update with bad ref name' ' + printf $F "update ~a" "$m" >stdin && + test_must_fail git update-ref -z --stdin <stdin 2>err && + grep "fatal: invalid ref format: ~a" err +' + +test_expect_success 'stdin -z fails update with no new value' ' + printf $F "update $a" >stdin && + test_must_fail git update-ref -z --stdin <stdin 2>err && + grep "fatal: update $a missing <newvalue>" err +' + +test_expect_success 'stdin -z fails update with no old value' ' + printf $F "update $a" "$m" >stdin && + test_must_fail git update-ref -z --stdin <stdin 2>err && + grep "fatal: update $a missing \\[<oldvalue>\\] NUL" err +' + +test_expect_success 'stdin -z fails update with too many arguments' ' + printf $F "update $a" "$m" "$m" "$m" >stdin && + test_must_fail git update-ref -z --stdin <stdin 2>err && + grep "fatal: unknown command: $m" err +' + +test_expect_success 'stdin -z fails delete with no ref' ' + printf $F "delete " >stdin && + test_must_fail git update-ref -z --stdin <stdin 2>err && + grep "fatal: delete line missing <ref>" err +' + +test_expect_success 'stdin -z fails delete with bad ref name' ' + printf $F "delete ~a" "$m" >stdin && + test_must_fail git update-ref -z --stdin <stdin 2>err && + grep "fatal: invalid ref format: ~a" err +' + +test_expect_success 'stdin -z fails delete with no old value' ' + printf $F "delete $a" >stdin && + test_must_fail git update-ref -z --stdin <stdin 2>err && + grep "fatal: delete $a missing \\[<oldvalue>\\] NUL" err +' + +test_expect_success 'stdin -z fails delete with too many arguments' ' + printf $F "delete $a" "$m" "$m" >stdin && + test_must_fail git update-ref -z --stdin <stdin 2>err && + grep "fatal: unknown command: $m" err +' + +test_expect_success 'stdin -z fails verify with too many arguments' ' + printf $F "verify $a" "$m" "$m" >stdin && + test_must_fail git update-ref -z --stdin <stdin 2>err && + grep "fatal: unknown command: $m" err +' + +test_expect_success 'stdin -z fails verify with no old value' ' + printf $F "verify $a" >stdin && + test_must_fail git update-ref -z --stdin <stdin 2>err && + grep "fatal: verify $a missing \\[<oldvalue>\\] NUL" err +' + +test_expect_success 'stdin -z fails option with unknown name' ' + printf $F "option unknown" >stdin && + test_must_fail git update-ref -z --stdin <stdin 2>err && + grep "fatal: option unknown: unknown" err +' + +test_expect_success 'stdin -z fails with duplicate refs' ' + printf $F "create $a" "$m" "create $b" "$m" "create $a" "$m" >stdin && + test_must_fail git update-ref -z --stdin <stdin 2>err && + grep "fatal: Multiple updates for ref '"'"'$a'"'"' not allowed." err +' + +test_expect_success 'stdin -z create ref works' ' + printf $F "create $a" "$m" >stdin && + git update-ref -z --stdin <stdin && + git rev-parse $m >expect && + git rev-parse $a >actual && + test_cmp expect actual +' + +test_expect_success 'stdin -z update ref creates with zero old value' ' + printf $F "update $b" "$m" "$Z" >stdin && + git update-ref -z --stdin <stdin && + git rev-parse $m >expect && + git rev-parse $b >actual && + test_cmp expect actual && + git update-ref -d $b +' + +test_expect_success 'stdin -z update ref creates with empty old value' ' + printf $F "update $b" "$m" "" >stdin && + git update-ref -z --stdin <stdin && + git rev-parse $m >expect && + git rev-parse $b >actual && + test_cmp expect actual +' + +test_expect_success 'stdin -z create ref works with path with space to blob' ' + printf $F "create refs/blobs/pws" "$m:$pws" >stdin && + git update-ref -z --stdin <stdin && + git rev-parse "$m:$pws" >expect && + git rev-parse refs/blobs/pws >actual && + test_cmp expect actual && + git update-ref -d refs/blobs/pws +' + +test_expect_success 'stdin -z update ref fails with wrong old value' ' + printf $F "update $c" "$m" "$m~1" >stdin && + test_must_fail git update-ref -z --stdin <stdin 2>err && + grep "fatal: Cannot lock the ref '"'"'$c'"'"'" err && + test_must_fail git rev-parse --verify -q $c +' + +test_expect_success 'stdin -z update ref fails with bad old value' ' + printf $F "update $c" "$m" "does-not-exist" >stdin && + test_must_fail git update-ref -z --stdin <stdin 2>err && + grep "fatal: invalid old value for ref $c: does-not-exist" err && + test_must_fail git rev-parse --verify -q $c +' + +test_expect_success 'stdin -z create ref fails with bad new value' ' + printf $F "create $c" "does-not-exist" >stdin && + test_must_fail git update-ref -z --stdin <stdin 2>err && + grep "fatal: invalid new value for ref $c: does-not-exist" err && + test_must_fail git rev-parse --verify -q $c +' + +test_expect_success 'stdin -z create ref fails with zero new value' ' + printf $F "create $c" "" >stdin && + test_must_fail git update-ref -z --stdin <stdin 2>err && + grep "fatal: create $c given zero new value" err && + test_must_fail git rev-parse --verify -q $c +' + +test_expect_success 'stdin -z update ref works with right old value' ' + printf $F "update $b" "$m~1" "$m" >stdin && + git update-ref -z --stdin <stdin && + git rev-parse $m~1 >expect && + git rev-parse $b >actual && + test_cmp expect actual +' + +test_expect_success 'stdin -z delete ref fails with wrong old value' ' + printf $F "delete $a" "$m~1" >stdin && + test_must_fail git update-ref -z --stdin <stdin 2>err && + grep "fatal: Cannot lock the ref '"'"'$a'"'"'" err && + git rev-parse $m >expect && + git rev-parse $a >actual && + test_cmp expect actual +' + +test_expect_success 'stdin -z delete ref fails with zero old value' ' + printf $F "delete $a" "$Z" >stdin && + test_must_fail git update-ref -z --stdin <stdin 2>err && + grep "fatal: delete $a given zero old value" err && + git rev-parse $m >expect && + git rev-parse $a >actual && + test_cmp expect actual +' + +test_expect_success 'stdin -z update symref works option no-deref' ' + git symbolic-ref TESTSYMREF $b && + printf $F "option no-deref" "update TESTSYMREF" "$a" "$b" >stdin && + git update-ref -z --stdin <stdin && + git rev-parse TESTSYMREF >expect && + git rev-parse $a >actual && + test_cmp expect actual && + git rev-parse $m~1 >expect && + git rev-parse $b >actual && + test_cmp expect actual +' + +test_expect_success 'stdin -z delete symref works option no-deref' ' + git symbolic-ref TESTSYMREF $b && + printf $F "option no-deref" "delete TESTSYMREF" "$b" >stdin && + git update-ref -z --stdin <stdin && + test_must_fail git rev-parse --verify -q TESTSYMREF && + git rev-parse $m~1 >expect && + git rev-parse $b >actual && + test_cmp expect actual +' + +test_expect_success 'stdin -z delete ref works with right old value' ' + printf $F "delete $b" "$m~1" >stdin && + git update-ref -z --stdin <stdin && + test_must_fail git rev-parse --verify -q $b +' + +test_expect_success 'stdin -z update/create/verify combination works' ' + printf $F "update $a" "$m" "" "create $b" "$m" "verify $c" "" >stdin && + git update-ref -z --stdin <stdin && + git rev-parse $m >expect && + git rev-parse $a >actual && + test_cmp expect actual && + git rev-parse $b >actual && + test_cmp expect actual && + test_must_fail git rev-parse --verify -q $c +' + +test_expect_success 'stdin -z update refs works with identity updates' ' + printf $F "update $a" "$m" "$m" "update $b" "$m" "$m" "update $c" "$Z" "" >stdin && + git update-ref -z --stdin <stdin && + git rev-parse $m >expect && + git rev-parse $a >actual && + test_cmp expect actual && + git rev-parse $b >actual && + test_cmp expect actual && + test_must_fail git rev-parse --verify -q $c +' + +test_expect_success 'stdin -z update refs fails with wrong old value' ' + git update-ref $c $m && + printf $F "update $a" "$m" "$m" "update $b" "$m" "$m" "update $c" "" "$Z" >stdin && + test_must_fail git update-ref -z --stdin <stdin 2>err && + grep "fatal: Cannot lock the ref '"'"'$c'"'"'" err && + git rev-parse $m >expect && + git rev-parse $a >actual && + test_cmp expect actual && + git rev-parse $b >actual && + test_cmp expect actual && + git rev-parse $c >actual && + test_cmp expect actual +' + +test_expect_success 'stdin -z delete refs works with packed and loose refs' ' + git pack-refs --all && + git update-ref $c $m~1 && + printf $F "delete $a" "$m" "update $b" "$Z" "$m" "update $c" "" "$m~1" >stdin && + git update-ref -z --stdin <stdin && + test_must_fail git rev-parse --verify -q $a && + test_must_fail git rev-parse --verify -q $b && + test_must_fail git rev-parse --verify -q $c +' + test_done diff --git a/t/t1508-at-combinations.sh b/t/t1508-at-combinations.sh index e5aea3b896..ceb844985f 100755 --- a/t/t1508-at-combinations.sh +++ b/t/t1508-at-combinations.sh @@ -32,6 +32,9 @@ test_expect_success 'setup' ' git checkout -b upstream-branch && test_commit upstream-one && test_commit upstream-two && + git checkout -b @/at-test && + git checkout -b @@/at-test && + git checkout -b @at-test && git checkout -b old-branch && test_commit old-one && test_commit old-two && @@ -55,6 +58,11 @@ check "HEAD@{u}" ref refs/heads/upstream-branch check "@{u}@{1}" commit upstream-one check "@{-1}@{u}" ref refs/heads/master check "@{-1}@{u}@{1}" commit master-one +check "@" commit new-two +check "@@{u}" ref refs/heads/upstream-branch +check "@@/at-test" ref refs/heads/@@/at-test +check "@/at-test" ref refs/heads/@/at-test +check "@at-test" ref refs/heads/@at-test nonsense "@{u}@{-1}" nonsense "@{0}@{0}" nonsense "@{1}@{u}" diff --git a/t/t1511-rev-parse-caret.sh b/t/t1511-rev-parse-caret.sh index eaefc777bd..15973f2094 100755 --- a/t/t1511-rev-parse-caret.sh +++ b/t/t1511-rev-parse-caret.sh @@ -54,6 +54,13 @@ test_expect_success 'ref^{tree}' ' test_must_fail git rev-parse blob-tag^{tree} ' +test_expect_success 'ref^{tag}' ' + test_must_fail git rev-parse HEAD^{tag} && + git rev-parse commit-tag >expected && + git rev-parse commit-tag^{tag} >actual && + test_cmp expected actual +' + test_expect_success 'ref^{/.}' ' git rev-parse master >expected && git rev-parse master^{/.} >actual && diff --git a/t/t2024-checkout-dwim.sh b/t/t2024-checkout-dwim.sh index dee55e428f..094b92ef48 100755 --- a/t/t2024-checkout-dwim.sh +++ b/t/t2024-checkout-dwim.sh @@ -104,7 +104,7 @@ test_expect_success 'setup more remotes with unconventional refspecs' ' cd repo_c && test_commit c_master && git checkout -b bar && - test_commit c_bar + test_commit c_bar && git checkout -b spam && test_commit c_spam ) && @@ -113,9 +113,9 @@ test_expect_success 'setup more remotes with unconventional refspecs' ' cd repo_d && test_commit d_master && git checkout -b baz && - test_commit f_baz + test_commit d_baz && git checkout -b eggs && - test_commit c_eggs + test_commit d_eggs ) && git remote add repo_c repo_c && git config remote.repo_c.fetch \ diff --git a/t/t3001-ls-files-others-exclude.sh b/t/t3001-ls-files-others-exclude.sh index f0421c09c7..b2798feef7 100755 --- a/t/t3001-ls-files-others-exclude.sh +++ b/t/t3001-ls-files-others-exclude.sh @@ -115,7 +115,7 @@ EOF git config core.excludesFile excludes-file -git status | grep "^# " > output +git -c status.displayCommentPrefix=true status | grep "^# " > output cat > expect << EOF # .gitignore diff --git a/t/t3010-ls-files-killed-modified.sh b/t/t3010-ls-files-killed-modified.sh index f611d799b6..6d3b828a95 100755 --- a/t/t3010-ls-files-killed-modified.sh +++ b/t/t3010-ls-files-killed-modified.sh @@ -11,6 +11,7 @@ This test prepares the following in the cache: path1 - a symlink path2/file2 - a file in a directory path3/file3 - a file in a directory + pathx/ju - a file in a directory submod1/ - a submodule submod2/ - another submodule @@ -23,6 +24,7 @@ and the following on the filesystem: path4 - a file path5 - a symlink path6/file6 - a file in a directory + pathx/ju/nk - a file in a directory to be killed submod1/ - a submodule (modified from the cache) submod2/ - a submodule (matches the cache) @@ -44,14 +46,15 @@ modified without reporting path9 and path10. submod1 is also modified. test_expect_success 'git update-index --add to add various paths.' ' date >path0 && test_ln_s_add xyzzy path1 && - mkdir path2 path3 && + mkdir path2 path3 pathx && date >path2/file2 && date >path3/file3 && + >pathx/ju && : >path7 && date >path8 && : >path9 && date >path10 && - git update-index --add -- path0 path?/file? path7 path8 path9 path10 && + git update-index --add -- path0 path?/file? pathx/ju path7 path8 path9 path10 && for i in 1 2 do git init submod$i && @@ -77,7 +80,7 @@ test_expect_success 'git ls-files -k to show killed files.' ' date >path3 && date >path5 fi && - mkdir path0 path1 path6 && + mkdir -p path0 path1 path6 pathx/ju && date >path0/file0 && date >path1/file1 && date >path6/file6 && @@ -85,16 +88,23 @@ test_expect_success 'git ls-files -k to show killed files.' ' : >path8 && : >path9 && touch path10 && - git ls-files -k >.output -' - -test_expect_success 'validate git ls-files -k output.' ' - cat >.expected <<-\EOF && + >pathx/ju/nk && + cat >.expected <<-\EOF path0/file0 path1/file1 path2 path3 + pathx/ju/nk EOF +' + +test_expect_success 'git ls-files -k output (w/o icase)' ' + git ls-files -k >.output + test_cmp .expected .output +' + +test_expect_success 'git ls-files -k output (w/ icase)' ' + git -c core.ignorecase=true ls-files -k >.output test_cmp .expected .output ' @@ -110,6 +120,7 @@ test_expect_success 'validate git ls-files -m output.' ' path3/file3 path7 path8 + pathx/ju submod1 EOF test_cmp .expected .output diff --git a/t/t3200-branch.sh b/t/t3200-branch.sh index 44ec6a45f4..0fe7647928 100755 --- a/t/t3200-branch.sh +++ b/t/t3200-branch.sh @@ -14,7 +14,8 @@ test_expect_success 'prepare a trivial repository' ' echo World >>A && git update-index --add A && git commit -m "Second commit." && - HEAD=$(git rev-parse --verify HEAD)' + HEAD=$(git rev-parse --verify HEAD) +' test_expect_success 'git branch --help should not have created a bogus branch' ' test_might_fail git branch --help </dev/null >/dev/null 2>/dev/null && @@ -319,8 +320,9 @@ test_expect_success 'test tracking setup (non-wildcard, matching)' ' test_expect_success 'tracking setup fails on non-matching refspec' ' git config remote.local.url . && - git config remote.local.fetch refs/heads/s:refs/remotes/local/s && + git config remote.local.fetch refs/heads/*:refs/remotes/local/* && (git show-ref -q refs/remotes/local/master || git fetch local) && + git config remote.local.fetch refs/heads/s:refs/remotes/local/s && test_must_fail git branch --track my5 local/master && test_must_fail git config branch.my5.remote && test_must_fail git config branch.my5.merge @@ -350,7 +352,7 @@ test_expect_success 'test overriding tracking setup via --no-track' ' test_expect_success 'no tracking without .fetch entries' ' git config branch.autosetupmerge true && git branch my6 s && - git config branch.automsetupmerge false && + git config branch.autosetupmerge false && test -z "$(git config branch.my6.remote)" && test -z "$(git config branch.my6.merge)" ' @@ -424,14 +426,14 @@ test_expect_success '--set-upstream-to fails on a non-ref' ' test_expect_success 'use --set-upstream-to modify HEAD' ' test_config branch.master.remote foo && test_config branch.master.merge foo && - git branch my12 + git branch my12 && git branch --set-upstream-to my12 && test "$(git config branch.master.remote)" = "." && test "$(git config branch.master.merge)" = "refs/heads/my12" ' test_expect_success 'use --set-upstream-to modify a particular branch' ' - git branch my13 + git branch my13 && git branch --set-upstream-to master my13 && test "$(git config branch.my13.remote)" = "." && test "$(git config branch.my13.merge)" = "refs/heads/master" @@ -442,7 +444,7 @@ test_expect_success '--unset-upstream should fail if given a non-existent branch ' test_expect_success 'test --unset-upstream on HEAD' ' - git branch my14 + git branch my14 && test_config branch.master.remote foo && test_config branch.master.merge foo && git branch --set-upstream-to my14 && @@ -464,7 +466,7 @@ test_expect_success '--unset-upstream should fail on detached HEAD' ' ' test_expect_success 'test --unset-upstream on a particular branch' ' - git branch my15 + git branch my15 && git branch --set-upstream-to master my14 && git branch --unset-upstream my14 && test_must_fail git config branch.my14.remote && @@ -870,4 +872,39 @@ test_expect_success '--merged catches invalid object names' ' test_must_fail git branch --merged 0000000000000000000000000000000000000000 ' +test_expect_success 'tracking with unexpected .fetch refspec' ' + rm -rf a b c d && + git init a && + ( + cd a && + test_commit a + ) && + git init b && + ( + cd b && + test_commit b + ) && + git init c && + ( + cd c && + test_commit c && + git remote add a ../a && + git remote add b ../b && + git fetch --all + ) && + git init d && + ( + cd d && + git remote add c ../c && + git config remote.c.fetch "+refs/remotes/*:refs/remotes/*" && + git fetch c && + git branch --track local/a/master remotes/a/master && + test "$(git config branch.local/a/master.remote)" = "c" && + test "$(git config branch.local/a/master.merge)" = "refs/remotes/a/master" && + git rev-parse --verify a >expect && + git rev-parse --verify local/a/master >actual && + test_cmp expect actual + ) +' + test_done diff --git a/t/t3404-rebase-interactive.sh b/t/t3404-rebase-interactive.sh index 4dbeddb0de..50e22b1cad 100755 --- a/t/t3404-rebase-interactive.sh +++ b/t/t3404-rebase-interactive.sh @@ -29,8 +29,6 @@ Initial setup: . "$TEST_DIRECTORY"/lib-rebase.sh -set_fake_editor - # WARNING: Modifications to the initial repository can change the SHA ID used # in the expect2 file for the 'stop on conflicting pick' test. @@ -72,6 +70,7 @@ export SHELL test_expect_success 'rebase -i with the exec command' ' git checkout master && ( + set_fake_editor && FAKE_LINES="1 exec_>touch-one 2 exec_>touch-two exec_false exec_>touch-three 3 4 exec_>\"touch-file__name_with_spaces\";_>touch-after-semicolon 5" && @@ -93,6 +92,7 @@ test_expect_success 'rebase -i with the exec command' ' test_expect_success 'rebase -i with the exec command runs from tree root' ' git checkout master && mkdir subdir && (cd subdir && + set_fake_editor && FAKE_LINES="1 exec_>touch-subdir" \ git rebase -i HEAD^ ) && @@ -103,6 +103,7 @@ test_expect_success 'rebase -i with the exec command runs from tree root' ' test_expect_success 'rebase -i with the exec command checks tree cleanness' ' git checkout master && ( + set_fake_editor && FAKE_LINES="exec_echo_foo_>file1 1" && export FAKE_LINES && test_must_fail git rebase -i HEAD^ @@ -116,6 +117,7 @@ test_expect_success 'rebase -i with exec of inexistent command' ' git checkout master && test_when_finished "git rebase --abort" && ( + set_fake_editor && FAKE_LINES="exec_this-command-does-not-exist 1" && export FAKE_LINES && test_must_fail git rebase -i HEAD^ >actual 2>&1 @@ -125,6 +127,7 @@ test_expect_success 'rebase -i with exec of inexistent command' ' test_expect_success 'no changes are a nop' ' git checkout branch2 && + set_fake_editor && git rebase -i F && test "$(git symbolic-ref -q HEAD)" = "refs/heads/branch2" && test $(git rev-parse I) = $(git rev-parse HEAD) @@ -134,6 +137,7 @@ test_expect_success 'test the [branch] option' ' git checkout -b dead-end && git rm file6 && git commit -m "stop here" && + set_fake_editor && git rebase -i F branch2 && test "$(git symbolic-ref -q HEAD)" = "refs/heads/branch2" && test $(git rev-parse I) = $(git rev-parse branch2) && @@ -142,6 +146,7 @@ test_expect_success 'test the [branch] option' ' test_expect_success 'test --onto <branch>' ' git checkout -b test-onto branch2 && + set_fake_editor && git rebase -i --onto branch1 F && test "$(git symbolic-ref -q HEAD)" = "refs/heads/test-onto" && test $(git rev-parse HEAD^) = $(git rev-parse branch1) && @@ -151,6 +156,7 @@ test_expect_success 'test --onto <branch>' ' test_expect_success 'rebase on top of a non-conflicting commit' ' git checkout branch1 && git tag original-branch1 && + set_fake_editor && git rebase -i branch2 && test file6 = $(git diff --name-only original-branch1) && test "$(git symbolic-ref -q HEAD)" = "refs/heads/branch1" && @@ -163,6 +169,7 @@ test_expect_success 'reflog for the branch shows state before rebase' ' ' test_expect_success 'exchange two commits' ' + set_fake_editor && FAKE_LINES="2 1" git rebase -i HEAD~2 && test H = $(git cat-file commit HEAD^ | sed -ne \$p) && test G = $(git cat-file commit HEAD | sed -ne \$p) @@ -188,6 +195,7 @@ EOF test_expect_success 'stop on conflicting pick' ' git tag new-branch1 && + set_fake_editor && test_must_fail git rebase -i master && test "$(git rev-parse HEAD~3)" = "$(git rev-parse master)" && test_cmp expect .git/rebase-merge/patch && @@ -208,6 +216,7 @@ test_expect_success 'abort' ' test_expect_success 'abort with error when new base cannot be checked out' ' git rm --cached file1 && git commit -m "remove file in base" && + set_fake_editor && test_must_fail git rebase -i master > output 2>&1 && grep "The following untracked working tree files would be overwritten by checkout:" \ output && @@ -222,6 +231,7 @@ test_expect_success 'retain authorship' ' test_tick && GIT_AUTHOR_NAME="Twerp Snog" git commit -m "different author" && git tag twerp && + set_fake_editor && git rebase -i --onto master HEAD^ && git show HEAD | grep "^Author: Twerp Snog" ' @@ -232,6 +242,7 @@ test_expect_success 'squash' ' test_tick && GIT_AUTHOR_NAME="Nitfol" git commit -m "nitfol" file7 && echo "******************************" && + set_fake_editor && FAKE_LINES="1 squash 2" EXPECT_HEADER_COUNT=2 \ git rebase -i --onto master HEAD~2 && test B = $(cat file7) && @@ -244,6 +255,7 @@ test_expect_success 'retain authorship when squashing' ' test_expect_success '-p handles "no changes" gracefully' ' HEAD=$(git rev-parse HEAD) && + set_fake_editor && git rebase -i -p HEAD^ && git update-index --refresh && git diff-files --quiet && @@ -253,6 +265,7 @@ test_expect_success '-p handles "no changes" gracefully' ' test_expect_failure 'exchange two commits with -p' ' git checkout H && + set_fake_editor && FAKE_LINES="2 1" git rebase -i -p HEAD~2 && test H = $(git cat-file commit HEAD^ | sed -ne \$p) && test G = $(git cat-file commit HEAD | sed -ne \$p) @@ -287,6 +300,7 @@ test_expect_success 'preserve merges with -p' ' git commit -m M file1 && git checkout -b to-be-rebased && test_tick && + set_fake_editor && git rebase -i -p --onto branch1 master && git update-index --refresh && git diff-files --quiet && @@ -301,6 +315,7 @@ test_expect_success 'preserve merges with -p' ' ' test_expect_success 'edit ancestor with -p' ' + set_fake_editor && FAKE_LINES="1 2 edit 3 4" git rebase -i -p HEAD~3 && echo 2 > unrelated-file && test_tick && @@ -314,6 +329,7 @@ test_expect_success 'edit ancestor with -p' ' test_expect_success '--continue tries to commit' ' test_tick && + set_fake_editor && test_must_fail git rebase -i --onto new-branch1 HEAD^ && echo resolved > file1 && git add file1 && @@ -325,6 +341,7 @@ test_expect_success '--continue tries to commit' ' test_expect_success 'verbose flag is heeded, even after --continue' ' git reset --hard master@{1} && test_tick && + set_fake_editor && test_must_fail git rebase -v -i --onto new-branch1 HEAD^ && echo resolved > file1 && git add file1 && @@ -334,6 +351,7 @@ test_expect_success 'verbose flag is heeded, even after --continue' ' test_expect_success 'multi-squash only fires up editor once' ' base=$(git rev-parse HEAD~4) && + set_fake_editor && FAKE_COMMIT_AMEND="ONCE" FAKE_LINES="1 squash 2 squash 3 squash 4" \ EXPECT_HEADER_COUNT=4 \ git rebase -i $base && @@ -344,6 +362,7 @@ test_expect_success 'multi-squash only fires up editor once' ' test_expect_success 'multi-fixup does not fire up editor' ' git checkout -b multi-fixup E && base=$(git rev-parse HEAD~4) && + set_fake_editor && FAKE_COMMIT_AMEND="NEVER" FAKE_LINES="1 fixup 2 fixup 3 fixup 4" \ git rebase -i $base && test $base = $(git rev-parse HEAD^) && @@ -355,6 +374,7 @@ test_expect_success 'multi-fixup does not fire up editor' ' test_expect_success 'commit message used after conflict' ' git checkout -b conflict-fixup conflict-branch && base=$(git rev-parse HEAD~4) && + set_fake_editor && ( FAKE_LINES="1 fixup 3 fixup 4" && export FAKE_LINES && @@ -373,6 +393,7 @@ test_expect_success 'commit message used after conflict' ' test_expect_success 'commit message retained after conflict' ' git checkout -b conflict-squash conflict-branch && base=$(git rev-parse HEAD~4) && + set_fake_editor && ( FAKE_LINES="1 fixup 3 squash 4" && export FAKE_LINES && @@ -399,6 +420,7 @@ EOF test_expect_success 'squash and fixup generate correct log messages' ' git checkout -b squash-fixup E && base=$(git rev-parse HEAD~4) && + set_fake_editor && FAKE_COMMIT_AMEND="ONCE" FAKE_LINES="1 fixup 2 squash 3 fixup 4" \ EXPECT_HEADER_COUNT=4 \ git rebase -i $base && @@ -411,6 +433,7 @@ test_expect_success 'squash and fixup generate correct log messages' ' test_expect_success 'squash ignores comments' ' git checkout -b skip-comments E && base=$(git rev-parse HEAD~4) && + set_fake_editor && FAKE_COMMIT_AMEND="ONCE" FAKE_LINES="# 1 # squash 2 # squash 3 # squash 4 #" \ EXPECT_HEADER_COUNT=4 \ git rebase -i $base && @@ -423,6 +446,7 @@ test_expect_success 'squash ignores comments' ' test_expect_success 'squash ignores blank lines' ' git checkout -b skip-blank-lines E && base=$(git rev-parse HEAD~4) && + set_fake_editor && FAKE_COMMIT_AMEND="ONCE" FAKE_LINES="> 1 > squash 2 > squash 3 > squash 4 >" \ EXPECT_HEADER_COUNT=4 \ git rebase -i $base && @@ -435,6 +459,7 @@ test_expect_success 'squash ignores blank lines' ' test_expect_success 'squash works as expected' ' git checkout -b squash-works no-conflict-branch && one=$(git rev-parse HEAD~3) && + set_fake_editor && FAKE_LINES="1 squash 3 2" EXPECT_HEADER_COUNT=2 \ git rebase -i HEAD~3 && test $one = $(git rev-parse HEAD~2) @@ -443,6 +468,7 @@ test_expect_success 'squash works as expected' ' test_expect_success 'interrupted squash works as expected' ' git checkout -b interrupted-squash conflict-branch && one=$(git rev-parse HEAD~3) && + set_fake_editor && ( FAKE_LINES="1 squash 3 2" && export FAKE_LINES && @@ -460,6 +486,7 @@ test_expect_success 'interrupted squash works as expected' ' test_expect_success 'interrupted squash works as expected (case 2)' ' git checkout -b interrupted-squash2 conflict-branch && one=$(git rev-parse HEAD~3) && + set_fake_editor && ( FAKE_LINES="3 squash 1 2" && export FAKE_LINES && @@ -484,6 +511,7 @@ test_expect_success '--continue tries to commit, even for "edit"' ' git commit -m "unrelated change" && parent=$(git rev-parse HEAD^) && test_tick && + set_fake_editor && FAKE_LINES="edit 1" git rebase -i HEAD^ && echo edited > file7 && git add file7 && @@ -496,6 +524,7 @@ test_expect_success '--continue tries to commit, even for "edit"' ' test_expect_success 'aborted --continue does not squash commits after "edit"' ' old=$(git rev-parse HEAD) && test_tick && + set_fake_editor && FAKE_LINES="edit 1" git rebase -i HEAD^ && echo "edited again" > file7 && git add file7 && @@ -510,6 +539,7 @@ test_expect_success 'aborted --continue does not squash commits after "edit"' ' test_expect_success 'auto-amend only edited commits after "edit"' ' test_tick && + set_fake_editor && FAKE_LINES="edit 1" git rebase -i HEAD^ && echo "edited again" > file7 && git add file7 && @@ -528,6 +558,7 @@ test_expect_success 'auto-amend only edited commits after "edit"' ' test_expect_success 'clean error after failed "exec"' ' test_tick && test_when_finished "git rebase --abort || :" && + set_fake_editor && ( FAKE_LINES="1 exec_false" && export FAKE_LINES && @@ -543,6 +574,7 @@ test_expect_success 'rebase a detached HEAD' ' grandparent=$(git rev-parse HEAD~2) && git checkout $(git rev-parse HEAD) && test_tick && + set_fake_editor && FAKE_LINES="2 1" git rebase -i HEAD~2 && test $grandparent = $(git rev-parse HEAD~2) ' @@ -559,6 +591,7 @@ test_expect_success 'rebase a commit violating pre-commit' ' test_must_fail git commit -m doesnt-verify file1 && git commit -m doesnt-verify --no-verify file1 && test_tick && + set_fake_editor && FAKE_LINES=2 git rebase -i HEAD~2 ' @@ -580,6 +613,7 @@ test_expect_success 'rebase with a file named HEAD in worktree' ' git commit -m "Add body" ) && + set_fake_editor && FAKE_LINES="1 squash 2" git rebase -i to-be-rebased && test "$(git show -s --pretty=format:%an)" = "Squashed Away" @@ -591,6 +625,7 @@ test_expect_success 'do "noop" when there is nothing to cherry-pick' ' GIT_EDITOR=: git commit --amend \ --author="Somebody else <somebody@else.com>" && test $(git rev-parse branch3) != $(git rev-parse branch4) && + set_fake_editor && git rebase -i branch3 && test $(git rev-parse branch3) = $(git rev-parse branch4) @@ -615,10 +650,12 @@ test_expect_success 'submodule rebase setup' ' git commit -a -m "submodule second" ) && test_tick && + set_fake_editor && git commit -a -m "Three changes submodule" ' test_expect_success 'submodule rebase -i' ' + set_fake_editor && FAKE_LINES="1 squash 2 3" git rebase -i A ' @@ -636,6 +673,7 @@ test_expect_success 'submodule conflict setup' ' ' test_expect_success 'rebase -i continue with only submodule staged' ' + set_fake_editor && test_must_fail git rebase -i submodule-base && git add sub && git rebase --continue && @@ -645,6 +683,7 @@ test_expect_success 'rebase -i continue with only submodule staged' ' test_expect_success 'rebase -i continue with unstaged submodule' ' git checkout submodule-topic && git reset --hard && + set_fake_editor && test_must_fail git rebase -i submodule-base && git reset && git rebase --continue && @@ -657,6 +696,7 @@ test_expect_success 'avoid unnecessary reset' ' test-chmtime =123456789 file3 && git update-index --refresh && HEAD=$(git rev-parse HEAD) && + set_fake_editor && git rebase -i HEAD~4 && test $HEAD = $(git rev-parse HEAD) && MTIME=$(test-chmtime -v +0 file3 | sed 's/[^0-9].*$//') && @@ -665,6 +705,7 @@ test_expect_success 'avoid unnecessary reset' ' test_expect_success 'reword' ' git checkout -b reword-branch master && + set_fake_editor && FAKE_LINES="1 2 3 reword 4" FAKE_COMMIT_MESSAGE="E changed" git rebase -i A && git show HEAD | grep "E changed" && test $(git rev-parse master) != $(git rev-parse HEAD) && @@ -684,6 +725,7 @@ test_expect_success 'rebase -i can copy notes' ' test_commit n2 && test_commit n3 && git notes add -m"a note" n3 && + set_fake_editor && git rebase -i --onto n1 n2 && test "a note" = "$(git notes show HEAD)" ' @@ -697,6 +739,7 @@ EOF test_expect_success 'rebase -i can copy notes over a fixup' ' git reset --hard n3 && git notes add -m"an earlier note" n2 && + set_fake_editor && GIT_NOTES_REWRITE_MODE=concatenate FAKE_LINES="1 fixup 2" git rebase -i n1 && git notes show > output && test_cmp expect output @@ -706,6 +749,7 @@ test_expect_success 'rebase while detaching HEAD' ' git symbolic-ref HEAD && grandparent=$(git rev-parse HEAD~2) && test_tick && + set_fake_editor && FAKE_LINES="2 1" git rebase -i HEAD~2 HEAD^0 && test $grandparent = $(git rev-parse HEAD~2) && test_must_fail git symbolic-ref HEAD @@ -715,6 +759,7 @@ test_tick # Ensure that the rebased commits get a different timestamp. test_expect_success 'always cherry-pick with --no-ff' ' git checkout no-ff-branch && git tag original-no-ff-branch && + set_fake_editor && git rebase -i --no-ff A && touch empty && for p in 0 1 2 @@ -747,6 +792,7 @@ test_expect_success 'set up commits with funny messages' ' test_expect_success 'rebase-i history with funny messages' ' git rev-list A..funny >expect && test_tick && + set_fake_editor && FAKE_LINES="1 2 3 4" git rebase -i A && git rev-list A.. >actual && test_cmp expect actual @@ -763,6 +809,7 @@ test_expect_success 'prepare for rebase -i --exec' ' test_expect_success 'running "git rebase -i --exec git show HEAD"' ' + set_fake_editor && git rebase -i --exec "git show HEAD" HEAD~2 >actual && ( FAKE_LINES="1 exec_git_show_HEAD 2 exec_git_show_HEAD" && @@ -776,6 +823,7 @@ test_expect_success 'running "git rebase -i --exec git show HEAD"' ' test_expect_success 'running "git rebase --exec git show HEAD -i"' ' git reset --hard execute && + set_fake_editor && git rebase --exec "git show HEAD" -i HEAD~2 >actual && ( FAKE_LINES="1 exec_git_show_HEAD 2 exec_git_show_HEAD" && @@ -789,6 +837,7 @@ test_expect_success 'running "git rebase --exec git show HEAD -i"' ' test_expect_success 'running "git rebase -ix git show HEAD"' ' git reset --hard execute && + set_fake_editor && git rebase -ix "git show HEAD" HEAD~2 >actual && ( FAKE_LINES="1 exec_git_show_HEAD 2 exec_git_show_HEAD" && @@ -802,6 +851,7 @@ test_expect_success 'running "git rebase -ix git show HEAD"' ' test_expect_success 'rebase -ix with several <CMD>' ' git reset --hard execute && + set_fake_editor && git rebase -ix "git show HEAD; pwd" HEAD~2 >actual && ( FAKE_LINES="1 exec_git_show_HEAD;_pwd 2 exec_git_show_HEAD;_pwd" && @@ -815,6 +865,7 @@ test_expect_success 'rebase -ix with several <CMD>' ' test_expect_success 'rebase -ix with several instances of --exec' ' git reset --hard execute && + set_fake_editor && git rebase -i --exec "git show HEAD" --exec "pwd" HEAD~2 >actual && ( FAKE_LINES="1 exec_git_show_HEAD exec_pwd 2 @@ -836,6 +887,7 @@ test_expect_success 'rebase -ix with --autosquash' ' echo bis >bis.txt && git add bis.txt && git commit -m "fixup! two_exec" && + set_fake_editor && ( git checkout -b autosquash_actual && git rebase -i --exec "git show HEAD" --autosquash HEAD~4 >actual @@ -854,6 +906,7 @@ test_expect_success 'rebase -ix with --autosquash' ' test_expect_success 'rebase --exec without -i shows error message' ' git reset --hard execute && + set_fake_editor && test_must_fail git rebase --exec "git show HEAD" HEAD~2 2>actual && echo "The --exec option must be used with the --interactive option" >expected && test_i18ncmp expected actual @@ -862,6 +915,7 @@ test_expect_success 'rebase --exec without -i shows error message' ' test_expect_success 'rebase -i --exec without <CMD>' ' git reset --hard execute && + set_fake_editor && test_must_fail git rebase -i --exec 2>tmp && sed -e "1d" tmp >actual && test_must_fail git rebase -h >expected && @@ -871,6 +925,7 @@ test_expect_success 'rebase -i --exec without <CMD>' ' test_expect_success 'rebase -i --root re-order and drop commits' ' git checkout E && + set_fake_editor && FAKE_LINES="3 1 2 5" git rebase -i --root && test E = $(git cat-file commit HEAD | sed -ne \$p) && test B = $(git cat-file commit HEAD^ | sed -ne \$p) && @@ -884,6 +939,7 @@ test_expect_success 'rebase -i --root retain root commit author and message' ' echo B >file7 && git add file7 && GIT_AUTHOR_NAME="Twerp Snog" git commit -m "different author" && + set_fake_editor && FAKE_LINES="2" git rebase -i --root && git cat-file commit HEAD | grep -q "^author Twerp Snog" && git cat-file commit HEAD | grep -q "^different author$" @@ -892,6 +948,7 @@ test_expect_success 'rebase -i --root retain root commit author and message' ' test_expect_success 'rebase -i --root temporary sentinel commit' ' git checkout B && ( + set_fake_editor && FAKE_LINES="2" && export FAKE_LINES && test_must_fail git rebase -i --root @@ -902,6 +959,7 @@ test_expect_success 'rebase -i --root temporary sentinel commit' ' test_expect_success 'rebase -i --root fixup root commit' ' git checkout B && + set_fake_editor && FAKE_LINES="1 fixup 2" git rebase -i --root && test A = $(git cat-file commit HEAD | sed -ne \$p) && test B = $(git show HEAD:file1) && @@ -911,6 +969,7 @@ test_expect_success 'rebase -i --root fixup root commit' ' test_expect_success 'rebase --edit-todo does not works on non-interactive rebase' ' git reset --hard && git checkout conflict-branch && + set_fake_editor && test_must_fail git rebase --onto HEAD~2 HEAD~ && test_must_fail git rebase --edit-todo && git rebase --abort @@ -919,6 +978,7 @@ test_expect_success 'rebase --edit-todo does not works on non-interactive rebase test_expect_success 'rebase --edit-todo can be used to modify todo' ' git reset --hard && git checkout no-conflict-branch^0 && + set_fake_editor && FAKE_LINES="edit 1 2 3" git rebase -i HEAD~3 && FAKE_LINES="2 1" git rebase --edit-todo && git rebase --continue @@ -929,6 +989,7 @@ test_expect_success 'rebase --edit-todo can be used to modify todo' ' test_expect_success 'rebase -i produces readable reflog' ' git reset --hard && git branch -f branch-reflog-test H && + set_fake_editor && git rebase -i --onto I F branch-reflog-test && cat >expect <<-\EOF && rebase -i (start): checkout I @@ -989,4 +1050,28 @@ test_expect_success 'rebase -i error on commits with \ in message' ' test_expect_code 1 grep " emp" error ' +test_expect_success 'short SHA-1 setup' ' + test_when_finished "git checkout master" && + git checkout --orphan collide && + git rm -rf . && + ( + unset test_tick && + test_commit collide1 collide && + test_commit --notick collide2 collide && + test_commit --notick collide3 collide + ) +' + +test_expect_success 'short SHA-1 collide' ' + test_when_finished "reset_rebase && git checkout master" && + git checkout collide && + ( + unset test_tick && + test_tick && + set_fake_editor && + FAKE_COMMIT_MESSAGE="collide2 ac4f2ee" \ + FAKE_LINES="reword 1 2" git rebase -i HEAD~2 + ) +' + test_done diff --git a/t/t3409-rebase-preserve-merges.sh b/t/t3409-rebase-preserve-merges.sh index 2e0c36415f..8c251c57a6 100755 --- a/t/t3409-rebase-preserve-merges.sh +++ b/t/t3409-rebase-preserve-merges.sh @@ -28,6 +28,8 @@ export GIT_AUTHOR_EMAIL # \--A3 <-- topic2 # \ # B2 <-- origin/topic +# +# Clone 4 (same as Clone 3) test_expect_success 'setup for merge-preserving rebase' \ 'echo First > A && @@ -64,6 +66,16 @@ test_expect_success 'setup for merge-preserving rebase' \ git merge --no-ff topic2 ) && + git clone ./. clone4 && + ( + cd clone4 && + git checkout -b topic2 origin/topic && + echo Sixth > A && + git commit -a -m "Modify A3" && + git checkout -b topic origin/topic && + git merge --no-ff topic2 + ) && + git checkout topic && echo Fourth >> B && git commit -a -m "Modify B2" @@ -96,4 +108,15 @@ test_expect_success 'rebase -p preserves no-ff merges' ' ) ' +test_expect_success 'rebase -p ignores merge.log config' ' + ( + cd clone4 && + git fetch && + git -c merge.log=1 rebase -p origin/topic && + echo >expected && + git log --format="%b" -1 >current && + test_cmp expected current + ) +' + test_done diff --git a/t/t3501-revert-cherry-pick.sh b/t/t3501-revert-cherry-pick.sh index 6f489e20ee..bff6ffe088 100755 --- a/t/t3501-revert-cherry-pick.sh +++ b/t/t3501-revert-cherry-pick.sh @@ -100,7 +100,7 @@ test_expect_success 'revert forbidden on dirty working tree' ' ' -test_expect_success 'chery-pick on unborn branch' ' +test_expect_success 'cherry-pick on unborn branch' ' git checkout --orphan unborn && git rm --cached -r . && rm -rf * && @@ -109,4 +109,24 @@ test_expect_success 'chery-pick on unborn branch' ' ! test_cmp_rev initial HEAD ' +test_expect_success 'cherry-pick "-" to pick from previous branch' ' + git checkout unborn && + test_commit to-pick actual content && + git checkout master && + git cherry-pick - && + echo content >expect && + test_cmp expect actual +' + +test_expect_success 'cherry-pick "-" is meaningless without checkout' ' + test_create_repo afresh && + ( + cd afresh && + test_commit one && + test_commit two && + test_commit three && + test_must_fail git cherry-pick - + ) +' + test_done diff --git a/t/t3506-cherry-pick-ff.sh b/t/t3506-cherry-pick-ff.sh index 373aad623c..fb889ac6f0 100755 --- a/t/t3506-cherry-pick-ff.sh +++ b/t/t3506-cherry-pick-ff.sh @@ -105,7 +105,7 @@ test_expect_success 'cherry pick a root commit with --ff' ' test "$(git rev-parse --verify HEAD)" = "1df192cd8bc58a2b275d842cede4d221ad9000d1" ' -test_expect_success 'chery-pick --ff on unborn branch' ' +test_expect_success 'cherry-pick --ff on unborn branch' ' git checkout --orphan unborn && git rm --cached -r . && rm -rf * && diff --git a/t/t3509-cherry-pick-merge-df.sh b/t/t3509-cherry-pick-merge-df.sh index a5b6a5f331..1e5b3948df 100755 --- a/t/t3509-cherry-pick-merge-df.sh +++ b/t/t3509-cherry-pick-merge-df.sh @@ -74,7 +74,7 @@ test_expect_success 'Setup rename with file on one side matching different dirna echo content > sub/file && echo foo > othersub/whatever && git add -A && - git commit -m "Common commmit" && + git commit -m "Common commit" && git rm -rf othersub && git mv sub/file othersub && diff --git a/t/t3701-add-interactive.sh b/t/t3701-add-interactive.sh index 9fab25cc96..9dc91d09d7 100755 --- a/t/t3701-add-interactive.sh +++ b/t/t3701-add-interactive.sh @@ -4,18 +4,24 @@ test_description='add -i basic tests' . ./test-lib.sh . "$TEST_DIRECTORY"/lib-prereq-FILEMODE.sh -test_expect_success PERL 'setup (initial)' ' +if ! test_have_prereq PERL +then + skip_all='skipping add -i tests, perl not available' + test_done +fi + +test_expect_success 'setup (initial)' ' echo content >file && git add file && echo more >>file && echo lines >>file ' -test_expect_success PERL 'status works (initial)' ' +test_expect_success 'status works (initial)' ' git add -i </dev/null >output && grep "+1/-0 *+2/-0 file" output ' -test_expect_success PERL 'setup expected' ' +test_expect_success 'setup expected' ' cat >expected <<EOF new file mode 100644 index 0000000..d95f3ad @@ -26,19 +32,19 @@ index 0000000..d95f3ad EOF ' -test_expect_success PERL 'diff works (initial)' ' +test_expect_success 'diff works (initial)' ' (echo d; echo 1) | git add -i >output && sed -ne "/new file/,/content/p" <output >diff && test_cmp expected diff ' -test_expect_success PERL 'revert works (initial)' ' +test_expect_success 'revert works (initial)' ' git add file && (echo r; echo 1) | git add -i && git ls-files >output && ! grep . output ' -test_expect_success PERL 'setup (commit)' ' +test_expect_success 'setup (commit)' ' echo baseline >file && git add file && git commit -m commit && @@ -47,12 +53,12 @@ test_expect_success PERL 'setup (commit)' ' echo more >>file && echo lines >>file ' -test_expect_success PERL 'status works (commit)' ' +test_expect_success 'status works (commit)' ' git add -i </dev/null >output && grep "+1/-0 *+2/-0 file" output ' -test_expect_success PERL 'setup expected' ' +test_expect_success 'setup expected' ' cat >expected <<EOF index 180b47c..b6f2c08 100644 --- a/file @@ -63,12 +69,12 @@ index 180b47c..b6f2c08 100644 EOF ' -test_expect_success PERL 'diff works (commit)' ' +test_expect_success 'diff works (commit)' ' (echo d; echo 1) | git add -i >output && sed -ne "/^index/,/content/p" <output >diff && test_cmp expected diff ' -test_expect_success PERL 'revert works (commit)' ' +test_expect_success 'revert works (commit)' ' git add file && (echo r; echo 1) | git add -i && git add -i </dev/null >output && @@ -76,24 +82,24 @@ test_expect_success PERL 'revert works (commit)' ' ' -test_expect_success PERL 'setup expected' ' +test_expect_success 'setup expected' ' cat >expected <<EOF EOF ' -test_expect_success PERL 'setup fake editor' ' +test_expect_success 'setup fake editor' ' >fake_editor.sh && chmod a+x fake_editor.sh && test_set_editor "$(pwd)/fake_editor.sh" ' -test_expect_success PERL 'dummy edit works' ' +test_expect_success 'dummy edit works' ' (echo e; echo a) | git add -p && git diff > diff && test_cmp expected diff ' -test_expect_success PERL 'setup patch' ' +test_expect_success 'setup patch' ' cat >patch <<EOF @@ -1,1 +1,4 @@ this @@ -103,7 +109,7 @@ cat >patch <<EOF EOF ' -test_expect_success PERL 'setup fake editor' ' +test_expect_success 'setup fake editor' ' echo "#!$SHELL_PATH" >fake_editor.sh && cat >>fake_editor.sh <<\EOF && mv -f "$1" oldpatch && @@ -113,26 +119,26 @@ EOF test_set_editor "$(pwd)/fake_editor.sh" ' -test_expect_success PERL 'bad edit rejected' ' +test_expect_success 'bad edit rejected' ' git reset && (echo e; echo n; echo d) | git add -p >output && grep "hunk does not apply" output ' -test_expect_success PERL 'setup patch' ' +test_expect_success 'setup patch' ' cat >patch <<EOF this patch is garbage EOF ' -test_expect_success PERL 'garbage edit rejected' ' +test_expect_success 'garbage edit rejected' ' git reset && (echo e; echo n; echo d) | git add -p >output && grep "hunk does not apply" output ' -test_expect_success PERL 'setup patch' ' +test_expect_success 'setup patch' ' cat >patch <<EOF @@ -1,0 +1,0 @@ baseline @@ -142,7 +148,7 @@ cat >patch <<EOF EOF ' -test_expect_success PERL 'setup expected' ' +test_expect_success 'setup expected' ' cat >expected <<EOF diff --git a/file b/file index b5dd6c9..f910ae9 100644 @@ -157,13 +163,13 @@ index b5dd6c9..f910ae9 100644 EOF ' -test_expect_success PERL 'real edit works' ' +test_expect_success 'real edit works' ' (echo e; echo n; echo d) | git add -p && git diff >output && test_cmp expected output ' -test_expect_success PERL 'skip files similarly as commit -a' ' +test_expect_success 'skip files similarly as commit -a' ' git reset && echo file >.gitignore && echo changed >file && @@ -177,7 +183,7 @@ test_expect_success PERL 'skip files similarly as commit -a' ' ' rm -f .gitignore -test_expect_success PERL,FILEMODE 'patch does not affect mode' ' +test_expect_success FILEMODE 'patch does not affect mode' ' git reset --hard && echo content >>file && chmod +x file && @@ -186,7 +192,7 @@ test_expect_success PERL,FILEMODE 'patch does not affect mode' ' git diff file | grep "new mode" ' -test_expect_success PERL,FILEMODE 'stage mode but not hunk' ' +test_expect_success FILEMODE 'stage mode but not hunk' ' git reset --hard && echo content >>file && chmod +x file && @@ -196,7 +202,7 @@ test_expect_success PERL,FILEMODE 'stage mode but not hunk' ' ' -test_expect_success PERL,FILEMODE 'stage mode and hunk' ' +test_expect_success FILEMODE 'stage mode and hunk' ' git reset --hard && echo content >>file && chmod +x file && @@ -208,14 +214,14 @@ test_expect_success PERL,FILEMODE 'stage mode and hunk' ' # end of tests disabled when filemode is not usable -test_expect_success PERL 'setup again' ' +test_expect_success 'setup again' ' git reset --hard && test_chmod +x file && echo content >>file ' # Write the patch file with a new line at the top and bottom -test_expect_success PERL 'setup patch' ' +test_expect_success 'setup patch' ' cat >patch <<EOF index 180b47c..b6f2c08 100644 --- a/file @@ -229,7 +235,7 @@ EOF ' # Expected output, similar to the patch but w/ diff at the top -test_expect_success PERL 'setup expected' ' +test_expect_success 'setup expected' ' cat >expected <<EOF diff --git a/file b/file index b6f2c08..61b9053 100755 @@ -244,7 +250,7 @@ EOF ' # Test splitting the first patch, then adding both -test_expect_success PERL 'add first line works' ' +test_expect_success 'add first line works' ' git commit -am "clear local changes" && git apply patch && (echo s; echo y; echo y) | git add -p file && @@ -252,7 +258,7 @@ test_expect_success PERL 'add first line works' ' test_cmp expected diff ' -test_expect_success PERL 'setup expected' ' +test_expect_success 'setup expected' ' cat >expected <<EOF diff --git a/non-empty b/non-empty deleted file mode 100644 @@ -264,7 +270,7 @@ index d95f3ad..0000000 EOF ' -test_expect_success PERL 'deleting a non-empty file' ' +test_expect_success 'deleting a non-empty file' ' git reset --hard && echo content >non-empty && git add non-empty && @@ -275,7 +281,7 @@ test_expect_success PERL 'deleting a non-empty file' ' test_cmp expected diff ' -test_expect_success PERL 'setup expected' ' +test_expect_success 'setup expected' ' cat >expected <<EOF diff --git a/empty b/empty deleted file mode 100644 @@ -283,7 +289,7 @@ index e69de29..0000000 EOF ' -test_expect_success PERL 'deleting an empty file' ' +test_expect_success 'deleting an empty file' ' git reset --hard && > empty && git add empty && @@ -294,7 +300,7 @@ test_expect_success PERL 'deleting an empty file' ' test_cmp expected diff ' -test_expect_success PERL 'split hunk setup' ' +test_expect_success 'split hunk setup' ' git reset --hard && for i in 10 20 30 40 50 60 do @@ -310,7 +316,7 @@ test_expect_success PERL 'split hunk setup' ' done >test ' -test_expect_success PERL 'split hunk "add -p (edit)"' ' +test_expect_success 'split hunk "add -p (edit)"' ' # Split, say Edit and do nothing. Then: # # 1. Broken version results in a patch that does not apply and diff --git a/t/t3910-mac-os-precompose.sh b/t/t3910-mac-os-precompose.sh index 5fe57c5438..e4ba6013e4 100755 --- a/t/t3910-mac-os-precompose.sh +++ b/t/t3910-mac-os-precompose.sh @@ -36,7 +36,7 @@ Alongc=$Alongc$AEligatu$AEligatu #254 Byte test_expect_success "detect if nfd needed" ' precomposeunicode=`git config core.precomposeunicode` && - test "$precomposeunicode" = false && + test "$precomposeunicode" = true && git config core.precomposeunicode true ' test_expect_success "setup" ' diff --git a/t/t4055-diff-context.sh b/t/t4055-diff-context.sh index 97172b46b2..cd0454356a 100755 --- a/t/t4055-diff-context.sh +++ b/t/t4055-diff-context.sh @@ -73,7 +73,7 @@ test_expect_success 'plumbing not affected' ' test_expect_success 'non-integer config parsing' ' git config diff.context no && test_must_fail git diff 2>output && - test_i18ngrep "bad config value" output + test_i18ngrep "bad numeric config value" output ' test_expect_success 'negative integer config parsing' ' diff --git a/t/t4201-shortlog.sh b/t/t4201-shortlog.sh index 5493500ef1..42866992cf 100755 --- a/t/t4201-shortlog.sh +++ b/t/t4201-shortlog.sh @@ -172,4 +172,20 @@ test_expect_success 'shortlog encoding' ' git shortlog HEAD~2.. > out && test_cmp expect out' +test_expect_success 'shortlog ignores commits with missing authors' ' + git commit --allow-empty -m normal && + git commit --allow-empty -m soon-to-be-broken && + git cat-file commit HEAD >commit.tmp && + sed "/^author/d" commit.tmp >broken.tmp && + commit=$(git hash-object -w -t commit --stdin <broken.tmp) && + git update-ref HEAD $commit && + cat >expect <<-\EOF && + A U Thor (1): + normal + + EOF + git shortlog HEAD~2.. >actual && + test_cmp expect actual +' + test_done diff --git a/t/t4203-mailmap.sh b/t/t4203-mailmap.sh index ce3eace065..0dd8b65d7c 100755 --- a/t/t4203-mailmap.sh +++ b/t/t4203-mailmap.sh @@ -484,4 +484,15 @@ test_expect_success 'Blame output (complex mapping)' ' test_cmp expect actual.fuzz ' +cat >expect <<\EOF +Some Dude <some@dude.xx> +EOF + +test_expect_success 'commit --author honors mailmap' ' + test_must_fail git commit --author "nick" --allow-empty -meight && + git commit --author "Some Dude" --allow-empty -meight && + git show --pretty=format:"%an <%ae>%n" >actual && + test_cmp expect actual +' + test_done diff --git a/t/t5308-pack-detect-duplicates.sh b/t/t5308-pack-detect-duplicates.sh new file mode 100755 index 0000000000..9c5a8766ab --- /dev/null +++ b/t/t5308-pack-detect-duplicates.sh @@ -0,0 +1,80 @@ +#!/bin/sh + +test_description='handling of duplicate objects in incoming packfiles' +. ./test-lib.sh +. "$TEST_DIRECTORY"/lib-pack.sh + +# The sha1s we have in our pack. It's important that these have the same +# starting byte, so that they end up in the same fanout section of the index. +# That lets us make sure we are exercising the binary search with both sets. +LO_SHA1=e68fe8129b546b101aee9510c5328e7f21ca1d18 +HI_SHA1=e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 + +# And here's a "missing sha1" which will produce failed lookups. It must also +# be in the same fanout section, and should be between the two (so that during +# our binary search, we are sure to end up looking at one or the other of the +# duplicate runs). +MISSING_SHA1='e69d000000000000000000000000000000000000' + +# git will never intentionally create packfiles with +# duplicate objects, so we have to construct them by hand. +# +# $1 is the name of the packfile to create +# +# $2 is the number of times to duplicate each object +create_pack () { + pack_header "$((2 * $2))" >"$1" && + for i in $(test_seq 1 "$2"); do + pack_obj $LO_SHA1 && + pack_obj $HI_SHA1 + done >>"$1" && + pack_trailer "$1" +} + +# double-check that create_pack actually works +test_expect_success 'pack with no duplicates' ' + create_pack no-dups.pack 1 && + git index-pack --stdin <no-dups.pack +' + +test_expect_success 'index-pack will allow duplicate objects by default' ' + clear_packs && + create_pack dups.pack 100 && + git index-pack --stdin <dups.pack +' + +test_expect_success 'create batch-check test vectors' ' + cat >input <<-EOF && + $LO_SHA1 + $HI_SHA1 + $MISSING_SHA1 + EOF + cat >expect <<-EOF + $LO_SHA1 blob 2 + $HI_SHA1 blob 0 + $MISSING_SHA1 missing + EOF +' + +test_expect_success 'lookup in duplicated pack (binary search)' ' + git cat-file --batch-check <input >actual && + test_cmp expect actual +' + +test_expect_success 'lookup in duplicated pack (GIT_USE_LOOKUP)' ' + ( + GIT_USE_LOOKUP=1 && + export GIT_USE_LOOKUP && + git cat-file --batch-check <input >actual + ) && + test_cmp expect actual +' + +test_expect_success 'index-pack can reject packs with duplicates' ' + clear_packs && + create_pack dups.pack 2 && + test_must_fail git index-pack --strict --stdin <dups.pack && + test_expect_code 1 git cat-file -e $LO_SHA1 +' + +test_done diff --git a/t/t5309-pack-delta-cycles.sh b/t/t5309-pack-delta-cycles.sh new file mode 100755 index 0000000000..3e7861b075 --- /dev/null +++ b/t/t5309-pack-delta-cycles.sh @@ -0,0 +1,77 @@ +#!/bin/sh + +test_description='test index-pack handling of delta cycles in packfiles' +. ./test-lib.sh +. "$TEST_DIRECTORY"/lib-pack.sh + +# Two similar-ish objects that we have computed deltas between. +A=01d7713666f4de822776c7622c10f1b07de280dc +B=e68fe8129b546b101aee9510c5328e7f21ca1d18 + +# double-check our hand-constucted packs +test_expect_success 'index-pack works with a single delta (A->B)' ' + clear_packs && + { + pack_header 2 && + pack_obj $A $B && + pack_obj $B + } >ab.pack && + pack_trailer ab.pack && + git index-pack --stdin <ab.pack && + git cat-file -t $A && + git cat-file -t $B +' + +test_expect_success 'index-pack works with a single delta (B->A)' ' + clear_packs && + { + pack_header 2 && + pack_obj $A && + pack_obj $B $A + } >ba.pack && + pack_trailer ba.pack && + git index-pack --stdin <ba.pack && + git cat-file -t $A && + git cat-file -t $B +' + +test_expect_success 'index-pack detects missing base objects' ' + clear_packs && + { + pack_header 1 && + pack_obj $A $B + } >missing.pack && + pack_trailer missing.pack && + test_must_fail git index-pack --fix-thin --stdin <missing.pack +' + +test_expect_success 'index-pack detects REF_DELTA cycles' ' + clear_packs && + { + pack_header 2 && + pack_obj $A $B && + pack_obj $B $A + } >cycle.pack && + pack_trailer cycle.pack && + test_must_fail git index-pack --fix-thin --stdin <cycle.pack +' + +test_expect_failure 'failover to an object in another pack' ' + clear_packs && + git index-pack --stdin <ab.pack && + git index-pack --stdin --fix-thin <cycle.pack +' + +test_expect_failure 'failover to a duplicate object in the same pack' ' + clear_packs && + { + pack_header 3 && + pack_obj $A $B && + pack_obj $B $A && + pack_obj $A + } >recoverable.pack && + pack_trailer recoverable.pack && + git index-pack --fix-thin --stdin <recoverable.pack +' + +test_done diff --git a/t/t5500-fetch-pack.sh b/t/t5500-fetch-pack.sh index a80584ea0e..d87ddf73b7 100755 --- a/t/t5500-fetch-pack.sh +++ b/t/t5500-fetch-pack.sh @@ -393,6 +393,17 @@ test_expect_success 'fetch in shallow repo unreachable shallow objects' ' git fsck --no-dangling ) ' +test_expect_success 'fetch creating new shallow root' ' + ( + git clone "file://$(pwd)/." shallow10 && + git commit --allow-empty -m empty && + cd shallow10 && + git fetch --depth=1 --progress 2>actual && + # This should fetch only the empty commit, no tree or + # blob objects + grep "remote: Total 1" actual + ) +' test_expect_success 'setup tests for the --stdin parameter' ' for head in C D E F diff --git a/t/t5516-fetch-push.sh b/t/t5516-fetch-push.sh index 4691d51b8c..99c32d7539 100755 --- a/t/t5516-fetch-push.sh +++ b/t/t5516-fetch-push.sh @@ -1172,4 +1172,21 @@ test_expect_success 'push --follow-tag only pushes relevant tags' ' test_cmp expect actual ' +test_expect_success 'push --no-thin must produce non-thin pack' ' + cat >>path1 <<\EOF && +keep base version of path1 big enough, compared to the new changes +later, in order to pass size heuristics in +builtin/pack-objects.c:try_delta() +EOF + git commit -am initial && + git init no-thin && + git --git-dir=no-thin/.git config receive.unpacklimit 0 && + git push no-thin/.git refs/heads/master:refs/heads/foo && + echo modified >> path1 && + git commit -am modified && + git repack -adf && + rcvpck="git receive-pack --reject-thin-pack-for-testing" && + git push --no-thin --receive-pack="$rcvpck" no-thin/.git refs/heads/master:refs/heads/foo +' + test_done diff --git a/t/t5520-pull.sh b/t/t5520-pull.sh index ed4d9c8318..227d293350 100755 --- a/t/t5520-pull.sh +++ b/t/t5520-pull.sh @@ -148,6 +148,95 @@ test_expect_success 'branch.to-rebase.rebase should override pull.rebase' ' test new = $(git show HEAD:file2) ' +# add a feature branch, keep-merge, that is merged into master, so the +# test can try preserving the merge commit (or not) with various +# --rebase flags/pull.rebase settings. +test_expect_success 'preserve merge setup' ' + git reset --hard before-rebase && + git checkout -b keep-merge second^ && + test_commit file3 && + git checkout to-rebase && + git merge keep-merge && + git tag before-preserve-rebase +' + +test_expect_success 'pull.rebase=false create a new merge commit' ' + git reset --hard before-preserve-rebase && + test_config pull.rebase false && + git pull . copy && + test $(git rev-parse HEAD^1) = $(git rev-parse before-preserve-rebase) && + test $(git rev-parse HEAD^2) = $(git rev-parse copy) && + test file3 = $(git show HEAD:file3.t) +' + +test_expect_success 'pull.rebase=true flattens keep-merge' ' + git reset --hard before-preserve-rebase && + test_config pull.rebase true && + git pull . copy && + test $(git rev-parse HEAD^^) = $(git rev-parse copy) && + test file3 = $(git show HEAD:file3.t) +' + +test_expect_success 'pull.rebase=1 is treated as true and flattens keep-merge' ' + git reset --hard before-preserve-rebase && + test_config pull.rebase 1 && + git pull . copy && + test $(git rev-parse HEAD^^) = $(git rev-parse copy) && + test file3 = $(git show HEAD:file3.t) +' + +test_expect_success 'pull.rebase=preserve rebases and merges keep-merge' ' + git reset --hard before-preserve-rebase && + test_config pull.rebase preserve && + git pull . copy && + test $(git rev-parse HEAD^^) = $(git rev-parse copy) && + test $(git rev-parse HEAD^2) = $(git rev-parse keep-merge) +' + +test_expect_success 'pull.rebase=invalid fails' ' + git reset --hard before-preserve-rebase && + test_config pull.rebase invalid && + ! git pull . copy +' + +test_expect_success '--rebase=false create a new merge commit' ' + git reset --hard before-preserve-rebase && + test_config pull.rebase true && + git pull --rebase=false . copy && + test $(git rev-parse HEAD^1) = $(git rev-parse before-preserve-rebase) && + test $(git rev-parse HEAD^2) = $(git rev-parse copy) && + test file3 = $(git show HEAD:file3.t) +' + +test_expect_success '--rebase=true rebases and flattens keep-merge' ' + git reset --hard before-preserve-rebase && + test_config pull.rebase preserve && + git pull --rebase=true . copy && + test $(git rev-parse HEAD^^) = $(git rev-parse copy) && + test file3 = $(git show HEAD:file3.t) +' + +test_expect_success '--rebase=preserve rebases and merges keep-merge' ' + git reset --hard before-preserve-rebase && + test_config pull.rebase true && + git pull --rebase=preserve . copy && + test $(git rev-parse HEAD^^) = $(git rev-parse copy) && + test $(git rev-parse HEAD^2) = $(git rev-parse keep-merge) +' + +test_expect_success '--rebase=invalid fails' ' + git reset --hard before-preserve-rebase && + ! git pull --rebase=invalid . copy +' + +test_expect_success '--rebase overrides pull.rebase=preserve and flattens keep-merge' ' + git reset --hard before-preserve-rebase && + test_config pull.rebase preserve && + git pull --rebase . copy && + test $(git rev-parse HEAD^^) = $(git rev-parse copy) && + test file3 = $(git show HEAD:file3.t) +' + test_expect_success '--rebase with rebased upstream' ' git remote add -f me . && diff --git a/t/t5530-upload-pack-error.sh b/t/t5530-upload-pack-error.sh index c983d3694c..3932e797f7 100755 --- a/t/t5530-upload-pack-error.sh +++ b/t/t5530-upload-pack-error.sh @@ -54,9 +54,6 @@ test_expect_success 'upload-pack fails due to error in rev-list' ' printf "0032want %s\n0034shallow %s00000009done\n0000" \ $(git rev-parse HEAD) $(git rev-parse HEAD^) >input && test_must_fail git upload-pack . <input >/dev/null 2>output.err && - # pack-objects survived - grep "Total.*, reused" output.err && - # but there was an error, which must have been in rev-list grep "bad tree object" output.err ' diff --git a/t/t5800-remote-testpy.sh b/t/t5800-remote-testpy.sh deleted file mode 100755 index 1e683d4220..0000000000 --- a/t/t5800-remote-testpy.sh +++ /dev/null @@ -1,169 +0,0 @@ -#!/bin/sh -# -# Copyright (c) 2010 Sverre Rabbelier -# - -test_description='Test python remote-helper framework' - -. ./test-lib.sh - -if ! test_have_prereq PYTHON ; then - skip_all='skipping python remote-helper tests, python not available' - test_done -fi - -"$PYTHON_PATH" -c ' -import sys -if sys.hexversion < 0x02040000: - sys.exit(1) -' || { - skip_all='skipping python remote-helper tests, python version < 2.4' - test_done -} - -compare_refs() { - git --git-dir="$1/.git" rev-parse --verify $2 >expect && - git --git-dir="$3/.git" rev-parse --verify $4 >actual && - test_cmp expect actual -} - -test_expect_success 'setup repository' ' - git init --bare server/.git && - git clone server public && - (cd public && - echo content >file && - git add file && - git commit -m one && - git push origin master) -' - -test_expect_success 'cloning from local repo' ' - git clone "testpy::${PWD}/server" localclone && - test_cmp public/file localclone/file -' - -test_expect_success 'cloning from remote repo' ' - git clone "testpy::file://${PWD}/server" clone && - test_cmp public/file clone/file -' - -test_expect_success 'create new commit on remote' ' - (cd public && - echo content >>file && - git commit -a -m two && - git push) -' - -test_expect_success 'pulling from local repo' ' - (cd localclone && git pull) && - test_cmp public/file localclone/file -' - -test_expect_success 'pulling from remote remote' ' - (cd clone && git pull) && - test_cmp public/file clone/file -' - -test_expect_success 'pushing to local repo' ' - (cd localclone && - echo content >>file && - git commit -a -m three && - git push) && - compare_refs localclone HEAD server HEAD -' - -# Generally, skip this test. It demonstrates a now-fixed race in -# git-remote-testpy, but is too slow to leave in for general use. -: test_expect_success 'racily pushing to local repo' ' - test_when_finished "rm -rf server2 localclone2" && - cp -R server server2 && - git clone "testpy::${PWD}/server2" localclone2 && - (cd localclone2 && - echo content >>file && - git commit -a -m three && - GIT_REMOTE_TESTGIT_SLEEPY=2 git push) && - compare_refs localclone2 HEAD server2 HEAD -' - -test_expect_success 'synch with changes from localclone' ' - (cd clone && - git pull) -' - -test_expect_success 'pushing remote local repo' ' - (cd clone && - echo content >>file && - git commit -a -m four && - git push) && - compare_refs clone HEAD server HEAD -' - -test_expect_success 'fetch new branch' ' - (cd public && - git checkout -b new && - echo content >>file && - git commit -a -m five && - git push origin new - ) && - (cd localclone && - git fetch origin new - ) && - compare_refs public HEAD localclone FETCH_HEAD -' - -test_expect_success 'fetch multiple branches' ' - (cd localclone && - git fetch - ) && - compare_refs server master localclone refs/remotes/origin/master && - compare_refs server new localclone refs/remotes/origin/new -' - -test_expect_success 'push when remote has extra refs' ' - (cd clone && - echo content >>file && - git commit -a -m six && - git push - ) && - compare_refs clone master server master -' - -test_expect_success 'push new branch by name' ' - (cd clone && - git checkout -b new-name && - echo content >>file && - git commit -a -m seven && - git push origin new-name - ) && - compare_refs clone HEAD server refs/heads/new-name -' - -test_expect_failure 'push new branch with old:new refspec' ' - (cd clone && - git push origin new-name:new-refspec - ) && - compare_refs clone HEAD server refs/heads/new-refspec -' - -test_expect_success 'proper failure checks for fetching' ' - (GIT_REMOTE_TESTGIT_FAILURE=1 && - export GIT_REMOTE_TESTGIT_FAILURE && - cd localclone && - test_must_fail git fetch 2>&1 | \ - grep "Error while running fast-import" - ) -' - -# We sleep to give fast-export a chance to catch the SIGPIPE -test_expect_failure 'proper failure checks for pushing' ' - (GIT_REMOTE_TESTGIT_FAILURE=1 && - export GIT_REMOTE_TESTGIT_FAILURE && - GIT_REMOTE_TESTGIT_SLEEPY=1 && - export GIT_REMOTE_TESTGIT_SLEEPY && - cd localclone && - test_must_fail git push --all 2>&1 | \ - grep "Error while running fast-export" - ) -' - -test_done diff --git a/t/t5801-remote-helpers.sh b/t/t5801-remote-helpers.sh index 8c4c5396a8..613f69a254 100755 --- a/t/t5801-remote-helpers.sh +++ b/t/t5801-remote-helpers.sh @@ -182,6 +182,17 @@ test_expect_success 'push update refs' ' ) ' +test_expect_success 'push update refs disabled by no-private-update' ' + (cd local && + echo more-update >>file && + git commit -a -m more-update && + git rev-parse --verify testgit/origin/heads/update >expect && + GIT_REMOTE_TESTGIT_NO_PRIVATE_UPDATE=t git push origin update && + git rev-parse --verify testgit/origin/heads/update >actual && + test_cmp expect actual + ) +' + test_expect_success 'push update refs failure' ' (cd local && git checkout update && diff --git a/t/t6022-merge-rename.sh b/t/t6022-merge-rename.sh index c680f789a7..a89dfbef08 100755 --- a/t/t6022-merge-rename.sh +++ b/t/t6022-merge-rename.sh @@ -259,7 +259,7 @@ test_expect_success 'setup for rename + d/f conflicts' ' printf "1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n" >sub/file && echo foo >dir/file-in-the-way && git add -A && - git commit -m "Common commmit" && + git commit -m "Common commit" && echo 11 >>sub/file && echo more >>dir/file-in-the-way && @@ -439,7 +439,7 @@ test_expect_success 'setup both rename source and destination involved in D/F co mkdir one && echo stuff >one/file && git add -A && - git commit -m "Common commmit" && + git commit -m "Common commit" && git mv one/file destdir && git commit -m "Renamed to destdir" && @@ -479,7 +479,7 @@ test_expect_success 'setup pair rename to parent of other (D/F conflicts)' ' echo stuff >one/file && echo other >two/file && git add -A && - git commit -m "Common commmit" && + git commit -m "Common commit" && git rm -rf one && git mv two/file one && @@ -539,7 +539,7 @@ test_expect_success 'setup rename of one file to two, with directories in the wa echo stuff >original && git add -A && - git commit -m "Common commmit" && + git commit -m "Common commit" && mkdir two && >two/file && @@ -583,7 +583,7 @@ test_expect_success 'setup rename one file to two; directories moving out of the mkdir one two && touch one/file two/file && git add -A && - git commit -m "Common commmit" && + git commit -m "Common commit" && git rm -rf one && git mv original one && @@ -618,7 +618,7 @@ test_expect_success 'setup avoid unnecessary update, normal rename' ' printf "1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n" >original && git add -A && - git commit -m "Common commmit" && + git commit -m "Common commit" && git mv original rename && echo 11 >>rename && @@ -649,7 +649,7 @@ test_expect_success 'setup to test avoiding unnecessary update, with D/F conflic mkdir df && printf "1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n" >df/file && git add -A && - git commit -m "Common commmit" && + git commit -m "Common commit" && git mv df/file temp && rm -rf df && diff --git a/t/t6040-tracking-info.sh b/t/t6040-tracking-info.sh index ec2b516c3f..ba26cfe923 100755 --- a/t/t6040-tracking-info.sh +++ b/t/t6040-tracking-info.sh @@ -28,10 +28,15 @@ test_expect_success setup ' git reset --hard HEAD^ && git checkout -b b4 origin && advance e && - advance f + advance f && + git checkout -b brokenbase origin && + git checkout -b b5 --track brokenbase && + advance g && + git branch -d brokenbase && + git checkout -b b6 origin ) && git checkout -b follower --track master && - advance g + advance h ' script='s/^..\(b.\)[ 0-9a-f]*\[\([^]]*\)\].*/\1 \2/p' @@ -56,6 +61,8 @@ b1 origin/master: ahead 1, behind 1 b2 origin/master: ahead 1, behind 1 b3 origin/master: behind 1 b4 origin/master: ahead 2 +b5 brokenbase: gone +b6 origin/master EOF test_expect_success 'branch -vv' ' @@ -67,7 +74,7 @@ test_expect_success 'branch -vv' ' test_i18ncmp expect actual ' -test_expect_success 'checkout' ' +test_expect_success 'checkout (diverged from upstream)' ' ( cd test && git checkout b1 ) >actual && @@ -80,7 +87,22 @@ test_expect_success 'checkout with local tracked branch' ' test_i18ngrep "is ahead of" actual ' -test_expect_success 'status' ' +test_expect_success 'checkout (upstream is gone)' ' + ( + cd test && + git checkout b5 + ) >actual && + test_i18ngrep "is based on .*, but the upstream is gone." actual +' + +test_expect_success 'checkout (up-to-date with upstream)' ' + ( + cd test && git checkout b6 + ) >actual && + test_i18ngrep "Your branch is up-to-date with .origin/master" actual +' + +test_expect_success 'status (diverged from upstream)' ' ( cd test && git checkout b1 >/dev/null && @@ -90,6 +112,65 @@ test_expect_success 'status' ' test_i18ngrep "have 1 and 1 different" actual ' +test_expect_success 'status (upstream is gone)' ' + ( + cd test && + git checkout b5 >/dev/null && + # reports nothing to commit + test_must_fail git commit --dry-run + ) >actual && + test_i18ngrep "is based on .*, but the upstream is gone." actual +' + +test_expect_success 'status (up-to-date with upstream)' ' + ( + cd test && + git checkout b6 >/dev/null && + # reports nothing to commit + test_must_fail git commit --dry-run + ) >actual && + test_i18ngrep "Your branch is up-to-date with .origin/master" actual +' + +cat >expect <<\EOF +## b1...origin/master [ahead 1, behind 1] +EOF + +test_expect_success 'status -s -b (diverged from upstream)' ' + ( + cd test && + git checkout b1 >/dev/null && + git status -s -b | head -1 + ) >actual && + test_i18ncmp expect actual +' + +cat >expect <<\EOF +## b5...brokenbase [gone] +EOF + +test_expect_success 'status -s -b (upstream is gone)' ' + ( + cd test && + git checkout b5 >/dev/null && + git status -s -b | head -1 + ) >actual && + test_i18ncmp expect actual +' + +cat >expect <<\EOF +## b6...origin/master +EOF + +test_expect_success 'status -s -b (up-to-date with upstream)' ' + ( + cd test && + git checkout b6 >/dev/null && + git status -s -b | head -1 + ) >actual && + test_i18ncmp expect actual +' + test_expect_success 'fail to track lightweight tags' ' git checkout master && git tag light && diff --git a/t/t6101-rev-parse-parents.sh b/t/t6101-rev-parse-parents.sh index e673c25e94..7ea14ced31 100755 --- a/t/t6101-rev-parse-parents.sh +++ b/t/t6101-rev-parse-parents.sh @@ -6,39 +6,86 @@ test_description='Test git rev-parse with different parent options' . ./test-lib.sh -. "$TEST_DIRECTORY"/lib-t6000.sh # t6xxx specific functions - -date >path0 -git update-index --add path0 -save_tag tree git write-tree -hide_error save_tag start unique_commit "start" tree -save_tag second unique_commit "second" tree -p start -hide_error save_tag start2 unique_commit "start2" tree -save_tag two_parents unique_commit "next" tree -p second -p start2 -save_tag final unique_commit "final" tree -p two_parents - -test_expect_success 'start is valid' 'git rev-parse start | grep "^[0-9a-f]\{40\}$"' -test_expect_success 'start^0' "test $(cat .git/refs/tags/start) = $(git rev-parse start^0)" -test_expect_success 'start^1 not valid' "if git rev-parse --verify start^1; then false; else :; fi" -test_expect_success 'second^1 = second^' "test $(git rev-parse second^1) = $(git rev-parse second^)" -test_expect_success 'final^1^1^1' "test $(git rev-parse start) = $(git rev-parse final^1^1^1)" -test_expect_success 'final^1^1^1 = final^^^' "test $(git rev-parse final^1^1^1) = $(git rev-parse final^^^)" -test_expect_success 'final^1^2' "test $(git rev-parse start2) = $(git rev-parse final^1^2)" -test_expect_success 'final^1^2 != final^1^1' "test $(git rev-parse final^1^2) != $(git rev-parse final^1^1)" -test_expect_success 'final^1^3 not valid' "if git rev-parse --verify final^1^3; then false; else :; fi" -test_expect_success '--verify start2^1' 'test_must_fail git rev-parse --verify start2^1' -test_expect_success '--verify start2^0' 'git rev-parse --verify start2^0' -test_expect_success 'final^1^@ = final^1^1 final^1^2' "test \"$(git rev-parse final^1^@)\" = \"$(git rev-parse final^1^1 final^1^2)\"" -test_expect_success 'final^1^! = final^1 ^final^1^1 ^final^1^2' "test \"$(git rev-parse final^1^\!)\" = \"$(git rev-parse final^1 ^final^1^1 ^final^1^2)\"" - -test_expect_success 'repack for next test' 'git repack -a -d' + +test_cmp_rev_output () { + git rev-parse --verify "$1" >expect && + eval "$2" >actual && + test_cmp expect actual +} + +test_expect_success 'setup' ' + test_commit start && + test_commit second && + git checkout --orphan tmp && + test_commit start2 && + git checkout master && + git merge -m next start2 && + test_commit final +' + +test_expect_success 'start is valid' ' + git rev-parse start | grep "^[0-9a-f]\{40\}$" +' + +test_expect_success 'start^0' ' + test_cmp_rev_output tags/start "git rev-parse start^0" +' + +test_expect_success 'start^1 not valid' ' + test_must_fail git rev-parse --verify start^1 +' + +test_expect_success 'second^1 = second^' ' + test_cmp_rev_output second^ "git rev-parse second^1" +' + +test_expect_success 'final^1^1^1' ' + test_cmp_rev_output start "git rev-parse final^1^1^1" +' + +test_expect_success 'final^1^1^1 = final^^^' ' + test_cmp_rev_output final^^^ "git rev-parse final^1^1^1" +' + +test_expect_success 'final^1^2' ' + test_cmp_rev_output start2 "git rev-parse final^1^2" +' + +test_expect_success 'final^1^2 != final^1^1' ' + test $(git rev-parse final^1^2) != $(git rev-parse final^1^1) +' + +test_expect_success 'final^1^3 not valid' ' + test_must_fail git rev-parse --verify final^1^3 +' + +test_expect_success '--verify start2^1' ' + test_must_fail git rev-parse --verify start2^1 +' + +test_expect_success '--verify start2^0' ' + git rev-parse --verify start2^0 +' + +test_expect_success 'final^1^@ = final^1^1 final^1^2' ' + git rev-parse final^1^1 final^1^2 >expect && + git rev-parse final^1^@ >actual && + test_cmp expect actual +' + +test_expect_success 'final^1^! = final^1 ^final^1^1 ^final^1^2' ' + git rev-parse final^1 ^final^1^1 ^final^1^2 >expect && + git rev-parse final^1^! >actual && + test_cmp expect actual +' + +test_expect_success 'repack for next test' ' + git repack -a -d +' + test_expect_success 'short SHA-1 works' ' - start=`git rev-parse --verify start` && - echo $start && - abbrv=`echo $start | sed s/.\$//` && - echo $abbrv && - abbrv=`git rev-parse --verify $abbrv` && - echo $abbrv && - test $start = $abbrv' + start=$(git rev-parse --verify start) && + test_cmp_rev_output start "git rev-parse ${start%?}" +' test_done diff --git a/t/t7009-filter-branch-null-sha1.sh b/t/t7009-filter-branch-null-sha1.sh new file mode 100755 index 0000000000..a997f7ac3a --- /dev/null +++ b/t/t7009-filter-branch-null-sha1.sh @@ -0,0 +1,49 @@ +#!/bin/sh + +test_description='filter-branch removal of trees with null sha1' +. ./test-lib.sh + +test_expect_success 'setup: base commits' ' + test_commit one && + test_commit two && + test_commit three +' + +test_expect_success 'setup: a commit with a bogus null sha1 in the tree' ' + { + git ls-tree HEAD && + printf "160000 commit $_z40\\tbroken\\n" + } >broken-tree + echo "add broken entry" >msg && + + tree=$(git mktree <broken-tree) && + test_tick && + commit=$(git commit-tree $tree -p HEAD <msg) && + git update-ref HEAD "$commit" +' + +# we have to make one more commit on top removing the broken +# entry, since otherwise our index does not match HEAD (and filter-branch will +# complain). We could make the index match HEAD, but doing so would involve +# writing a null sha1 into the index. +test_expect_success 'setup: bring HEAD and index in sync' ' + test_tick && + git commit -a -m "back to normal" +' + +test_expect_success 'filter commands are still checked' ' + test_must_fail git filter-branch \ + --force --prune-empty \ + --index-filter "git rm --cached --ignore-unmatch three.t" +' + +test_expect_success 'removing the broken entry works' ' + echo three >expect && + git filter-branch \ + --force --prune-empty \ + --index-filter "git rm --cached --ignore-unmatch broken" && + git log -1 --format=%s >actual && + test_cmp expect actual +' + +test_done diff --git a/t/t7060-wtstatus.sh b/t/t7060-wtstatus.sh index 52ef06b000..7d467c034a 100755 --- a/t/t7060-wtstatus.sh +++ b/t/t7060-wtstatus.sh @@ -29,20 +29,19 @@ test_expect_success 'Report new path with conflict' ' test_cmp expect actual ' -cat >expect <<EOF -# On branch side -# You have unmerged paths. -# (fix conflicts and run "git commit") -# -# Unmerged paths: -# (use "git add/rm <file>..." as appropriate to mark resolution) -# -# deleted by us: foo -# +test_expect_success 'M/D conflict does not segfault' ' + cat >expect <<EOF && +On branch side +You have unmerged paths. + (fix conflicts and run "git commit") + +Unmerged paths: + (use "git add/rm <file>..." as appropriate to mark resolution) + + deleted by us: foo + no changes added to commit (use "git add" and/or "git commit -a") EOF - -test_expect_success 'M/D conflict does not segfault' ' mkdir mdconflict && ( cd mdconflict && @@ -135,19 +134,19 @@ test_expect_success 'status when conflicts with add and rm advice (deleted by th test_commit on_second main.txt on_second && test_commit master conflict.txt master && test_must_fail git merge second_branch && - cat >expected <<-\EOF && - # On branch master - # You have unmerged paths. - # (fix conflicts and run "git commit") - # - # Unmerged paths: - # (use "git add/rm <file>..." as appropriate to mark resolution) - # - # both added: conflict.txt - # deleted by them: main.txt - # - no changes added to commit (use "git add" and/or "git commit -a") - EOF + cat >expected <<\EOF && +On branch master +You have unmerged paths. + (fix conflicts and run "git commit") + +Unmerged paths: + (use "git add/rm <file>..." as appropriate to mark resolution) + + both added: conflict.txt + deleted by them: main.txt + +no changes added to commit (use "git add" and/or "git commit -a") +EOF git status --untracked-files=no >actual && test_i18ncmp expected actual ' @@ -168,20 +167,20 @@ test_expect_success 'prepare for conflicts' ' test_expect_success 'status when conflicts with add and rm advice (both deleted)' ' test_must_fail git merge conflict && - cat >expected <<-\EOF && - # On branch conflict_second - # You have unmerged paths. - # (fix conflicts and run "git commit") - # - # Unmerged paths: - # (use "git add/rm <file>..." as appropriate to mark resolution) - # - # both deleted: main.txt - # added by them: sub_master.txt - # added by us: sub_second.txt - # - no changes added to commit (use "git add" and/or "git commit -a") - EOF + cat >expected <<\EOF && +On branch conflict_second +You have unmerged paths. + (fix conflicts and run "git commit") + +Unmerged paths: + (use "git add/rm <file>..." as appropriate to mark resolution) + + both deleted: main.txt + added by them: sub_master.txt + added by us: sub_second.txt + +no changes added to commit (use "git add" and/or "git commit -a") +EOF git status --untracked-files=no >actual && test_i18ncmp expected actual ' @@ -192,22 +191,22 @@ test_expect_success 'status when conflicts with only rm advice (both deleted)' ' test_must_fail git merge conflict && git add sub_master.txt && git add sub_second.txt && - cat >expected <<-\EOF && - # On branch conflict_second - # You have unmerged paths. - # (fix conflicts and run "git commit") - # - # Changes to be committed: - # - # new file: sub_master.txt - # - # Unmerged paths: - # (use "git rm <file>..." to mark resolution) - # - # both deleted: main.txt - # - # Untracked files not listed (use -u option to show untracked files) - EOF + cat >expected <<\EOF && +On branch conflict_second +You have unmerged paths. + (fix conflicts and run "git commit") + +Changes to be committed: + + new file: sub_master.txt + +Unmerged paths: + (use "git rm <file>..." to mark resolution) + + both deleted: main.txt + +Untracked files not listed (use -u option to show untracked files) +EOF git status --untracked-files=no >actual && test_i18ncmp expected actual && git reset --hard && diff --git a/t/t7106-reset-unborn-branch.sh b/t/t7106-reset-unborn-branch.sh index 8062cf502b..af00ab4d88 100755 --- a/t/t7106-reset-unborn-branch.sh +++ b/t/t7106-reset-unborn-branch.sh @@ -11,7 +11,10 @@ test_expect_success 'setup' ' test_expect_success 'reset' ' git add a b && git reset && - test "$(git ls-files)" = "" + + >expect && + git ls-files >actual && + test_cmp expect actual ' test_expect_success 'reset HEAD' ' @@ -24,28 +27,42 @@ test_expect_success 'reset $file' ' rm .git/index && git add a b && git reset a && - test "$(git ls-files)" = "b" + + echo b >expect && + git ls-files >actual && + test_cmp expect actual ' -test_expect_success 'reset -p' ' +test_expect_success PERL 'reset -p' ' rm .git/index && git add a && - echo y | git reset -p && - test "$(git ls-files)" = "" + echo y >yes && + git reset -p <yes && + + >expect && + git ls-files >actual && + test_cmp expect actual ' test_expect_success 'reset --soft is a no-op' ' rm .git/index && git add a && - git reset --soft - test "$(git ls-files)" = "a" + git reset --soft && + + echo a >expect && + git ls-files >actual && + test_cmp expect actual ' test_expect_success 'reset --hard' ' rm .git/index && git add a && + test_when_finished "echo a >a" && git reset --hard && - test "$(git ls-files)" = "" && + + >expect && + git ls-files >actual && + test_cmp expect actual && test_path_is_missing a ' diff --git a/t/t7400-submodule-basic.sh b/t/t7400-submodule-basic.sh index 4192fe0ec6..10f89bd0ce 100755 --- a/t/t7400-submodule-basic.sh +++ b/t/t7400-submodule-basic.sh @@ -962,7 +962,6 @@ test_expect_success 'submodule with UTF-8 name' ' git add sub && git commit -m "init sub" ) && - test_config core.precomposeunicode true && git submodule add ./"$svname" && git submodule >&2 && test -n "$(git submodule | grep "$svname")" diff --git a/t/t7401-submodule-summary.sh b/t/t7401-submodule-summary.sh index ac2434c0db..5a6d6d62eb 100755 --- a/t/t7401-submodule-summary.sh +++ b/t/t7401-submodule-summary.sh @@ -265,13 +265,11 @@ EOF test_expect_success '--for-status' " git submodule summary --for-status HEAD^ >actual && test_i18ncmp actual - <<EOF -# Submodule changes to be committed: -# -# * sm1 $head6...0000000: -# -# * sm2 0000000...$head7 (2): -# > Add foo9 -# +* sm1 $head6...0000000: + +* sm2 0000000...$head7 (2): + > Add foo9 + EOF " diff --git a/t/t7406-submodule-update.sh b/t/t7406-submodule-update.sh index b192f936bc..f0b33053ab 100755 --- a/t/t7406-submodule-update.sh +++ b/t/t7406-submodule-update.sh @@ -58,7 +58,7 @@ test_expect_success 'setup a submodule tree' ' git submodule add ../merging merging && test_tick && git commit -m "rebasing" - ) + ) && (cd super && git submodule add ../none none && test_tick && diff --git a/t/t7501-commit.sh b/t/t7501-commit.sh index 99ce36f5ef..f04798f872 100755 --- a/t/t7501-commit.sh +++ b/t/t7501-commit.sh @@ -53,7 +53,7 @@ test_expect_success PERL 'can use paths with --interactive' ' ' test_expect_success 'using invalid commit with -C' ' - test_must_fail git commit -C bogus + test_must_fail git commit --allow-empty -C bogus ' test_expect_success 'nothing to commit' ' diff --git a/t/t7508-status.sh b/t/t7508-status.sh index ac3d0fe445..d8c531da76 100755 --- a/t/t7508-status.sh +++ b/t/t7508-status.sh @@ -60,8 +60,13 @@ test_expect_success 'status (1)' ' test_i18ngrep "use \"git rm --cached <file>\.\.\.\" to unstage" output ' +strip_comments () { + tab=' ' + sed "s/^\# //; s/^\#$//; s/^#$tab/$tab/" <"$1" >"$1".tmp && + rm "$1" && mv "$1".tmp "$1" +} + test_expect_success 'status --column' ' - COLUMNS=50 git status --column="column dense" >output && cat >expect <<\EOF && # On branch master # Changes to be committed: @@ -78,9 +83,17 @@ test_expect_success 'status --column' ' # Untracked files: # (use "git add <file>..." to include in what will be committed) # -# dir1/untracked dir2/untracked untracked -# dir2/modified output +# dir1/untracked dir2/untracked output +# dir2/modified expect untracked +# EOF + COLUMNS=50 git -c status.displayCommentPrefix=true status --column="column dense" >output && + test_i18ncmp expect output +' + +test_expect_success 'status --column status.displayCommentPrefix=false' ' + strip_comments expect && + COLUMNS=49 git -c status.displayCommentPrefix=false status --column="column dense" >output && test_i18ncmp expect output ' @@ -106,28 +119,58 @@ cat >expect <<\EOF # expect # output # untracked +# EOF -test_expect_success 'status (2)' ' - git status >output && +test_expect_success 'status with status.displayCommentPrefix=true' ' + git -c status.displayCommentPrefix=true status >output && + test_i18ncmp expect output +' + +test_expect_success 'status with status.displayCommentPrefix=false' ' + strip_comments expect && + git -c status.displayCommentPrefix=false status >output && test_i18ncmp expect output ' +test_expect_success 'setup fake editor' ' + cat >.git/editor <<-\EOF && + #! /bin/sh + cp "$1" output +EOF + chmod 755 .git/editor +' + +commit_template_commented () { + ( + EDITOR=.git/editor && + export EDITOR && + # Fails due to empty message + test_must_fail git commit + ) && + ! grep '^[^#]' output +} + +test_expect_success 'commit ignores status.displayCommentPrefix=false in COMMIT_EDITMSG' ' + commit_template_commented +' + cat >expect <<\EOF -# On branch master -# Changes to be committed: -# new file: dir2/added -# -# Changes not staged for commit: -# modified: dir1/modified -# -# Untracked files: -# dir1/untracked -# dir2/modified -# dir2/untracked -# expect -# output -# untracked +On branch master +Changes to be committed: + new file: dir2/added + +Changes not staged for commit: + modified: dir1/modified + +Untracked files: + dir1/untracked + dir2/modified + dir2/untracked + expect + output + untracked + EOF test_expect_success 'status (advice.statusHints false)' ' @@ -185,33 +228,35 @@ test_expect_success 'status with gitignore' ' git status -s --ignored >output && test_cmp expect output && - cat >expect <<-\EOF && - # On branch master - # Changes to be committed: - # (use "git reset HEAD <file>..." to unstage) - # - # new file: dir2/added - # - # Changes not staged for commit: - # (use "git add <file>..." to update what will be committed) - # (use "git checkout -- <file>..." to discard changes in working directory) - # - # modified: dir1/modified - # - # Untracked files: - # (use "git add <file>..." to include in what will be committed) - # - # dir2/modified - # Ignored files: - # (use "git add -f <file>..." to include in what will be committed) - # - # .gitignore - # dir1/untracked - # dir2/untracked - # expect - # output - # untracked - EOF + cat >expect <<\EOF && +On branch master +Changes to be committed: + (use "git reset HEAD <file>..." to unstage) + + new file: dir2/added + +Changes not staged for commit: + (use "git add <file>..." to update what will be committed) + (use "git checkout -- <file>..." to discard changes in working directory) + + modified: dir1/modified + +Untracked files: + (use "git add <file>..." to include in what will be committed) + + dir2/modified + +Ignored files: + (use "git add -f <file>..." to include in what will be committed) + + .gitignore + dir1/untracked + dir2/untracked + expect + output + untracked + +EOF git status --ignored >output && test_i18ncmp expect output ' @@ -246,30 +291,31 @@ test_expect_success 'status with gitignore (nothing untracked)' ' git status -s --ignored >output && test_cmp expect output && - cat >expect <<-\EOF && - # On branch master - # Changes to be committed: - # (use "git reset HEAD <file>..." to unstage) - # - # new file: dir2/added - # - # Changes not staged for commit: - # (use "git add <file>..." to update what will be committed) - # (use "git checkout -- <file>..." to discard changes in working directory) - # - # modified: dir1/modified - # - # Ignored files: - # (use "git add -f <file>..." to include in what will be committed) - # - # .gitignore - # dir1/untracked - # dir2/modified - # dir2/untracked - # expect - # output - # untracked - EOF + cat >expect <<\EOF && +On branch master +Changes to be committed: + (use "git reset HEAD <file>..." to unstage) + + new file: dir2/added + +Changes not staged for commit: + (use "git add <file>..." to update what will be committed) + (use "git checkout -- <file>..." to discard changes in working directory) + + modified: dir1/modified + +Ignored files: + (use "git add -f <file>..." to include in what will be committed) + + .gitignore + dir1/untracked + dir2/modified + dir2/untracked + expect + output + untracked + +EOF git status --ignored >output && test_i18ncmp expect output ' @@ -310,22 +356,22 @@ test_expect_success 'setup dir3' ' : >dir3/untracked2 ' -cat >expect <<EOF -# On branch master -# Changes to be committed: -# (use "git reset HEAD <file>..." to unstage) -# -# new file: dir2/added -# -# Changes not staged for commit: -# (use "git add <file>..." to update what will be committed) -# (use "git checkout -- <file>..." to discard changes in working directory) -# -# modified: dir1/modified -# -# Untracked files not listed (use -u option to show untracked files) -EOF test_expect_success 'status -uno' ' + cat >expect <<EOF && +On branch master +Changes to be committed: + (use "git reset HEAD <file>..." to unstage) + + new file: dir2/added + +Changes not staged for commit: + (use "git add <file>..." to update what will be committed) + (use "git checkout -- <file>..." to discard changes in working directory) + + modified: dir1/modified + +Untracked files not listed (use -u option to show untracked files) +EOF git status -uno >output && test_i18ncmp expect output ' @@ -336,17 +382,17 @@ test_expect_success 'status (status.showUntrackedFiles no)' ' test_i18ncmp expect output ' -cat >expect <<EOF -# On branch master -# Changes to be committed: -# new file: dir2/added -# -# Changes not staged for commit: -# modified: dir1/modified -# -# Untracked files not listed -EOF test_expect_success 'status -uno (advice.statusHints false)' ' + cat >expect <<EOF && +On branch master +Changes to be committed: + new file: dir2/added + +Changes not staged for commit: + modified: dir1/modified + +Untracked files not listed +EOF test_config advice.statusHints false && git status -uno >output && test_i18ncmp expect output @@ -367,31 +413,32 @@ test_expect_success 'status -s (status.showUntrackedFiles no)' ' test_cmp expect output ' -cat >expect <<EOF -# On branch master -# Changes to be committed: -# (use "git reset HEAD <file>..." to unstage) -# -# new file: dir2/added -# -# Changes not staged for commit: -# (use "git add <file>..." to update what will be committed) -# (use "git checkout -- <file>..." to discard changes in working directory) -# -# modified: dir1/modified -# -# Untracked files: -# (use "git add <file>..." to include in what will be committed) -# -# dir1/untracked -# dir2/modified -# dir2/untracked -# dir3/ -# expect -# output -# untracked -EOF test_expect_success 'status -unormal' ' + cat >expect <<EOF && +On branch master +Changes to be committed: + (use "git reset HEAD <file>..." to unstage) + + new file: dir2/added + +Changes not staged for commit: + (use "git add <file>..." to update what will be committed) + (use "git checkout -- <file>..." to discard changes in working directory) + + modified: dir1/modified + +Untracked files: + (use "git add <file>..." to include in what will be committed) + + dir1/untracked + dir2/modified + dir2/untracked + dir3/ + expect + output + untracked + +EOF git status -unormal >output && test_i18ncmp expect output ' @@ -424,32 +471,33 @@ test_expect_success 'status -s (status.showUntrackedFiles normal)' ' test_cmp expect output ' -cat >expect <<EOF -# On branch master -# Changes to be committed: -# (use "git reset HEAD <file>..." to unstage) -# -# new file: dir2/added -# -# Changes not staged for commit: -# (use "git add <file>..." to update what will be committed) -# (use "git checkout -- <file>..." to discard changes in working directory) -# -# modified: dir1/modified -# -# Untracked files: -# (use "git add <file>..." to include in what will be committed) -# -# dir1/untracked -# dir2/modified -# dir2/untracked -# dir3/untracked1 -# dir3/untracked2 -# expect -# output -# untracked -EOF test_expect_success 'status -uall' ' + cat >expect <<EOF && +On branch master +Changes to be committed: + (use "git reset HEAD <file>..." to unstage) + + new file: dir2/added + +Changes not staged for commit: + (use "git add <file>..." to update what will be committed) + (use "git checkout -- <file>..." to discard changes in working directory) + + modified: dir1/modified + +Untracked files: + (use "git add <file>..." to include in what will be committed) + + dir1/untracked + dir2/modified + dir2/untracked + dir3/untracked1 + dir3/untracked2 + expect + output + untracked + +EOF git status -uall >output && test_i18ncmp expect output ' @@ -486,31 +534,31 @@ test_expect_success 'status -s (status.showUntrackedFiles all)' ' test_cmp expect output ' -cat >expect <<\EOF -# On branch master -# Changes to be committed: -# (use "git reset HEAD <file>..." to unstage) -# -# new file: ../dir2/added -# -# Changes not staged for commit: -# (use "git add <file>..." to update what will be committed) -# (use "git checkout -- <file>..." to discard changes in working directory) -# -# modified: modified -# -# Untracked files: -# (use "git add <file>..." to include in what will be committed) -# -# untracked -# ../dir2/modified -# ../dir2/untracked -# ../expect -# ../output -# ../untracked -EOF - test_expect_success 'status with relative paths' ' + cat >expect <<\EOF && +On branch master +Changes to be committed: + (use "git reset HEAD <file>..." to unstage) + + new file: ../dir2/added + +Changes not staged for commit: + (use "git add <file>..." to update what will be committed) + (use "git checkout -- <file>..." to discard changes in working directory) + + modified: modified + +Untracked files: + (use "git add <file>..." to include in what will be committed) + + untracked + ../dir2/modified + ../dir2/untracked + ../expect + ../output + ../untracked + +EOF (cd dir1 && git status) >output && test_i18ncmp expect output ' @@ -557,31 +605,31 @@ test_expect_success 'setup unique colors' ' ' -cat >expect <<\EOF -# On branch <GREEN>master<RESET> -# Changes to be committed: -# (use "git reset HEAD <file>..." to unstage) -# -# <GREEN>new file: dir2/added<RESET> -# -# Changes not staged for commit: -# (use "git add <file>..." to update what will be committed) -# (use "git checkout -- <file>..." to discard changes in working directory) -# -# <RED>modified: dir1/modified<RESET> -# -# Untracked files: -# (use "git add <file>..." to include in what will be committed) -# -# <BLUE>dir1/untracked<RESET> -# <BLUE>dir2/modified<RESET> -# <BLUE>dir2/untracked<RESET> -# <BLUE>expect<RESET> -# <BLUE>output<RESET> -# <BLUE>untracked<RESET> -EOF - test_expect_success 'status with color.ui' ' + cat >expect <<\EOF && +On branch <GREEN>master<RESET> +Changes to be committed: + (use "git reset HEAD <file>..." to unstage) + + <GREEN>new file: dir2/added<RESET> + +Changes not staged for commit: + (use "git add <file>..." to update what will be committed) + (use "git checkout -- <file>..." to discard changes in working directory) + + <RED>modified: dir1/modified<RESET> + +Untracked files: + (use "git add <file>..." to include in what will be committed) + + <BLUE>dir1/untracked<RESET> + <BLUE>dir2/modified<RESET> + <BLUE>dir2/untracked<RESET> + <BLUE>expect<RESET> + <BLUE>output<RESET> + <BLUE>untracked<RESET> + +EOF test_config color.ui always && git status | test_decode_color >output && test_i18ncmp expect output @@ -685,33 +733,33 @@ test_expect_success 'status --porcelain respects -b' ' ' -cat >expect <<\EOF -# On branch master -# Changes to be committed: -# (use "git reset HEAD <file>..." to unstage) -# -# new file: dir2/added -# -# Changes not staged for commit: -# (use "git add <file>..." to update what will be committed) -# (use "git checkout -- <file>..." to discard changes in working directory) -# -# modified: dir1/modified -# -# Untracked files: -# (use "git add <file>..." to include in what will be committed) -# -# dir1/untracked -# dir2/modified -# dir2/untracked -# expect -# output -# untracked -EOF test_expect_success 'status without relative paths' ' + cat >expect <<\EOF && +On branch master +Changes to be committed: + (use "git reset HEAD <file>..." to unstage) + + new file: dir2/added +Changes not staged for commit: + (use "git add <file>..." to update what will be committed) + (use "git checkout -- <file>..." to discard changes in working directory) + + modified: dir1/modified + +Untracked files: + (use "git add <file>..." to include in what will be committed) + + dir1/untracked + dir2/modified + dir2/untracked + expect + output + untracked + +EOF test_config status.relativePaths false && (cd dir1 && git status) >output && test_i18ncmp expect output @@ -737,23 +785,24 @@ test_expect_success 'status -s without relative paths' ' ' -cat <<EOF >expect -# On branch master -# Changes to be committed: -# (use "git reset HEAD <file>..." to unstage) -# -# modified: dir1/modified -# -# Untracked files: -# (use "git add <file>..." to include in what will be committed) -# -# dir1/untracked -# dir2/ -# expect -# output -# untracked -EOF test_expect_success 'dry-run of partial commit excluding new file in index' ' + cat >expect <<EOF && +On branch master +Changes to be committed: + (use "git reset HEAD <file>..." to unstage) + + modified: dir1/modified + +Untracked files: + (use "git add <file>..." to include in what will be committed) + + dir1/untracked + dir2/ + expect + output + untracked + +EOF git commit --dry-run dir1/modified >output && test_i18ncmp expect output ' @@ -778,31 +827,32 @@ test_expect_success 'setup status submodule summary' ' git add sm ' -cat >expect <<EOF -# On branch master -# Changes to be committed: -# (use "git reset HEAD <file>..." to unstage) -# -# new file: dir2/added -# new file: sm -# -# Changes not staged for commit: -# (use "git add <file>..." to update what will be committed) -# (use "git checkout -- <file>..." to discard changes in working directory) -# -# modified: dir1/modified -# -# Untracked files: -# (use "git add <file>..." to include in what will be committed) -# -# dir1/untracked -# dir2/modified -# dir2/untracked -# expect -# output -# untracked -EOF test_expect_success 'status submodule summary is disabled by default' ' + cat >expect <<EOF && +On branch master +Changes to be committed: + (use "git reset HEAD <file>..." to unstage) + + new file: dir2/added + new file: sm + +Changes not staged for commit: + (use "git add <file>..." to update what will be committed) + (use "git checkout -- <file>..." to discard changes in working directory) + + modified: dir1/modified + +Untracked files: + (use "git add <file>..." to include in what will be committed) + + dir1/untracked + dir2/modified + dir2/untracked + expect + output + untracked + +EOF git status >output && test_i18ncmp expect output ' @@ -837,41 +887,52 @@ test_expect_success 'status -s --untracked-files=all does not show submodule' ' head=$(cd sm && git rev-parse --short=7 --verify HEAD) -cat >expect <<EOF -# On branch master -# Changes to be committed: -# (use "git reset HEAD <file>..." to unstage) -# -# new file: dir2/added -# new file: sm -# -# Changes not staged for commit: -# (use "git add <file>..." to update what will be committed) -# (use "git checkout -- <file>..." to discard changes in working directory) -# -# modified: dir1/modified -# -# Submodule changes to be committed: -# -# * sm 0000000...$head (1): -# > Add foo -# -# Untracked files: -# (use "git add <file>..." to include in what will be committed) -# -# dir1/untracked -# dir2/modified -# dir2/untracked -# expect -# output -# untracked -EOF test_expect_success 'status submodule summary' ' + cat >expect <<EOF && +On branch master +Changes to be committed: + (use "git reset HEAD <file>..." to unstage) + + new file: dir2/added + new file: sm + +Changes not staged for commit: + (use "git add <file>..." to update what will be committed) + (use "git checkout -- <file>..." to discard changes in working directory) + + modified: dir1/modified + +Submodule changes to be committed: + +* sm 0000000...$head (1): + > Add foo + +Untracked files: + (use "git add <file>..." to include in what will be committed) + + dir1/untracked + dir2/modified + dir2/untracked + expect + output + untracked + +EOF git config status.submodulesummary 10 && git status >output && test_i18ncmp expect output ' +test_expect_success 'status submodule summary with status.displayCommentPrefix=false' ' + strip_comments expect && + git -c status.displayCommentPrefix=false status >output && + test_i18ncmp expect output +' + +test_expect_success 'commit with submodule summary ignores status.displayCommentPrefix' ' + commit_template_commented +' + cat >expect <<EOF M dir1/modified A dir2/added @@ -888,26 +949,27 @@ test_expect_success 'status -s submodule summary' ' test_cmp expect output ' -cat >expect <<EOF -# On branch master -# Changes not staged for commit: -# (use "git add <file>..." to update what will be committed) -# (use "git checkout -- <file>..." to discard changes in working directory) -# -# modified: dir1/modified -# -# Untracked files: -# (use "git add <file>..." to include in what will be committed) -# -# dir1/untracked -# dir2/modified -# dir2/untracked -# expect -# output -# untracked +test_expect_success 'status submodule summary (clean submodule): commit' ' + cat >expect <<EOF && +On branch master +Changes not staged for commit: + (use "git add <file>..." to update what will be committed) + (use "git checkout -- <file>..." to discard changes in working directory) + + modified: dir1/modified + +Untracked files: + (use "git add <file>..." to include in what will be committed) + + dir1/untracked + dir2/modified + dir2/untracked + expect + output + untracked + no changes added to commit (use "git add" and/or "git commit -a") EOF -test_expect_success 'status submodule summary (clean submodule): commit' ' git commit -m "commit submodule" && git config status.submodulesummary 10 && test_must_fail git commit --dry-run >output && @@ -937,36 +999,37 @@ test_expect_success 'status -z implies porcelain' ' test_cmp expect output ' -cat >expect <<EOF -# On branch master -# Changes to be committed: -# (use "git reset HEAD^1 <file>..." to unstage) -# -# new file: dir2/added -# new file: sm -# -# Changes not staged for commit: -# (use "git add <file>..." to update what will be committed) -# (use "git checkout -- <file>..." to discard changes in working directory) -# -# modified: dir1/modified -# -# Submodule changes to be committed: -# -# * sm 0000000...$head (1): -# > Add foo -# -# Untracked files: -# (use "git add <file>..." to include in what will be committed) -# -# dir1/untracked -# dir2/modified -# dir2/untracked -# expect -# output -# untracked -EOF test_expect_success 'commit --dry-run submodule summary (--amend)' ' + cat >expect <<EOF && +On branch master +Changes to be committed: + (use "git reset HEAD^1 <file>..." to unstage) + + new file: dir2/added + new file: sm + +Changes not staged for commit: + (use "git add <file>..." to update what will be committed) + (use "git checkout -- <file>..." to discard changes in working directory) + + modified: dir1/modified + +Submodule changes to be committed: + +* sm 0000000...$head (1): + > Add foo + +Untracked files: + (use "git add <file>..." to include in what will be committed) + + dir1/untracked + dir2/modified + dir2/untracked + expect + output + untracked + +EOF git config status.submodulesummary 10 && git commit --dry-run --amend >output && test_i18ncmp expect output @@ -991,37 +1054,37 @@ test_expect_success POSIXPERM,SANITY 'status succeeds in a read-only repository' new_head=$(cd sm && git rev-parse --short=7 --verify HEAD) touch .gitmodules -cat > expect << EOF -# On branch master -# Changes to be committed: -# (use "git reset HEAD <file>..." to unstage) -# -# modified: sm -# -# Changes not staged for commit: -# (use "git add <file>..." to update what will be committed) -# (use "git checkout -- <file>..." to discard changes in working directory) -# -# modified: dir1/modified -# -# Submodule changes to be committed: -# -# * sm $head...$new_head (1): -# > Add bar -# -# Untracked files: -# (use "git add <file>..." to include in what will be committed) -# -# .gitmodules -# dir1/untracked -# dir2/modified -# dir2/untracked -# expect -# output -# untracked -EOF - test_expect_success '--ignore-submodules=untracked suppresses submodules with untracked content' ' + cat > expect << EOF && +On branch master +Changes to be committed: + (use "git reset HEAD <file>..." to unstage) + + modified: sm + +Changes not staged for commit: + (use "git add <file>..." to update what will be committed) + (use "git checkout -- <file>..." to discard changes in working directory) + + modified: dir1/modified + +Submodule changes to be committed: + +* sm $head...$new_head (1): + > Add bar + +Untracked files: + (use "git add <file>..." to include in what will be committed) + + .gitmodules + dir1/untracked + dir2/modified + dir2/untracked + expect + output + untracked + +EOF echo modified sm/untracked && git status --ignore-submodules=untracked >output && test_i18ncmp expect output @@ -1101,39 +1164,39 @@ test_expect_success '.git/config ignore=dirty suppresses submodules with modifie git config -f .gitmodules --remove-section submodule.subname ' -cat > expect << EOF -# On branch master -# Changes to be committed: -# (use "git reset HEAD <file>..." to unstage) -# -# modified: sm -# -# Changes not staged for commit: -# (use "git add <file>..." to update what will be committed) -# (use "git checkout -- <file>..." to discard changes in working directory) -# (commit or discard the untracked or modified content in submodules) -# -# modified: dir1/modified -# modified: sm (modified content) -# -# Submodule changes to be committed: -# -# * sm $head...$new_head (1): -# > Add bar -# -# Untracked files: -# (use "git add <file>..." to include in what will be committed) -# -# .gitmodules -# dir1/untracked -# dir2/modified -# dir2/untracked -# expect -# output -# untracked -EOF - test_expect_success "--ignore-submodules=untracked doesn't suppress submodules with modified content" ' + cat > expect << EOF && +On branch master +Changes to be committed: + (use "git reset HEAD <file>..." to unstage) + + modified: sm + +Changes not staged for commit: + (use "git add <file>..." to update what will be committed) + (use "git checkout -- <file>..." to discard changes in working directory) + (commit or discard the untracked or modified content in submodules) + + modified: dir1/modified + modified: sm (modified content) + +Submodule changes to be committed: + +* sm $head...$new_head (1): + > Add bar + +Untracked files: + (use "git add <file>..." to include in what will be committed) + + .gitmodules + dir1/untracked + dir2/modified + dir2/untracked + expect + output + untracked + +EOF git status --ignore-submodules=untracked > output && test_i18ncmp expect output ' @@ -1159,43 +1222,43 @@ test_expect_success ".git/config ignore=untracked doesn't suppress submodules wi head2=$(cd sm && git commit -q -m "2nd commit" foo && git rev-parse --short=7 --verify HEAD) -cat > expect << EOF -# On branch master -# Changes to be committed: -# (use "git reset HEAD <file>..." to unstage) -# -# modified: sm -# -# Changes not staged for commit: -# (use "git add <file>..." to update what will be committed) -# (use "git checkout -- <file>..." to discard changes in working directory) -# -# modified: dir1/modified -# modified: sm (new commits) -# -# Submodule changes to be committed: -# -# * sm $head...$new_head (1): -# > Add bar -# -# Submodules changed but not updated: -# -# * sm $new_head...$head2 (1): -# > 2nd commit -# -# Untracked files: -# (use "git add <file>..." to include in what will be committed) -# -# .gitmodules -# dir1/untracked -# dir2/modified -# dir2/untracked -# expect -# output -# untracked -EOF - test_expect_success "--ignore-submodules=untracked doesn't suppress submodule summary" ' + cat > expect << EOF && +On branch master +Changes to be committed: + (use "git reset HEAD <file>..." to unstage) + + modified: sm + +Changes not staged for commit: + (use "git add <file>..." to update what will be committed) + (use "git checkout -- <file>..." to discard changes in working directory) + + modified: dir1/modified + modified: sm (new commits) + +Submodule changes to be committed: + +* sm $head...$new_head (1): + > Add bar + +Submodules changed but not updated: + +* sm $new_head...$head2 (1): + > 2nd commit + +Untracked files: + (use "git add <file>..." to include in what will be committed) + + .gitmodules + dir1/untracked + dir2/modified + dir2/untracked + expect + output + untracked + +EOF git status --ignore-submodules=untracked > output && test_i18ncmp expect output ' @@ -1276,42 +1339,43 @@ cat > expect << EOF ; expect ; output ; untracked +; EOF test_expect_success "status (core.commentchar with submodule summary)" ' test_config core.commentchar ";" && - git status >output && + git -c status.displayCommentPrefix=true status >output && test_i18ncmp expect output ' test_expect_success "status (core.commentchar with two chars with submodule summary)" ' test_config core.commentchar ";;" && - git status >output && + git -c status.displayCommentPrefix=true status >output && test_i18ncmp expect output ' -cat > expect << EOF -# On branch master -# Changes not staged for commit: -# (use "git add <file>..." to update what will be committed) -# (use "git checkout -- <file>..." to discard changes in working directory) -# -# modified: dir1/modified -# -# Untracked files: -# (use "git add <file>..." to include in what will be committed) -# -# .gitmodules -# dir1/untracked -# dir2/modified -# dir2/untracked -# expect -# output -# untracked +test_expect_success "--ignore-submodules=all suppresses submodule summary" ' + cat > expect << EOF && +On branch master +Changes not staged for commit: + (use "git add <file>..." to update what will be committed) + (use "git checkout -- <file>..." to discard changes in working directory) + + modified: dir1/modified + +Untracked files: + (use "git add <file>..." to include in what will be committed) + + .gitmodules + dir1/untracked + dir2/modified + dir2/untracked + expect + output + untracked + no changes added to commit (use "git add" and/or "git commit -a") EOF - -test_expect_success "--ignore-submodules=all suppresses submodule summary" ' git status --ignore-submodules=all > output && test_i18ncmp expect output ' diff --git a/t/t7512-status-help.sh b/t/t7512-status-help.sh index 31a798fda2..0688d58884 100755 --- a/t/t7512-status-help.sh +++ b/t/t7512-status-help.sh @@ -25,18 +25,18 @@ test_expect_success 'prepare for conflicts' ' test_expect_success 'status when conflicts unresolved' ' test_must_fail git merge master && - cat >expected <<-\EOF && - # On branch conflicts - # You have unmerged paths. - # (fix conflicts and run "git commit") - # - # Unmerged paths: - # (use "git add <file>..." to mark resolution) - # - # both modified: main.txt - # - no changes added to commit (use "git add" and/or "git commit -a") - EOF + cat >expected <<\EOF && +On branch conflicts +You have unmerged paths. + (fix conflicts and run "git commit") + +Unmerged paths: + (use "git add <file>..." to mark resolution) + + both modified: main.txt + +no changes added to commit (use "git add" and/or "git commit -a") +EOF git status --untracked-files=no >actual && test_i18ncmp expected actual ' @@ -47,17 +47,17 @@ test_expect_success 'status when conflicts resolved before commit' ' test_must_fail git merge master && echo one >main.txt && git add main.txt && - cat >expected <<-\EOF && - # On branch conflicts - # All conflicts fixed but you are still merging. - # (use "git commit" to conclude merge) - # - # Changes to be committed: - # - # modified: main.txt - # - # Untracked files not listed (use -u option to show untracked files) - EOF + cat >expected <<\EOF && +On branch conflicts +All conflicts fixed but you are still merging. + (use "git commit" to conclude merge) + +Changes to be committed: + + modified: main.txt + +Untracked files not listed (use -u option to show untracked files) +EOF git status --untracked-files=no >actual && test_i18ncmp expected actual ' @@ -76,21 +76,21 @@ test_expect_success 'status when rebase in progress before resolving conflicts' test_when_finished "git rebase --abort" && ONTO=$(git rev-parse --short HEAD^^) && test_must_fail git rebase HEAD^ --onto HEAD^^ && - cat >expected <<-EOF && - # rebase in progress; onto $ONTO - # You are currently rebasing branch '\''rebase_conflicts'\'' on '\''$ONTO'\''. - # (fix conflicts and then run "git rebase --continue") - # (use "git rebase --skip" to skip this patch) - # (use "git rebase --abort" to check out the original branch) - # - # Unmerged paths: - # (use "git reset HEAD <file>..." to unstage) - # (use "git add <file>..." to mark resolution) - # - # both modified: main.txt - # - no changes added to commit (use "git add" and/or "git commit -a") - EOF + cat >expected <<EOF && +rebase in progress; onto $ONTO +You are currently rebasing branch '\''rebase_conflicts'\'' on '\''$ONTO'\''. + (fix conflicts and then run "git rebase --continue") + (use "git rebase --skip" to skip this patch) + (use "git rebase --abort" to check out the original branch) + +Unmerged paths: + (use "git reset HEAD <file>..." to unstage) + (use "git add <file>..." to mark resolution) + + both modified: main.txt + +no changes added to commit (use "git add" and/or "git commit -a") +EOF git status --untracked-files=no >actual && test_i18ncmp expected actual ' @@ -103,18 +103,18 @@ test_expect_success 'status when rebase in progress before rebase --continue' ' test_must_fail git rebase HEAD^ --onto HEAD^^ && echo three >main.txt && git add main.txt && - cat >expected <<-EOF && - # rebase in progress; onto $ONTO - # You are currently rebasing branch '\''rebase_conflicts'\'' on '\''$ONTO'\''. - # (all conflicts fixed: run "git rebase --continue") - # - # Changes to be committed: - # (use "git reset HEAD <file>..." to unstage) - # - # modified: main.txt - # - # Untracked files not listed (use -u option to show untracked files) - EOF + cat >expected <<EOF && +rebase in progress; onto $ONTO +You are currently rebasing branch '\''rebase_conflicts'\'' on '\''$ONTO'\''. + (all conflicts fixed: run "git rebase --continue") + +Changes to be committed: + (use "git reset HEAD <file>..." to unstage) + + modified: main.txt + +Untracked files not listed (use -u option to show untracked files) +EOF git status --untracked-files=no >actual && test_i18ncmp expected actual ' @@ -135,21 +135,21 @@ test_expect_success 'status during rebase -i when conflicts unresolved' ' test_when_finished "git rebase --abort" && ONTO=$(git rev-parse --short rebase_i_conflicts) && test_must_fail git rebase -i rebase_i_conflicts && - cat >expected <<-EOF && - # rebase in progress; onto $ONTO - # You are currently rebasing branch '\''rebase_i_conflicts_second'\'' on '\''$ONTO'\''. - # (fix conflicts and then run "git rebase --continue") - # (use "git rebase --skip" to skip this patch) - # (use "git rebase --abort" to check out the original branch) - # - # Unmerged paths: - # (use "git reset HEAD <file>..." to unstage) - # (use "git add <file>..." to mark resolution) - # - # both modified: main.txt - # - no changes added to commit (use "git add" and/or "git commit -a") - EOF + cat >expected <<EOF && +rebase in progress; onto $ONTO +You are currently rebasing branch '\''rebase_i_conflicts_second'\'' on '\''$ONTO'\''. + (fix conflicts and then run "git rebase --continue") + (use "git rebase --skip" to skip this patch) + (use "git rebase --abort" to check out the original branch) + +Unmerged paths: + (use "git reset HEAD <file>..." to unstage) + (use "git add <file>..." to mark resolution) + + both modified: main.txt + +no changes added to commit (use "git add" and/or "git commit -a") +EOF git status --untracked-files=no >actual && test_i18ncmp expected actual ' @@ -161,18 +161,18 @@ test_expect_success 'status during rebase -i after resolving conflicts' ' ONTO=$(git rev-parse --short rebase_i_conflicts) && test_must_fail git rebase -i rebase_i_conflicts && git add main.txt && - cat >expected <<-EOF && - # rebase in progress; onto $ONTO - # You are currently rebasing branch '\''rebase_i_conflicts_second'\'' on '\''$ONTO'\''. - # (all conflicts fixed: run "git rebase --continue") - # - # Changes to be committed: - # (use "git reset HEAD <file>..." to unstage) - # - # modified: main.txt - # - # Untracked files not listed (use -u option to show untracked files) - EOF + cat >expected <<EOF && +rebase in progress; onto $ONTO +You are currently rebasing branch '\''rebase_i_conflicts_second'\'' on '\''$ONTO'\''. + (all conflicts fixed: run "git rebase --continue") + +Changes to be committed: + (use "git reset HEAD <file>..." to unstage) + + modified: main.txt + +Untracked files not listed (use -u option to show untracked files) +EOF git status --untracked-files=no >actual && test_i18ncmp expected actual ' @@ -189,14 +189,14 @@ test_expect_success 'status when rebasing -i in edit mode' ' test_when_finished "git rebase --abort" && ONTO=$(git rev-parse --short HEAD~2) && git rebase -i HEAD~2 && - cat >expected <<-EOF && - # rebase in progress; onto $ONTO - # You are currently editing a commit while rebasing branch '\''rebase_i_edit'\'' on '\''$ONTO'\''. - # (use "git commit --amend" to amend the current commit) - # (use "git rebase --continue" once you are satisfied with your changes) - # - nothing to commit (use -u to show untracked files) - EOF + cat >expected <<EOF && +rebase in progress; onto $ONTO +You are currently editing a commit while rebasing branch '\''rebase_i_edit'\'' on '\''$ONTO'\''. + (use "git commit --amend" to amend the current commit) + (use "git rebase --continue" once you are satisfied with your changes) + +nothing to commit (use -u to show untracked files) +EOF git status --untracked-files=no >actual && test_i18ncmp expected actual ' @@ -215,19 +215,19 @@ test_expect_success 'status when splitting a commit' ' ONTO=$(git rev-parse --short HEAD~3) && git rebase -i HEAD~3 && git reset HEAD^ && - cat >expected <<-EOF && - # rebase in progress; onto $ONTO - # You are currently splitting a commit while rebasing branch '\''split_commit'\'' on '\''$ONTO'\''. - # (Once your working directory is clean, run "git rebase --continue") - # - # Changes not staged for commit: - # (use "git add <file>..." to update what will be committed) - # (use "git checkout -- <file>..." to discard changes in working directory) - # - # modified: main.txt - # - no changes added to commit (use "git add" and/or "git commit -a") - EOF + cat >expected <<EOF && +rebase in progress; onto $ONTO +You are currently splitting a commit while rebasing branch '\''split_commit'\'' on '\''$ONTO'\''. + (Once your working directory is clean, run "git rebase --continue") + +Changes not staged for commit: + (use "git add <file>..." to update what will be committed) + (use "git checkout -- <file>..." to discard changes in working directory) + + modified: main.txt + +no changes added to commit (use "git add" and/or "git commit -a") +EOF git status --untracked-files=no >actual && test_i18ncmp expected actual ' @@ -246,14 +246,14 @@ test_expect_success 'status after editing the last commit with --amend during a ONTO=$(git rev-parse --short HEAD~3) && git rebase -i HEAD~3 && git commit --amend -m "foo" && - cat >expected <<-EOF && - # rebase in progress; onto $ONTO - # You are currently editing a commit while rebasing branch '\''amend_last'\'' on '\''$ONTO'\''. - # (use "git commit --amend" to amend the current commit) - # (use "git rebase --continue" once you are satisfied with your changes) - # - nothing to commit (use -u to show untracked files) - EOF + cat >expected <<EOF && +rebase in progress; onto $ONTO +You are currently editing a commit while rebasing branch '\''amend_last'\'' on '\''$ONTO'\''. + (use "git commit --amend" to amend the current commit) + (use "git rebase --continue" once you are satisfied with your changes) + +nothing to commit (use -u to show untracked files) +EOF git status --untracked-files=no >actual && test_i18ncmp expected actual ' @@ -276,14 +276,14 @@ test_expect_success 'status: (continue first edit) second edit' ' ONTO=$(git rev-parse --short HEAD~3) && git rebase -i HEAD~3 && git rebase --continue && - cat >expected <<-EOF && - # rebase in progress; onto $ONTO - # You are currently editing a commit while rebasing branch '\''several_edits'\'' on '\''$ONTO'\''. - # (use "git commit --amend" to amend the current commit) - # (use "git rebase --continue" once you are satisfied with your changes) - # - nothing to commit (use -u to show untracked files) - EOF + cat >expected <<EOF && +rebase in progress; onto $ONTO +You are currently editing a commit while rebasing branch '\''several_edits'\'' on '\''$ONTO'\''. + (use "git commit --amend" to amend the current commit) + (use "git rebase --continue" once you are satisfied with your changes) + +nothing to commit (use -u to show untracked files) +EOF git status --untracked-files=no >actual && test_i18ncmp expected actual ' @@ -298,19 +298,19 @@ test_expect_success 'status: (continue first edit) second edit and split' ' git rebase -i HEAD~3 && git rebase --continue && git reset HEAD^ && - cat >expected <<-EOF && - # rebase in progress; onto $ONTO - # You are currently splitting a commit while rebasing branch '\''several_edits'\'' on '\''$ONTO'\''. - # (Once your working directory is clean, run "git rebase --continue") - # - # Changes not staged for commit: - # (use "git add <file>..." to update what will be committed) - # (use "git checkout -- <file>..." to discard changes in working directory) - # - # modified: main.txt - # - no changes added to commit (use "git add" and/or "git commit -a") - EOF + cat >expected <<EOF && +rebase in progress; onto $ONTO +You are currently splitting a commit while rebasing branch '\''several_edits'\'' on '\''$ONTO'\''. + (Once your working directory is clean, run "git rebase --continue") + +Changes not staged for commit: + (use "git add <file>..." to update what will be committed) + (use "git checkout -- <file>..." to discard changes in working directory) + + modified: main.txt + +no changes added to commit (use "git add" and/or "git commit -a") +EOF git status --untracked-files=no >actual && test_i18ncmp expected actual ' @@ -325,14 +325,14 @@ test_expect_success 'status: (continue first edit) second edit and amend' ' git rebase -i HEAD~3 && git rebase --continue && git commit --amend -m "foo" && - cat >expected <<-EOF && - # rebase in progress; onto $ONTO - # You are currently editing a commit while rebasing branch '\''several_edits'\'' on '\''$ONTO'\''. - # (use "git commit --amend" to amend the current commit) - # (use "git rebase --continue" once you are satisfied with your changes) - # - nothing to commit (use -u to show untracked files) - EOF + cat >expected <<EOF && +rebase in progress; onto $ONTO +You are currently editing a commit while rebasing branch '\''several_edits'\'' on '\''$ONTO'\''. + (use "git commit --amend" to amend the current commit) + (use "git rebase --continue" once you are satisfied with your changes) + +nothing to commit (use -u to show untracked files) +EOF git status --untracked-files=no >actual && test_i18ncmp expected actual ' @@ -347,14 +347,14 @@ test_expect_success 'status: (amend first edit) second edit' ' git rebase -i HEAD~3 && git commit --amend -m "a" && git rebase --continue && - cat >expected <<-EOF && - # rebase in progress; onto $ONTO - # You are currently editing a commit while rebasing branch '\''several_edits'\'' on '\''$ONTO'\''. - # (use "git commit --amend" to amend the current commit) - # (use "git rebase --continue" once you are satisfied with your changes) - # - nothing to commit (use -u to show untracked files) - EOF + cat >expected <<EOF && +rebase in progress; onto $ONTO +You are currently editing a commit while rebasing branch '\''several_edits'\'' on '\''$ONTO'\''. + (use "git commit --amend" to amend the current commit) + (use "git rebase --continue" once you are satisfied with your changes) + +nothing to commit (use -u to show untracked files) +EOF git status --untracked-files=no >actual && test_i18ncmp expected actual ' @@ -370,19 +370,19 @@ test_expect_success 'status: (amend first edit) second edit and split' ' git commit --amend -m "b" && git rebase --continue && git reset HEAD^ && - cat >expected <<-EOF && - # rebase in progress; onto $ONTO - # You are currently splitting a commit while rebasing branch '\''several_edits'\'' on '\''$ONTO'\''. - # (Once your working directory is clean, run "git rebase --continue") - # - # Changes not staged for commit: - # (use "git add <file>..." to update what will be committed) - # (use "git checkout -- <file>..." to discard changes in working directory) - # - # modified: main.txt - # - no changes added to commit (use "git add" and/or "git commit -a") - EOF + cat >expected <<EOF && +rebase in progress; onto $ONTO +You are currently splitting a commit while rebasing branch '\''several_edits'\'' on '\''$ONTO'\''. + (Once your working directory is clean, run "git rebase --continue") + +Changes not staged for commit: + (use "git add <file>..." to update what will be committed) + (use "git checkout -- <file>..." to discard changes in working directory) + + modified: main.txt + +no changes added to commit (use "git add" and/or "git commit -a") +EOF git status --untracked-files=no >actual && test_i18ncmp expected actual ' @@ -398,14 +398,14 @@ test_expect_success 'status: (amend first edit) second edit and amend' ' git commit --amend -m "c" && git rebase --continue && git commit --amend -m "d" && - cat >expected <<-EOF && - # rebase in progress; onto $ONTO - # You are currently editing a commit while rebasing branch '\''several_edits'\'' on '\''$ONTO'\''. - # (use "git commit --amend" to amend the current commit) - # (use "git rebase --continue" once you are satisfied with your changes) - # - nothing to commit (use -u to show untracked files) - EOF + cat >expected <<EOF && +rebase in progress; onto $ONTO +You are currently editing a commit while rebasing branch '\''several_edits'\'' on '\''$ONTO'\''. + (use "git commit --amend" to amend the current commit) + (use "git rebase --continue" once you are satisfied with your changes) + +nothing to commit (use -u to show untracked files) +EOF git status --untracked-files=no >actual && test_i18ncmp expected actual ' @@ -422,14 +422,14 @@ test_expect_success 'status: (split first edit) second edit' ' git add main.txt && git commit -m "e" && git rebase --continue && - cat >expected <<-EOF && - # rebase in progress; onto $ONTO - # You are currently editing a commit while rebasing branch '\''several_edits'\'' on '\''$ONTO'\''. - # (use "git commit --amend" to amend the current commit) - # (use "git rebase --continue" once you are satisfied with your changes) - # - nothing to commit (use -u to show untracked files) - EOF + cat >expected <<EOF && +rebase in progress; onto $ONTO +You are currently editing a commit while rebasing branch '\''several_edits'\'' on '\''$ONTO'\''. + (use "git commit --amend" to amend the current commit) + (use "git rebase --continue" once you are satisfied with your changes) + +nothing to commit (use -u to show untracked files) +EOF git status --untracked-files=no >actual && test_i18ncmp expected actual ' @@ -447,19 +447,19 @@ test_expect_success 'status: (split first edit) second edit and split' ' git commit --amend -m "f" && git rebase --continue && git reset HEAD^ && - cat >expected <<-EOF && - # rebase in progress; onto $ONTO - # You are currently splitting a commit while rebasing branch '\''several_edits'\'' on '\''$ONTO'\''. - # (Once your working directory is clean, run "git rebase --continue") - # - # Changes not staged for commit: - # (use "git add <file>..." to update what will be committed) - # (use "git checkout -- <file>..." to discard changes in working directory) - # - # modified: main.txt - # - no changes added to commit (use "git add" and/or "git commit -a") - EOF + cat >expected <<EOF && +rebase in progress; onto $ONTO +You are currently splitting a commit while rebasing branch '\''several_edits'\'' on '\''$ONTO'\''. + (Once your working directory is clean, run "git rebase --continue") + +Changes not staged for commit: + (use "git add <file>..." to update what will be committed) + (use "git checkout -- <file>..." to discard changes in working directory) + + modified: main.txt + +no changes added to commit (use "git add" and/or "git commit -a") +EOF git status --untracked-files=no >actual && test_i18ncmp expected actual ' @@ -477,14 +477,14 @@ test_expect_success 'status: (split first edit) second edit and amend' ' git commit --amend -m "g" && git rebase --continue && git commit --amend -m "h" && - cat >expected <<-EOF && - # rebase in progress; onto $ONTO - # You are currently editing a commit while rebasing branch '\''several_edits'\'' on '\''$ONTO'\''. - # (use "git commit --amend" to amend the current commit) - # (use "git rebase --continue" once you are satisfied with your changes) - # - nothing to commit (use -u to show untracked files) - EOF + cat >expected <<EOF && +rebase in progress; onto $ONTO +You are currently editing a commit while rebasing branch '\''several_edits'\'' on '\''$ONTO'\''. + (use "git commit --amend" to amend the current commit) + (use "git rebase --continue" once you are satisfied with your changes) + +nothing to commit (use -u to show untracked files) +EOF git status --untracked-files=no >actual && test_i18ncmp expected actual ' @@ -504,15 +504,15 @@ test_expect_success 'status in an am session: file already exists' ' test_when_finished "rm Maildir/* && git am --abort" && git format-patch -1 -oMaildir && test_must_fail git am Maildir/*.patch && - cat >expected <<-\EOF && - # On branch am_already_exists - # You are in the middle of an am session. - # (fix conflicts and then run "git am --continue") - # (use "git am --skip" to skip this patch) - # (use "git am --abort" to restore the original branch) - # - nothing to commit (use -u to show untracked files) - EOF + cat >expected <<\EOF && +On branch am_already_exists +You are in the middle of an am session. + (fix conflicts and then run "git am --continue") + (use "git am --skip" to skip this patch) + (use "git am --abort" to restore the original branch) + +nothing to commit (use -u to show untracked files) +EOF git status --untracked-files=no >actual && test_i18ncmp expected actual ' @@ -526,15 +526,15 @@ test_expect_success 'status in an am session: file does not exist' ' test_when_finished "rm Maildir/* && git am --abort" && git format-patch -1 -oMaildir && test_must_fail git am Maildir/*.patch && - cat >expected <<-\EOF && - # On branch am_not_exists - # You are in the middle of an am session. - # (fix conflicts and then run "git am --continue") - # (use "git am --skip" to skip this patch) - # (use "git am --abort" to restore the original branch) - # - nothing to commit (use -u to show untracked files) - EOF + cat >expected <<\EOF && +On branch am_not_exists +You are in the middle of an am session. + (fix conflicts and then run "git am --continue") + (use "git am --skip" to skip this patch) + (use "git am --abort" to restore the original branch) + +nothing to commit (use -u to show untracked files) +EOF git status --untracked-files=no >actual && test_i18ncmp expected actual ' @@ -549,15 +549,15 @@ test_expect_success 'status in an am session: empty patch' ' git commit -m "delete all am_empty" && echo error >Maildir/0002-two_am.patch && test_must_fail git am Maildir/*.patch && - cat >expected <<-\EOF && - # On branch am_empty - # You are in the middle of an am session. - # The current patch is empty. - # (use "git am --skip" to skip this patch) - # (use "git am --abort" to restore the original branch) - # - nothing to commit (use -u to show untracked files) - EOF + cat >expected <<\EOF && +On branch am_empty +You are in the middle of an am session. +The current patch is empty. + (use "git am --skip" to skip this patch) + (use "git am --abort" to restore the original branch) + +nothing to commit (use -u to show untracked files) +EOF git status --untracked-files=no >actual && test_i18ncmp expected actual ' @@ -574,13 +574,13 @@ test_expect_success 'status when bisecting' ' git bisect bad && git bisect good one_bisect && TGT=$(git rev-parse --short two_bisect) && - cat >expected <<-EOF && - # HEAD detached at $TGT - # You are currently bisecting, started from branch '\''bisect'\''. - # (use "git bisect reset" to get back to the original branch) - # - nothing to commit (use -u to show untracked files) - EOF + cat >expected <<EOF && +HEAD detached at $TGT +You are currently bisecting, started from branch '\''bisect'\''. + (use "git bisect reset" to get back to the original branch) + +nothing to commit (use -u to show untracked files) +EOF git status --untracked-files=no >actual && test_i18ncmp expected actual ' @@ -597,15 +597,15 @@ test_expect_success 'status when rebase conflicts with statushints disabled' ' test_when_finished "git rebase --abort" && ONTO=$(git rev-parse --short HEAD^^) && test_must_fail git rebase HEAD^ --onto HEAD^^ && - cat >expected <<-EOF && - # rebase in progress; onto $ONTO - # You are currently rebasing branch '\''statushints_disabled'\'' on '\''$ONTO'\''. - # - # Unmerged paths: - # both modified: main.txt - # - no changes added to commit - EOF + cat >expected <<EOF && +rebase in progress; onto $ONTO +You are currently rebasing branch '\''statushints_disabled'\'' on '\''$ONTO'\''. + +Unmerged paths: + both modified: main.txt + +no changes added to commit +EOF git status --untracked-files=no >actual && test_i18ncmp expected actual ' @@ -626,19 +626,19 @@ test_expect_success 'prepare for cherry-pick conflicts' ' test_expect_success 'status when cherry-picking before resolving conflicts' ' test_when_finished "git cherry-pick --abort" && test_must_fail git cherry-pick cherry_branch_second && - cat >expected <<-\EOF && - # On branch cherry_branch - # You are currently cherry-picking. - # (fix conflicts and run "git cherry-pick --continue") - # (use "git cherry-pick --abort" to cancel the cherry-pick operation) - # - # Unmerged paths: - # (use "git add <file>..." to mark resolution) - # - # both modified: main.txt - # - no changes added to commit (use "git add" and/or "git commit -a") - EOF + cat >expected <<\EOF && +On branch cherry_branch +You are currently cherry-picking. + (fix conflicts and run "git cherry-pick --continue") + (use "git cherry-pick --abort" to cancel the cherry-pick operation) + +Unmerged paths: + (use "git add <file>..." to mark resolution) + + both modified: main.txt + +no changes added to commit (use "git add" and/or "git commit -a") +EOF git status --untracked-files=no >actual && test_i18ncmp expected actual ' @@ -650,18 +650,18 @@ test_expect_success 'status when cherry-picking after resolving conflicts' ' test_must_fail git cherry-pick cherry_branch_second && echo end >main.txt && git add main.txt && - cat >expected <<-\EOF && - # On branch cherry_branch - # You are currently cherry-picking. - # (all conflicts fixed: run "git cherry-pick --continue") - # (use "git cherry-pick --abort" to cancel the cherry-pick operation) - # - # Changes to be committed: - # - # modified: main.txt - # - # Untracked files not listed (use -u option to show untracked files) - EOF + cat >expected <<\EOF && +On branch cherry_branch +You are currently cherry-picking. + (all conflicts fixed: run "git cherry-pick --continue") + (use "git cherry-pick --abort" to cancel the cherry-pick operation) + +Changes to be committed: + + modified: main.txt + +Untracked files not listed (use -u option to show untracked files) +EOF git status --untracked-files=no >actual && test_i18ncmp expected actual ' @@ -669,18 +669,18 @@ test_expect_success 'status when cherry-picking after resolving conflicts' ' test_expect_success 'status showing detached at and from a tag' ' test_commit atag tagging && git checkout atag && - cat >expected <<-\EOF - # HEAD detached at atag - nothing to commit (use -u to show untracked files) - EOF + cat >expected <<\EOF +HEAD detached at atag +nothing to commit (use -u to show untracked files) +EOF git status --untracked-files=no >actual && test_i18ncmp expected actual && git reset --hard HEAD^ && - cat >expected <<-\EOF - # HEAD detached from atag - nothing to commit (use -u to show untracked files) - EOF + cat >expected <<\EOF +HEAD detached from atag +nothing to commit (use -u to show untracked files) +EOF git status --untracked-files=no >actual && test_i18ncmp expected actual ' @@ -695,20 +695,20 @@ test_expect_success 'status while reverting commit (conflicts)' ' test_commit new to-revert.txt && TO_REVERT=$(git rev-parse --short HEAD^) && test_must_fail git revert $TO_REVERT && - cat >expected <<-EOF - # On branch master - # You are currently reverting commit $TO_REVERT. - # (fix conflicts and run "git revert --continue") - # (use "git revert --abort" to cancel the revert operation) - # - # Unmerged paths: - # (use "git reset HEAD <file>..." to unstage) - # (use "git add <file>..." to mark resolution) - # - # both modified: to-revert.txt - # - no changes added to commit (use "git add" and/or "git commit -a") - EOF + cat >expected <<EOF +On branch master +You are currently reverting commit $TO_REVERT. + (fix conflicts and run "git revert --continue") + (use "git revert --abort" to cancel the revert operation) + +Unmerged paths: + (use "git reset HEAD <file>..." to unstage) + (use "git add <file>..." to mark resolution) + + both modified: to-revert.txt + +no changes added to commit (use "git add" and/or "git commit -a") +EOF git status --untracked-files=no >actual && test_i18ncmp expected actual ' @@ -716,29 +716,29 @@ test_expect_success 'status while reverting commit (conflicts)' ' test_expect_success 'status while reverting commit (conflicts resolved)' ' echo reverted >to-revert.txt && git add to-revert.txt && - cat >expected <<-EOF - # On branch master - # You are currently reverting commit $TO_REVERT. - # (all conflicts fixed: run "git revert --continue") - # (use "git revert --abort" to cancel the revert operation) - # - # Changes to be committed: - # (use "git reset HEAD <file>..." to unstage) - # - # modified: to-revert.txt - # - # Untracked files not listed (use -u option to show untracked files) - EOF + cat >expected <<EOF +On branch master +You are currently reverting commit $TO_REVERT. + (all conflicts fixed: run "git revert --continue") + (use "git revert --abort" to cancel the revert operation) + +Changes to be committed: + (use "git reset HEAD <file>..." to unstage) + + modified: to-revert.txt + +Untracked files not listed (use -u option to show untracked files) +EOF git status --untracked-files=no >actual && test_i18ncmp expected actual ' test_expect_success 'status after reverting commit' ' git revert --continue && - cat >expected <<-\EOF - # On branch master - nothing to commit (use -u to show untracked files) - EOF + cat >expected <<\EOF +On branch master +nothing to commit (use -u to show untracked files) +EOF git status --untracked-files=no >actual && test_i18ncmp expected actual ' diff --git a/t/t9300-fast-import.sh b/t/t9300-fast-import.sh index 31a770d9bc..88fc407ed6 100755 --- a/t/t9300-fast-import.sh +++ b/t/t9300-fast-import.sh @@ -2864,14 +2864,14 @@ test_expect_success 'S: notemodify with garbage after sha1 dataref must fail' ' ' # -# notemodify, mark in committish +# notemodify, mark in commit-ish # -test_expect_success 'S: notemodify with garbarge after mark committish must fail' ' +test_expect_success 'S: notemodify with garbarge after mark commit-ish must fail' ' test_must_fail git fast-import --import-marks=marks <<-EOF 2>err && commit refs/heads/Snotes committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE data <<COMMIT - commit S note committish + commit S note commit-ish COMMIT N :202 :302x EOF diff --git a/t/test-lib.sh b/t/test-lib.sh index 1aa27bdbbf..0fa7dfde7b 100644 --- a/t/test-lib.sh +++ b/t/test-lib.sh @@ -700,15 +700,6 @@ test -d "$GIT_BUILD_DIR"/templates/blt || { error "You haven't built things yet, have you?" } -if test -z "$GIT_TEST_INSTALLED" && test -z "$NO_PYTHON" -then - GITPYTHONLIB="$GIT_BUILD_DIR/git_remote_helpers/build/lib" - export GITPYTHONLIB - test -d "$GIT_BUILD_DIR"/git_remote_helpers/build || { - error "You haven't built git_remote_helpers yet, have you?" - } -fi - if ! test -x "$GIT_BUILD_DIR"/test-chmtime then echo >&2 'You need to build test-chmtime:' |