Linus Torvalds | a3e870f | 2005-05-30 12:51:00 -0700 | [diff] [blame] | 1 | #!/bin/sh |
Junio C Hamano | 5fec3ef | 2005-06-25 02:22:05 -0700 | [diff] [blame] | 2 | # |
| 3 | # Copyright (c) 2005 Linus Torvalds |
Junio C Hamano | 130fcca | 2006-02-05 00:07:44 -0800 | [diff] [blame] | 4 | # Copyright (c) 2006 Junio C Hamano |
Junio C Hamano | 5fec3ef | 2005-06-25 02:22:05 -0700 | [diff] [blame] | 5 | |
Matthias Lederhofer | 443f833 | 2006-05-22 23:02:06 +0200 | [diff] [blame] | 6 | USAGE='[-a] [-s] [-v] [--no-verify] [-m <message> | -F <logfile> | (-C|-c) <commit>] [-u] [--amend] [-e] [--author <author>] [[-i | -o] <path>...]' |
Junio C Hamano | 130fcca | 2006-02-05 00:07:44 -0800 | [diff] [blame] | 7 | SUBDIRECTORY_OK=Yes |
Junio C Hamano | ae2b0f1 | 2005-11-24 00:12:11 -0800 | [diff] [blame] | 8 | . git-sh-setup |
Linus Torvalds | b33e966 | 2005-07-08 10:57:21 -0700 | [diff] [blame] | 9 | |
Junio C Hamano | cf7bb58 | 2006-02-10 00:45:59 -0800 | [diff] [blame] | 10 | git-rev-parse --verify HEAD >/dev/null 2>&1 || initial_commit=t |
| 11 | branch=$(GIT_DIR="$GIT_DIR" git-symbolic-ref HEAD) |
| 12 | |
| 13 | case "$0" in |
| 14 | *status) |
| 15 | status_only=t |
| 16 | unmerged_ok_if_status=--unmerged ;; |
| 17 | *commit) |
| 18 | status_only= |
| 19 | unmerged_ok_if_status= ;; |
| 20 | esac |
Junio C Hamano | 130fcca | 2006-02-05 00:07:44 -0800 | [diff] [blame] | 21 | |
| 22 | refuse_partial () { |
| 23 | echo >&2 "$1" |
Junio C Hamano | 130fcca | 2006-02-05 00:07:44 -0800 | [diff] [blame] | 24 | echo >&2 "You might have meant to say 'git commit -i paths...', perhaps?" |
| 25 | exit 1 |
| 26 | } |
| 27 | |
Junio C Hamano | cf7bb58 | 2006-02-10 00:45:59 -0800 | [diff] [blame] | 28 | THIS_INDEX="$GIT_DIR/index" |
| 29 | NEXT_INDEX="$GIT_DIR/next-index$$" |
| 30 | rm -f "$NEXT_INDEX" |
Junio C Hamano | 5a798fb | 2006-02-05 16:08:01 -0800 | [diff] [blame] | 31 | save_index () { |
Junio C Hamano | cc7d5bc | 2006-06-29 14:48:22 -0700 | [diff] [blame] | 32 | cp -p "$THIS_INDEX" "$NEXT_INDEX" |
Junio C Hamano | cf7bb58 | 2006-02-10 00:45:59 -0800 | [diff] [blame] | 33 | } |
| 34 | |
| 35 | report () { |
| 36 | header="# |
| 37 | # $1: |
| 38 | # ($2) |
| 39 | # |
| 40 | " |
| 41 | trailer="" |
| 42 | while read status name newname |
| 43 | do |
| 44 | printf '%s' "$header" |
| 45 | header="" |
| 46 | trailer="# |
| 47 | " |
| 48 | case "$status" in |
| 49 | M ) echo "# modified: $name";; |
| 50 | D*) echo "# deleted: $name";; |
| 51 | T ) echo "# typechange: $name";; |
| 52 | C*) echo "# copied: $name -> $newname";; |
| 53 | R*) echo "# renamed: $name -> $newname";; |
| 54 | A*) echo "# new file: $name";; |
| 55 | U ) echo "# unmerged: $name";; |
| 56 | esac |
| 57 | done |
| 58 | printf '%s' "$trailer" |
| 59 | [ "$header" ] |
Junio C Hamano | 5a798fb | 2006-02-05 16:08:01 -0800 | [diff] [blame] | 60 | } |
| 61 | |
| 62 | run_status () { |
Junio C Hamano | cf7bb58 | 2006-02-10 00:45:59 -0800 | [diff] [blame] | 63 | # If TMP_INDEX is defined, that means we are doing |
| 64 | # "--only" partial commit, and that index file is used |
| 65 | # to build the tree for the commit. Otherwise, if |
| 66 | # NEXT_INDEX exists, that is the index file used to |
| 67 | # make the commit. Otherwise we are using as-is commit |
| 68 | # so the regular index file is what we use to compare. |
| 69 | if test '' != "$TMP_INDEX" |
| 70 | then |
| 71 | GIT_INDEX_FILE="$TMP_INDEX" |
| 72 | export GIT_INDEX_FILE |
| 73 | elif test -f "$NEXT_INDEX" |
| 74 | then |
| 75 | GIT_INDEX_FILE="$NEXT_INDEX" |
| 76 | export GIT_INDEX_FILE |
| 77 | fi |
| 78 | |
Jeff King | c91f0d9 | 2006-09-08 04:05:34 -0400 | [diff] [blame] | 79 | case "$status_only" in |
| 80 | t) color= ;; |
| 81 | *) color=--nocolor ;; |
| 82 | esac |
| 83 | git-runstatus ${color} \ |
| 84 | ${verbose:+--verbose} \ |
Johannes Schindelin | 2074cb0 | 2006-09-12 22:45:12 +0200 | [diff] [blame] | 85 | ${amend:+--amend} \ |
| 86 | ${untracked_files:+--untracked} |
Junio C Hamano | 5a798fb | 2006-02-05 16:08:01 -0800 | [diff] [blame] | 87 | } |
| 88 | |
Junio C Hamano | cf7bb58 | 2006-02-10 00:45:59 -0800 | [diff] [blame] | 89 | trap ' |
| 90 | test -z "$TMP_INDEX" || { |
| 91 | test -f "$TMP_INDEX" && rm -f "$TMP_INDEX" |
| 92 | } |
| 93 | rm -f "$NEXT_INDEX" |
| 94 | ' 0 |
| 95 | |
| 96 | ################################################################ |
| 97 | # Command line argument parsing and sanity checking |
| 98 | |
Junio C Hamano | 130fcca | 2006-02-05 00:07:44 -0800 | [diff] [blame] | 99 | all= |
| 100 | also= |
Junio C Hamano | 5a798fb | 2006-02-05 16:08:01 -0800 | [diff] [blame] | 101 | only= |
Junio C Hamano | 130fcca | 2006-02-05 00:07:44 -0800 | [diff] [blame] | 102 | logfile= |
| 103 | use_commit= |
Junio C Hamano | b4019f0 | 2006-03-02 21:04:05 -0800 | [diff] [blame] | 104 | amend= |
Jeff King | cda8ab5 | 2006-06-23 09:43:38 -0400 | [diff] [blame] | 105 | edit_flag= |
Junio C Hamano | 130fcca | 2006-02-05 00:07:44 -0800 | [diff] [blame] | 106 | no_edit= |
| 107 | log_given= |
| 108 | log_message= |
| 109 | verify=t |
Junio C Hamano | cf7bb58 | 2006-02-10 00:45:59 -0800 | [diff] [blame] | 110 | verbose= |
Junio C Hamano | 130fcca | 2006-02-05 00:07:44 -0800 | [diff] [blame] | 111 | signoff= |
| 112 | force_author= |
Junio C Hamano | bba319b | 2006-02-14 12:40:20 -0800 | [diff] [blame] | 113 | only_include_assumed= |
Matthias Lederhofer | 443f833 | 2006-05-22 23:02:06 +0200 | [diff] [blame] | 114 | untracked_files= |
Junio C Hamano | 0c09129 | 2005-08-08 17:03:14 -0700 | [diff] [blame] | 115 | while case "$#" in 0) break;; esac |
Junio C Hamano | 5fec3ef | 2005-06-25 02:22:05 -0700 | [diff] [blame] | 116 | do |
Junio C Hamano | 0c09129 | 2005-08-08 17:03:14 -0700 | [diff] [blame] | 117 | case "$1" in |
Junio C Hamano | 130fcca | 2006-02-05 00:07:44 -0800 | [diff] [blame] | 118 | -F|--F|-f|--f|--fi|--fil|--file) |
| 119 | case "$#" in 1) usage ;; esac |
| 120 | shift |
| 121 | no_edit=t |
| 122 | log_given=t$log_given |
| 123 | logfile="$1" |
| 124 | shift |
| 125 | ;; |
| 126 | -F*|-f*) |
| 127 | no_edit=t |
| 128 | log_given=t$log_given |
Dennis Stosberg | 8096fae | 2006-06-27 18:54:26 +0200 | [diff] [blame] | 129 | logfile=`expr "z$1" : 'z-[Ff]\(.*\)'` |
Junio C Hamano | 130fcca | 2006-02-05 00:07:44 -0800 | [diff] [blame] | 130 | shift |
| 131 | ;; |
| 132 | --F=*|--f=*|--fi=*|--fil=*|--file=*) |
| 133 | no_edit=t |
| 134 | log_given=t$log_given |
Dennis Stosberg | 8096fae | 2006-06-27 18:54:26 +0200 | [diff] [blame] | 135 | logfile=`expr "z$1" : 'z-[^=]*=\(.*\)'` |
Junio C Hamano | 130fcca | 2006-02-05 00:07:44 -0800 | [diff] [blame] | 136 | shift |
| 137 | ;; |
Junio C Hamano | 0c09129 | 2005-08-08 17:03:14 -0700 | [diff] [blame] | 138 | -a|--a|--al|--all) |
Junio C Hamano | 130fcca | 2006-02-05 00:07:44 -0800 | [diff] [blame] | 139 | all=t |
| 140 | shift |
| 141 | ;; |
| 142 | --au=*|--aut=*|--auth=*|--autho=*|--author=*) |
Dennis Stosberg | 8096fae | 2006-06-27 18:54:26 +0200 | [diff] [blame] | 143 | force_author=`expr "z$1" : 'z-[^=]*=\(.*\)'` |
Junio C Hamano | 130fcca | 2006-02-05 00:07:44 -0800 | [diff] [blame] | 144 | shift |
| 145 | ;; |
| 146 | --au|--aut|--auth|--autho|--author) |
| 147 | case "$#" in 1) usage ;; esac |
| 148 | shift |
| 149 | force_author="$1" |
| 150 | shift |
| 151 | ;; |
| 152 | -e|--e|--ed|--edi|--edit) |
Jeff King | cda8ab5 | 2006-06-23 09:43:38 -0400 | [diff] [blame] | 153 | edit_flag=t |
Junio C Hamano | 130fcca | 2006-02-05 00:07:44 -0800 | [diff] [blame] | 154 | shift |
| 155 | ;; |
| 156 | -i|--i|--in|--inc|--incl|--inclu|--includ|--include) |
| 157 | also=t |
| 158 | shift |
| 159 | ;; |
Junio C Hamano | 5a798fb | 2006-02-05 16:08:01 -0800 | [diff] [blame] | 160 | -o|--o|--on|--onl|--only) |
| 161 | only=t |
| 162 | shift |
| 163 | ;; |
Junio C Hamano | 0c09129 | 2005-08-08 17:03:14 -0700 | [diff] [blame] | 164 | -m|--m|--me|--mes|--mess|--messa|--messag|--message) |
Junio C Hamano | 130fcca | 2006-02-05 00:07:44 -0800 | [diff] [blame] | 165 | case "$#" in 1) usage ;; esac |
| 166 | shift |
Shawn Pearce | 6891281 | 2006-05-29 04:45:49 -0400 | [diff] [blame] | 167 | log_given=m$log_given |
| 168 | if test "$log_message" = '' |
| 169 | then |
| 170 | log_message="$1" |
| 171 | else |
| 172 | log_message="$log_message |
| 173 | |
| 174 | $1" |
| 175 | fi |
Junio C Hamano | 130fcca | 2006-02-05 00:07:44 -0800 | [diff] [blame] | 176 | no_edit=t |
| 177 | shift |
| 178 | ;; |
| 179 | -m*) |
Shawn Pearce | 6891281 | 2006-05-29 04:45:49 -0400 | [diff] [blame] | 180 | log_given=m$log_given |
| 181 | if test "$log_message" = '' |
| 182 | then |
Dennis Stosberg | 8096fae | 2006-06-27 18:54:26 +0200 | [diff] [blame] | 183 | log_message=`expr "z$1" : 'z-m\(.*\)'` |
Shawn Pearce | 6891281 | 2006-05-29 04:45:49 -0400 | [diff] [blame] | 184 | else |
| 185 | log_message="$log_message |
| 186 | |
Dennis Stosberg | 8096fae | 2006-06-27 18:54:26 +0200 | [diff] [blame] | 187 | `expr "z$1" : 'z-m\(.*\)'`" |
Shawn Pearce | 6891281 | 2006-05-29 04:45:49 -0400 | [diff] [blame] | 188 | fi |
Junio C Hamano | 130fcca | 2006-02-05 00:07:44 -0800 | [diff] [blame] | 189 | no_edit=t |
| 190 | shift |
| 191 | ;; |
| 192 | --m=*|--me=*|--mes=*|--mess=*|--messa=*|--messag=*|--message=*) |
Shawn Pearce | 6891281 | 2006-05-29 04:45:49 -0400 | [diff] [blame] | 193 | log_given=m$log_given |
| 194 | if test "$log_message" = '' |
| 195 | then |
Dennis Stosberg | 8096fae | 2006-06-27 18:54:26 +0200 | [diff] [blame] | 196 | log_message=`expr "z$1" : 'z-[^=]*=\(.*\)'` |
Shawn Pearce | 6891281 | 2006-05-29 04:45:49 -0400 | [diff] [blame] | 197 | else |
| 198 | log_message="$log_message |
| 199 | |
Dennis Stosberg | 8096fae | 2006-06-27 18:54:26 +0200 | [diff] [blame] | 200 | `expr "z$1" : 'zq-[^=]*=\(.*\)'`" |
Shawn Pearce | 6891281 | 2006-05-29 04:45:49 -0400 | [diff] [blame] | 201 | fi |
Junio C Hamano | 130fcca | 2006-02-05 00:07:44 -0800 | [diff] [blame] | 202 | no_edit=t |
| 203 | shift |
| 204 | ;; |
| 205 | -n|--n|--no|--no-|--no-v|--no-ve|--no-ver|--no-veri|--no-verif|--no-verify) |
| 206 | verify= |
| 207 | shift |
| 208 | ;; |
Junio C Hamano | b4019f0 | 2006-03-02 21:04:05 -0800 | [diff] [blame] | 209 | --a|--am|--ame|--amen|--amend) |
| 210 | amend=t |
| 211 | log_given=t$log_given |
| 212 | use_commit=HEAD |
| 213 | shift |
| 214 | ;; |
Junio C Hamano | 130fcca | 2006-02-05 00:07:44 -0800 | [diff] [blame] | 215 | -c) |
| 216 | case "$#" in 1) usage ;; esac |
| 217 | shift |
| 218 | log_given=t$log_given |
| 219 | use_commit="$1" |
| 220 | no_edit= |
| 221 | shift |
| 222 | ;; |
| 223 | --ree=*|--reed=*|--reedi=*|--reedit=*|--reedit-=*|--reedit-m=*|\ |
Junio C Hamano | 0c09129 | 2005-08-08 17:03:14 -0700 | [diff] [blame] | 224 | --reedit-me=*|--reedit-mes=*|--reedit-mess=*|--reedit-messa=*|\ |
| 225 | --reedit-messag=*|--reedit-message=*) |
Junio C Hamano | 130fcca | 2006-02-05 00:07:44 -0800 | [diff] [blame] | 226 | log_given=t$log_given |
Dennis Stosberg | 8096fae | 2006-06-27 18:54:26 +0200 | [diff] [blame] | 227 | use_commit=`expr "z$1" : 'z-[^=]*=\(.*\)'` |
Junio C Hamano | 130fcca | 2006-02-05 00:07:44 -0800 | [diff] [blame] | 228 | no_edit= |
| 229 | shift |
| 230 | ;; |
| 231 | --ree|--reed|--reedi|--reedit|--reedit-|--reedit-m|--reedit-me|\ |
Junio C Hamano | 0c09129 | 2005-08-08 17:03:14 -0700 | [diff] [blame] | 232 | --reedit-mes|--reedit-mess|--reedit-messa|--reedit-messag|--reedit-message) |
Junio C Hamano | 130fcca | 2006-02-05 00:07:44 -0800 | [diff] [blame] | 233 | case "$#" in 1) usage ;; esac |
| 234 | shift |
| 235 | log_given=t$log_given |
| 236 | use_commit="$1" |
| 237 | no_edit= |
| 238 | shift |
| 239 | ;; |
| 240 | -C) |
| 241 | case "$#" in 1) usage ;; esac |
| 242 | shift |
| 243 | log_given=t$log_given |
| 244 | use_commit="$1" |
| 245 | no_edit=t |
| 246 | shift |
| 247 | ;; |
| 248 | --reu=*|--reus=*|--reuse=*|--reuse-=*|--reuse-m=*|--reuse-me=*|\ |
Junio C Hamano | 0c09129 | 2005-08-08 17:03:14 -0700 | [diff] [blame] | 249 | --reuse-mes=*|--reuse-mess=*|--reuse-messa=*|--reuse-messag=*|\ |
| 250 | --reuse-message=*) |
Junio C Hamano | 130fcca | 2006-02-05 00:07:44 -0800 | [diff] [blame] | 251 | log_given=t$log_given |
Dennis Stosberg | 8096fae | 2006-06-27 18:54:26 +0200 | [diff] [blame] | 252 | use_commit=`expr "z$1" : 'z-[^=]*=\(.*\)'` |
Junio C Hamano | 130fcca | 2006-02-05 00:07:44 -0800 | [diff] [blame] | 253 | no_edit=t |
| 254 | shift |
| 255 | ;; |
| 256 | --reu|--reus|--reuse|--reuse-|--reuse-m|--reuse-me|--reuse-mes|\ |
Junio C Hamano | 0c09129 | 2005-08-08 17:03:14 -0700 | [diff] [blame] | 257 | --reuse-mess|--reuse-messa|--reuse-messag|--reuse-message) |
Junio C Hamano | 130fcca | 2006-02-05 00:07:44 -0800 | [diff] [blame] | 258 | case "$#" in 1) usage ;; esac |
| 259 | shift |
| 260 | log_given=t$log_given |
| 261 | use_commit="$1" |
| 262 | no_edit=t |
| 263 | shift |
| 264 | ;; |
Junio C Hamano | 0cfe1d3 | 2005-08-12 23:39:15 -0700 | [diff] [blame] | 265 | -s|--s|--si|--sig|--sign|--signo|--signof|--signoff) |
Junio C Hamano | 130fcca | 2006-02-05 00:07:44 -0800 | [diff] [blame] | 266 | signoff=t |
| 267 | shift |
| 268 | ;; |
Junio C Hamano | cf7bb58 | 2006-02-10 00:45:59 -0800 | [diff] [blame] | 269 | -v|--v|--ve|--ver|--verb|--verbo|--verbos|--verbose) |
| 270 | verbose=t |
| 271 | shift |
Junio C Hamano | 130fcca | 2006-02-05 00:07:44 -0800 | [diff] [blame] | 272 | ;; |
Matthias Lederhofer | 443f833 | 2006-05-22 23:02:06 +0200 | [diff] [blame] | 273 | -u|--u|--un|--unt|--untr|--untra|--untrac|--untrack|--untracke|--untracked|\ |
| 274 | --untracked-|--untracked-f|--untracked-fi|--untracked-fil|--untracked-file|\ |
| 275 | --untracked-files) |
| 276 | untracked_files=t |
| 277 | shift |
| 278 | ;; |
Junio C Hamano | 0c09129 | 2005-08-08 17:03:14 -0700 | [diff] [blame] | 279 | --) |
Junio C Hamano | 130fcca | 2006-02-05 00:07:44 -0800 | [diff] [blame] | 280 | shift |
| 281 | break |
| 282 | ;; |
Junio C Hamano | 0c09129 | 2005-08-08 17:03:14 -0700 | [diff] [blame] | 283 | -*) |
Junio C Hamano | 130fcca | 2006-02-05 00:07:44 -0800 | [diff] [blame] | 284 | usage |
| 285 | ;; |
Junio C Hamano | 0c09129 | 2005-08-08 17:03:14 -0700 | [diff] [blame] | 286 | *) |
Junio C Hamano | 130fcca | 2006-02-05 00:07:44 -0800 | [diff] [blame] | 287 | break |
| 288 | ;; |
Junio C Hamano | 0c09129 | 2005-08-08 17:03:14 -0700 | [diff] [blame] | 289 | esac |
Junio C Hamano | 5fec3ef | 2005-06-25 02:22:05 -0700 | [diff] [blame] | 290 | done |
Jeff King | cda8ab5 | 2006-06-23 09:43:38 -0400 | [diff] [blame] | 291 | case "$edit_flag" in t) no_edit= ;; esac |
Junio C Hamano | 5fec3ef | 2005-06-25 02:22:05 -0700 | [diff] [blame] | 292 | |
Junio C Hamano | cf7bb58 | 2006-02-10 00:45:59 -0800 | [diff] [blame] | 293 | ################################################################ |
| 294 | # Sanity check options |
| 295 | |
Junio C Hamano | b4019f0 | 2006-03-02 21:04:05 -0800 | [diff] [blame] | 296 | case "$amend,$initial_commit" in |
| 297 | t,t) |
| 298 | die "You do not have anything to amend." ;; |
| 299 | t,) |
| 300 | if [ -f "$GIT_DIR/MERGE_HEAD" ]; then |
| 301 | die "You are in the middle of a merge -- cannot amend." |
| 302 | fi ;; |
| 303 | esac |
| 304 | |
Junio C Hamano | 0c09129 | 2005-08-08 17:03:14 -0700 | [diff] [blame] | 305 | case "$log_given" in |
| 306 | tt*) |
Shawn Pearce | 6891281 | 2006-05-29 04:45:49 -0400 | [diff] [blame] | 307 | die "Only one of -c/-C/-F can be used." ;; |
| 308 | *tm*|*mt*) |
| 309 | die "Option -m cannot be combined with -c/-C/-F." ;; |
Junio C Hamano | 0c09129 | 2005-08-08 17:03:14 -0700 | [diff] [blame] | 310 | esac |
| 311 | |
Junio C Hamano | 6a74642 | 2006-04-20 01:20:56 -0700 | [diff] [blame] | 312 | case "$#,$also,$only,$amend" in |
| 313 | *,t,t,*) |
Junio C Hamano | 5a798fb | 2006-02-05 16:08:01 -0800 | [diff] [blame] | 314 | die "Only one of --include/--only can be used." ;; |
Junio C Hamano | 6a74642 | 2006-04-20 01:20:56 -0700 | [diff] [blame] | 315 | 0,t,,* | 0,,t,) |
Junio C Hamano | 5a798fb | 2006-02-05 16:08:01 -0800 | [diff] [blame] | 316 | die "No paths with --include/--only does not make sense." ;; |
Junio C Hamano | 6a74642 | 2006-04-20 01:20:56 -0700 | [diff] [blame] | 317 | 0,,t,t) |
| 318 | only_include_assumed="# Clever... amending the last one with dirty index." ;; |
| 319 | 0,,,*) |
Junio C Hamano | 5a798fb | 2006-02-05 16:08:01 -0800 | [diff] [blame] | 320 | ;; |
Junio C Hamano | 6a74642 | 2006-04-20 01:20:56 -0700 | [diff] [blame] | 321 | *,,,*) |
Junio C Hamano | 756e3ee | 2006-02-14 17:51:02 -0800 | [diff] [blame] | 322 | only_include_assumed="# Explicit paths specified without -i nor -o; assuming --only paths..." |
Junio C Hamano | 4170a19 | 2006-02-12 23:55:07 -0800 | [diff] [blame] | 323 | also= |
Junio C Hamano | 5a798fb | 2006-02-05 16:08:01 -0800 | [diff] [blame] | 324 | ;; |
| 325 | esac |
| 326 | unset only |
Junio C Hamano | cf7bb58 | 2006-02-10 00:45:59 -0800 | [diff] [blame] | 327 | case "$all,$also,$#" in |
| 328 | t,t,*) |
| 329 | die "Cannot use -a and -i at the same time." ;; |
| 330 | t,,[1-9]*) |
| 331 | die "Paths with -a does not make sense." ;; |
| 332 | ,t,0) |
| 333 | die "No paths with -i does not make sense." ;; |
| 334 | esac |
| 335 | |
| 336 | ################################################################ |
| 337 | # Prepare index to have a tree to be committed |
Junio C Hamano | 5a798fb | 2006-02-05 16:08:01 -0800 | [diff] [blame] | 338 | |
Junio C Hamano | 130fcca | 2006-02-05 00:07:44 -0800 | [diff] [blame] | 339 | TOP=`git-rev-parse --show-cdup` |
Junio C Hamano | 5a798fb | 2006-02-05 16:08:01 -0800 | [diff] [blame] | 340 | if test -z "$TOP" |
| 341 | then |
| 342 | TOP=./ |
| 343 | fi |
Junio C Hamano | 130fcca | 2006-02-05 00:07:44 -0800 | [diff] [blame] | 344 | |
| 345 | case "$all,$also" in |
Junio C Hamano | 130fcca | 2006-02-05 00:07:44 -0800 | [diff] [blame] | 346 | t,) |
Junio C Hamano | 5a798fb | 2006-02-05 16:08:01 -0800 | [diff] [blame] | 347 | save_index && |
Junio C Hamano | 130fcca | 2006-02-05 00:07:44 -0800 | [diff] [blame] | 348 | ( |
Junio C Hamano | 5a798fb | 2006-02-05 16:08:01 -0800 | [diff] [blame] | 349 | cd "$TOP" |
Junio C Hamano | cf7bb58 | 2006-02-10 00:45:59 -0800 | [diff] [blame] | 350 | GIT_INDEX_FILE="$NEXT_INDEX" |
| 351 | export GIT_INDEX_FILE |
Junio C Hamano | 130fcca | 2006-02-05 00:07:44 -0800 | [diff] [blame] | 352 | git-diff-files --name-only -z | |
| 353 | git-update-index --remove -z --stdin |
| 354 | ) |
| 355 | ;; |
| 356 | ,t) |
Junio C Hamano | 5a798fb | 2006-02-05 16:08:01 -0800 | [diff] [blame] | 357 | save_index && |
Junio C Hamano | bba319b | 2006-02-14 12:40:20 -0800 | [diff] [blame] | 358 | git-ls-files --error-unmatch -- "$@" >/dev/null || exit |
| 359 | |
Junio C Hamano | 130fcca | 2006-02-05 00:07:44 -0800 | [diff] [blame] | 360 | git-diff-files --name-only -z -- "$@" | |
Junio C Hamano | cf7bb58 | 2006-02-10 00:45:59 -0800 | [diff] [blame] | 361 | ( |
| 362 | cd "$TOP" |
| 363 | GIT_INDEX_FILE="$NEXT_INDEX" |
| 364 | export GIT_INDEX_FILE |
| 365 | git-update-index --remove -z --stdin |
| 366 | ) |
Junio C Hamano | 22cff6a | 2005-08-16 18:08:19 -0700 | [diff] [blame] | 367 | ;; |
Junio C Hamano | 130fcca | 2006-02-05 00:07:44 -0800 | [diff] [blame] | 368 | ,) |
| 369 | case "$#" in |
| 370 | 0) |
| 371 | ;; # commit as-is |
| 372 | *) |
| 373 | if test -f "$GIT_DIR/MERGE_HEAD" |
| 374 | then |
| 375 | refuse_partial "Cannot do a partial commit during a merge." |
| 376 | fi |
| 377 | TMP_INDEX="$GIT_DIR/tmp-index$$" |
| 378 | if test -z "$initial_commit" |
| 379 | then |
| 380 | # make sure index is clean at the specified paths, or |
| 381 | # they are additions. |
| 382 | dirty_in_index=`git-diff-index --cached --name-status \ |
Junio C Hamano | 5a798fb | 2006-02-05 16:08:01 -0800 | [diff] [blame] | 383 | --diff-filter=DMTU HEAD -- "$@"` |
Junio C Hamano | 130fcca | 2006-02-05 00:07:44 -0800 | [diff] [blame] | 384 | test -z "$dirty_in_index" || |
Junio C Hamano | 5a798fb | 2006-02-05 16:08:01 -0800 | [diff] [blame] | 385 | refuse_partial "Different in index and the last commit: |
Junio C Hamano | 130fcca | 2006-02-05 00:07:44 -0800 | [diff] [blame] | 386 | $dirty_in_index" |
| 387 | fi |
Junio C Hamano | bba319b | 2006-02-14 12:40:20 -0800 | [diff] [blame] | 388 | commit_only=`git-ls-files --error-unmatch -- "$@"` || exit |
Junio C Hamano | cf7bb58 | 2006-02-10 00:45:59 -0800 | [diff] [blame] | 389 | |
| 390 | # Build the temporary index and update the real index |
| 391 | # the same way. |
| 392 | if test -z "$initial_commit" |
| 393 | then |
| 394 | cp "$THIS_INDEX" "$TMP_INDEX" |
| 395 | GIT_INDEX_FILE="$TMP_INDEX" git-read-tree -m HEAD |
| 396 | else |
| 397 | rm -f "$TMP_INDEX" |
| 398 | fi || exit |
| 399 | |
| 400 | echo "$commit_only" | |
| 401 | GIT_INDEX_FILE="$TMP_INDEX" \ |
| 402 | git-update-index --add --remove --stdin && |
| 403 | |
| 404 | save_index && |
| 405 | echo "$commit_only" | |
| 406 | ( |
| 407 | GIT_INDEX_FILE="$NEXT_INDEX" |
| 408 | export GIT_INDEX_FILE |
| 409 | git-update-index --remove --stdin |
| 410 | ) || exit |
| 411 | ;; |
Junio C Hamano | 130fcca | 2006-02-05 00:07:44 -0800 | [diff] [blame] | 412 | esac |
Junio C Hamano | f678dd1 | 2005-11-25 13:33:14 -0800 | [diff] [blame] | 413 | ;; |
Junio C Hamano | 130fcca | 2006-02-05 00:07:44 -0800 | [diff] [blame] | 414 | esac |
| 415 | |
Junio C Hamano | cf7bb58 | 2006-02-10 00:45:59 -0800 | [diff] [blame] | 416 | ################################################################ |
| 417 | # If we do as-is commit, the index file will be THIS_INDEX, |
| 418 | # otherwise NEXT_INDEX after we make this commit. We leave |
| 419 | # the index as is if we abort. |
Junio C Hamano | 0c09129 | 2005-08-08 17:03:14 -0700 | [diff] [blame] | 420 | |
Junio C Hamano | cf7bb58 | 2006-02-10 00:45:59 -0800 | [diff] [blame] | 421 | if test -f "$NEXT_INDEX" |
Junio C Hamano | 130fcca | 2006-02-05 00:07:44 -0800 | [diff] [blame] | 422 | then |
Junio C Hamano | cf7bb58 | 2006-02-10 00:45:59 -0800 | [diff] [blame] | 423 | USE_INDEX="$NEXT_INDEX" |
| 424 | else |
| 425 | USE_INDEX="$THIS_INDEX" |
Junio C Hamano | 130fcca | 2006-02-05 00:07:44 -0800 | [diff] [blame] | 426 | fi |
| 427 | |
Junio C Hamano | cf7bb58 | 2006-02-10 00:45:59 -0800 | [diff] [blame] | 428 | GIT_INDEX_FILE="$USE_INDEX" \ |
| 429 | git-update-index -q $unmerged_ok_if_status --refresh || exit |
| 430 | |
| 431 | ################################################################ |
| 432 | # If the request is status, just show it and exit. |
| 433 | |
| 434 | case "$0" in |
| 435 | *status) |
| 436 | run_status |
| 437 | exit $? |
| 438 | esac |
| 439 | |
| 440 | ################################################################ |
| 441 | # Grab commit message, write out tree and make commit. |
| 442 | |
Junio C Hamano | 130fcca | 2006-02-05 00:07:44 -0800 | [diff] [blame] | 443 | if test t = "$verify" && test -x "$GIT_DIR"/hooks/pre-commit |
| 444 | then |
| 445 | if test "$TMP_INDEX" |
| 446 | then |
| 447 | GIT_INDEX_FILE="$TMP_INDEX" "$GIT_DIR"/hooks/pre-commit |
| 448 | else |
Junio C Hamano | cf7bb58 | 2006-02-10 00:45:59 -0800 | [diff] [blame] | 449 | GIT_INDEX_FILE="$USE_INDEX" "$GIT_DIR"/hooks/pre-commit |
Junio C Hamano | 130fcca | 2006-02-05 00:07:44 -0800 | [diff] [blame] | 450 | fi || exit |
| 451 | fi |
Junio C Hamano | 0cfe1d3 | 2005-08-12 23:39:15 -0700 | [diff] [blame] | 452 | |
Junio C Hamano | aba2da1 | 2005-08-25 18:57:35 -0700 | [diff] [blame] | 453 | if test "$log_message" != '' |
| 454 | then |
| 455 | echo "$log_message" |
| 456 | elif test "$logfile" != "" |
| 457 | then |
| 458 | if test "$logfile" = - |
| 459 | then |
| 460 | test -t 0 && |
| 461 | echo >&2 "(reading log message from standard input)" |
| 462 | cat |
| 463 | else |
| 464 | cat <"$logfile" |
| 465 | fi |
| 466 | elif test "$use_commit" != "" |
| 467 | then |
| 468 | git-cat-file commit "$use_commit" | sed -e '1,/^$/d' |
Junio C Hamano | e521580 | 2005-11-01 22:01:28 -0800 | [diff] [blame] | 469 | elif test -f "$GIT_DIR/MERGE_HEAD" && test -f "$GIT_DIR/MERGE_MSG" |
| 470 | then |
| 471 | cat "$GIT_DIR/MERGE_MSG" |
Junio C Hamano | 7d0c688 | 2006-06-23 01:37:02 -0700 | [diff] [blame] | 472 | elif test -f "$GIT_DIR/SQUASH_MSG" |
| 473 | then |
| 474 | cat "$GIT_DIR/SQUASH_MSG" |
Santi_Béjar | f8e2c54 | 2005-10-09 17:30:19 -0700 | [diff] [blame] | 475 | fi | git-stripspace >"$GIT_DIR"/COMMIT_EDITMSG |
Junio C Hamano | 2d56993 | 2005-08-31 17:15:25 -0700 | [diff] [blame] | 476 | |
| 477 | case "$signoff" in |
| 478 | t) |
Junio C Hamano | f641339 | 2005-10-03 23:49:46 -0700 | [diff] [blame] | 479 | { |
| 480 | echo |
| 481 | git-var GIT_COMMITTER_IDENT | sed -e ' |
| 482 | s/>.*/>/ |
| 483 | s/^/Signed-off-by: / |
| 484 | ' |
Santi_Béjar | f8e2c54 | 2005-10-09 17:30:19 -0700 | [diff] [blame] | 485 | } >>"$GIT_DIR"/COMMIT_EDITMSG |
Junio C Hamano | 2d56993 | 2005-08-31 17:15:25 -0700 | [diff] [blame] | 486 | ;; |
| 487 | esac |
| 488 | |
Junio C Hamano | 475443c | 2006-04-12 11:45:18 -0700 | [diff] [blame] | 489 | if test -f "$GIT_DIR/MERGE_HEAD" && test -z "$no_edit"; then |
Junio C Hamano | 2d56993 | 2005-08-31 17:15:25 -0700 | [diff] [blame] | 490 | echo "#" |
Alex Riesen | b6ae540 | 2006-01-05 12:44:59 +0100 | [diff] [blame] | 491 | echo "# It looks like you may be committing a MERGE." |
Junio C Hamano | 2d56993 | 2005-08-31 17:15:25 -0700 | [diff] [blame] | 492 | echo "# If this is not correct, please remove the file" |
| 493 | echo "# $GIT_DIR/MERGE_HEAD" |
| 494 | echo "# and try again" |
| 495 | echo "#" |
Santi_Béjar | f8e2c54 | 2005-10-09 17:30:19 -0700 | [diff] [blame] | 496 | fi >>"$GIT_DIR"/COMMIT_EDITMSG |
Junio C Hamano | aba2da1 | 2005-08-25 18:57:35 -0700 | [diff] [blame] | 497 | |
Junio C Hamano | 130fcca | 2006-02-05 00:07:44 -0800 | [diff] [blame] | 498 | # Author |
Junio C Hamano | 5a798fb | 2006-02-05 16:08:01 -0800 | [diff] [blame] | 499 | if test '' != "$force_author" |
| 500 | then |
Mark Wooding | f327dbc | 2006-04-13 22:01:24 +0000 | [diff] [blame] | 501 | GIT_AUTHOR_NAME=`expr "z$force_author" : 'z\(.*[^ ]\) *<.*'` && |
| 502 | GIT_AUTHOR_EMAIL=`expr "z$force_author" : '.*\(<.*\)'` && |
Junio C Hamano | 5a798fb | 2006-02-05 16:08:01 -0800 | [diff] [blame] | 503 | test '' != "$GIT_AUTHOR_NAME" && |
| 504 | test '' != "$GIT_AUTHOR_EMAIL" || |
Pavel Roskin | 82e5a82 | 2006-07-10 01:50:18 -0400 | [diff] [blame] | 505 | die "malformed --author parameter" |
Junio C Hamano | 5a798fb | 2006-02-05 16:08:01 -0800 | [diff] [blame] | 506 | export GIT_AUTHOR_NAME GIT_AUTHOR_EMAIL |
| 507 | elif test '' != "$use_commit" |
Junio C Hamano | 130fcca | 2006-02-05 00:07:44 -0800 | [diff] [blame] | 508 | then |
| 509 | pick_author_script=' |
| 510 | /^author /{ |
| 511 | s/'\''/'\''\\'\'\''/g |
| 512 | h |
| 513 | s/^author \([^<]*\) <[^>]*> .*$/\1/ |
| 514 | s/'\''/'\''\'\'\''/g |
| 515 | s/.*/GIT_AUTHOR_NAME='\''&'\''/p |
| 516 | |
| 517 | g |
| 518 | s/^author [^<]* <\([^>]*\)> .*$/\1/ |
| 519 | s/'\''/'\''\'\'\''/g |
| 520 | s/.*/GIT_AUTHOR_EMAIL='\''&'\''/p |
| 521 | |
| 522 | g |
| 523 | s/^author [^<]* <[^>]*> \(.*\)$/\1/ |
| 524 | s/'\''/'\''\'\'\''/g |
| 525 | s/.*/GIT_AUTHOR_DATE='\''&'\''/p |
| 526 | |
| 527 | q |
| 528 | } |
| 529 | ' |
| 530 | set_author_env=`git-cat-file commit "$use_commit" | |
| 531 | LANG=C LC_ALL=C sed -ne "$pick_author_script"` |
| 532 | eval "$set_author_env" |
| 533 | export GIT_AUTHOR_NAME |
| 534 | export GIT_AUTHOR_EMAIL |
| 535 | export GIT_AUTHOR_DATE |
Junio C Hamano | 130fcca | 2006-02-05 00:07:44 -0800 | [diff] [blame] | 536 | fi |
| 537 | |
Linus Torvalds | 96069cf | 2005-06-14 10:20:14 -0700 | [diff] [blame] | 538 | PARENTS="-p HEAD" |
Junio C Hamano | 130fcca | 2006-02-05 00:07:44 -0800 | [diff] [blame] | 539 | if test -z "$initial_commit" |
Junio C Hamano | 8098a17 | 2005-09-30 14:26:57 -0700 | [diff] [blame] | 540 | then |
Shawn Pearce | a3a733e | 2006-07-10 22:48:47 -0400 | [diff] [blame] | 541 | rloga='commit' |
Junio C Hamano | 5fec3ef | 2005-06-25 02:22:05 -0700 | [diff] [blame] | 542 | if [ -f "$GIT_DIR/MERGE_HEAD" ]; then |
Shawn Pearce | a3a733e | 2006-07-10 22:48:47 -0400 | [diff] [blame] | 543 | rloga='commit (merge)' |
Junio C Hamano | 91063bb | 2005-09-08 13:47:12 -0700 | [diff] [blame] | 544 | PARENTS="-p HEAD "`sed -e 's/^/-p /' "$GIT_DIR/MERGE_HEAD"` |
Junio C Hamano | b4019f0 | 2006-03-02 21:04:05 -0800 | [diff] [blame] | 545 | elif test -n "$amend"; then |
Shawn Pearce | a3a733e | 2006-07-10 22:48:47 -0400 | [diff] [blame] | 546 | rloga='commit (amend)' |
Junio C Hamano | b4019f0 | 2006-03-02 21:04:05 -0800 | [diff] [blame] | 547 | PARENTS=$(git-cat-file commit HEAD | |
| 548 | sed -n -e '/^$/q' -e 's/^parent /-p /p') |
Junio C Hamano | aba2da1 | 2005-08-25 18:57:35 -0700 | [diff] [blame] | 549 | fi |
Junio C Hamano | cede752 | 2006-09-27 02:06:31 -0700 | [diff] [blame^] | 550 | current="$(git-rev-parse --verify HEAD)" |
Junio C Hamano | 8098a17 | 2005-09-30 14:26:57 -0700 | [diff] [blame] | 551 | else |
| 552 | if [ -z "$(git-ls-files)" ]; then |
Junio C Hamano | 5a798fb | 2006-02-05 16:08:01 -0800 | [diff] [blame] | 553 | echo >&2 Nothing to commit |
Junio C Hamano | 8098a17 | 2005-09-30 14:26:57 -0700 | [diff] [blame] | 554 | exit 1 |
| 555 | fi |
| 556 | PARENTS="" |
Shawn Pearce | a3a733e | 2006-07-10 22:48:47 -0400 | [diff] [blame] | 557 | rloga='commit (initial)' |
Junio C Hamano | cede752 | 2006-09-27 02:06:31 -0700 | [diff] [blame^] | 558 | current='' |
Linus Torvalds | 96069cf | 2005-06-14 10:20:14 -0700 | [diff] [blame] | 559 | fi |
Junio C Hamano | 130fcca | 2006-02-05 00:07:44 -0800 | [diff] [blame] | 560 | |
Junio C Hamano | 475443c | 2006-04-12 11:45:18 -0700 | [diff] [blame] | 561 | if test -z "$no_edit" |
| 562 | then |
| 563 | { |
Martin Waitz | 88a1531 | 2006-05-26 01:42:18 +0200 | [diff] [blame] | 564 | echo "" |
| 565 | echo "# Please enter the commit message for your changes." |
| 566 | echo "# (Comment lines starting with '#' will not be included)" |
Junio C Hamano | 475443c | 2006-04-12 11:45:18 -0700 | [diff] [blame] | 567 | test -z "$only_include_assumed" || echo "$only_include_assumed" |
| 568 | run_status |
| 569 | } >>"$GIT_DIR"/COMMIT_EDITMSG |
| 570 | else |
| 571 | # we need to check if there is anything to commit |
| 572 | run_status >/dev/null |
| 573 | fi |
Junio C Hamano | 8588452 | 2006-03-04 20:36:28 -0800 | [diff] [blame] | 574 | if [ "$?" != "0" -a ! -f "$GIT_DIR/MERGE_HEAD" -a -z "$amend" ] |
Linus Torvalds | a3e870f | 2005-05-30 12:51:00 -0700 | [diff] [blame] | 575 | then |
Junio C Hamano | 7d0c688 | 2006-06-23 01:37:02 -0700 | [diff] [blame] | 576 | rm -f "$GIT_DIR/COMMIT_EDITMSG" "$GIT_DIR/SQUASH_MSG" |
Junio C Hamano | 5a798fb | 2006-02-05 16:08:01 -0800 | [diff] [blame] | 577 | run_status |
Linus Torvalds | a3e870f | 2005-05-30 12:51:00 -0700 | [diff] [blame] | 578 | exit 1 |
| 579 | fi |
Junio C Hamano | 475443c | 2006-04-12 11:45:18 -0700 | [diff] [blame] | 580 | |
Junio C Hamano | 0c09129 | 2005-08-08 17:03:14 -0700 | [diff] [blame] | 581 | case "$no_edit" in |
Junio C Hamano | 5fec3ef | 2005-06-25 02:22:05 -0700 | [diff] [blame] | 582 | '') |
Junio C Hamano | 7334f06 | 2006-02-04 22:10:32 -0800 | [diff] [blame] | 583 | case "${VISUAL:-$EDITOR},$TERM" in |
| 584 | ,dumb) |
| 585 | echo >&2 "Terminal is dumb but no VISUAL nor EDITOR defined." |
| 586 | echo >&2 "Please supply the commit log message using either" |
| 587 | echo >&2 "-m or -F option. A boilerplate log message has" |
| 588 | echo >&2 "been prepared in $GIT_DIR/COMMIT_EDITMSG" |
Junio C Hamano | 130fcca | 2006-02-05 00:07:44 -0800 | [diff] [blame] | 589 | exit 1 |
| 590 | ;; |
Junio C Hamano | 7334f06 | 2006-02-04 22:10:32 -0800 | [diff] [blame] | 591 | esac |
Sean | ec4e69c | 2006-05-13 23:09:32 -0400 | [diff] [blame] | 592 | git-var GIT_AUTHOR_IDENT > /dev/null || die |
| 593 | git-var GIT_COMMITTER_IDENT > /dev/null || die |
Santi_Béjar | f8e2c54 | 2005-10-09 17:30:19 -0700 | [diff] [blame] | 594 | ${VISUAL:-${EDITOR:-vi}} "$GIT_DIR/COMMIT_EDITMSG" |
Junio C Hamano | 5fec3ef | 2005-06-25 02:22:05 -0700 | [diff] [blame] | 595 | ;; |
| 596 | esac |
Junio C Hamano | 89e2c5f | 2005-08-18 17:20:08 -0700 | [diff] [blame] | 597 | |
| 598 | case "$verify" in |
| 599 | t) |
| 600 | if test -x "$GIT_DIR"/hooks/commit-msg |
| 601 | then |
Santi_Béjar | f8e2c54 | 2005-10-09 17:30:19 -0700 | [diff] [blame] | 602 | "$GIT_DIR"/hooks/commit-msg "$GIT_DIR"/COMMIT_EDITMSG || exit |
Junio C Hamano | 89e2c5f | 2005-08-18 17:20:08 -0700 | [diff] [blame] | 603 | fi |
| 604 | esac |
| 605 | |
Yann Dirson | 29f4ad8 | 2006-06-24 00:04:05 +0200 | [diff] [blame] | 606 | if test -z "$no_edit" |
| 607 | then |
| 608 | sed -e ' |
| 609 | /^diff --git a\/.*/{ |
| 610 | s/// |
| 611 | q |
| 612 | } |
| 613 | /^#/d |
| 614 | ' "$GIT_DIR"/COMMIT_EDITMSG |
| 615 | else |
| 616 | cat "$GIT_DIR"/COMMIT_EDITMSG |
| 617 | fi | |
Junio C Hamano | cf7bb58 | 2006-02-10 00:45:59 -0800 | [diff] [blame] | 618 | git-stripspace >"$GIT_DIR"/COMMIT_MSG |
Santi_Béjar | f8e2c54 | 2005-10-09 17:30:19 -0700 | [diff] [blame] | 619 | |
| 620 | if cnt=`grep -v -i '^Signed-off-by' "$GIT_DIR"/COMMIT_MSG | |
| 621 | git-stripspace | |
| 622 | wc -l` && |
| 623 | test 0 -lt $cnt |
Junio C Hamano | 0c09129 | 2005-08-08 17:03:14 -0700 | [diff] [blame] | 624 | then |
Junio C Hamano | 130fcca | 2006-02-05 00:07:44 -0800 | [diff] [blame] | 625 | if test -z "$TMP_INDEX" |
| 626 | then |
Junio C Hamano | cf7bb58 | 2006-02-10 00:45:59 -0800 | [diff] [blame] | 627 | tree=$(GIT_INDEX_FILE="$USE_INDEX" git-write-tree) |
Junio C Hamano | 130fcca | 2006-02-05 00:07:44 -0800 | [diff] [blame] | 628 | else |
| 629 | tree=$(GIT_INDEX_FILE="$TMP_INDEX" git-write-tree) && |
| 630 | rm -f "$TMP_INDEX" |
| 631 | fi && |
Santi_Béjar | f8e2c54 | 2005-10-09 17:30:19 -0700 | [diff] [blame] | 632 | commit=$(cat "$GIT_DIR"/COMMIT_MSG | git-commit-tree $tree $PARENTS) && |
Shawn Pearce | 67644a4 | 2006-05-19 05:16:18 -0400 | [diff] [blame] | 633 | rlogm=$(sed -e 1q "$GIT_DIR"/COMMIT_MSG) && |
Junio C Hamano | cede752 | 2006-09-27 02:06:31 -0700 | [diff] [blame^] | 634 | git-update-ref -m "$rloga: $rlogm" HEAD $commit "$current" && |
Junio C Hamano | cf7bb58 | 2006-02-10 00:45:59 -0800 | [diff] [blame] | 635 | rm -f -- "$GIT_DIR/MERGE_HEAD" && |
| 636 | if test -f "$NEXT_INDEX" |
| 637 | then |
| 638 | mv "$NEXT_INDEX" "$THIS_INDEX" |
| 639 | else |
| 640 | : ;# happy |
| 641 | fi |
Junio C Hamano | 0c09129 | 2005-08-08 17:03:14 -0700 | [diff] [blame] | 642 | else |
| 643 | echo >&2 "* no commit message? aborting commit." |
| 644 | false |
| 645 | fi |
Linus Torvalds | 170241b | 2005-06-19 19:57:01 -0700 | [diff] [blame] | 646 | ret="$?" |
Junio C Hamano | 7d0c688 | 2006-06-23 01:37:02 -0700 | [diff] [blame] | 647 | rm -f "$GIT_DIR/COMMIT_MSG" "$GIT_DIR/COMMIT_EDITMSG" "$GIT_DIR/SQUASH_MSG" |
Junio C Hamano | 1536dd9c6 | 2006-02-11 18:55:43 -0800 | [diff] [blame] | 648 | if test -d "$GIT_DIR/rr-cache" |
| 649 | then |
| 650 | git-rerere |
| 651 | fi |
Junio C Hamano | 89e2c5f | 2005-08-18 17:20:08 -0700 | [diff] [blame] | 652 | |
| 653 | if test -x "$GIT_DIR"/hooks/post-commit && test "$ret" = 0 |
| 654 | then |
| 655 | "$GIT_DIR"/hooks/post-commit |
| 656 | fi |
Linus Torvalds | 170241b | 2005-06-19 19:57:01 -0700 | [diff] [blame] | 657 | exit "$ret" |