summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJunio C Hamano <junkio@cox.net>2005-08-27 05:47:27 (GMT)
committerJunio C Hamano <junkio@cox.net>2005-08-27 05:47:27 (GMT)
commit0f583175317a1c5c57b56c87856fbe46c3f3c296 (patch)
tree743751d750cb7355c02dd2aa7f53a655ba6fd11c
parentb033b4e48195ef5974b7255f30de2cd7f67868b8 (diff)
parentaba2da13391d2adc72c0a2805e7196db2c803753 (diff)
downloadgit-0f583175317a1c5c57b56c87856fbe46c3f3c296.zip
git-0f583175317a1c5c57b56c87856fbe46c3f3c296.tar.gz
git-0f583175317a1c5c57b56c87856fbe46c3f3c296.tar.bz2
Merge master branch changes into release candidate branch.
Signed-off-by: Junio C Hamano <junkio@cox.net>
-rw-r--r--Documentation/git-add-script.txt17
-rw-r--r--Documentation/git-branch-script.txt19
-rw-r--r--Documentation/git-cherry.txt22
-rw-r--r--Documentation/git-count-objects-script.txt18
-rw-r--r--Documentation/git-patch-id.txt19
-rw-r--r--Documentation/git-rebase-script.txt17
-rw-r--r--Documentation/git-relink-script.txt19
-rw-r--r--Documentation/git-revert-script.txt18
-rw-r--r--Documentation/git-sh-setup-script.txt18
-rw-r--r--Documentation/git-verify-tag-script.txt16
-rw-r--r--Documentation/git.txt62
-rw-r--r--Documentation/howto/rebuild-from-update-hook.txt83
-rw-r--r--Makefile5
-rw-r--r--debian/changelog7
-rwxr-xr-xdebian/rules3
-rwxr-xr-xgit-commit-script86
-rwxr-xr-xgit-fetch-script34
-rwxr-xr-xgit-pull-script20
18 files changed, 293 insertions, 190 deletions
diff --git a/Documentation/git-add-script.txt b/Documentation/git-add-script.txt
index 866d9c2..3001143 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 ] <args>...
+'git-add-script' <file>...
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.
-
-<args>...::
- Some argument not yet documented.
-
+<file>...::
+ 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 ] <args>...
+'git-branch-script' [<branchname> [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 <branchname>.
+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.
-
-<args>...::
- Some argument not yet documented.
+<branchname>::
+ 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 ] <args>...
+'git-cherry' [-v] <upstream> [<head>]
DESCRIPTION
-----------
-Does something not yet documented.
-
+Each commit between the fork-point and <head> is examined, and compared against
+the change each commit between the fork-point and <upstream> 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.
-<args>...::
- Some argument not yet documented.
+<upstream>::
+ Upstream branch to compare against.
+<head>::
+ 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 ] <args>...
+'git-count-objects-script'
DESCRIPTION
-----------
-Does something not yet documented.
-
-
-OPTIONS
--------
---option::
- Some option not yet documented.
-
-<args>...::
- 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 ] <args>...
+'git-patch-id' < <patch>
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.
-
-<args>...::
- Some argument not yet documented.
-
+<patch>::
+ The diff to create the ID of.
Author
------
diff --git a/Documentation/git-rebase-script.txt b/Documentation/git-rebase-script.txt
index ba7cbb7..8f14186 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 ] <args>...
+'git-rebase-script' <upstream> [<head>]
DESCRIPTION
-----------
-Does something not yet documented.
-
+Rebases local commits to the new head of the upstream tree.
OPTIONS
-------
---option::
- Some option not yet documented.
-
-<args>...::
- Some argument not yet documented.
+<upstream>::
+ Upstream branch to compare against.
+<head>::
+ 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 ] <args>...
+'git-relink-script' [--safe] <dir> <dir> [<dir>]\*
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.
-
-<args>...::
- 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.
+<dir>::
+ 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 ] <args>...
+'git-revert-script' <commit>
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.
-
-<args>...::
- Some argument not yet documented.
-
+<commit>::
+ 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 ] <args>...
+'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
-<args>...::
- 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 ] <args>...
+'git-verify-tag-script' <tag>
DESCRIPTION
-----------
-Does something not yet documented.
-
+Validates the gpg signature created by git-tag-script.
OPTIONS
-------
---option::
- Some option not yet documented.
-
-<args>...::
- Some argument not yet documented.
-
+<tag>::
+ SHA1 identifier of a git tag object.
Author
------
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.
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 <junkio@cox.net>
+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.
+
diff --git a/Makefile b/Makefile
index bc2f389..57d4f11 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 0c87797..f3cf358 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -4,6 +4,13 @@ git-core (0.99.6-0) unstable; urgency=low
-- Junio C Hamano <junkio@cox.net> Wed, 24 Aug 2005 23:09:35 -0700
+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 <junkio@cox.net> 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/
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
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' ' ')