Merge branch 'master' into jc/combine
authorJunio C Hamano <junkio@cox.net>
Wed, 12 Apr 2006 20:24:04 +0000 (13:24 -0700)
committerJunio C Hamano <junkio@cox.net>
Wed, 12 Apr 2006 20:24:04 +0000 (13:24 -0700)
* master:
  stripspace: make sure not to leave an incomplete line.
  git-commit: do not muck with commit message when no_edit is set.
  When showing a commit message, do not lose an incomplete line.
  Retire t5501-old-fetch-and-upload test.

commit.c
git-commit.sh
stripspace.c
t/t5501-old-fetch-and-upload.sh [deleted file]

index d534c9b..c7bb8db 100644 (file)
--- a/commit.c
+++ b/commit.c
@@ -400,11 +400,11 @@ static int get_one_line(const char *msg, unsigned long len)
 
        while (len--) {
                char c = *msg++;
+               if (!c)
+                       break;
                ret++;
                if (c == '\n')
                        break;
-               if (!c)
-                       return 0;
        }
        return ret;
 }
index 1e7c09e..bd3dc71 100755 (executable)
@@ -537,7 +537,7 @@ t)
        ;;
 esac
 
-if [ -f "$GIT_DIR/MERGE_HEAD" ]; then
+if test -f "$GIT_DIR/MERGE_HEAD" && test -z "$no_edit"; then
        echo "#"
        echo "# It looks like you may be committing a MERGE."
        echo "# If this is not correct, please remove the file"
@@ -605,16 +605,23 @@ else
        current=
 fi
 
-{
-       test -z "$only_include_assumed" || echo "$only_include_assumed"
-       run_status
-} >>"$GIT_DIR"/COMMIT_EDITMSG
+if test -z "$no_edit"
+then
+       {
+               test -z "$only_include_assumed" || echo "$only_include_assumed"
+               run_status
+       } >>"$GIT_DIR"/COMMIT_EDITMSG
+else
+       # we need to check if there is anything to commit
+       run_status >/dev/null 
+fi
 if [ "$?" != "0" -a ! -f "$GIT_DIR/MERGE_HEAD" -a -z "$amend" ]
 then
        rm -f "$GIT_DIR/COMMIT_EDITMSG"
        run_status
        exit 1
 fi
+
 case "$no_edit" in
 '')
        case "${VISUAL:-$EDITOR},$TERM" in
index 96cd0a8..dee1ef0 100644 (file)
@@ -6,9 +6,9 @@
  * Remove empty lines from the beginning and end.
  *
  * Turn multiple consecutive empty lines into just one
- * empty line.
+ * empty line.  Return true if it is an incomplete line.
  */
-static void cleanup(char *line)
+static int cleanup(char *line)
 {
        int len = strlen(line);
 
@@ -21,16 +21,19 @@ static void cleanup(char *line)
                        len--;
                        line[len] = 0;
                } while (len > 1);
+               return 0;
        }
+       return 1;
 }
 
 int main(int argc, char **argv)
 {
        int empties = -1;
+       int incomplete = 0;
        char line[1024];
 
        while (fgets(line, sizeof(line), stdin)) {
-               cleanup(line);
+               incomplete = cleanup(line);
 
                /* Not just an empty line? */
                if (line[0] != '\n') {
@@ -44,5 +47,7 @@ int main(int argc, char **argv)
                        continue;
                empties++;
        }
+       if (incomplete)
+               putchar('\n');
        return 0;
 }
diff --git a/t/t5501-old-fetch-and-upload.sh b/t/t5501-old-fetch-and-upload.sh
deleted file mode 100755 (executable)
index 596c88b..0000000
+++ /dev/null
@@ -1,48 +0,0 @@
-#!/bin/sh
-#
-# Copyright (c) 2005 Johannes Schindelin
-#
-
-# Test that the current fetch-pack/upload-pack plays nicely with
-# an old counterpart
-
-cd $(dirname $0) || exit 1
-: ${SHELL_PATH=/bin/sh}
-
-tmp=`pwd`/.tmp$$
-
-retval=0
-
-if [ -z "$1" ]; then
-       list="fetch upload"
-else
-       list="$@"
-fi
-
-for i in $list; do
-       case "$i" in
-       fetch) pgm="old-git-fetch-pack"; replace="$pgm";;
-       upload) pgm="old-git-upload-pack"; replace="git-fetch-pack --exec=$pgm";;
-       both) pgm="old-git-upload-pack"; replace="old-git-fetch-pack --exec=$pgm";;
-       esac
-
-       if where=`LANG=C LC_ALL=C which "$pgm" 2>/dev/null` &&
-          case "$where" in
-          "no "*) (exit 1) ;;
-          esac
-       then
-               echo "Testing with $pgm"
-               sed -e "s/git-fetch-pack/$replace/g" \
-                       -e "s/# old fails/warn/" < t5500-fetch-pack.sh > $tmp
-
-               "$SHELL_PATH" "$tmp" || retval=$?
-               rm -f "$tmp"
-
-               test $retval != 0 && exit $retval
-       else
-               echo "Skipping test for $i, since I cannot find $pgm"
-       fi
-done
-
-exit 0
-