[PATCH] git-commit -f <file>: take message from file, and remove file upon completion.

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

 



Change (undocumented) git commit -f option from a synonym for git-commit -F
to "Take the commit message from the given file, and remove the file upon
successful commit".

git-revert and git-cherry-pick should make use of this to properly cleanup
the automatically created ./.msg file.

Signed-off-by: Gerrit Pape <pape@xxxxxxxxxxx>
---
 Documentation/git-commit.txt |    7 ++++---
 git-commit.sh                |   25 +++++++++++++++++++++++--
 2 files changed, 27 insertions(+), 5 deletions(-)

diff --git a/Documentation/git-commit.txt b/Documentation/git-commit.txt
index 53a7bb0..da68c81 100644
--- a/Documentation/git-commit.txt
+++ b/Documentation/git-commit.txt
@@ -9,7 +9,7 @@ SYNOPSIS
 --------
 [verse]
 'git-commit' [-a | --interactive] [-s] [-v]
-	   [(-c | -C) <commit> | -F <file> | -m <msg> | --amend]
+	   [(-c | -C) <commit> | (-F | -f) <file> | -m <msg> | --amend]
 	   [--no-verify] [-e] [--author <author>]
 	   [--] [[-i | -o ]<file>...]
 
@@ -63,9 +63,10 @@ OPTIONS
 	invoked; with '-c' the user can further edit the commit
 	message.
 
--F <file>::
+-F or -f <file>::
 	Take the commit message from the given file.  Use '-' to
-	read the message from the standard input.
+	read the message from the standard input.  With '-f', the
+	file is removed upon successful commit; with '-F' not.
 
 --author <author>::
 	Override the author name used in the commit.  Use
diff --git a/git-commit.sh b/git-commit.sh
index f28fc24..e4518c4 100755
--- a/git-commit.sh
+++ b/git-commit.sh
@@ -74,6 +74,7 @@ also=
 interactive=
 only=
 logfile=
+logfile_rm=
 use_commit=
 amend=
 edit_flag=
@@ -90,15 +91,31 @@ untracked_files=
 while case "$#" in 0) break;; esac
 do
 	case "$1" in
-	-F|--F|-f|--f|--fi|--fil|--file)
+	-f)
 		case "$#" in 1) usage ;; esac
 		shift
 		no_edit=t
 		log_given=t$log_given
 		logfile="$1"
+		test "$logfile" = '-' || logfile_rm=1
 		shift
 		;;
-	-F*|-f*)
+	-F|--F|--f|--fi|--fil|--file)
+		case "$#" in 1) usage ;; esac
+		shift
+		no_edit=t
+		log_given=t$log_given
+		logfile="$1"
+		shift
+		;;
+	-f*)
+		no_edit=t
+		log_given=t$log_given
+		logfile=`expr "z$1" : 'z-[Ff]\(.*\)'`
+		test "$logfile" = '-' || logfile_rm=1
+		shift
+		;;
+	-F*)
 		no_edit=t
 		log_given=t$log_given
 		logfile=`expr "z$1" : 'z-[Ff]\(.*\)'`
@@ -653,6 +670,10 @@ then
 		       --summary --root HEAD --`
 		echo "Created${initial_commit:+ initial} commit $commit"
 	fi
+	if test -n "$logfile_rm"
+	then
+		rm -f "$logfile"
+	fi
 fi
 
 exit "$ret"
-- 
1.5.1.2

-
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]