From: Sam Vilain <sam.vilain@xxxxxxxxxxxxxxx> Add command-line support for --prior and add a description to the ASCIIDOC --- Documentation/git-commit.txt | 10 ++++++++++ git-commit.sh | 19 +++++++++++++++++-- 2 files changed, 27 insertions(+), 2 deletions(-) diff --git a/Documentation/git-commit.txt b/Documentation/git-commit.txt index 6f2c495..ca5073c 100644 --- a/Documentation/git-commit.txt +++ b/Documentation/git-commit.txt @@ -10,6 +10,7 @@ SYNOPSIS [verse] 'git-commit' [-a] [-s] [-v] [(-c | -C) <commit> | -F <file> | -m <msg>] [--no-verify] [--amend] [-e] [--author <author>] + [-p <commit>] [--] [[-i | -o ]<file>...] DESCRIPTION @@ -106,6 +107,15 @@ but can be used to amend a merge commit. index and the latest commit does not match on the specified paths to avoid confusion. +-p|--prior <commit>:: + Specify a commit that this new commit is the next version of. + Use when you want a branch to supercede another branch, but + with a new commit history. It is also use for sub-projects, + where commits on the parent tree mirror commits in the + sub-project. <commit> does not have to exist in the local + repository, if it is specified as a full 40-digit hex SHA1 + sum. Otherwise it is parsed as a local revision. + --:: Do not interpret any more arguments as options. diff --git a/git-commit.sh b/git-commit.sh index 26cd7ca..3feb60d 100755 --- a/git-commit.sh +++ b/git-commit.sh @@ -3,7 +3,7 @@ # # Copyright (c) 2005 Linus Torvalds # Copyright (c) 2006 Junio C Hamano -USAGE='[-a] [-s] [-v] [--no-verify] [-m <message> | -F <logfile> | (-C|-c) <commit>) [--amend] [-e] [--author <author>] [[-i | -o] <path>...]' +USAGE='[-a] [-s] [-v] [--no-verify] [-m <message> | -F <logfile> | (-C|-c) <commit>) [--amend] [-e] [--author <author>] [-p <commit>] [[-i | -o] <path>...]' SUBDIRECTORY_OK=Yes . git-sh-setup @@ -200,6 +200,7 @@ log_given= log_message= verify=t verbose= +prior= signoff= force_author= only_include_assumed= @@ -344,6 +345,19 @@ do shift break ;; + -p|--p|--pr|--pri|--prio|--prior) + shift + prior="$1" + if echo $prior | perl -ne 'exit 1 unless /^[0-9a-f]{40}$/i' + then + prior=`echo "$prior" | tr '[A-Z]' '[a-z]'` + else + prior=`git-rev-parse "$prior"` + [ -n "$prior" ] || exit 1 + fi + PRIOR="-r $prior" + shift + ;; -*) usage ;; @@ -602,6 +616,7 @@ then PARENTS=$(git-cat-file commit HEAD | sed -n -e '/^$/q' -e 's/^parent /-p /p') fi + current=$(git-rev-parse --verify HEAD) else if [ -z "$(git-ls-files)" ]; then @@ -673,7 +688,7 @@ then tree=$(GIT_INDEX_FILE="$TMP_INDEX" git-write-tree) && rm -f "$TMP_INDEX" fi && - commit=$(cat "$GIT_DIR"/COMMIT_MSG | git-commit-tree $tree $PARENTS) && + commit=$(cat "$GIT_DIR"/COMMIT_MSG | git-commit-tree $tree $PARENTS $PRIOR) && git-update-ref HEAD $commit $current && rm -f -- "$GIT_DIR/MERGE_HEAD" && if test -f "$NEXT_INDEX" - : 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