From 52a22d1e726f91b0ba4ea0afb7cfbfaaf624127b Mon Sep 17 00:00:00 2001 From: A Large Angry SCM Date: Fri, 26 Aug 2005 18:18:48 -0700 Subject: [PATCH] Subject: [PATCH] Add some documentation. Add some documentation. Text taken from the the commit messages and the command sources. diff --git a/Documentation/git-add-script.txt b/Documentation/git-add-script.txt index 866d9c2..7ad2cfd 100644 --- a/Documentation/git-add-script.txt +++ b/Documentation/git-add-script.txt @@ -3,26 +3,21 @@ git-add-script(1) NAME ---- -git-add-script - Some git command not yet documented. - +git-add-script - Add files to the cache. SYNOPSIS -------- -'git-add-script' [ --option ] ... +'git-add-script' []\+ DESCRIPTION ----------- -Does something not yet documented. - +A simple wrapper to git-update-cache to add files to the cache for people used +to do "cvs add". OPTIONS ------- ---option:: - Some option not yet documented. - -...:: - Some argument not yet documented. - +:: + Files to add to the cache. Author ------ diff --git a/Documentation/git-branch-script.txt b/Documentation/git-branch-script.txt index fe9a041..3ace8ad 100644 --- a/Documentation/git-branch-script.txt +++ b/Documentation/git-branch-script.txt @@ -3,26 +3,27 @@ git-branch-script(1) NAME ---- -git-branch-script - Some git command not yet documented. - +git-branch-script - Create a new branch. SYNOPSIS -------- -'git-branch-script' [ --option ] ... +'git-branch-script' [ [start-point]] DESCRIPTION ----------- -Does something not yet documented. +If no argument is provided, show available branches and mark current +branch with star. Otherwise, create a new branch of name . +If a starting point is also specified, that will be where the branch is +created, otherwise it will be created at the current HEAD. OPTIONS ------- ---option:: - Some option not yet documented. - -...:: - Some argument not yet documented. +:: + The name of the branch to create. +start-point:: + Where to make the branch; defaults to HEAD. Author ------ diff --git a/Documentation/git-cherry.txt b/Documentation/git-cherry.txt index 14d0bd5..9ff7bc2 100644 --- a/Documentation/git-cherry.txt +++ b/Documentation/git-cherry.txt @@ -3,26 +3,30 @@ git-cherry(1) NAME ---- -git-cherry - Some git command not yet documented. - +git-cherry - Find commits not merged upstream. SYNOPSIS -------- -'git-cherry' [ --option ] ... +'git-cherry' [-v] [] DESCRIPTION ----------- -Does something not yet documented. - +Each commit between the fork-point and is examined, and compared against +the change each commit between the fork-point and introduces. +Commits already included in upstream are prefixed with '-' (meaning "drop from +my local pull"), while commits missing from upstream are prefixed with '+' +(meaning "add to the updated upstream"). OPTIONS ------- ---option:: - Some option not yet documented. +-v:: + Verbose. -...:: - Some argument not yet documented. +:: + Upstream branch to compare against. +:: + Working branch; defaults to HEAD. Author ------ diff --git a/Documentation/git-count-objects-script.txt b/Documentation/git-count-objects-script.txt index 2543617..8a3cedf 100644 --- a/Documentation/git-count-objects-script.txt +++ b/Documentation/git-count-objects-script.txt @@ -3,26 +3,16 @@ git-count-objects-script(1) NAME ---- -git-count-objects-script - Some git command not yet documented. - +git-count-objects-script - Reports on unpacked objects. SYNOPSIS -------- -'git-count-objects-script' [ --option ] ... +'git-count-objects-script' DESCRIPTION ----------- -Does something not yet documented. - - -OPTIONS -------- ---option:: - Some option not yet documented. - -...:: - Some argument not yet documented. - +This counts the number of unpacked object files and disk space consumed by +them, to help you decide when it is a good time to repack. Author ------ diff --git a/Documentation/git-patch-id.txt b/Documentation/git-patch-id.txt index 9a4abd1..b6fa2a8 100644 --- a/Documentation/git-patch-id.txt +++ b/Documentation/git-patch-id.txt @@ -3,26 +3,25 @@ git-patch-id(1) NAME ---- -git-patch-id - Some git command not yet documented. - +git-patch-id - Generate a patch ID. SYNOPSIS -------- -'git-patch-id' [ --option ] ... +'git-patch-id' < DESCRIPTION ----------- -Does something not yet documented. +A "patch ID" is nothing but a SHA1 of the diff associated with a patch, with +whitespace and line numbers ignored. As such, it's "reasonably stable", but at +the same time also reasonably unique, ie two patches that have the same "patch +ID" are almost guaranteed to be the same thing. +IOW, you can use this thing to look for likely duplicate commits. OPTIONS ------- ---option:: - Some option not yet documented. - -...:: - Some argument not yet documented. - +:: + The diff to create the ID of. Author ------ diff --git a/Documentation/git-rebase-script.txt b/Documentation/git-rebase-script.txt index ba7cbb7..a9e4b21 100644 --- a/Documentation/git-rebase-script.txt +++ b/Documentation/git-rebase-script.txt @@ -3,26 +3,23 @@ git-rebase-script(1) NAME ---- -git-rebase-script - Some git command not yet documented. - +git-rebase-script - Rebase local commits to new upstream head. SYNOPSIS -------- -'git-rebase-script' [ --option ] ... +'git-rebase-script' [] DESCRIPTION ----------- -Does something not yet documented. - +Rebases local commits to the new head of the upstream tree.' OPTIONS ------- ---option:: - Some option not yet documented. - -...:: - Some argument not yet documented. +:: + Upstream branch to compare against. +:: + Working branch; defaults to HEAD. Author ------ diff --git a/Documentation/git-relink-script.txt b/Documentation/git-relink-script.txt index 4c2b435..99c05d4 100644 --- a/Documentation/git-relink-script.txt +++ b/Documentation/git-relink-script.txt @@ -3,26 +3,25 @@ git-relink-script(1) NAME ---- -git-relink-script - Some git command not yet documented. - +git-relink-script - Hardlink common objects in local repositories. SYNOPSIS -------- -'git-relink-script' [ --option ] ... +'git-relink-script' [--safe] []\* DESCRIPTION ----------- -Does something not yet documented. - +This will scan 2 or more object repositories and look for common objects, check +if they are hardlinked, and replace one with a hardlink to the other if not. OPTIONS ------- ---option:: - Some option not yet documented. - -...:: - Some argument not yet documented. +--safe:: + Stops if two objects with the same hash exist but have different sizes. + Default is to warn and continue. +:: + Directories containing a .git/objects/ subdirectory. Author ------ diff --git a/Documentation/git-revert-script.txt b/Documentation/git-revert-script.txt index 8a532e6..727073e 100644 --- a/Documentation/git-revert-script.txt +++ b/Documentation/git-revert-script.txt @@ -3,26 +3,22 @@ git-revert-script(1) NAME ---- -git-revert-script - Some git command not yet documented. - +git-revert-script - Revert an existing commit. SYNOPSIS -------- -'git-revert-script' [ --option ] ... +'git-revert-script' DESCRIPTION ----------- -Does something not yet documented. - +Given one existing commit, revert the change the patch introduces, and record a +new commit that records it. This requires your working tree to be clean (no +modifications from the HEAD commit). OPTIONS ------- ---option:: - Some option not yet documented. - -...:: - Some argument not yet documented. - +:: + Commit to revert. Author ------ diff --git a/Documentation/git-sh-setup-script.txt b/Documentation/git-sh-setup-script.txt index 92addd7..5ac613a 100644 --- a/Documentation/git-sh-setup-script.txt +++ b/Documentation/git-sh-setup-script.txt @@ -3,26 +3,22 @@ git-sh-setup-script(1) NAME ---- -git-sh-setup-script - Some git command not yet documented. - +git-sh-setup-script - Common git shell script setup code. SYNOPSIS -------- -'git-sh-setup-script' [ --option ] ... +'git-sh-setup-script' DESCRIPTION ----------- -Does something not yet documented. - -OPTIONS -------- ---option:: - Some option not yet documented. +Sets up the normal git environment variables and a few helper functions +(currently just "die()"), and returns ok if it all looks like a git archive. +So use it something like -...:: - Some argument not yet documented. + . git-sh-setup-script || die "Not a git archive" +to make the rest of the git scripts more careful and readable. Author ------ diff --git a/Documentation/git-verify-tag-script.txt b/Documentation/git-verify-tag-script.txt index 88a2646..d5d747c 100644 --- a/Documentation/git-verify-tag-script.txt +++ b/Documentation/git-verify-tag-script.txt @@ -3,26 +3,20 @@ git-verify-tag-script(1) NAME ---- -git-verify-tag-script - Some git command not yet documented. - +git-verify-tag-script - Check the GPG signature of tag. SYNOPSIS -------- -'git-verify-tag-script' [ --option ] ... +'git-verify-tag-script' DESCRIPTION ----------- -Does something not yet documented. - +Validates the gpg signature created by git-tag-script. OPTIONS ------- ---option:: - Some option not yet documented. - -...:: - Some argument not yet documented. - +:: + SHA1 identifier of a git tag object. Author ------ -- cgit v0.10.2-6-g49f6 From 905197de9f8f1a2ce619ac888ab7a2e1a67acb56 Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Fri, 26 Aug 2005 21:33:46 -0700 Subject: Update the main documentation index. Gitzilla updated bunch of undocumented command pages, so move the entries in the main documentation index around to put them in proper category. Ordering within category will be fixed later. Signed-off-by: Junio C Hamano diff --git a/Documentation/git-add-script.txt b/Documentation/git-add-script.txt index 7ad2cfd..3001143 100644 --- a/Documentation/git-add-script.txt +++ b/Documentation/git-add-script.txt @@ -7,7 +7,7 @@ git-add-script - Add files to the cache. SYNOPSIS -------- -'git-add-script' []\+ +'git-add-script' ... DESCRIPTION ----------- @@ -16,7 +16,7 @@ to do "cvs add". OPTIONS ------- -:: +...:: Files to add to the cache. Author diff --git a/Documentation/git-rebase-script.txt b/Documentation/git-rebase-script.txt index a9e4b21..8f14186 100644 --- a/Documentation/git-rebase-script.txt +++ b/Documentation/git-rebase-script.txt @@ -11,7 +11,7 @@ SYNOPSIS DESCRIPTION ----------- -Rebases local commits to the new head of the upstream tree.' +Rebases local commits to the new head of the upstream tree. OPTIONS ------- diff --git a/Documentation/git.txt b/Documentation/git.txt index d4ede09..f63cbdd 100644 --- a/Documentation/git.txt +++ b/Documentation/git.txt @@ -1,6 +1,6 @@ git(7) ====== -v0.99.4, Aug 2005 +v0.99.5, Aug 2005 NAME ---- @@ -195,6 +195,18 @@ link:git-update-server-info.html[git-update-server-info]:: Porcelain-ish Commands ---------------------- +link:git-revert-script.html[git-revert-script]:: + Revert an existing commit. + +link:git-rebase-script.html[git-rebase-script]:: + Rebase local commits to new upstream head. + +link:git-add-script.html[git-add-script]:: + Add paths to the index file. + +link:git-branch-script.html[git-branch-script]:: + Create and Show branches. + link:git-whatchanged.html[git-whatchanged]:: Shows commit logs and differences they introduce. @@ -237,11 +249,17 @@ link:git-rename-script.html[git-rename]:: link:git-ls-remote-script.html[git-ls-remote-script]:: Shows references in a remote or local repository. +link:git-verify-tag-script.html[git-verify-tag-script]:: + Check the GPG signature of tag. + Ancillary Commands ------------------ Manipulators: +link:git-relink-script.html[git-relink-script]:: + Hardlink common objects in local repositories. + link:git-apply-patch-script.html[git-apply-patch-script]:: Sample script to apply the diffs from git-diff-* @@ -263,6 +281,15 @@ link:git-cvsimport-script.html[git-cvsimport-script]:: Interrogators: +link:git-patch-id.html[git-patch-id]:: + Compute unique ID for a patch. + +link:git-count-objects-script.html[git-count-objects-script]:: + Count unpacked number of objects and their disk consumption. + +link:git-cherry.html[git-cherry]:: + Find commits not merged upstream. + link:git-diff-helper.html[git-diff-helper]:: Generates patch format output for git-diff-* @@ -272,6 +299,9 @@ link:git-ssh-push.html[git-ssh-push]:: link:git-send-email-script.html[git-send-email]:: Send patch e-mails out of "format-patch --mbox" output. +link:git-sh-setup-script.html[git-sh-setup-script]:: + Common git shell script setup code. + Commands not yet documented --------------------------- @@ -288,30 +318,18 @@ link:git-mailinfo.html[git-mailinfo]:: link:git-mailsplit.html[git-mailsplit]:: git-mailsplit. -link:git-add-script.html[git-add-script]:: - git-add-script. - link:git-bisect-script.html[git-bisect-script]:: git-bisect-script. -link:git-branch-script.html[git-branch-script]:: - git-branch-script. - link:git-build-rev-cache.html[git-build-rev-cache]:: git-build-rev-cache. link:git-checkout-script.html[git-checkout-script]:: git-checkout-script. -link:git-cherry.html[git-cherry]:: - git-cherry. - link:git-clone-dumb-http.html[git-clone-dumb-http]:: git-clone-dumb-http. -link:git-count-objects-script.html[git-count-objects-script]:: - git-count-objects-script. - link:git-daemon.html[git-daemon]:: git-daemon. @@ -324,15 +342,6 @@ link:git-format-patch-script.html[git-format-patch-script]:: link:git-get-tar-commit-id.html[git-get-tar-commit-id]:: git-get-tar-commit-id. -link:git-patch-id.html[git-patch-id]:: - git-patch-id. - -link:git-rebase-script.html[git-rebase-script]:: - git-rebase-script. - -link:git-relink-script.html[git-relink-script]:: - git-relink-script. - link:git-request-pull-script.html[git-request-pull-script]:: git-request-pull-script. @@ -342,21 +351,12 @@ link:git-reset-script.html[git-reset-script]:: link:git-rev-parse.html[git-rev-parse]:: git-rev-parse. -link:git-revert-script.html[git-revert-script]:: - git-revert-script. - -link:git-sh-setup-script.html[git-sh-setup-script]:: - git-sh-setup-script. - link:git-show-rev-cache.html[git-show-rev-cache]:: git-show-rev-cache. link:git-stripspace.html[git-stripspace]:: git-stripspace. -link:git-verify-tag-script.html[git-verify-tag-script]:: - git-verify-tag-script. - link:gitk.html[gitk]:: gitk. -- cgit v0.10.2-6-g49f6 From 90bc118fc53916a623cad84e72b7dec597907b1e Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Thu, 25 Aug 2005 16:31:43 -0700 Subject: Enable git-send-email-script on Debian. You can define WITH_SEND_EMAIL to include the send-email command as part of the installation. Since Debian, unlike RPM/Fedora, has the two necessary Perl modules available as part of the mainline distribution, there is no reason for us to shy away from shipping send-email. Signed-off-by: Junio C Hamano diff --git a/Makefile b/Makefile index adb4965..c0fdaa7 100644 --- a/Makefile +++ b/Makefile @@ -69,7 +69,6 @@ SCRIPTS=git git-apply-patch-script git-merge-one-file-script git-prune-script \ git-request-pull-script git-bisect-script SCRIPTS += git-count-objects-script -# SCRIPTS += git-send-email-script SCRIPTS += git-revert-script SCRIPTS += git-octopus-script @@ -87,6 +86,10 @@ PROG= git-update-cache git-diff-files git-init-db git-write-tree \ git-show-index git-daemon git-var git-peek-remote git-show-branch \ git-update-server-info git-show-rev-cache git-build-rev-cache +ifdef WITH_SEND_EMAIL +SCRIPTS += git-send-email-script +endif + ifndef NO_CURL PROG+= git-http-pull endif diff --git a/debian/changelog b/debian/changelog index da7526e..5b7b4d3 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,10 @@ +git-core (0.99.5-1) unstable; urgency=low + + * Enable git-send-email-script on Debian. There is no reason to shy + away from it, since we have the necessary Perl modules available. + + -- Junio C Hamano Thu, 25 Aug 2005 14:16:59 -0700 + git-core (0.99.5-0) unstable; urgency=low * GIT 0.99.5 diff --git a/debian/rules b/debian/rules index c46b4d9..86464bf 100755 --- a/debian/rules +++ b/debian/rules @@ -25,6 +25,9 @@ else export MOZILLA_SHA1=YesPlease endif +# We do have the requisite perl modules in the mainline, and +# have no reason to shy away from this script. +export WITH_SEND_EMAIL=YesPlease PREFIX := /usr MANDIR := /usr/share/man/ -- cgit v0.10.2-6-g49f6 From b10ac50f1e9ef851128f9800cd481d8cace18f01 Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Thu, 25 Aug 2005 18:15:32 -0700 Subject: Fix pulling into the same branch. When the "git pull" command updates the branch head you are currently on, before doing anything else, first update your index file and the working tree contents to that of the new branch head. Otherwise, the later resolving steps would think your index file is attempting to revert the change between the original head commit and the updated head commit. It uses two-tree fast-forward form of "read-tree -m -u" to prevent losing whatever local changes you may have in the working tree to do this update. I think this would at least make things safer (a lot safer), and prevent mistakes. Also "git fetch" command is forbidden from fetching and fast forwarding the current branch head unless --update-head-ok flag is given. "git pull" passes the flag when it internally calls "git fetch". Signed-off-by: Junio C Hamano diff --git a/git-fetch-script b/git-fetch-script index b581dc4..dd94ede 100755 --- a/git-fetch-script +++ b/git-fetch-script @@ -7,28 +7,33 @@ _x40="$_x40$_x40$_x40$_x40$_x40$_x40$_x40$_x40" append= force= +update_head_ok= while case "$#" in 0) break ;; esac do case "$1" in -a|--a|--ap|--app|--appe|--appen|--append) append=t - shift ;; -f|--f|--fo|--for|--forc|--force) force=t - shift + ;; + -u|--u|--up|--upd|--upda|--updat|--update|--update-|--update-h|\ + --update-he|--update-hea|--update-head|--update-head-|\ + --update-head-o|--update-head-ok) + update_head_ok=t ;; *) break ;; esac + shift done case "$#" in 0) test -f "$GIT_DIR/branches/origin" || test -f "$GIT_DIR/remotes/origin" || - die "Where do you want to fetch from?" + die "Where do you want to fetch from today?" set origin ;; esac @@ -124,6 +129,12 @@ fast_forward_local () { esac } +case "$update_head_ok" in +'') + orig_head=$(cat "$GIT_DIR/HEAD" 2>/dev/null) + ;; +esac + for ref in $(get_remote_refs_for_fetch "$@") do refs="$refs $ref" @@ -150,7 +161,7 @@ do fi head=$(curl -nsf $curl_extra_args "$remote/$remote_name") && expr "$head" : "$_x40\$" >/dev/null || - die "Failed to fetch $remote_name from $remote" + die "Failed to fetch $remote_name from $remote" echo Fetching "$remote_name from $remote" using http git-http-pull -v -a "$head" "$remote/" || exit ;; @@ -201,3 +212,18 @@ http://* | https://* | rsync://* ) done ;; esac + +# If the original head was empty (i.e. no "master" yet), or +# if we were told not to worry, we do not have to check. +case ",$update_head_ok,$orig_head," in +*,, | t,* ) + ;; +*) + curr_head=$(cat "$GIT_DIR/HEAD" 2>/dev/null) + if test "$curr_head" != "$orig_head" + then + echo "$orig_head" >$GIT_DIR/HEAD + die "Cannot fetch into the current branch." + fi + ;; +esac diff --git a/git-pull-script b/git-pull-script index 7016fbf..c31a65c 100755 --- a/git-pull-script +++ b/git-pull-script @@ -5,7 +5,25 @@ # Fetch one or more remote refs and merge it/them into the current HEAD. . git-sh-setup-script || die "Not a git archive" -git-fetch-script "$@" || exit 1 + +orig_head=$(cat "$GIT_DIR/HEAD") || die "Pulling into a black hole?" +git-fetch-script --update-head-ok "$@" || exit 1 + +curr_head=$(cat "$GIT_DIR/HEAD") +if test "$curr_head" != "$orig_head" +then + # The fetch involved updating the current branch. + + # The working tree and the index file is still based on the + # $orig_head commit, but we are merging into $curr_head. + # First update the working tree to match $curr_head. + + echo >&2 "Warning: fetch updated the current branch head." + echo >&2 "Warning: fast forwarding your working tree." + git-read-tree -u -m "$orig_head" "$curr_head" || + die "You need to first update your working tree." +fi + merge_head=$(sed -e 's/ .*//' "$GIT_DIR"/FETCH_HEAD | tr '\012' ' ') merge_name=$(sed -e 's/^[0-9a-f]* //' "$GIT_DIR"/FETCH_HEAD | tr '\012' ' ') -- cgit v0.10.2-6-g49f6 From 7311d9f10476f9b478348dab597bcc3d8736f091 Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Fri, 26 Aug 2005 22:35:45 -0700 Subject: Add how-to on using update-hook. Signed-off-by: Junio C Hamano diff --git a/Documentation/howto/rebuild-from-update-hook.txt b/Documentation/howto/rebuild-from-update-hook.txt new file mode 100644 index 0000000..ebd025d --- /dev/null +++ b/Documentation/howto/rebuild-from-update-hook.txt @@ -0,0 +1,83 @@ +Subject: [HOWTO] Using post-update hook +Message-ID: <7vy86o6usx.fsf@assigned-by-dhcp.cox.net> +From: Junio C Hamano +Date: Fri, 26 Aug 2005 18:19:10 -0700 +Abstract: In this how-to article, JC talks about how he + uses the post-update hook to automate git documentation page + shown at http://www.kernel.org/pub/software/scm/git/docs/. + +The pages under http://www.kernel.org/pub/software/scm/git/docs/ +are built from Documentation/ directory of the git.git project +and needed to be kept up-to-date. The www.kernel.org/ servers +are mirrored and I was told that the origin of the mirror is on +the machine master.kernel.org, on which I was given an account +when I took over git maintainership from Linus. + +The directories relevant to this how-to are these two: + + /pub/scm/git/git.git/ The public git repository. + /pub/software/scm/git/docs/ The HTML documentation page. + +So I made a repository to generate the documentation under my +home directory over there. + + $ cd + $ mkdir doc-git && cd doc-git + $ git clone /pub/scm/git/git.git/ docgen + +What needs to happen is to update the $HOME/doc-git/docgen/ +working tree, build HTML docs there and install the result in +/pub/software/scm/git/docs/ directory. So I wrote a little +script: + + $ cat >dododoc.sh <<\EOF + #!/bin/sh + cd $HOME/doc-git/docgen || exit + + unset GIT_DIR + + git pull /pub/scm/git/git.git/ master && + cd Documentation && + make install-webdoc + EOF + +Initially I used to run this by hand whenever I push into the +public git repository. Then I did a cron job that ran twice a +day. The current round uses the post-update hook mechanism, +like this: + + $ cat >/pub/scm/git/git.git/hooks/post-update <<\EOF + #!/bin/sh + # + # An example hook script to prepare a packed repository for use over + # dumb transports. + # + # To enable this hook, make this file executable by "chmod +x post-update". + + case " $* " in + *' refs/heads/master '*) + echo $HOME/doc-git/dododoc.sh | at now + ;; + esac + exec git-update-server-info + EOF + $ chmod +x /pub/scm/git/git.git/hooks/post-update + +There are three things worth mentioning: + + - The update-hook is run after the repository accepts a "git + push", under my user privilege. It is given the full names + of refs that have been updated as arguments. My post-update + runs the dododoc.sh script only when the master head is + updated. + + - When update-hook is run, GIT_DIR is set to '.' by the calling + receive-pack. This is inherited by the dododoc.sh run via + the "at" command, and needs to be unset; otherwise, "git + pull" it does into $HOME/doc-git/docgen/ repository would not + work correctly. + + - This is still crude and does not protect against simultaneous + make invocations stomping on each other. I would need to add + some locking mechanism for this. + -- cgit v0.10.2-6-g49f6 From aba2da13391d2adc72c0a2805e7196db2c803753 Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Thu, 25 Aug 2005 18:57:35 -0700 Subject: Accept -m and friends for initial commits and merge commits. Yes it was irritating not to be able to do so. Signed-off-by: Junio C Hamano diff --git a/git-commit-script b/git-commit-script index 5c5f564..e47a090 100755 --- a/git-commit-script +++ b/git-commit-script @@ -110,57 +110,51 @@ t) fi esac +if [ ! -r "$GIT_DIR/HEAD" ] +then + echo "#" + echo "# Initial commit" + echo "#" + git-ls-files | sed 's/^/# New file: /' + echo "#" +elif [ -f "$GIT_DIR/MERGE_HEAD" ]; then + echo "#" + echo "# It looks like your may be committing a MERGE." + echo "# If this is not correct, please remove the file" + echo "# $GIT_DIR/MERGE_HEAD" + echo "# and try again" + echo "#" +fi >.editmsg +if test "$log_message" != '' +then + echo "$log_message" +elif test "$logfile" != "" +then + if test "$logfile" = - + then + test -t 0 && + echo >&2 "(reading log message from standard input)" + cat + else + cat <"$logfile" + fi +elif test "$use_commit" != "" +then + git-cat-file commit "$use_commit" | sed -e '1,/^$/d' +fi | git-stripspace >>.editmsg + PARENTS="-p HEAD" if [ ! -r "$GIT_DIR/HEAD" ]; then if [ -z "$(git-ls-files)" ]; then echo Nothing to commit 1>&2 exit 1 fi - { - echo "#" - echo "# Initial commit" - case "$no_edit" in - t) echo "# (ignoring your commit message for initial commit)" - no_edit= - esac - echo "#" - git-ls-files | sed 's/^/# New file: /' - echo "#" - } >.editmsg PARENTS="" - no_edit= else if [ -f "$GIT_DIR/MERGE_HEAD" ]; then - { - echo "#" - echo "# It looks like your may be committing a MERGE." - echo "# If this is not correct, please remove the file" - echo "# $GIT_DIR/MERGE_HEAD" - echo "# and try again" - case "$no_edit" in - t) echo "# (ignoring your commit message for merge commit)" - no_edit= - esac - echo "#" - } | - git-stripspace >.editmsg PARENTS="-p HEAD -p MERGE_HEAD" - elif test "$log_message" != '' - then - echo "$log_message" | - git-stripspace >.editmsg - elif test "$logfile" != "" - then - if test "$logfile" = - - then - test -t 0 && - echo >&2 "(reading log message from standard input)" - cat - else - cat <"$logfile" - fi | - git-stripspace >.editmsg - elif test "$use_commit" != "" + fi + if test "$use_commit" != "" then pick_author_script=' /^author /{ @@ -188,22 +182,20 @@ else export GIT_AUTHOR_NAME export GIT_AUTHOR_EMAIL export GIT_AUTHOR_DATE - git-cat-file commit "$use_commit" | - sed -e '1,/^$/d' | - git-stripspace >.editmsg fi - case "$signoff" in t) git-var GIT_COMMITTER_IDENT | sed -e ' s/>.*/>/ - s/^/Signed-off-by: /' >>.editmsg ;; + s/^/Signed-off-by: / + ' >>.editmsg + ;; esac git-status-script >>.editmsg fi if [ "$?" != "0" -a ! -f $GIT_DIR/MERGE_HEAD ] then - cat .editmsg + sed -ne '/^#/p' .editmsg rm .editmsg exit 1 fi -- cgit v0.10.2-6-g49f6