Merge branch 'fp/make-j'
authorJunio C Hamano <junkio@cox.net>
Sat, 7 Apr 2007 09:20:47 +0000 (02:20 -0700)
committerJunio C Hamano <junkio@cox.net>
Sat, 7 Apr 2007 09:20:47 +0000 (02:20 -0700)
* fp/make-j:
Makefile: Add '+' to QUIET_SUBDIR0 to fix parallel make.

32 files changed:
Documentation/Makefile
Documentation/cmd-list.perl
Documentation/git-bisect.txt
Documentation/git-cvsimport.txt
Documentation/git-rev-list.txt
Documentation/user-manual.txt
Makefile
builtin-apply.c
builtin-archive.c
builtin-branch.c
builtin-rerere.c
builtin-rev-list.c
config.c
contrib/emacs/Makefile
contrib/hooks/post-receieve-email [deleted file]
contrib/hooks/post-receive-email [new file with mode: 0644]
git-bisect.sh
git-checkout.sh
git-cvsimport.perl
git-send-email.perl
git.c
gitweb/gitweb.perl
http-fetch.c
http-push.c
refs.c
t/t3200-branch.sh
t/t4120-apply-popt.sh [new file with mode: 0755]
t/t4200-rerere.sh
t/t5000-tar-tree.sh
t/t5300-pack-object.sh
t/t6030-bisect-run.sh
t/t7201-co.sh
index e82596dcdf0545d528806797c990e101d40f1436..a637d8d559b6a41505e5381b92d523e55f4b3be8 100644 (file)
@@ -90,14 +90,17 @@ cmds_txt = cmds-ancillaryinterrogators.txt \
        cmds-purehelpers.txt \
        cmds-foreignscminterface.txt
 
-$(cmds_txt): cmd-list.perl $(MAN1_TXT)
+$(cmds_txt): cmd-list.made
+
+cmd-list.made: cmd-list.perl $(MAN1_TXT)
        perl ./cmd-list.perl
+       date >$@
 
 git.7 git.html: git.txt core-intro.txt
 
 clean:
        rm -f *.xml *.xml+ *.html *.html+ *.1 *.7 howto-index.txt howto/*.html doc.dep
-       rm -f $(cmds_txt)
+       rm -f $(cmds_txt) *.made
 
 %.html : %.txt
        rm -f $@+ $@
index b54382b2bfdfc7926af8c4b0552f82235619f1c6..0381590d383c4fffbf04895be4c47e407dd94e80 100755 (executable)
@@ -1,8 +1,11 @@
-#
+#!/usr/bin/perl -w
+
+use File::Compare qw(compare);
 
 sub format_one {
        my ($out, $name) = @_;
        my ($state, $description);
+       $state = 0;
        open I, '<', "$name.txt" or die "No such file $name.txt";
        while (<I>) {
                if (/^NAME$/) {
@@ -55,7 +58,14 @@ sub format_one {
                format_one(\*O, $_);
        }
        close O;
-       rename "$out+", "$out";
+
+       if (-f "$out" && compare("$out", "$out+") == 0) {
+               unlink "$out+";
+       }
+       else {
+               print STDERR "$out\n";
+               rename "$out+", "$out";
+       }
 }
 
 __DATA__
index b2bc58d8513b0c064333d8b0aa357ebcea3ba28f..5f68ee1584b294a9395f2a3d4f29e0b1208f5913 100644 (file)
@@ -15,7 +15,7 @@ DESCRIPTION
 The command takes various subcommands, and different options depending
 on the subcommand:
 
- git bisect start [<paths>...]
+ git bisect start [<bad> [<good>...]] [--] [<paths>...]
  git bisect bad <rev>
  git bisect good <rev>
  git bisect reset [<branch>]
@@ -134,15 +134,26 @@ $ git reset --hard HEAD~3         # try 3 revs before what
 Then compile and test the one you chose to try. After that, tell
 bisect what the result was as usual.
 
-Cutting down bisection by giving path parameter to bisect start
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+Cutting down bisection by giving more parameters to bisect start
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
 You can further cut down the number of trials if you know what part of
 the tree is involved in the problem you are tracking down, by giving
 paths parameters when you say `bisect start`, like this:
 
 ------------
-$ git bisect start arch/i386 include/asm-i386
+$ git bisect start -- arch/i386 include/asm-i386
+------------
+
+If you know beforehand more than one good commits, you can narrow the
+bisect space down without doing the whole tree checkout every time you
+give good commits. You give the bad revision immediately after `start`
+and then you give all the good revisions you have:
+
+------------
+$ git bisect start v2.6.20-rc6 v2.6.20-rc4 v2.6.20-rc1 --
+                   # v2.6.20-rc6 is bad
+                   # v2.6.20-rc4 and v2.6.20-rc1 are good
 ------------
 
 Bisect run
index 0d59c061394777c9b4655e7096b8ea372971e360..e0be8565468c0b278147abc3e83eb7d19f481a40 100644 (file)
@@ -9,9 +9,11 @@ git-cvsimport - Salvage your data out of another SCM people love to hate
 SYNOPSIS
 --------
 [verse]
-'git-cvsimport' [-o <branch-for-HEAD>] [-h] [-v] [-d <CVSROOT>] [-s <subst>]
-             [-p <options-for-cvsps>] [-C <git_repository>] [-i] [-P <file>]
-             [-m] [-M regex] [<CVS_module>]
+'git-cvsimport' [-o <branch-for-HEAD>] [-h] [-v] [-d <CVSROOT>]
+             [-A <author-conv-file>] [-p <options-for-cvsps>] [-P <file>]
+             [-C <git_repository>] [-z <fuzz>] [-i] [-k] [-u] [-s <subst>]
+             [-a] [-m] [-M <regex>] [-S <regex>] [-L <commitlimit>]
+             [<CVS_module>]
 
 
 DESCRIPTION
@@ -30,35 +32,48 @@ any CVS branches, yourself.
 
 OPTIONS
 -------
+-v::
+       Verbosity: let 'cvsimport' report what it is doing.
+
 -d <CVSROOT>::
        The root of the CVS archive. May be local (a simple path) or remote;
        currently, only the :local:, :ext: and :pserver: access methods 
-       are supported.
+       are supported. If not given, git-cvsimport will try to read it
+       from `CVS/Root`. If no such file exists, it checks for the
+       `CVSROOT` environment variable.
+
+<CVS_module>::
+       The CVS module you want to import. Relative to <CVSROOT>.
+       If not given, git-cvsimport tries to read it from
+       `CVS/Repository`.
 
 -C <target-dir>::
         The git repository to import to.  If the directory doesn't
         exist, it will be created.  Default is the current directory.
 
+-o <branch-for-HEAD>::
+       The 'HEAD' branch from CVS is imported to the 'origin' branch within
+       the git repository, as 'HEAD' already has a special meaning for git.
+       Use this option if you want to import into a different branch.
++
+Use '-o master' for continuing an import that was initially done by
+the old cvs2git tool.
+
 -i::
        Import-only: don't perform a checkout after importing.  This option
        ensures the working directory and index remain untouched and will
        not create them if they do not exist.
 
 -k::
-       Kill keywords: will extract files with -kk from the CVS archive
+       Kill keywords: will extract files with '-kk' from the CVS archive
        to avoid noisy changesets. Highly recommended, but off by default
        to preserve compatibility with early imported trees. 
 
 -u::
        Convert underscores in tag and branch names to dots.
 
--o <branch-for-HEAD>::
-       The 'HEAD' branch from CVS is imported to the 'origin' branch within
-       the git repository, as 'HEAD' already has a special meaning for git.
-       Use this option if you want to import into a different branch.
-+
-Use '-o master' for continuing an import that was initially done by
-the old cvs2git tool.
+-s <subst>::
+       Substitute the character "/" in branch names with <subst>
 
 -p <options-for-cvsps>::
        Additional options for cvsps.
@@ -66,6 +81,10 @@ the old cvs2git tool.
 +
 If you need to pass multiple options, separate them with a comma.
 
+-z <fuzz>::
+       Pass the timestamp fuzz factor to cvsps, in seconds. If unset,
+       cvsps defaults to 300s.
+
 -P <cvsps-output-file>::
        Instead of calling cvsps, read the provided cvsps output file. Useful
        for debugging or when cvsps is being handled outside cvsimport.
@@ -77,32 +96,16 @@ If you need to pass multiple options, separate them with a comma.
 
 -M <regex>::
        Attempt to detect merges based on the commit message with a custom
-       regex. It can be used with -m to also see the default regexes. 
+       regex. It can be used with '-m' to also see the default regexes.
        You must escape forward slashes. 
 
--v::
-       Verbosity: let 'cvsimport' report what it is doing.
-
-<CVS_module>::
-       The CVS module you want to import. Relative to <CVSROOT>.
-
--h::
-       Print a short usage message and exit.
-
--z <fuzz>::
-       Pass the timestamp fuzz factor to cvsps, in seconds. If unset,
-       cvsps defaults to 300s.
-
--s <subst>::
-       Substitute the character "/" in branch names with <subst>
+-S <regex>::
+       Skip paths matching the regex.
 
 -a::
        Import all commits, including recent ones. cvsimport by default
        skips commits that have a timestamp less than 10 minutes ago.
 
--S <regex>::
-       Skip paths matching the regex.
-
 -L <limit>::
        Limit the number of commits imported. Workaround for cases where
        cvsimport leaks memory.
@@ -122,14 +125,17 @@ git-cvsimport will make it appear as those authors had
 their GIT_AUTHOR_NAME and GIT_AUTHOR_EMAIL set properly
 all along.
 +
-For convenience, this data is saved to $GIT_DIR/cvs-authors
-each time the -A option is provided and read from that same
+For convenience, this data is saved to `$GIT_DIR/cvs-authors`
+each time the '-A' option is provided and read from that same
 file each time git-cvsimport is run.
 +
 It is not recommended to use this feature if you intend to
 export changes back to CVS again later with
 gitlink:git-cvsexportcommit[1].
 
+-h::
+       Print a short usage message and exit.
+
 OUTPUT
 ------
 If '-v' is specified, the script reports what it is doing.
index 3fa45b81cc6de7b5104d343538c9ad040c208ce1..12b71ed0bbae2516cb67c98c96a56e6278a6f5c2 100644 (file)
@@ -21,6 +21,7 @@ SYNOPSIS
             [ \--stdin ]
             [ \--topo-order ]
             [ \--parents ]
+            [ \--left-right ]
             [ \--encoding[=<encoding>] ]
             [ \--(author|committer|grep)=<pattern> ]
             [ [\--objects | \--objects-edge] [ \--unpacked ] ]
@@ -101,6 +102,36 @@ include::pretty-formats.txt[]
 
        Print the parents of the commit.
 
+--left-right::
+
+       Mark which side of a symmetric diff a commit is reachable from.
+       Commits from the left side are prefixed with `<` and those from
+       the right with `>`.  If combined with `--boundary`, those
+       commits are prefixed with `-`.
++
+For example, if you have this topology:
++
+-----------------------------------------------------------------------
+             y---b---b  branch B
+            / \ /
+           /   .
+          /   / \
+         o---x---a---a  branch A
+-----------------------------------------------------------------------
++
+you would get an output line this:
++
+-----------------------------------------------------------------------
+       $ git rev-list --left-right --boundary --pretty=oneline A...B
+
+       >bbbbbbb... 3rd on b
+       >bbbbbbb... 2nd on b
+       <aaaaaaa... 3rd on a
+       <aaaaaaa... 2nd on a
+       -yyyyyyy... 1st on b
+       -xxxxxxx... 1st on a
+-----------------------------------------------------------------------
+
 Diff Formatting
 ~~~~~~~~~~~~~~~
 
index 574e9c0e50d324ead7262e1f6b3bde72d5969350..d43d2377ec51e88116dbfed90bb1064d8fed05a1 100644 (file)
@@ -1015,7 +1015,7 @@ $ git commit
 -------------------------------------------------
 
 [[how-to-make-a-commit]]
-how to make a commit
+How to make a commit
 --------------------
 
 Creating a new commit takes three steps:
@@ -1109,7 +1109,7 @@ $ git diff            # difference between the index file and your
 $ git status       # a brief per-file summary of the above.
 -------------------------------------------------
 
-creating good commit messages
+Creating good commit messages
 -----------------------------
 
 Though not required, it's a good idea to begin the commit message
@@ -1119,7 +1119,7 @@ description.  Tools that turn commits into email, for example, use
 the first line on the Subject line and the rest of the commit in the
 body.
 
-how to merge
+How to merge
 ------------
 
 You can rejoin two diverging branches of development using
@@ -1298,7 +1298,7 @@ the different stages of that file will be "collapsed", after which
 git-diff will (by default) no longer show diffs for that file.
 
 [[undoing-a-merge]]
-undoing a merge
+Undoing a merge
 ---------------
 
 If you get stuck and decide to just give up and throw the whole mess
index c9a84aa25a6ebf7aaad133e6cafe4c2186e1db01..ac29c629e3927ad59142cf73d03eea501fc30962 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -385,6 +385,7 @@ endif
 ifeq ($(uname_S),Darwin)
        NEEDS_SSL_WITH_CRYPTO = YesPlease
        NEEDS_LIBICONV = YesPlease
+       OLD_ICONV = UnfortunatelyYes
        NO_STRLCPY = YesPlease
 endif
 ifeq ($(uname_S),SunOS)
@@ -727,7 +728,7 @@ help.o: common-cmds.h
 $(BUILT_INS): git$X
        $(QUIET_BUILT_IN)rm -f $@ && ln git$X $@
 
-common-cmds.h: Documentation/git-*.txt
+common-cmds.h: $(wildcard Documentation/git-*.txt)
        $(QUIET_GEN)./generate-cmdlist.sh > $@+ && mv $@+ $@
 
 $(patsubst %.sh,%,$(SCRIPT_SH)) : % : %.sh
index 6a8292e2a5448389fbe76d9d899cb1d066e2a996..4b8311b4de3f5c5d93352dac62856d67acfb143f 100644 (file)
@@ -417,7 +417,7 @@ static int gitdiff_hdrend(const char *line, struct patch *patch)
 static char *gitdiff_verify_name(const char *line, int isnull, char *orig_name, const char *oldnew)
 {
        if (!orig_name && !isnull)
-               return find_name(line, NULL, 1, TERM_TAB);
+               return find_name(line, NULL, p_value, TERM_TAB);
 
        if (orig_name) {
                int len;
@@ -427,7 +427,7 @@ static char *gitdiff_verify_name(const char *line, int isnull, char *orig_name,
                len = strlen(name);
                if (isnull)
                        die("git-apply: bad git-diff - expected /dev/null, got %s on line %d", name, linenr);
-               another = find_name(line, NULL, 1, TERM_TAB);
+               another = find_name(line, NULL, p_value, TERM_TAB);
                if (!another || memcmp(another, name, len))
                        die("git-apply: bad git-diff - inconsistent %s filename on line %d", oldnew, linenr);
                free(another);
index 2fae885f5c27f73820824b612d41fd37ab91239d..8ea6cb1efc4f988fb09051852f9e51fc88b5efd7 100644 (file)
@@ -252,6 +252,8 @@ int cmd_archive(int argc, const char **argv, const char *prefix)
 
        memset(&ar, 0, sizeof(ar));
        tree_idx = parse_archive_args(argc, argv, &ar);
+       if (prefix == NULL)
+               prefix = setup_git_directory();
 
        argv += tree_idx;
        parse_treeish_arg(argv, &ar.args, prefix);
index a4494ee337d70a400664e529e84f90d475a03b92..7408285050a0f41a33d31c73e79c2fdefe567593 100644 (file)
@@ -493,6 +493,7 @@ static void rename_branch(const char *oldname, const char *newname, int force)
 {
        char oldref[PATH_MAX], newref[PATH_MAX], logmsg[PATH_MAX*2 + 100];
        unsigned char sha1[20];
+       char oldsection[PATH_MAX], newsection[PATH_MAX];
 
        if (!oldname)
                die("cannot rename the current branch while not on any.");
@@ -521,6 +522,11 @@ static void rename_branch(const char *oldname, const char *newname, int force)
        /* no need to pass logmsg here as HEAD didn't really move */
        if (!strcmp(oldname, head) && create_symref("HEAD", newref, NULL))
                die("Branch renamed to %s, but HEAD is not updated!", newname);
+
+       snprintf(oldsection, sizeof(oldsection), "branch.%s", oldref + 11);
+       snprintf(newsection, sizeof(newsection), "branch.%s", newref + 11);
+       if (git_config_rename_section(oldsection, newsection) < 0)
+               die("Branch is renamed, but update of config-file failed");
 }
 
 int cmd_branch(int argc, const char **argv, const char *prefix)
index b463c07f04b127ee3d1e17962813367fb4a5a588..8c2c8bdc18a69e4dff7386548e5f7ea78a133f7b 100644 (file)
@@ -117,10 +117,13 @@ static int handle_file(const char *path,
                else if (!prefixcmp(buf, "======="))
                        hunk = 2;
                else if (!prefixcmp(buf, ">>>>>>> ")) {
+                       int one_is_longer = (one->nr > two->nr);
+                       int common_len = one_is_longer ? two->nr : one->nr;
+                       int cmp = memcmp(one->ptr, two->ptr, common_len);
+
                        hunk_no++;
                        hunk = 0;
-                       if (memcmp(one->ptr, two->ptr, one->nr < two->nr ?
-                                               one->nr : two->nr) > 0) {
+                       if ((cmp > 0) || ((cmp == 0) && one_is_longer)) {
                                struct buffer *swap = one;
                                one = two;
                                two = swap;
index f91685a4067630b49e6d9235f29ab8f8060faf66..09774f9559b81050d89bd6663b8b672438da4342 100644 (file)
@@ -35,6 +35,7 @@ static const char rev_list_usage[] =
 "    --header | --pretty\n"
 "    --abbrev=nr | --no-abbrev\n"
 "    --abbrev-commit\n"
+"    --left-right\n"
 "  special purpose:\n"
 "    --bisect\n"
 "    --bisect-vars"
index 6479855723d6dc94fa7c440868724a794bb59901..70d105567921fe75518d8d5fe3d3df4aad0659cd 100644 (file)
--- a/config.c
+++ b/config.c
@@ -916,8 +916,8 @@ int git_config_rename_section(const char *old_name, const char *new_name)
        }
 
        if (!(config_file = fopen(config_filename, "rb"))) {
-               ret = error("Could not open config file!");
-               goto out;
+               /* no config file means nothing to rename, no error */
+               goto unlock_and_out;
        }
 
        while (fgets(buf, sizeof(buf), config_file)) {
@@ -951,6 +951,7 @@ int git_config_rename_section(const char *old_name, const char *new_name)
                }
        }
        fclose(config_file);
+ unlock_and_out:
        if (close(out_fd) || commit_lock_file(lock) < 0)
                        ret = error("Cannot commit config file!");
  out:
index 8554e3967cc692c6916e5aee35952074d07e8bf0..98aa0aae9b2e9e4a758fa58e7dd1e1adc3214883 100644 (file)
@@ -11,8 +11,8 @@ emacsdir = $(prefix)/share/emacs/site-lisp
 all: $(ELC)
 
 install: all
-       $(INSTALL) -d $(emacsdir)
-       $(INSTALL_ELC) $(ELC) $(emacsdir)
+       $(INSTALL) -d $(DESTDIR)$(emacsdir)
+       $(INSTALL_ELC) $(ELC) $(DESTDIR)$(emacsdir)
 
 %.elc: %.el
        $(EMACS) -batch -f batch-byte-compile $<
diff --git a/contrib/hooks/post-receieve-email b/contrib/hooks/post-receieve-email
deleted file mode 100644 (file)
index 6516015..0000000
+++ /dev/null
@@ -1,588 +0,0 @@
-#!/bin/sh
-#
-# Copyright (c) 2007 Andy Parkins
-#
-# An example hook script to mail out commit update information.  This hook sends emails
-# listing new revisions to the repository introduced by the change being reported.  The
-# rule is that (for branch updates) each commit will appear on one email and one email
-# only.
-#
-# This hook is stored in the contrib/hooks directory.  Your distribution will have put
-# this somewhere standard.  You should make this script executable then link to it in
-# the repository you would like to use it in.  For example, on debian the hook is stored
-# in /usr/share/doc/git-core/contrib/hooks/post-receive-email:
-#
-#  chmod a+x post-receive-email
-#  cd /path/to/your/repository.git
-#  ln -sf /usr/share/doc/git-core/contrib/hooks/post-receive-email hooks/post-receive
-#
-# This hook script assumes it is enabled on the central repository of a project, with
-# all users pushing only to it and not between each other.  It will still work if you
-# don't operate in that style, but it would become possible for the email to be from
-# someone other than the person doing the push.
-#
-# Config
-# ------
-# hooks.mailinglist
-#   This is the list that all pushes will go to; leave it blank to not send
-#   emails for every ref update.
-# hooks.announcelist
-#   This is the list that all pushes of annotated tags will go to.  Leave it
-#   blank to default to the mailinglist field.  The announce emails lists the
-#   short log summary of the changes since the last annotated tag.
-# hook.envelopesender
-#   If set then the -f option is passed to sendmail to allow the envelope sender
-#   address to be set
-#
-# Notes
-# -----
-# All emails have their subjects prefixed with "[SCM]" to aid filtering.
-# All emails include the headers "X-Git-Refname", "X-Git-Oldrev",
-# "X-Git-Newrev", and "X-Git-Reftype" to enable fine tuned filtering and
-# give information for debugging.
-#
-
-# ---------------------------- Functions
-
-#
-# Top level email generation function.  This decides what type of update
-# this is and calls the appropriate body-generation routine after outputting
-# the common header
-#
-# Note this function doesn't actually generate any email output, that is taken
-# care of by the functions it calls:
-#  - generate_email_header
-#  - generate_create_XXXX_email
-#  - generate_update_XXXX_email
-#  - generate_delete_XXXX_email
-#  - generate_email_footer
-#
-generate_email()
-{
-       # --- Arguments
-       oldrev=$(git rev-parse $1)
-       newrev=$(git rev-parse $2)
-       refname="$3"
-
-       # --- Interpret
-       # 0000->1234 (create)
-       # 1234->2345 (update)
-       # 2345->0000 (delete)
-       if expr "$oldrev" : '0*$' >/dev/null
-       then
-               change_type="create"
-       else
-               if expr "$newrev" : '0*$' >/dev/null
-               then
-                       change_type="delete"
-               else
-                       change_type="update"
-               fi
-       fi
-
-       # --- Get the revision types
-       newrev_type=$(git cat-file -t $newrev 2> /dev/null)
-       oldrev_type=$(git cat-file -t "$oldrev" 2> /dev/null)
-       case "$change_type" in
-       create|update)
-               rev="$newrev"
-               rev_type="$newrev_type"
-               ;;
-       delete)
-               rev="$oldrev"
-               rev_type="$oldrev_type"
-               ;;
-       esac
-
-       # The revision type tells us what type the commit is, combined with
-       # the location of the ref we can decide between
-       #  - working branch
-       #  - tracking branch
-       #  - unannoted tag
-       #  - annotated tag
-       case "$refname","$rev_type" in
-               refs/tags/*,commit)
-                       # un-annotated tag
-                       refname_type="tag"
-                       short_refname=${refname##refs/tags/}
-                       ;;
-               refs/tags/*,tag)
-                       # annotated tag
-                       refname_type="annotated tag"
-                       short_refname=${refname##refs/tags/}
-                       # change recipients
-                       if [ -n "$announcerecipients" ]; then
-                               recipients="$announcerecipients"
-                       fi
-                       ;;
-               refs/heads/*,commit)
-                       # branch
-                       refname_type="branch"
-                       short_refname=${refname##refs/heads/}
-                       ;;
-               refs/remotes/*,commit)
-                       # tracking branch
-                       refname_type="tracking branch"
-                       short_refname=${refname##refs/remotes/}
-                       echo >&2 "*** Push-update of tracking branch, $refname"
-                       echo >&2 "***  - no email generated."
-                       exit 0
-                       ;;
-               *)
-                       # Anything else (is there anything else?)
-                       echo >&2 "*** Unknown type of update to $refname ($rev_type)"
-                       echo >&2 "***  - no email generated"
-                       exit 1
-                       ;;
-       esac
-
-       # Check if we've got anyone to send to
-       if [ -z "$recipients" ]; then
-               echo >&2 "*** hooks.recipients is not set so no email will be sent"
-               echo >&2 "*** for $refname update $oldrev->$newrev"
-               exit 0
-       fi
-
-       # Email parameters
-       # The committer will be obtained from the latest existing rev; so
-       # for a deletion it will be the oldrev, for the others, then newrev
-       committer=$(git show --pretty=full -s $rev | sed -ne "s/^Commit: //p" |
-               sed -ne 's/\(.*\) </"\1" </p')
-       # The email subject will contain the best description of the ref
-       # that we can build from the parameters
-       describe=$(git describe $rev 2>/dev/null)
-       if [ -z "$describe" ]; then
-               describe=$rev
-       fi
-
-       generate_email_header
-
-       # Call the correct body generation function
-       fn_name=general
-       case "$refname_type" in
-       "tracking branch"|branch)
-               fn_name=branch
-               ;;
-       "annotated tag")
-               fn_name=atag
-               ;;
-       esac
-       generate_${change_type}_${fn_name}_email
-
-       generate_email_footer
-}
-
-generate_email_header()
-{
-       # --- Email (all stdout will be the email)
-       # Generate header
-       cat <<-EOF
-       From: $committer
-       To: $recipients
-       Subject: ${EMAILPREFIX}$projectdesc $refname_type, $short_refname, ${change_type}d. $describe
-       X-Git-Refname: $refname
-       X-Git-Reftype: $refname_type
-       X-Git-Oldrev: $oldrev
-       X-Git-Newrev: $newrev
-
-       This is an automated email from the git hooks/post-receive script. It was
-       generated because a ref change was pushed to the repository containing
-       the project "$projectdesc".
-
-       The $refname_type, $short_refname has been ${change_type}d
-       EOF
-}
-
-generate_email_footer()
-{
-       cat <<-EOF
-
-
-       hooks/post-receive
-       -- 
-       $projectdesc
-       EOF
-}
-
-# --------------- Branches
-
-#
-# Called for the creation of a branch
-#
-generate_create_branch_email()
-{
-       # This is a new branch and so oldrev is not valid
-       echo "        at  $newrev ($newrev_type)"
-       echo ""
-
-       echo $LOGBEGIN
-       # This shows all log entries that are not already covered by
-       # another ref - i.e. commits that are now accessible from this
-       # ref that were previously not accessible (see generate_update_branch_email
-       # for the explanation of this command)
-       git rev-parse --not --branches | grep -v $(git rev-parse $refname) |
-       git rev-list --pretty --stdin $newrev
-       echo $LOGEND
-}
-
-#
-# Called for the change of a pre-existing branch
-#
-generate_update_branch_email()
-{
-       # Consider this:
-       #   1 --- 2 --- O --- X --- 3 --- 4 --- N
-       #
-       # O is $oldrev for $refname
-       # N is $newrev for $refname
-       # X is a revision pointed to by some other ref, for which we may
-       #   assume that an email has already been generated.
-       # In this case we want to issue an email containing only revisions
-       # 3, 4, and N.  Given (almost) by
-       #
-       #  git-rev-list N ^O --not --all
-       #
-       # The reason for the "almost", is that the "--not --all" will take
-       # precedence over the "N", and effectively will translate to
-       #
-       #  git-rev-list N ^O ^X ^N
-       #
-       # So, we need to build up the list more carefully.  git-rev-parse will
-       # generate a list of revs that may be fed into git-rev-list.  We can get
-       # it to make the "--not --all" part and then filter out the "^N" with:
-       #
-       #  git-rev-parse --not --all | grep -v N
-       #
-       # Then, using the --stdin switch to git-rev-list we have effectively
-       # manufactured
-       #
-       #  git-rev-list N ^O ^X
-       #
-       # This leaves a problem when someone else updates the repository
-       # while this script is running.  Their new value of the ref we're working
-       # on would be included in the "--not --all" output; and as our $newrev
-       # would be an ancestor of that commit, it would exclude all of our
-       # commits.  What we really want is to exclude the current value of
-       # $refname from the --not list, rather than N itself.  So:
-       #
-       #  git-rev-parse --not --all | grep -v $(git-rev-parse $refname)
-       #
-       # Get's us to something pretty safe (apart from the small time between
-       # refname being read, and git-rev-parse running - for that, I give up)
-       #
-       #
-       # Next problem, consider this:
-       #   * --- B --- * --- O ($oldrev)
-       #          \
-       #           * --- X --- * --- N ($newrev)
-       #
-       # That is to say, there is no guarantee that oldrev is a strict subset of
-       # newrev (it would have required a --force, but that's allowed).  So, we
-       # can't simply say rev-list $oldrev..$newrev.  Instead we find the common
-       # base of the two revs and list from there.
-       #
-       # As above, we need to take into account the presence of X; if another
-       # branch is already in the repository and points at some of the revisions
-       # that we are about to output - we don't want them.  The solution is as
-       # before: git-rev-parse output filtered.
-       #
-       # Finally, tags:
-       #   1 --- 2 --- O --- T --- 3 --- 4 --- N
-       #
-       # Tags pushed into the repository generate nice shortlog emails that
-       # summarise the commits between them and the previous tag.  However,
-       # those emails don't include the full commit messages that we output
-       # for a branch update.  Therefore we still want to output revisions
-       # that have been output on a tag email.
-       #
-       # Luckily, git-rev-parse includes just the tool.  Instead of using "--all"
-       # we use "--branches"; this has the added benefit that "remotes/" will
-       # be ignored as well.
-
-       # List all of the revisions that were removed by this update, in a fast forward
-       # update, this list will be empty, because rev-list O ^N is empty.  For a non
-       # fast forward, O ^N is the list of removed revisions
-       fastforward=""
-       rev=""
-       for rev in $(git rev-list $newrev..$oldrev)
-       do
-               revtype=$(git cat-file -t "$rev")
-               echo "  discards  $rev ($revtype)"
-       done
-       if [ -z "$rev" ]; then
-               fast_forward=1
-       fi
-
-       # List all the revisions from baserev to newrev in a kind of
-       # "table-of-contents"; note this list can include revisions that have
-       # already had notification emails and is present to show the full detail
-       # of the change from rolling back the old revision to the base revision and
-       # then forward to the new revision
-       for rev in $(git rev-list $oldrev..$newrev)
-       do
-               revtype=$(git cat-file -t "$rev")
-               echo "       via  $rev ($revtype)"
-       done
-
-       if [ -z "$fastforward" ]; then
-               echo "      from  $oldrev ($oldrev_type)"
-       else
-               echo ""
-               echo "This update added new revisions after undoing old revisions.  That is to"
-               echo "say, the old revision is not a strict subset of the new revision.  This"
-               echo "situation occurs when you --force push a change and generate a"
-               echo "repository containing something like this:"
-               echo ""
-               echo " * -- * -- B -- O -- O -- O ($oldrev)"
-               echo "            \\"
-               echo "             N -- N -- N ($newrev)"
-               echo ""
-               echo "When this happens we assume that you've already had alert emails for all"
-               echo "of the O revisions, and so we here report only the revisions in the N"
-               echo "branch from the common base, B."
-       fi
-
-       echo ""
-       echo "Those revisions listed above that are new to this repository have"
-       echo "not appeared on any other notification email; so we list those"
-       echo "revisions in full, below."
-
-       echo ""
-       echo $LOGBEGIN
-       git rev-parse --not --branches | grep -v $(git rev-parse $refname) |
-       git rev-list --pretty --stdin $oldrev..$newrev
-
-       # XXX: Need a way of detecting whether git rev-list actually outputted
-       # anything, so that we can issue a "no new revisions added by this
-       # update" message
-
-       echo $LOGEND
-
-       # The diffstat is shown from the old revision to the new revision.  This
-       # is to show the truth of what happened in this change.  There's no point
-       # showing the stat from the base to the new revision because the base
-       # is effectively a random revision at this point - the user will be
-       # interested in what this revision changed - including the undoing of
-       # previous revisions in the case of non-fast forward updates.
-       echo ""
-       echo "Summary of changes:"
-       git diff-tree --stat --summary --find-copies-harder $oldrev..$newrev
-}
-
-#
-# Called for the deletion of a branch
-#
-generate_delete_branch_email()
-{
-       echo "       was  $oldrev"
-       echo ""
-       echo $LOGEND
-       git show -s --pretty=oneline $oldrev
-       echo $LOGEND
-}
-
-# --------------- Annotated tags
-
-#
-# Called for the creation of an annotated tag
-#
-generate_create_atag_email()
-{
-       echo "        at  $newrev ($newrev_type)"
-
-       generate_atag_email
-}
-
-#
-# Called for the update of an annotated tag (this is probably a rare event
-# and may not even be allowed)
-#
-generate_update_atag_email()
-{
-       echo "        to  $newrev ($newrev_type)"
-       echo "      from  $oldrev (which is now obsolete)"
-
-       generate_atag_email
-}
-
-#
-# Called when an annotated tag is created or changed
-#
-generate_atag_email()
-{
-       # Use git-for-each-ref to pull out the individual fields from the tag
-       eval $(git for-each-ref --shell --format='
-       tagobject=%(*objectname)
-       tagtype=%(*objecttype)
-       tagger=%(taggername)
-       tagged=%(taggerdate)' $refname
-       )
-
-       echo "   tagging  $tagobject ($tagtype)"
-       case "$tagtype" in
-       commit)
-               # If the tagged object is a commit, then we assume this is a
-               # release, and so we calculate which tag this tag is replacing
-               prevtag=$(git describe --abbrev=0 $newrev^ 2>/dev/null)
-
-               if [ -n "$prevtag" ]; then
-                       echo "  replaces  $prevtag"
-               fi
-               ;;
-       *)
-               echo "    length  $(git cat-file -s $tagobject) bytes"
-               ;;
-       esac
-       echo " tagged by  $tagger"
-       echo "        on  $tagged"
-
-       echo ""
-       echo $LOGBEGIN
-
-       # Show the content of the tag message; this might contain a change log
-       # or release notes so is worth displaying.
-       git cat-file tag $newrev | sed -e '1,/^$/d'
-
-       echo ""
-       case "$tagtype" in
-       commit)
-               # Only commit tags make sense to have rev-list operations performed
-               # on them
-               if [ -n "$prevtag" ]; then
-                       # Show changes since the previous release
-                       git rev-list --pretty=short "$prevtag..$newrev" | git shortlog
-               else
-                       # No previous tag, show all the changes since time began
-                       git rev-list --pretty=short $newrev | git shortlog
-               fi
-               ;;
-       *)
-               # XXX: Is there anything useful we can do for non-commit objects?
-               ;;
-       esac
-
-       echo $LOGEND
-}
-
-#
-# Called for the deletion of an annotated tag
-#
-generate_delete_atag_email()
-{
-       echo "       was  $oldrev"
-       echo ""
-       echo $LOGEND
-       git show -s --pretty=oneline $oldrev
-       echo $LOGEND
-}
-
-# --------------- General references
-
-#
-# Called when any other type of reference is created (most likely a
-# non-annotated tag)
-#
-generate_create_general_email()
-{
-       echo "        at  $newrev ($newrev_type)"
-
-       generate_general_email
-}
-
-#
-# Called when any other type of reference is updated (most likely a
-# non-annotated tag)
-#
-generate_update_general_email()
-{
-       echo "        to  $newrev ($newrev_type)"
-       echo "      from  $oldrev"
-
-       generate_general_email
-}
-
-#
-# Called for creation or update of any other type of reference
-#
-generate_general_email()
-{
-       # Unannotated tags are more about marking a point than releasing a version;
-       # therefore we don't do the shortlog summary that we do for annotated tags
-       # above - we simply show that the point has been marked, and print the log
-       # message for the marked point for reference purposes
-       #
-       # Note this section also catches any other reference type (although there
-       # aren't any) and deals with them in the same way.
-
-       echo ""
-       if [ "$newrev_type" = "commit" ]; then
-               echo $LOGBEGIN
-               git show --no-color --root -s $newrev
-               echo $LOGEND
-       else
-               # What can we do here?  The tag marks an object that is not a commit,
-               # so there is no log for us to display.  It's probably not wise to
-               # output git-cat-file as it could be a binary blob.  We'll just say how
-               # big it is
-               echo "$newrev is a $newrev_type, and is $(git cat-file -s $newrev) bytes long."
-       fi
-}
-
-#
-# Called for the deletion of any other type of reference
-#
-generate_delete_general_email()
-{
-       echo "       was  $oldrev"
-       echo ""
-       echo $LOGEND
-       git show -s --pretty=oneline $oldrev
-       echo $LOGEND
-}
-
-# ---------------------------- main()
-
-# --- Constants
-EMAILPREFIX="[SCM] "
-LOGBEGIN="- Log -----------------------------------------------------------------"
-LOGEND="-----------------------------------------------------------------------"
-
-# --- Config
-# Set GIT_DIR either from the working directory, or from the environment
-# variable.
-GIT_DIR=$(git rev-parse --git-dir 2>/dev/null)
-if [ -z "$GIT_DIR" ]; then
-       echo >&2 "fatal: post-receive: GIT_DIR not set"
-       exit 1
-fi
-
-projectdesc=$(sed -e '1p' "$GIT_DIR/description")
-# Check if the description is unchanged from it's default, and shorten it to a
-# more manageable length if it is
-if expr "$projectdesc" : "Unnamed repository.*$" >/dev/null
-then
-       projectdesc="UNNAMED PROJECT"
-fi
-
-recipients=$(git repo-config hooks.mailinglist)
-announcerecipients=$(git repo-config hooks.announcelist)
-envelopesender=$(git-repo-config hooks.envelopesender)
-
-# --- Main loop
-# Allow dual mode: run from the command line just like the update hook, or if
-# no arguments are given then run as a hook script
-if [ -n "$1" -a -n "$2" -a -n "$3" ]; then
-       # Output to the terminal in command line mode - if someone wanted to
-       # resend an email; they could redirect the output to sendmail themselves
-       PAGER= generate_email $2 $3 $1
-else
-       if [ -n "$envelopesender" ]; then
-               envelopesender="-f '$envelopesender'"
-       fi
-
-       while read oldrev newrev refname
-       do
-               generate_email $oldrev $newrev $refname |
-               /usr/sbin/sendmail -t $envelopesender
-       done
-fi
diff --git a/contrib/hooks/post-receive-email b/contrib/hooks/post-receive-email
new file mode 100644 (file)
index 0000000..6516015
--- /dev/null
@@ -0,0 +1,588 @@
+#!/bin/sh
+#
+# Copyright (c) 2007 Andy Parkins
+#
+# An example hook script to mail out commit update information.  This hook sends emails
+# listing new revisions to the repository introduced by the change being reported.  The
+# rule is that (for branch updates) each commit will appear on one email and one email
+# only.
+#
+# This hook is stored in the contrib/hooks directory.  Your distribution will have put
+# this somewhere standard.  You should make this script executable then link to it in
+# the repository you would like to use it in.  For example, on debian the hook is stored
+# in /usr/share/doc/git-core/contrib/hooks/post-receive-email:
+#
+#  chmod a+x post-receive-email
+#  cd /path/to/your/repository.git
+#  ln -sf /usr/share/doc/git-core/contrib/hooks/post-receive-email hooks/post-receive
+#
+# This hook script assumes it is enabled on the central repository of a project, with
+# all users pushing only to it and not between each other.  It will still work if you
+# don't operate in that style, but it would become possible for the email to be from
+# someone other than the person doing the push.
+#
+# Config
+# ------
+# hooks.mailinglist
+#   This is the list that all pushes will go to; leave it blank to not send
+#   emails for every ref update.
+# hooks.announcelist
+#   This is the list that all pushes of annotated tags will go to.  Leave it
+#   blank to default to the mailinglist field.  The announce emails lists the
+#   short log summary of the changes since the last annotated tag.
+# hook.envelopesender
+#   If set then the -f option is passed to sendmail to allow the envelope sender
+#   address to be set
+#
+# Notes
+# -----
+# All emails have their subjects prefixed with "[SCM]" to aid filtering.
+# All emails include the headers "X-Git-Refname", "X-Git-Oldrev",
+# "X-Git-Newrev", and "X-Git-Reftype" to enable fine tuned filtering and
+# give information for debugging.
+#
+
+# ---------------------------- Functions
+
+#
+# Top level email generation function.  This decides what type of update
+# this is and calls the appropriate body-generation routine after outputting
+# the common header
+#
+# Note this function doesn't actually generate any email output, that is taken
+# care of by the functions it calls:
+#  - generate_email_header
+#  - generate_create_XXXX_email
+#  - generate_update_XXXX_email
+#  - generate_delete_XXXX_email
+#  - generate_email_footer
+#
+generate_email()
+{
+       # --- Arguments
+       oldrev=$(git rev-parse $1)
+       newrev=$(git rev-parse $2)
+       refname="$3"
+
+       # --- Interpret
+       # 0000->1234 (create)
+       # 1234->2345 (update)
+       # 2345->0000 (delete)
+       if expr "$oldrev" : '0*$' >/dev/null
+       then
+               change_type="create"
+       else
+               if expr "$newrev" : '0*$' >/dev/null
+               then
+                       change_type="delete"
+               else
+                       change_type="update"
+               fi
+       fi
+
+       # --- Get the revision types
+       newrev_type=$(git cat-file -t $newrev 2> /dev/null)
+       oldrev_type=$(git cat-file -t "$oldrev" 2> /dev/null)
+       case "$change_type" in
+       create|update)
+               rev="$newrev"
+               rev_type="$newrev_type"
+               ;;
+       delete)
+               rev="$oldrev"
+               rev_type="$oldrev_type"
+               ;;
+       esac
+
+       # The revision type tells us what type the commit is, combined with
+       # the location of the ref we can decide between
+       #  - working branch
+       #  - tracking branch
+       #  - unannoted tag
+       #  - annotated tag
+       case "$refname","$rev_type" in
+               refs/tags/*,commit)
+                       # un-annotated tag
+                       refname_type="tag"
+                       short_refname=${refname##refs/tags/}
+                       ;;
+               refs/tags/*,tag)
+                       # annotated tag
+                       refname_type="annotated tag"
+                       short_refname=${refname##refs/tags/}
+                       # change recipients
+                       if [ -n "$announcerecipients" ]; then
+                               recipients="$announcerecipients"
+                       fi
+                       ;;
+               refs/heads/*,commit)
+                       # branch
+                       refname_type="branch"
+                       short_refname=${refname##refs/heads/}
+                       ;;
+               refs/remotes/*,commit)
+                       # tracking branch
+                       refname_type="tracking branch"
+                       short_refname=${refname##refs/remotes/}
+                       echo >&2 "*** Push-update of tracking branch, $refname"
+                       echo >&2 "***  - no email generated."
+                       exit 0
+                       ;;
+               *)
+                       # Anything else (is there anything else?)
+                       echo >&2 "*** Unknown type of update to $refname ($rev_type)"
+                       echo >&2 "***  - no email generated"
+                       exit 1
+                       ;;
+       esac
+
+       # Check if we've got anyone to send to
+       if [ -z "$recipients" ]; then
+               echo >&2 "*** hooks.recipients is not set so no email will be sent"
+               echo >&2 "*** for $refname update $oldrev->$newrev"
+               exit 0
+       fi
+
+       # Email parameters
+       # The committer will be obtained from the latest existing rev; so
+       # for a deletion it will be the oldrev, for the others, then newrev
+       committer=$(git show --pretty=full -s $rev | sed -ne "s/^Commit: //p" |
+               sed -ne 's/\(.*\) </"\1" </p')
+       # The email subject will contain the best description of the ref
+       # that we can build from the parameters
+       describe=$(git describe $rev 2>/dev/null)
+       if [ -z "$describe" ]; then
+               describe=$rev
+       fi
+
+       generate_email_header
+
+       # Call the correct body generation function
+       fn_name=general
+       case "$refname_type" in
+       "tracking branch"|branch)
+               fn_name=branch
+               ;;
+       "annotated tag")
+               fn_name=atag
+               ;;
+       esac
+       generate_${change_type}_${fn_name}_email
+
+       generate_email_footer
+}
+
+generate_email_header()
+{
+       # --- Email (all stdout will be the email)
+       # Generate header
+       cat <<-EOF
+       From: $committer
+       To: $recipients
+       Subject: ${EMAILPREFIX}$projectdesc $refname_type, $short_refname, ${change_type}d. $describe
+       X-Git-Refname: $refname
+       X-Git-Reftype: $refname_type
+       X-Git-Oldrev: $oldrev
+       X-Git-Newrev: $newrev
+
+       This is an automated email from the git hooks/post-receive script. It was
+       generated because a ref change was pushed to the repository containing
+       the project "$projectdesc".
+
+       The $refname_type, $short_refname has been ${change_type}d
+       EOF
+}
+
+generate_email_footer()
+{
+       cat <<-EOF
+
+
+       hooks/post-receive
+       -- 
+       $projectdesc
+       EOF
+}
+
+# --------------- Branches
+
+#
+# Called for the creation of a branch
+#
+generate_create_branch_email()
+{
+       # This is a new branch and so oldrev is not valid
+       echo "        at  $newrev ($newrev_type)"
+       echo ""
+
+       echo $LOGBEGIN
+       # This shows all log entries that are not already covered by
+       # another ref - i.e. commits that are now accessible from this
+       # ref that were previously not accessible (see generate_update_branch_email
+       # for the explanation of this command)
+       git rev-parse --not --branches | grep -v $(git rev-parse $refname) |
+       git rev-list --pretty --stdin $newrev
+       echo $LOGEND
+}
+
+#
+# Called for the change of a pre-existing branch
+#
+generate_update_branch_email()
+{
+       # Consider this:
+       #   1 --- 2 --- O --- X --- 3 --- 4 --- N
+       #
+       # O is $oldrev for $refname
+       # N is $newrev for $refname
+       # X is a revision pointed to by some other ref, for which we may
+       #   assume that an email has already been generated.
+       # In this case we want to issue an email containing only revisions
+       # 3, 4, and N.  Given (almost) by
+       #
+       #  git-rev-list N ^O --not --all
+       #
+       # The reason for the "almost", is that the "--not --all" will take
+       # precedence over the "N", and effectively will translate to
+       #
+       #  git-rev-list N ^O ^X ^N
+       #
+       # So, we need to build up the list more carefully.  git-rev-parse will
+       # generate a list of revs that may be fed into git-rev-list.  We can get
+       # it to make the "--not --all" part and then filter out the "^N" with:
+       #
+       #  git-rev-parse --not --all | grep -v N
+       #
+       # Then, using the --stdin switch to git-rev-list we have effectively
+       # manufactured
+       #
+       #  git-rev-list N ^O ^X
+       #
+       # This leaves a problem when someone else updates the repository
+       # while this script is running.  Their new value of the ref we're working
+       # on would be included in the "--not --all" output; and as our $newrev
+       # would be an ancestor of that commit, it would exclude all of our
+       # commits.  What we really want is to exclude the current value of
+       # $refname from the --not list, rather than N itself.  So:
+       #
+       #  git-rev-parse --not --all | grep -v $(git-rev-parse $refname)
+       #
+       # Get's us to something pretty safe (apart from the small time between
+       # refname being read, and git-rev-parse running - for that, I give up)
+       #
+       #
+       # Next problem, consider this:
+       #   * --- B --- * --- O ($oldrev)
+       #          \
+       #           * --- X --- * --- N ($newrev)
+       #
+       # That is to say, there is no guarantee that oldrev is a strict subset of
+       # newrev (it would have required a --force, but that's allowed).  So, we
+       # can't simply say rev-list $oldrev..$newrev.  Instead we find the common
+       # base of the two revs and list from there.
+       #
+       # As above, we need to take into account the presence of X; if another
+       # branch is already in the repository and points at some of the revisions
+       # that we are about to output - we don't want them.  The solution is as
+       # before: git-rev-parse output filtered.
+       #
+       # Finally, tags:
+       #   1 --- 2 --- O --- T --- 3 --- 4 --- N
+       #
+       # Tags pushed into the repository generate nice shortlog emails that
+       # summarise the commits between them and the previous tag.  However,
+       # those emails don't include the full commit messages that we output
+       # for a branch update.  Therefore we still want to output revisions
+       # that have been output on a tag email.
+       #
+       # Luckily, git-rev-parse includes just the tool.  Instead of using "--all"
+       # we use "--branches"; this has the added benefit that "remotes/" will
+       # be ignored as well.
+
+       # List all of the revisions that were removed by this update, in a fast forward
+       # update, this list will be empty, because rev-list O ^N is empty.  For a non
+       # fast forward, O ^N is the list of removed revisions
+       fastforward=""
+       rev=""
+       for rev in $(git rev-list $newrev..$oldrev)
+       do
+               revtype=$(git cat-file -t "$rev")
+               echo "  discards  $rev ($revtype)"
+       done
+       if [ -z "$rev" ]; then
+               fast_forward=1
+       fi
+
+       # List all the revisions from baserev to newrev in a kind of
+       # "table-of-contents"; note this list can include revisions that have
+       # already had notification emails and is present to show the full detail
+       # of the change from rolling back the old revision to the base revision and
+       # then forward to the new revision
+       for rev in $(git rev-list $oldrev..$newrev)
+       do
+               revtype=$(git cat-file -t "$rev")
+               echo "       via  $rev ($revtype)"
+       done
+
+       if [ -z "$fastforward" ]; then
+               echo "      from  $oldrev ($oldrev_type)"
+       else
+               echo ""
+               echo "This update added new revisions after undoing old revisions.  That is to"
+               echo "say, the old revision is not a strict subset of the new revision.  This"
+               echo "situation occurs when you --force push a change and generate a"
+               echo "repository containing something like this:"
+               echo ""
+               echo " * -- * -- B -- O -- O -- O ($oldrev)"
+               echo "            \\"
+               echo "             N -- N -- N ($newrev)"
+               echo ""
+               echo "When this happens we assume that you've already had alert emails for all"
+               echo "of the O revisions, and so we here report only the revisions in the N"
+               echo "branch from the common base, B."
+       fi
+
+       echo ""
+       echo "Those revisions listed above that are new to this repository have"
+       echo "not appeared on any other notification email; so we list those"
+       echo "revisions in full, below."
+
+       echo ""
+       echo $LOGBEGIN
+       git rev-parse --not --branches | grep -v $(git rev-parse $refname) |
+       git rev-list --pretty --stdin $oldrev..$newrev
+
+       # XXX: Need a way of detecting whether git rev-list actually outputted
+       # anything, so that we can issue a "no new revisions added by this
+       # update" message
+
+       echo $LOGEND
+
+       # The diffstat is shown from the old revision to the new revision.  This
+       # is to show the truth of what happened in this change.  There's no point
+       # showing the stat from the base to the new revision because the base
+       # is effectively a random revision at this point - the user will be
+       # interested in what this revision changed - including the undoing of
+       # previous revisions in the case of non-fast forward updates.
+       echo ""
+       echo "Summary of changes:"
+       git diff-tree --stat --summary --find-copies-harder $oldrev..$newrev
+}
+
+#
+# Called for the deletion of a branch
+#
+generate_delete_branch_email()
+{
+       echo "       was  $oldrev"
+       echo ""
+       echo $LOGEND
+       git show -s --pretty=oneline $oldrev
+       echo $LOGEND
+}
+
+# --------------- Annotated tags
+
+#
+# Called for the creation of an annotated tag
+#
+generate_create_atag_email()
+{
+       echo "        at  $newrev ($newrev_type)"
+
+       generate_atag_email
+}
+
+#
+# Called for the update of an annotated tag (this is probably a rare event
+# and may not even be allowed)
+#
+generate_update_atag_email()
+{
+       echo "        to  $newrev ($newrev_type)"
+       echo "      from  $oldrev (which is now obsolete)"
+
+       generate_atag_email
+}
+
+#
+# Called when an annotated tag is created or changed
+#
+generate_atag_email()
+{
+       # Use git-for-each-ref to pull out the individual fields from the tag
+       eval $(git for-each-ref --shell --format='
+       tagobject=%(*objectname)
+       tagtype=%(*objecttype)
+       tagger=%(taggername)
+       tagged=%(taggerdate)' $refname
+       )
+
+       echo "   tagging  $tagobject ($tagtype)"
+       case "$tagtype" in
+       commit)
+               # If the tagged object is a commit, then we assume this is a
+               # release, and so we calculate which tag this tag is replacing
+               prevtag=$(git describe --abbrev=0 $newrev^ 2>/dev/null)
+
+               if [ -n "$prevtag" ]; then
+                       echo "  replaces  $prevtag"
+               fi
+               ;;
+       *)
+               echo "    length  $(git cat-file -s $tagobject) bytes"
+               ;;
+       esac
+       echo " tagged by  $tagger"
+       echo "        on  $tagged"
+
+       echo ""
+       echo $LOGBEGIN
+
+       # Show the content of the tag message; this might contain a change log
+       # or release notes so is worth displaying.
+       git cat-file tag $newrev | sed -e '1,/^$/d'
+
+       echo ""
+       case "$tagtype" in
+       commit)
+               # Only commit tags make sense to have rev-list operations performed
+               # on them
+               if [ -n "$prevtag" ]; then
+                       # Show changes since the previous release
+                       git rev-list --pretty=short "$prevtag..$newrev" | git shortlog
+               else
+                       # No previous tag, show all the changes since time began
+                       git rev-list --pretty=short $newrev | git shortlog
+               fi
+               ;;
+       *)
+               # XXX: Is there anything useful we can do for non-commit objects?
+               ;;
+       esac
+
+       echo $LOGEND
+}
+
+#
+# Called for the deletion of an annotated tag
+#
+generate_delete_atag_email()
+{
+       echo "       was  $oldrev"
+       echo ""
+       echo $LOGEND
+       git show -s --pretty=oneline $oldrev
+       echo $LOGEND
+}
+
+# --------------- General references
+
+#
+# Called when any other type of reference is created (most likely a
+# non-annotated tag)
+#
+generate_create_general_email()
+{
+       echo "        at  $newrev ($newrev_type)"
+
+       generate_general_email
+}
+
+#
+# Called when any other type of reference is updated (most likely a
+# non-annotated tag)
+#
+generate_update_general_email()
+{
+       echo "        to  $newrev ($newrev_type)"
+       echo "      from  $oldrev"
+
+       generate_general_email
+}
+
+#
+# Called for creation or update of any other type of reference
+#
+generate_general_email()
+{
+       # Unannotated tags are more about marking a point than releasing a version;
+       # therefore we don't do the shortlog summary that we do for annotated tags
+       # above - we simply show that the point has been marked, and print the log
+       # message for the marked point for reference purposes
+       #
+       # Note this section also catches any other reference type (although there
+       # aren't any) and deals with them in the same way.
+
+       echo ""
+       if [ "$newrev_type" = "commit" ]; then
+               echo $LOGBEGIN
+               git show --no-color --root -s $newrev
+               echo $LOGEND
+       else
+               # What can we do here?  The tag marks an object that is not a commit,
+               # so there is no log for us to display.  It's probably not wise to
+               # output git-cat-file as it could be a binary blob.  We'll just say how
+               # big it is
+               echo "$newrev is a $newrev_type, and is $(git cat-file -s $newrev) bytes long."
+       fi
+}
+
+#
+# Called for the deletion of any other type of reference
+#
+generate_delete_general_email()
+{
+       echo "       was  $oldrev"
+       echo ""
+       echo $LOGEND
+       git show -s --pretty=oneline $oldrev
+       echo $LOGEND
+}
+
+# ---------------------------- main()
+
+# --- Constants
+EMAILPREFIX="[SCM] "
+LOGBEGIN="- Log -----------------------------------------------------------------"
+LOGEND="-----------------------------------------------------------------------"
+
+# --- Config
+# Set GIT_DIR either from the working directory, or from the environment
+# variable.
+GIT_DIR=$(git rev-parse --git-dir 2>/dev/null)
+if [ -z "$GIT_DIR" ]; then
+       echo >&2 "fatal: post-receive: GIT_DIR not set"
+       exit 1
+fi
+
+projectdesc=$(sed -e '1p' "$GIT_DIR/description")
+# Check if the description is unchanged from it's default, and shorten it to a
+# more manageable length if it is
+if expr "$projectdesc" : "Unnamed repository.*$" >/dev/null
+then
+       projectdesc="UNNAMED PROJECT"
+fi
+
+recipients=$(git repo-config hooks.mailinglist)
+announcerecipients=$(git repo-config hooks.announcelist)
+envelopesender=$(git-repo-config hooks.envelopesender)
+
+# --- Main loop
+# Allow dual mode: run from the command line just like the update hook, or if
+# no arguments are given then run as a hook script
+if [ -n "$1" -a -n "$2" -a -n "$3" ]; then
+       # Output to the terminal in command line mode - if someone wanted to
+       # resend an email; they could redirect the output to sendmail themselves
+       PAGER= generate_email $2 $3 $1
+else
+       if [ -n "$envelopesender" ]; then
+               envelopesender="-f '$envelopesender'"
+       fi
+
+       while read oldrev newrev refname
+       do
+               generate_email $oldrev $newrev $refname |
+               /usr/sbin/sendmail -t $envelopesender
+       done
+fi
index 11313a7949909f61f47ccc061cfc6390b225c630..85c374e21e7076cae8f186afe899437bda1ac770 100755 (executable)
@@ -1,15 +1,24 @@
 #!/bin/sh
 
 USAGE='[start|bad|good|next|reset|visualize|replay|log|run]'
-LONG_USAGE='git bisect start [<pathspec>]      reset bisect state and start bisection.
-git bisect bad [<rev>]         mark <rev> a known-bad revision.
-git bisect good [<rev>...]     mark <rev>... known-good revisions.
-git bisect next                        find next bisection to test and check it out.
-git bisect reset [<branch>]    finish bisection search and go back to branch.
-git bisect visualize            show bisect status in gitk.
-git bisect replay <logfile>    replay bisection log.
-git bisect log                 show bisect log.
-git bisect run <cmd>...        use <cmd>... to automatically bisect.'
+LONG_USAGE='git bisect start [<bad> [<good>...]] [--] [<pathspec>...]
+        reset bisect state and start bisection.
+git bisect bad [<rev>]
+        mark <rev> a known-bad revision.
+git bisect good [<rev>...]
+        mark <rev>... known-good revisions.
+git bisect next
+        find next bisection to test and check it out.
+git bisect reset [<branch>]
+        finish bisection search and go back to branch.
+git bisect visualize
+        show bisect status in gitk.
+git bisect replay <logfile>
+        replay bisection log.
+git bisect log
+        show bisect log.
+git bisect run <cmd>...
+        use <cmd>... to automatically bisect.'
 
 . git-sh-setup
 require_work_tree
@@ -70,14 +79,48 @@ bisect_start() {
        #
        # Get rid of any old bisect state
        #
-       rm -f "$GIT_DIR/refs/heads/bisect"
-       rm -rf "$GIT_DIR/refs/bisect/"
+       bisect_clean_state
        mkdir "$GIT_DIR/refs/bisect"
+
+       #
+       # Check for one bad and then some good revisions.
+       #
+       has_double_dash=0
+       for arg; do
+           case "$arg" in --) has_double_dash=1; break ;; esac
+       done
+       orig_args=$(sq "$@")
+       bad_seen=0
+       while [ $# -gt 0 ]; do
+           arg="$1"
+           case "$arg" in
+           --)
+               shift
+               break
+               ;;
+           *)
+               rev=$(git-rev-parse --verify "$arg^{commit}" 2>/dev/null) || {
+                   test $has_double_dash -eq 1 &&
+                       die "'$arg' does not appear to be a valid revision"
+                   break
+               }
+               if [ $bad_seen -eq 0 ]; then
+                   bad_seen=1
+                   bisect_write_bad "$rev"
+               else
+                   bisect_write_good "$rev"
+               fi
+               shift
+               ;;
+           esac
+        done
+
+       sq "$@" >"$GIT_DIR/BISECT_NAMES"
        {
            printf "git-bisect start"
-           sq "$@"
-       } >"$GIT_DIR/BISECT_LOG"
-       sq "$@" >"$GIT_DIR/BISECT_NAMES"
+           echo "$orig_args"
+       } >>"$GIT_DIR/BISECT_LOG"
+       bisect_auto_next
 }
 
 bisect_bad() {
@@ -90,12 +133,17 @@ bisect_bad() {
        *)
                usage ;;
        esac || exit
-       echo "$rev" >"$GIT_DIR/refs/bisect/bad"
-       echo "# bad: "$(git-show-branch $rev) >>"$GIT_DIR/BISECT_LOG"
+       bisect_write_bad "$rev"
        echo "git-bisect bad $rev" >>"$GIT_DIR/BISECT_LOG"
        bisect_auto_next
 }
 
+bisect_write_bad() {
+       rev="$1"
+       echo "$rev" >"$GIT_DIR/refs/bisect/bad"
+       echo "# bad: "$(git-show-branch $rev) >>"$GIT_DIR/BISECT_LOG"
+}
+
 bisect_good() {
        bisect_autostart
         case "$#" in
@@ -106,35 +154,54 @@ bisect_good() {
        for rev in $revs
        do
                rev=$(git-rev-parse --verify "$rev^{commit}") || exit
-               echo "$rev" >"$GIT_DIR/refs/bisect/good-$rev"
-               echo "# good: "$(git-show-branch $rev) >>"$GIT_DIR/BISECT_LOG"
+               bisect_write_good "$rev"
                echo "git-bisect good $rev" >>"$GIT_DIR/BISECT_LOG"
+
        done
        bisect_auto_next
 }
 
+bisect_write_good() {
+       rev="$1"
+       echo "$rev" >"$GIT_DIR/refs/bisect/good-$rev"
+       echo "# good: "$(git-show-branch $rev) >>"$GIT_DIR/BISECT_LOG"
+}
+
 bisect_next_check() {
-       next_ok=no
-        test -f "$GIT_DIR/refs/bisect/bad" &&
-       case "$(cd "$GIT_DIR" && echo refs/bisect/good-*)" in
-       refs/bisect/good-\*) ;;
-       *) next_ok=yes ;;
-       esac
-       case "$next_ok,$1" in
-       no,) false ;;
-       no,fail)
-           THEN=''
-           test -d "$GIT_DIR/refs/bisect" || {
-               echo >&2 'You need to start by "git bisect start".'
-               THEN='then '
-           }
-           echo >&2 'You '$THEN'need to give me at least one good' \
-               'and one bad revisions.'
-           echo >&2 '(You can use "git bisect bad" and' \
-               '"git bisect good" for that.)'
-           exit 1 ;;
+       missing_good= missing_bad=
+       git show-ref -q --verify refs/bisect/bad || missing_bad=t
+       test -n "$(git for-each-ref "refs/bisect/good-*")" || missing_good=t
+
+       case "$missing_good,$missing_bad,$1" in
+       ,,*)
+               : have both good and bad - ok
+               ;;
+       *,)
+               # do not have both but not asked to fail - just report.
+               false
+               ;;
+       t,,good)
+               # have bad but not good.  we could bisect although
+               # this is less optimum.
+               echo >&2 'Warning: bisecting only with a bad commit.'
+               if test -t 0
+               then
+                       printf >&2 'Are you sure [Y/n]? '
+                       case "$(read yesno)" in [Nn]*) exit 1 ;; esac
+               fi
+               : bisect without good...
+               ;;
        *)
-           true ;;
+               THEN=''
+               test -d "$GIT_DIR/refs/bisect" || {
+                       echo >&2 'You need to start by "git bisect start".'
+                       THEN='then '
+               }
+               echo >&2 'You '$THEN'need to give me at least one good' \
+                       'and one bad revisions.'
+               echo >&2 '(You can use "git bisect bad" and' \
+                       '"git bisect good" for that.)'
+               exit 1 ;;
        esac
 }
 
@@ -145,27 +212,32 @@ bisect_auto_next() {
 bisect_next() {
         case "$#" in 0) ;; *) usage ;; esac
        bisect_autostart
-       bisect_next_check fail
+       bisect_next_check good
+
        bad=$(git-rev-parse --verify refs/bisect/bad) &&
-       good=$(git-rev-parse --sq --revs-only --not \
-               $(cd "$GIT_DIR" && ls refs/bisect/good-*)) &&
-       rev=$(eval "git-rev-list --bisect $good $bad -- $(cat "$GIT_DIR/BISECT_NAMES")") || exit
-       if [ -z "$rev" ]; then
-           echo "$bad was both good and bad"
-           exit 1
+       good=$(git for-each-ref --format='^%(objectname)' \
+               "refs/bisect/good-*" | tr '[\012]' ' ') &&
+       eval="git-rev-list --bisect-vars $good $bad --" &&
+       eval="$eval $(cat "$GIT_DIR/BISECT_NAMES")" &&
+       eval=$(eval "$eval") &&
+       eval "$eval" || exit
+
+       if [ -z "$bisect_rev" ]; then
+               echo "$bad was both good and bad"
+               exit 1
        fi
-       if [ "$rev" = "$bad" ]; then
-           echo "$rev is first bad commit"
-           git-diff-tree --pretty $rev
-           exit 0
+       if [ "$bisect_rev" = "$bad" ]; then
+               echo "$bisect_rev is first bad commit"
+               git-diff-tree --pretty $bisect_rev
+               exit 0
        fi
-       nr=$(eval "git-rev-list $rev $good -- $(cat $GIT_DIR/BISECT_NAMES)" | wc -l) || exit
-       echo "Bisecting: $nr revisions left to test after this"
-       echo "$rev" > "$GIT_DIR/refs/heads/new-bisect"
+
+       echo "Bisecting: $bisect_nr revisions left to test after this"
+       echo "$bisect_rev" >"$GIT_DIR/refs/heads/new-bisect"
        git checkout -q new-bisect || exit
        mv "$GIT_DIR/refs/heads/new-bisect" "$GIT_DIR/refs/heads/bisect" &&
        GIT_DIR="$GIT_DIR" git-symbolic-ref HEAD refs/heads/bisect
-       git-show-branch "$rev"
+       git-show-branch "$bisect_rev"
 }
 
 bisect_visualize() {
@@ -190,14 +262,19 @@ bisect_reset() {
            usage ;;
        esac
        if git checkout "$branch"; then
-               rm -fr "$GIT_DIR/refs/bisect"
-               rm -f "$GIT_DIR/refs/heads/bisect" "$GIT_DIR/head-name"
-               rm -f "$GIT_DIR/BISECT_LOG"
-               rm -f "$GIT_DIR/BISECT_NAMES"
-               rm -f "$GIT_DIR/BISECT_RUN"
+               rm -f "$GIT_DIR/head-name"
+               bisect_clean_state
        fi
 }
 
+bisect_clean_state() {
+       rm -fr "$GIT_DIR/refs/bisect"
+       rm -f "$GIT_DIR/refs/heads/bisect"
+       rm -f "$GIT_DIR/BISECT_LOG"
+       rm -f "$GIT_DIR/BISECT_NAMES"
+       rm -f "$GIT_DIR/BISECT_RUN"
+}
+
 bisect_replay () {
        test -r "$1" || {
                echo >&2 "cannot read $1 for replaying"
index a7390e808c76dd5c8dab04396974ee5a709497fd..deb0a9a3c733ed889158d05b7cae4d174917553d 100755 (executable)
@@ -170,7 +170,7 @@ describe_detached_head () {
        }
 }
 
-if test -z "$branch$newbranch" && test "$new" != "$old"
+if test -z "$branch$newbranch" && test "$new_name" != "$old_name"
 then
        detached="$new"
        if test -n "$oldbranch" && test -z "$quiet"
@@ -180,7 +180,7 @@ If you want to create a new branch from this checkout, you may do so
 (now or later) by using -b with the checkout command again. Example:
   git checkout -b <new_branch_name>"
        fi
-elif test -z "$oldbranch"
+elif test -z "$oldbranch" && test "$new" != "$old"
 then
        describe_detached_head 'Previous HEAD position was' "$old"
 fi
index 1a1ba7b1a6f779773702ae3c1efb56425c31beb4..ac74bc51b3197d06f13f588d6916400ac3e6fcf0 100755 (executable)
 our ($opt_h,$opt_o,$opt_v,$opt_k,$opt_u,$opt_d,$opt_p,$opt_C,$opt_z,$opt_i,$opt_P, $opt_s,$opt_m,$opt_M,$opt_A,$opt_S,$opt_L, $opt_a);
 my (%conv_author_name, %conv_author_email);
 
-sub usage() {
+sub usage(;$) {
+       my $msg = shift;
+       print(STDERR "Error: $msg\n") if $msg;
        print STDERR <<END;
 Usage: ${\basename $0}     # fetch/update GIT from CVS
        [-o branch-for-HEAD] [-h] [-v] [-d CVSROOT] [-A author-conv-file]
-       [-p opts-for-cvsps] [-C GIT_repository] [-z fuzz] [-i] [-k] [-u]
-       [-s subst] [-a] [-m] [-M regex] [-S regex] [CVS_module]
+       [-p opts-for-cvsps] [-P file] [-C GIT_repository] [-z fuzz] [-i] [-k]
+       [-u] [-s subst] [-a] [-m] [-M regex] [-S regex] [-L commitlimit]
+       [CVS_module]
 END
        exit(1);
 }
@@ -116,7 +119,7 @@ sub read_repo_config {
 getopts($opts) or usage();
 usage if $opt_h;
 
-@ARGV <= 1 or usage();
+@ARGV <= 1 or usage("You can't specify more than one CVS module");
 
 if ($opt_d) {
        $ENV{"CVSROOT"} = $opt_d;
@@ -129,7 +132,7 @@ sub read_repo_config {
 } elsif ($ENV{"CVSROOT"}) {
        $opt_d = $ENV{"CVSROOT"};
 } else {
-       die "CVSROOT needs to be set";
+       usage("CVSROOT needs to be set");
 }
 $opt_o ||= "origin";
 $opt_s ||= "-";
@@ -148,7 +151,7 @@ sub read_repo_config {
        chomp $cvs_tree;
        close $f;
 } else {
-       usage();
+       usage("CVS module has to be specified");
 }
 
 our @mergerx = ();
index ae50990d081c3709c0a498422be382b9a632f5ec..1278fcba462f632a3687742f74cc15c0498874e2 100755 (executable)
@@ -595,7 +595,7 @@ sub send_message
        if ($chain_reply_to || !defined $reply_to || length($reply_to) == 0) {
                $reply_to = $message_id;
                if (length $references > 0) {
-                       $references .= " $message_id";
+                       $references .= "\n $message_id";
                } else {
                        $references = "$message_id";
                }
diff --git a/git.c b/git.c
index 5b1bc2a895306157649e399d5bad9bb827935318..33dd4d39d907a229679a41f9712ee99007a34f3b 100644 (file)
--- a/git.c
+++ b/git.c
@@ -226,7 +226,7 @@ static void handle_internal_command(int argc, const char **argv, char **envp)
                { "add", cmd_add, RUN_SETUP | NOT_BARE },
                { "annotate", cmd_annotate, USE_PAGER },
                { "apply", cmd_apply },
-               { "archive", cmd_archive, RUN_SETUP },
+               { "archive", cmd_archive },
                { "blame", cmd_blame, RUN_SETUP },
                { "branch", cmd_branch, RUN_SETUP },
                { "bundle", cmd_bundle },
index ea491562c80fbb8147746bd0dd711529555780ee..e49eb91d69c2344163ab9477883777476c789bc7 100755 (executable)
@@ -3934,7 +3934,8 @@ sub git_blobdiff {
 
                # open patch output
                open $fd, "-|", git_cmd(), "diff-tree", '-r', @diff_opts,
-                       '-p', $hash_parent_base, $hash_base,
+                       '-p', ($format eq 'html' ? "--full-index" : ()),
+                       $hash_parent_base, $hash_base,
                        "--", (defined $file_parent ? $file_parent : ()), $file_name
                        or die_error(undef, "Open git-diff-tree failed");
        }
@@ -3969,7 +3970,8 @@ sub git_blobdiff {
                }
 
                # open patch output
-               open $fd, "-|", git_cmd(), "diff", '-p', @diff_opts,
+               open $fd, "-|", git_cmd(), "diff", @diff_opts,
+                       '-p', ($format eq 'html' ? "--full-index" : ()),
                        $hash_parent, $hash, "--"
                        or die_error(undef, "Open git-diff failed");
        } else  {
index 557b40322f22b77a81140ff8f29b2b2be0505581..09baedc18ae320a2f09fa61d9065bedb69c02a41 100644 (file)
@@ -198,7 +198,7 @@ static void start_object_request(struct object_request *obj_req)
                SHA1_Init(&obj_req->c);
                if (prev_posn>0) {
                        prev_posn = 0;
-                       lseek(obj_req->local, SEEK_SET, 0);
+                       lseek(obj_req->local, 0, SEEK_SET);
                        ftruncate(obj_req->local, 0);
                }
        }
index 724720c562ab6da2b02e91b69f5365bc7bfee4f4..e3f767582bfc71fc3d1b90be8fa76ab3ad7e1664 100644 (file)
@@ -312,7 +312,7 @@ static void start_fetch_loose(struct transfer_request *request)
                SHA1_Init(&request->c);
                if (prev_posn>0) {
                        prev_posn = 0;
-                       lseek(request->local_fileno, SEEK_SET, 0);
+                       lseek(request->local_fileno, 0, SEEK_SET);
                        ftruncate(request->local_fileno, 0);
                }
        }
diff --git a/refs.c b/refs.c
index f471152bfc6c500a2597068496ffff3f4d8f5961..d2b7b7fb56f76294bb48526496429968d86e49b2 100644 (file)
--- a/refs.c
+++ b/refs.c
@@ -828,16 +828,6 @@ int rename_ref(const char *oldref, const char *newref, const char *logmsg)
                goto rollback;
        }
 
-       if (!prefixcmp(oldref, "refs/heads/") &&
-                       !prefixcmp(newref, "refs/heads/")) {
-               char oldsection[1024], newsection[1024];
-
-               snprintf(oldsection, 1024, "branch.%s", oldref + 11);
-               snprintf(newsection, 1024, "branch.%s", newref + 11);
-               if (git_config_rename_section(oldsection, newsection) < 0)
-                       return 1;
-       }
-
        return 0;
 
  rollback:
index 9558bdb6318cc2956c43153084e1f1cc8386973f..828d553a4b53210e9bd15c522e2a798901b2ac35 100755 (executable)
@@ -11,7 +11,7 @@ handled.  Specifically, that a bogus branch is not created.
 . ./test-lib.sh
 
 test_expect_success \
-    'prepare an trivial repository' \
+    'prepare a trivial repository' \
     'echo Hello > A &&
      git-update-index --add A &&
      git-commit -m "Initial commit." &&
@@ -83,6 +83,15 @@ test_expect_failure \
          git-branch r &&
          git-branch -m q r/q'
 
+mv .git/config .git/config-saved
+
+test_expect_success 'git branch -m q q2 without config should succeed' '
+       git-branch -m q q2 &&
+       git-branch -m q2 q
+'
+
+mv .git/config-saved .git/config
+
 git-config branch.s/s.dummy Hello
 
 test_expect_success \
diff --git a/t/t4120-apply-popt.sh b/t/t4120-apply-popt.sh
new file mode 100755 (executable)
index 0000000..2f672f3
--- /dev/null
@@ -0,0 +1,25 @@
+#!/bin/sh
+#
+# Copyright (c) 2007 Shawn O. Pearce
+#
+
+test_description='git-apply -p handling.'
+
+. ./test-lib.sh
+
+test_expect_success setup '
+       mkdir sub &&
+       echo A >sub/file1 &&
+       cp sub/file1 file1 &&
+       git add sub/file1 &&
+       echo B >sub/file1 &&
+       git diff >patch.file &&
+       rm sub/file1 &&
+       rmdir sub
+'
+
+test_expect_success 'apply git diff with -p2' '
+       git apply -p2 patch.file
+'
+
+test_done
index 8b611bbea210551d86016b53718ba1af313f1353..6ba63d7173ba5d333d80c017c4ef5a8c77b90a11 100755 (executable)
@@ -35,7 +35,8 @@ git commit -q -a -m first
 
 git checkout -b second master
 git show first:a1 |
-sed -e 's/To die, t/To die! T/' -e 's/life;$/life./' > a1
+sed -e 's/To die, t/To die! T/' > a1
+echo "* END *" >>a1
 git commit -q -a -m second
 
 # activate rerere
@@ -50,10 +51,10 @@ test_expect_success 'recorded preimage' "grep ======= $rr/preimage"
 test_expect_success 'no postimage or thisimage yet' \
        "test ! -f $rr/postimage -a ! -f $rr/thisimage"
 
-test_expect_success 'preimage have right number of lines' '
+test_expect_success 'preimage has right number of lines' '
 
        cnt=$(sed -ne "/^<<<<<<</,/^>>>>>>>/p" $rr/preimage | wc -l) &&
-       test "$cnt" = 10
+       test $cnt = 9
 
 '
 
@@ -75,10 +76,10 @@ cat > expect << EOF
  For in that sleep of death what dreams may come
  When we have shuffled off this mortal coil,
  Must give us pause: there's the respect
+ That makes calamity of so long life;
 -<<<<<<<
--That makes calamity of so long life.
 -=======
- That makes calamity of so long life;
+-* END *
 ->>>>>>>
 EOF
 git rerere diff > out
index ac835fe4317b7a37d77205487066d8f10bd71422..b4359df795483691e61452366add69a212347723 100755 (executable)
@@ -130,4 +130,8 @@ test_expect_success \
     'validate file contents with prefix' \
     'diff -r a e/prefix/a'
 
+test_expect_success \
+    'git-archive --list outside of a git repo' \
+    'GIT_DIR=some/non-existing/directory git-archive --list'
+
 test_done
index 35e036a86465ce066b3e3a5f98c769fba6cd4276..083095f7f3a6720836f135835091e6d27d18617a 100755 (executable)
@@ -123,11 +123,12 @@ test_expect_success \
      done'
 cd "$TRASH"
 
-test_expect_success \
-    'compare delta flavors' \
-    'size_2=`stat -c "%s" test-2-${packname_2}.pack` &&
-     size_3=`stat -c "%s" test-3-${packname_3}.pack` &&
-     test $size_2 -gt $size_3'
+test_expect_success 'compare delta flavors' '
+       perl -e '\''
+               defined($_ = -s $_) or die for @ARGV;
+               exit 1 if $ARGV[0] <= $ARGV[1];
+       '\'' test-2-$packname_2.pack test-3-$packname_3.pack
+'
 
 rm -fr .git2
 mkdir .git2
index 39c72283b516001ec110614a4f40dcdd2b06e90e..de3123522aba7d4a371cc30d8fbbd74f4d063d19 100755 (executable)
@@ -2,7 +2,9 @@
 #
 # Copyright (c) 2007 Christian Couder
 #
-test_description='Tests git-bisect run functionality'
+test_description='Tests git-bisect functionality'
+
+exec </dev/null
 
 . ./test-lib.sh
 
@@ -37,11 +39,40 @@ test_expect_success \
      HASH3=$(git rev-list HEAD | head -2 | tail -1) &&
      HASH4=$(git rev-list HEAD | head -1)'
 
+test_expect_success 'bisect starts with only one bad' '
+       git bisect reset &&
+       git bisect start &&
+       git bisect bad $HASH4 &&
+       git bisect next
+'
+
+test_expect_success 'bisect starts with only one good' '
+       git bisect reset &&
+       git bisect start &&
+       git bisect good $HASH1 || return 1
+
+       if git bisect next
+       then
+               echo Oops, should have failed.
+               false
+       else
+               :
+       fi
+'
+
+test_expect_success 'bisect start with one bad and good' '
+       git bisect reset &&
+       git bisect start &&
+       git bisect good $HASH1 &&
+       git bisect bad $HASH4 &&
+       git bisect next
+'
+
 # We want to automatically find the commit that
 # introduced "Another" into hello.
 test_expect_success \
-    'git bisect run simple case' \
-    'echo "#!/bin/sh" > test_script.sh &&
+    '"git bisect run" simple case' \
+    'echo "#"\!"/bin/sh" > test_script.sh &&
      echo "grep Another hello > /dev/null" >> test_script.sh &&
      echo "test \$? -ne 0" >> test_script.sh &&
      chmod +x test_script.sh &&
@@ -49,7 +80,21 @@ test_expect_success \
      git bisect good $HASH1 &&
      git bisect bad $HASH4 &&
      git bisect run ./test_script.sh > my_bisect_log.txt &&
-     grep "$HASH3 is first bad commit" my_bisect_log.txt'
+     grep "$HASH3 is first bad commit" my_bisect_log.txt &&
+     git bisect reset'
+
+# We want to automatically find the commit that
+# introduced "Ciao" into hello.
+test_expect_success \
+    '"git bisect run" with more complex "git bisect start"' \
+    'echo "#"\!"/bin/sh" > test_script.sh &&
+     echo "grep Ciao hello > /dev/null" >> test_script.sh &&
+     echo "test \$? -ne 0" >> test_script.sh &&
+     chmod +x test_script.sh &&
+     git bisect start $HASH4 $HASH1 &&
+     git bisect run ./test_script.sh > my_bisect_log.txt &&
+     grep "$HASH4 is first bad commit" my_bisect_log.txt &&
+     git bisect reset'
 
 #
 #
index 867bbd26cbbacbe03ef76cadb6ff34976c324da5..5fa6a45577894e05446351fc5076a27accb1fa9f 100755 (executable)
@@ -3,7 +3,20 @@
 # Copyright (c) 2006 Junio C Hamano
 #
 
-test_description='git-checkout tests.'
+test_description='git-checkout tests.
+
+Creates master, forks renamer and side branches from it.
+Test switching across them.
+
+  ! [master] Initial A one, A two
+   * [renamer] Renamer R one->uno, M two
+    ! [side] Side M one, D two, A three
+  ---
+    + [side] Side M one, D two, A three
+   *  [renamer] Renamer R one->uno, M two
+  +*+ [master] Initial A one, A two
+
+'
 
 . ./test-lib.sh
 
@@ -129,4 +142,52 @@ test_expect_success 'checkout -m with merge conflict' '
        ! test -s current
 '
 
+test_expect_success 'checkout to detach HEAD' '
+
+       git checkout -f renamer && git clean &&
+       git checkout renamer^ &&
+       H=$(git rev-parse --verify HEAD) &&
+       M=$(git show-ref -s --verify refs/heads/master) &&
+       test "z$H" = "z$M" &&
+       if git symbolic-ref HEAD >/dev/null 2>&1
+       then
+               echo "OOPS, HEAD is still symbolic???"
+               false
+       else
+               : happy
+       fi
+'
+
+test_expect_success 'checkout to detach HEAD with branchname^' '
+
+       git checkout -f master && git clean &&
+       git checkout renamer^ &&
+       H=$(git rev-parse --verify HEAD) &&
+       M=$(git show-ref -s --verify refs/heads/master) &&
+       test "z$H" = "z$M" &&
+       if git symbolic-ref HEAD >/dev/null 2>&1
+       then
+               echo "OOPS, HEAD is still symbolic???"
+               false
+       else
+               : happy
+       fi
+'
+
+test_expect_success 'checkout to detach HEAD with HEAD^0' '
+
+       git checkout -f master && git clean &&
+       git checkout HEAD^0 &&
+       H=$(git rev-parse --verify HEAD) &&
+       M=$(git show-ref -s --verify refs/heads/master) &&
+       test "z$H" = "z$M" &&
+       if git symbolic-ref HEAD >/dev/null 2>&1
+       then
+               echo "OOPS, HEAD is still symbolic???"
+               false
+       else
+               : happy
+       fi
+'
+
 test_done