Merge branch 'jc/int'
authorJunio C Hamano <junkio@cox.net>
Sun, 14 Jan 2007 20:04:25 +0000 (12:04 -0800)
committerJunio C Hamano <junkio@cox.net>
Sun, 14 Jan 2007 20:04:25 +0000 (12:04 -0800)
* jc/int:
More tests in t3901.
Consistent message encoding while reusing log from an existing commit.
t3901: test "format-patch | am" pipe with i18n
Use log output encoding in --pretty=email headers.

15 files changed:
Documentation/git-commit.txt
cache.h
git-checkout.sh
git-commit.sh
git-fetch.sh
git-merge.sh
git-pull.sh
git-rebase.sh
git-reset.sh
git-revert.sh
git-sh-setup.sh
sha1_file.c
t/lib-git-svn.sh
write_or_die.c
wt-status.c
index cb081cda891e6a740b6a1d2772789aabf923bf69..b4528d72ba376bb0444002698196afa89f781fc1 100644 (file)
@@ -32,7 +32,8 @@ methods:
 
 4. by using the -a switch with the 'commit' command to automatically "add"
    changes from all known files i.e. files that have already been committed
-   before, and perform the actual commit.
+   before, and to automatically "rm" files that have been
+   removed from the working tree, and perform the actual commit.
 
 The gitlink:git-status[1] command can be used to obtain a
 summary of what is included by any of the above for the next
diff --git a/cache.h b/cache.h
index c482c32a03ebc55a293aa96c8add08abf355f2ea..620b6a4ed47b9b94700a7f9bec270aca7efe29db 100644 (file)
--- a/cache.h
+++ b/cache.h
@@ -434,7 +434,6 @@ extern char *git_log_output_encoding;
 
 extern int copy_fd(int ifd, int ofd);
 extern int read_in_full(int fd, void *buf, size_t count);
-extern void read_or_die(int fd, void *buf, size_t count);
 extern int write_in_full(int fd, const void *buf, size_t count);
 extern void write_or_die(int fd, const void *buf, size_t count);
 extern int write_or_whine(int fd, const void *buf, size_t count, const char *msg);
index a2b8e4fa4aa3607ce4981c84b9c6f9d31a9dec97..66e40b90ebfa8e65e9c42731203f10dde0424b8c 100755 (executable)
@@ -135,11 +135,7 @@ fi
 
 # We are switching branches and checking out trees, so
 # we *NEED* to be at the toplevel.
-cdup=$(git-rev-parse --show-cdup)
-if test ! -z "$cdup"
-then
-       cd "$cdup"
-fi
+cd_to_toplevel
 
 [ -z "$new" ] && new=$old && new_name="$old_name"
 
index b6387239dda2d9314b37eeabc2ff79bb4b013e01..e23918cd6c515e193d3bc5d476c360001fdc1222 100755 (executable)
@@ -316,22 +316,16 @@ esac
 ################################################################
 # Prepare index to have a tree to be committed
 
-TOP=`git-rev-parse --show-cdup`
-if test -z "$TOP"
-then
-       TOP=./
-fi
-
 case "$all,$also" in
 t,)
        save_index &&
        (
-               cd "$TOP"
-               GIT_INDEX_FILE="$NEXT_INDEX"
-               export GIT_INDEX_FILE
+               cd_to_toplevel &&
+               GIT_INDEX_FILE="$NEXT_INDEX" &&
+               export GIT_INDEX_FILE &&
                git-diff-files --name-only -z |
                git-update-index --remove -z --stdin
-       )
+       ) || exit
        ;;
 ,t)
        save_index &&
@@ -339,11 +333,11 @@ t,)
 
        git-diff-files --name-only -z -- "$@"  |
        (
-               cd "$TOP"
-               GIT_INDEX_FILE="$NEXT_INDEX"
-               export GIT_INDEX_FILE
+               cd_to_toplevel &&
+               GIT_INDEX_FILE="$NEXT_INDEX" &&
+               export GIT_INDEX_FILE &&
                git-update-index --remove -z --stdin
-       )
+       ) || exit
        ;;
 ,)
        case "$#" in
index c58704d7946d47d238f1dd25bad00d7d29533b48..87b940b85b5b128f29dc6084bb545640e5bf6b92 100755 (executable)
@@ -5,12 +5,8 @@ USAGE='<fetch-options> <repository> <refspec>...'
 SUBDIRECTORY_OK=Yes
 . git-sh-setup
 set_reflog_action "fetch $*"
+cd_to_toplevel ;# probably unnecessary...
 
-TOP=$(git-rev-parse --show-cdup)
-if test ! -z "$TOP"
-then
-       cd "$TOP"
-fi
 . git-parse-remote
 _x40='[0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f]'
 _x40="$_x40$_x40$_x40$_x40$_x40$_x40$_x40$_x40"
index 3eef048efc7a848145697e205d154c92f8c7ec0f..7b590268edb44cc5455fe9bdbcbfc0698a6fb800 100755 (executable)
@@ -5,12 +5,14 @@
 
 USAGE='[-n] [--no-commit] [--squash] [-s <strategy>] [-m=<merge-message>] <commit>+'
 
+SUBDIRECTORY_OK=Yes
 . git-sh-setup
 set_reflog_action "merge $*"
 require_work_tree
+cd_to_toplevel
 
 test -z "$(git ls-files -u)" ||
-       die "You are in a middle of conflicted merge."
+       die "You are in the middle of a conflicted merge."
 
 LF='
 '
@@ -299,24 +301,30 @@ f,*)
        ;;
 ?,1,*,)
        # We are not doing octopus, not fast forward, and have only
-       # one common.  See if it is really trivial.
-       git var GIT_COMMITTER_IDENT >/dev/null || exit
-
-       echo "Trying really trivial in-index merge..."
+       # one common.
        git-update-index --refresh 2>/dev/null
-       if git-read-tree --trivial -m -u -v $common $head "$1" &&
-          result_tree=$(git-write-tree)
-       then
-           echo "Wonderful."
-           result_commit=$(
-               echo "$merge_msg" |
-               git-commit-tree $result_tree -p HEAD -p "$1"
-           ) || exit
-           finish "$result_commit" "In-index merge"
-           dropsave
-           exit 0
-       fi
-       echo "Nope."
+       case " $use_strategies " in
+       *' recursive '*|*' recur '*)
+               : run merge later
+               ;;
+       *)
+               # See if it is really trivial.
+               git var GIT_COMMITTER_IDENT >/dev/null || exit
+               echo "Trying really trivial in-index merge..."
+               if git-read-tree --trivial -m -u -v $common $head "$1" &&
+                  result_tree=$(git-write-tree)
+               then
+                       echo "Wonderful."
+                       result_commit=$(
+                               echo "$merge_msg" |
+                               git-commit-tree $result_tree -p HEAD -p "$1"
+                       ) || exit
+                       finish "$result_commit" "In-index merge"
+                       dropsave
+                       exit 0
+               fi
+               echo "Nope."
+       esac
        ;;
 *)
        # An octopus.  If we can reach all the remote we are up to date.
index e9826fc4cec14d82171f495af25324b24fe9f19b..959261757c1fd8df50f7894ba449b76d621f3c45 100755 (executable)
@@ -6,12 +6,14 @@
 
 USAGE='[-n | --no-summary] [--no-commit] [-s strategy]... [<fetch-options>] <repo> <head>...'
 LONG_USAGE='Fetch one or more remote refs and merge it/them into the current HEAD.'
+SUBDIRECTORY_OK=Yes
 . git-sh-setup
 set_reflog_action "pull $*"
 require_work_tree
+cd_to_toplevel
 
 test -z "$(git ls-files -u)" ||
-       die "You are in a middle of conflicted merge."
+       die "You are in the middle of a conflicted merge."
 
 strategy_args= no_summary= no_commit= squash=
 while case "$#,$1" in 0) break ;; *,-*) ;; *) break ;; esac
index 98f9558145f269e05e121006a5853368f0572abf..c8bd0f99d1306cd311eaf45f73581efc8bb0e512 100755 (executable)
@@ -27,9 +27,12 @@ Example:       git-rebase master~1 topic
        /                   -->           /
   D---E---F---G master          D---E---F---G master
 '
+
+SUBDIRECTORY_OK=Yes
 . git-sh-setup
 set_reflog_action rebase
 require_work_tree
+cd_to_toplevel
 
 RESOLVEMSG="
 When you have resolved this problem run \"git rebase --continue\".
index b9045bc762471b462c3c99a5357b4b30421ea49f..91c7e6e664eeac0a130044d3d026ccbbfa00f3b3 100755 (executable)
@@ -53,11 +53,7 @@ then
        exit
 fi
 
-TOP=$(git-rev-parse --show-cdup)
-if test ! -z "$TOP"
-then
-       cd "$TOP"
-fi
+cd_to_toplevel
 
 if test "$reset_type" = "--hard"
 then
index fcbefb4e688317ebbd6563da898ff6010e8b660b..71cbcbc2b886b2770c61c4b3a496db913ef56d9d 100755 (executable)
@@ -19,8 +19,11 @@ case "$0" in
        echo >&2 "What are you talking about?"
        exit 1 ;;
 esac
+
+SUBDIRECTORY_OK=Yes ;# we will cd up
 . git-sh-setup
 require_work_tree
+cd_to_toplevel
 
 no_commit=
 while case "$#" in 0) break ;; esac
index 57f7f7777602eadc79b6bb04e6652d81d14d770c..6b1c1423ebb7fde53aae566fa09211d331c422bc 100755 (executable)
@@ -36,6 +36,17 @@ is_bare_repository () {
        esac
 }
 
+cd_to_toplevel () {
+       cdup=$(git-rev-parse --show-cdup)
+       if test ! -z "$cdup"
+       then
+               cd "$cdup" || {
+                       echo >&2 "Cannot chdir to $cdup, the toplevel of the working tree"
+                       exit 1
+               }
+       fi
+}
+
 require_work_tree () {
        test $(is_bare_repository) = false ||
        die "fatal: $0 cannot be used without a working tree."
index 2a5be53faca4524f5a70e6e928044ba3aa402d8f..1b1c0f7b4dc814764ead5ba1af77070ed381110c 100644 (file)
@@ -572,7 +572,8 @@ static void open_packed_git(struct packed_git *p)
                die("cannot set FD_CLOEXEC");
 
        /* Verify we recognize this pack file format. */
-       read_or_die(p->pack_fd, &hdr, sizeof(hdr));
+       if (read_in_full(p->pack_fd, &hdr, sizeof(hdr)) != sizeof(hdr))
+               die("file %s is far too short to be a packfile", p->pack_name);
        if (hdr.hdr_signature != htonl(PACK_SIGNATURE))
                die("file %s is not a GIT packfile", p->pack_name);
        if (!pack_version_ok(hdr.hdr_version))
@@ -588,7 +589,8 @@ static void open_packed_git(struct packed_git *p)
                        num_packed_objects(p));
        if (lseek(p->pack_fd, p->pack_size - sizeof(sha1), SEEK_SET) == -1)
                die("end of packfile %s is unavailable", p->pack_name);
-       read_or_die(p->pack_fd, sha1, sizeof(sha1));
+       if (read_in_full(p->pack_fd, sha1, sizeof(sha1)) != sizeof(sha1))
+               die("packfile %s signature is unavailable", p->pack_name);
        idx_sha1 = ((unsigned char *)p->index_base) + p->index_size - 40;
        if (hashcmp(sha1, idx_sha1))
                die("packfile %s does not match index", p->pack_name);
index a0f28140837cc427b6c244bb5234e261cfec77d6..bb1d7b84bcdd3a413e900a0002baf268fa631f3f 100644 (file)
@@ -26,7 +26,7 @@ use SVN::Core;
 use SVN::Repos;
 \$SVN::Core::VERSION gt '1.1.0' or exit(42);
 system(qw/svnadmin create --fs-type fsfs/, '$svnrepo') == 0 or exit(41);
-"
+" >&3 2>&4
 x=$?
 if test $x -ne 0
 then
index 4e8183e93e88e7336baed561b026b702b9dcba4e..046e79d485feaa26d305868012f73b04088366b6 100644 (file)
@@ -17,18 +17,6 @@ int read_in_full(int fd, void *buf, size_t count)
        return total;
 }
 
-void read_or_die(int fd, void *buf, size_t count)
-{
-       ssize_t loaded;
-
-       loaded = read_in_full(fd, buf, count);
-       if (loaded != count) {
-               if (loaded < 0)
-                       die("read error (%s)", strerror(errno));
-               die("read error: end of file");
-       }
-}
-
 int write_in_full(int fd, const void *buf, size_t count)
 {
        const char *p = buf;
index daba9a6105882c671edd7da21f0a9ae34fbdaaa4..b7250e43100244abcdaa5bc923574aad7f815d0b 100644 (file)
@@ -335,7 +335,7 @@ void wt_status_print(struct wt_status *s)
                if (s->amend)
                        printf("# No changes\n");
                else if (s->workdir_dirty)
-                       printf("no changes added to commit (use \"git add\" and/or \"git commit [-a|-i|-o]\")\n");
+                       printf("no changes added to commit (use \"git add\" and/or \"git commit -a\")\n");
                else if (s->workdir_untracked)
                        printf("nothing added to commit but untracked files present (use \"git add\" to track)\n");
                else if (s->is_initial)