unexpected empty commit after checkout with uncommitted index

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The following test script fails after 83ae209 (checkout branch: prime cache-tree fully, 2009-04-20).

--
Chris

#!/usr/bin/env dash
abort() {
    printf "$@"
    exit 128
}
failed=0
fail() {
    failed=1
    printf "$@"
}

set -e

GIT="${1:-git}"
case "$GIT" in
./*|../*) GIT="$PWD/$GIT"
esac
type "$GIT" > /dev/null ||
    abort 'bad git command?: %s\n' "$GIT"

tn=checkout-with-changed-index
td="$(mktemp -d -t "$tn")"
if test -z "$td"; then
    td="/tmp/$tn"
    mkdir "$td" ||
        abort 'unable to create test dir: %s\n' "$td"
    test -d "$td"/.git &&
        abort '.git already exists in test dir: %s\n' "$td"
fi
trap 'rm -rf "$td"' 0

cd "$td"
"$GIT" --version
"$GIT" init
echo foo > foo
echo bar > bar
"$GIT" add foo bar
"$GIT" commit -m 'add foo, bar'
echo BAR > bar
echo baz > baz
"$GIT" rm foo
"$GIT" add bar baz
"$GIT" checkout -b new
"$GIT" commit -m 'rm foo, change bar, add baz'

# After 83ae209 the commit on "new" (or even a detached HEAD if
# we use "HEAD@{0}" instead of "-b new") appears to be an empty
# commit. The same thing happens whether the changes (add new, rm
# existing, add edited) are done in a group, as above, or
# individually.  Both before and after the commit, [git status]
# seems to show that the changes are properly staged, but they
# never make it into the committed tree. [git reset] and then
# [git add --all] resolves the strange state and allows the
# expected commit to take place.

test -z "$("$GIT" ls-tree HEAD foo)" ||
    fail '*** foo was not removed\n'
test "$("$GIT" cat-file blob HEAD:bar)" = "BAR" ||
    fail '*** bar was not changed\n'
test "$("$GIT" cat-file blob HEAD:baz)" = "baz" ||
    fail '*** baz was not added\n'
exit $failed

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]