Code

Update the gitweb/README file to include setting the GITWEB_CONFIG environment
[git.git] / git-commit.sh
index 128db6c52a878a421a67c658dfd175f774c24fea..5a4c659b6fb5f0b23c6a10b0e3bd69893d9c380a 100755 (executable)
@@ -29,7 +29,7 @@ THIS_INDEX="$GIT_DIR/index"
 NEXT_INDEX="$GIT_DIR/next-index$$"
 rm -f "$NEXT_INDEX"
 save_index () {
-       cp "$THIS_INDEX" "$NEXT_INDEX"
+       cp -p "$THIS_INDEX" "$NEXT_INDEX"
 }
 
 report () {
@@ -60,26 +60,6 @@ report () {
 }
 
 run_status () {
-    (
-       # We always show status for the whole tree.
-       cd "$TOP"
-
-       IS_INITIAL="$initial_commit"
-       REFERENCE=HEAD
-       case "$amend" in
-       t)
-               # If we are amending the initial commit, there
-               # is no HEAD^1.
-               if git-rev-parse --verify "HEAD^1" >/dev/null 2>&1
-               then
-                       REFERENCE="HEAD^1"
-                       IS_INITIAL=
-               else
-                       IS_INITIAL=t
-               fi
-               ;;
-       esac
-
        # If TMP_INDEX is defined, that means we are doing
        # "--only" partial commit, and that index file is used
        # to build the tree for the commit.  Otherwise, if
@@ -96,91 +76,14 @@ run_status () {
            export GIT_INDEX_FILE
        fi
 
-       case "$branch" in
-       refs/heads/master) ;;
-       *)  echo "# On branch $branch" ;;
-       esac
-
-       if test -z "$IS_INITIAL"
-       then
-           git-diff-index -M --cached --name-status \
-               --diff-filter=MDTCRA $REFERENCE |
-           sed -e '
-                   s/\\/\\\\/g
-                   s/ /\\ /g
-           ' |
-           report "Updated but not checked in" "will commit"
-           committable="$?"
-       else
-           echo '#
-# Initial commit
-#'
-           git-ls-files |
-           sed -e '
-                   s/\\/\\\\/g
-                   s/ /\\ /g
-                   s/^/A /
-           ' |
-           report "Updated but not checked in" "will commit"
-
-           committable="$?"
-       fi
-
-       git-diff-files  --name-status |
-       sed -e '
-               s/\\/\\\\/g
-               s/ /\\ /g
-       ' |
-       report "Changed but not updated" \
-           "use git-update-index to mark for commit"
-
-        option=""
-        if test -z "$untracked_files"; then
-            option="--directory --no-empty-directory"
-        fi
-       if test -f "$GIT_DIR/info/exclude"
-       then
-           git-ls-files -z --others $option \
-               --exclude-from="$GIT_DIR/info/exclude" \
-               --exclude-per-directory=.gitignore
-       else
-           git-ls-files -z --others $option \
-               --exclude-per-directory=.gitignore
-       fi |
-       perl -e '$/ = "\0";
-           my $shown = 0;
-           while (<>) {
-               chomp;
-               s|\\|\\\\|g;
-               s|\t|\\t|g;
-               s|\n|\\n|g;
-               s/^/#   /;
-               if (!$shown) {
-                   print "#\n# Untracked files:\n";
-                   print "#   (use \"git add\" to add to commit)\n";
-                   print "#\n";
-                   $shown = 1;
-               }
-               print "$_\n";
-           }
-       '
-
-       if test -n "$verbose" -a -z "$IS_INITIAL"
-       then
-           git-diff-index --cached -M -p --diff-filter=MDTCRA $REFERENCE
-       fi
-       case "$committable" in
-       0)
-               case "$amend" in
-               t)
-                       echo "# No changes" ;;
-               *)
-                       echo "nothing to commit" ;;
-               esac
-               exit 1 ;;
-       esac
-       exit 0
-    )
+  case "$status_only" in
+    t) color= ;;
+    *) color=--nocolor ;;
+  esac
+  git-runstatus ${color} \
+                ${verbose:+--verbose} \
+                ${amend:+--amend} \
+               ${untracked_files:+--untracked}
 }
 
 trap '
@@ -223,13 +126,13 @@ do
   -F*|-f*)
       no_edit=t
       log_given=t$log_given
-      logfile=`expr "$1" : '-[Ff]\(.*\)'`
+      logfile=`expr "z$1" : 'z-[Ff]\(.*\)'`
       shift
       ;;
   --F=*|--f=*|--fi=*|--fil=*|--file=*)
       no_edit=t
       log_given=t$log_given
-      logfile=`expr "$1" : '-[^=]*=\(.*\)'`
+      logfile=`expr "z$1" : 'z-[^=]*=\(.*\)'`
       shift
       ;;
   -a|--a|--al|--all)
@@ -237,7 +140,7 @@ do
       shift
       ;;
   --au=*|--aut=*|--auth=*|--autho=*|--author=*)
-      force_author=`expr "$1" : '-[^=]*=\(.*\)'`
+      force_author=`expr "z$1" : 'z-[^=]*=\(.*\)'`
       shift
       ;;
   --au|--aut|--auth|--autho|--author)
@@ -277,11 +180,11 @@ $1"
       log_given=m$log_given
       if test "$log_message" = ''
       then
-          log_message=`expr "$1" : '-m\(.*\)'`
+          log_message=`expr "z$1" : 'z-m\(.*\)'`
       else
           log_message="$log_message
 
-`expr "$1" : '-m\(.*\)'`"
+`expr "z$1" : 'z-m\(.*\)'`"
       fi
       no_edit=t
       shift
@@ -290,11 +193,11 @@ $1"
       log_given=m$log_given
       if test "$log_message" = ''
       then
-          log_message=`expr "$1" : '-[^=]*=\(.*\)'`
+          log_message=`expr "z$1" : 'z-[^=]*=\(.*\)'`
       else
           log_message="$log_message
 
-`expr "$1" : '-[^=]*=\(.*\)'`"
+`expr "z$1" : 'zq-[^=]*=\(.*\)'`"
       fi
       no_edit=t
       shift
@@ -321,7 +224,7 @@ $1"
   --reedit-me=*|--reedit-mes=*|--reedit-mess=*|--reedit-messa=*|\
   --reedit-messag=*|--reedit-message=*)
       log_given=t$log_given
-      use_commit=`expr "$1" : '-[^=]*=\(.*\)'`
+      use_commit=`expr "z$1" : 'z-[^=]*=\(.*\)'`
       no_edit=
       shift
       ;;
@@ -346,7 +249,7 @@ $1"
   --reuse-mes=*|--reuse-mess=*|--reuse-messa=*|--reuse-messag=*|\
   --reuse-message=*)
       log_given=t$log_given
-      use_commit=`expr "$1" : '-[^=]*=\(.*\)'`
+      use_commit=`expr "z$1" : 'z-[^=]*=\(.*\)'`
       no_edit=t
       shift
       ;;
@@ -566,6 +469,9 @@ then
 elif test -f "$GIT_DIR/MERGE_HEAD" && test -f "$GIT_DIR/MERGE_MSG"
 then
        cat "$GIT_DIR/MERGE_MSG"
+elif test -f "$GIT_DIR/SQUASH_MSG"
+then
+       cat "$GIT_DIR/SQUASH_MSG"
 fi | git-stripspace >"$GIT_DIR"/COMMIT_EDITMSG
 
 case "$signoff" in
@@ -596,7 +502,7 @@ then
        GIT_AUTHOR_EMAIL=`expr "z$force_author" : '.*\(<.*\)'` &&
        test '' != "$GIT_AUTHOR_NAME" &&
        test '' != "$GIT_AUTHOR_EMAIL" ||
-       die "malformatted --author parameter"
+       die "malformed --author parameter"
        export GIT_AUTHOR_NAME GIT_AUTHOR_EMAIL
 elif test '' != "$use_commit"
 then
@@ -632,9 +538,12 @@ fi
 PARENTS="-p HEAD"
 if test -z "$initial_commit"
 then
+       rloga='commit'
        if [ -f "$GIT_DIR/MERGE_HEAD" ]; then
+               rloga='commit (merge)'
                PARENTS="-p HEAD "`sed -e 's/^/-p /' "$GIT_DIR/MERGE_HEAD"`
        elif test -n "$amend"; then
+               rloga='commit (amend)'
                PARENTS=$(git-cat-file commit HEAD |
                        sed -n -e '/^$/q' -e 's/^parent /-p /p')
        fi
@@ -646,6 +555,7 @@ else
        fi
        PARENTS=""
        current=
+       rloga='commit (initial)'
 fi
 
 if test -z "$no_edit"
@@ -663,7 +573,7 @@ else
 fi
 if [ "$?" != "0" -a ! -f "$GIT_DIR/MERGE_HEAD" -a -z "$amend" ]
 then
-       rm -f "$GIT_DIR/COMMIT_EDITMSG"
+       rm -f "$GIT_DIR/COMMIT_EDITMSG" "$GIT_DIR/SQUASH_MSG"
        run_status
        exit 1
 fi
@@ -721,7 +631,7 @@ then
        fi &&
        commit=$(cat "$GIT_DIR"/COMMIT_MSG | git-commit-tree $tree $PARENTS) &&
        rlogm=$(sed -e 1q "$GIT_DIR"/COMMIT_MSG) &&
-       git-update-ref -m "commit: $rlogm" HEAD $commit $current &&
+       git-update-ref -m "$rloga: $rlogm" HEAD $commit $current &&
        rm -f -- "$GIT_DIR/MERGE_HEAD" &&
        if test -f "$NEXT_INDEX"
        then
@@ -734,7 +644,7 @@ else
        false
 fi
 ret="$?"
-rm -f "$GIT_DIR/COMMIT_MSG" "$GIT_DIR/COMMIT_EDITMSG"
+rm -f "$GIT_DIR/COMMIT_MSG" "$GIT_DIR/COMMIT_EDITMSG" "$GIT_DIR/SQUASH_MSG"
 if test -d "$GIT_DIR/rr-cache"
 then
        git-rerere