]> git.ipfire.org Git - thirdparty/git.git/commitdiff
Merge branch 'jc/maint-apply-report-offset' into maint
authorJunio C Hamano <gitster@pobox.com>
Fri, 1 Apr 2011 23:20:19 +0000 (16:20 -0700)
committerJunio C Hamano <gitster@pobox.com>
Fri, 1 Apr 2011 23:20:19 +0000 (16:20 -0700)
* jc/maint-apply-report-offset:
  apply -v: show offset count when patch did not apply exactly

103 files changed:
Documentation/CodingGuidelines
Documentation/RelNotes/1.7.4.2.txt [new file with mode: 0644]
Documentation/SubmittingPatches
Documentation/config.txt
Documentation/diff-generate-patch.txt
Documentation/git-am.txt
Documentation/git-bisect.txt
Documentation/git-filter-branch.txt
Documentation/git-for-each-ref.txt
Documentation/git-grep.txt
Documentation/git-ls-remote.txt
Documentation/git-pack-objects.txt
Documentation/git-remote-ext.txt
Documentation/git-remote-helpers.txt
Documentation/git-svn.txt
Documentation/git-tag.txt
Documentation/gitattributes.txt
Documentation/rev-list-options.txt
GIT-VERSION-GEN
Makefile
RelNotes
abspath.c
builtin/add.c
builtin/apply.c
builtin/blame.c
builtin/branch.c
builtin/checkout.c
builtin/clone.c
builtin/commit.c
builtin/config.c
builtin/describe.c
builtin/fast-export.c
builtin/fetch.c
builtin/grep.c
builtin/index-pack.c
builtin/log.c
builtin/merge.c
builtin/notes.c
builtin/patch-id.c
builtin/push.c
builtin/read-tree.c
builtin/tag.c
cache.h
commit.h
compat/bswap.h
compat/mingw.h
config.c
contrib/thunderbird-patch-inline/appp.sh
convert.c
diff.c
diffcore-rename.c
environment.c
fast-import.c
fetch-pack.h
generate-cmdlist.sh
git-bisect.sh
git-compat-util.h
git-mergetool--lib.sh
git-parse-remote.sh
git-submodule.sh
gitweb/gitweb.perl
hash.c
hash.h
http-push.c
http-walker.c
http.h
merge-recursive.c
pack-check.c
parse-options.h
perl/Git.pm
sha1_file.c
sha1_name.c
strbuf.h
string-list.h
submodule.c
symlinks.c
t/README
t/lib-terminal.sh
t/t0040-parse-options.sh
t/t0070-fundamental.sh
t/t2019-checkout-ambiguous-ref.sh [new file with mode: 0755]
t/t2021-checkout-overwrite.sh [new file with mode: 0755]
t/t4003-diff-rename-1.sh
t/t4004-diff-rename-symlink.sh
t/t4005-diff-rename-2.sh
t/t4008-diff-break-rewrite.sh
t/t4009-diff-rename-4.sh
t/t4031-diff-rewrite-binary.sh
t/t4204-patch-id.sh
t/t5701-clone-local.sh
t/t6035-merge-dir-to-symlink.sh
t/t7406-submodule-update.sh
t/t7500-commit.sh
t/t7505-prepare-commit-msg-hook.sh
t/t8001-annotate.sh
t/t8006-blame-textconv.sh
t/t9700/test.pl
t/test-lib.sh
t/valgrind/default.supp
test-mktemp.c [new file with mode: 0644]
test-parse-options.c
transport-helper.c
wrapper.c

index ba2006d892ec09d606f8846588c7727396b1ee28..fe1c1e5bc26e683540cb9fe5f43320192be9185d 100644 (file)
@@ -152,7 +152,7 @@ Writing Documentation:
  when writing or modifying command usage strings and synopsis sections
  in the manual pages:
 
- Placeholders are enclosed in angle brackets:
+ Placeholders are spelled in lowercase and enclosed in angle brackets:
    <file>
    --sort=<key>
    --abbrev[=<n>]
diff --git a/Documentation/RelNotes/1.7.4.2.txt b/Documentation/RelNotes/1.7.4.2.txt
new file mode 100644 (file)
index 0000000..ef4ce1f
--- /dev/null
@@ -0,0 +1,58 @@
+Git v1.7.4.2 Release Notes
+==========================
+
+Fixes since v1.7.4.1
+--------------------
+
+ * Many documentation updates to match "git cmd -h" output and the
+   git-cmd manual page.
+
+ * We used to keep one file descriptor open for each and every packfile
+   that we have a mmap window on it (read: "in use"), even when for very
+   tiny packfiles.  We now close the file descriptor early when the entire
+   packfile fits inside one mmap window.
+
+ * "git bisect visualize" tried to run "gitk" in windowing
+   environments even when "gitk" is not installed, resulting in a
+   strange error message.
+
+ * "git clone /no/such/path" did not fail correctly.
+
+ * "git commit" did not correctly error out when the user asked to use a
+   non existent file as the commit message template.
+
+ * "git diff --stat -B" ran on binary files counted the changes in lines,
+   which was nonsensical.
+
+ * "git diff -M" opportunistically detected copies, which was not
+   necessarily a good thing, especially when it is internally run by
+   recursive merge.
+
+ * "git difftool" didn't tell (g)vimdiff that the files it is reading are
+   to be opened read-only.
+
+ * "git merge" didn't pay attention to prepare-commit-msg hook, even
+   though if a merge is conflicted and manually resolved, the subsequent
+   "git commit" would have triggered the hook, which was inconsistent.
+
+ * "git patch-id" (and commands like "format-patch --ignore-in-upstream"
+   that use it as their internal logic) handled changes to files that end
+   with incomplete lines incorrectly.
+
+ * The official value to tell "git push" to push the current branch back
+   to update the upstream branch it forked from is now called "upstream".
+   The old name "tracking" is and will be supported.
+
+ * "git submodule update" used to honor the --merge/--rebase option (or
+   corresponding configuration variables) even for a newly cloned
+   subproject, which made no sense (so/submodule-no-update-first-time).
+
+ * gitweb's "highlight" interface mishandled tabs.
+
+ * gitweb didn't understand timezones with GMT offset that is not
+   multiple of a whole hour.
+
+ * gitweb had a few forward-incompatible syntactic constructs and
+   also used incorrect variable when showing the file mode in a diff.
+
+And other minor fixes and documentation updates.
index 72741ebda12de8fbf786f12531d70ab465eecf42..c3b0816ed7e5f4d5989de85c3c3ad3f7eb829591 100644 (file)
@@ -10,10 +10,18 @@ Checklist (and a short version for the impatient):
          description (50 characters is the soft limit, see DISCUSSION
          in git-commit(1)), and should skip the full stop
        - the body should provide a meaningful commit message, which:
-               - uses the imperative, present tense: "change",
-                 not "changed" or "changes".
-               - includes motivation for the change, and contrasts
-                 its implementation with previous behaviour
+         . explains the problem the change tries to solve, iow, what
+           is wrong with the current code without the change.
+         . justifies the way the change solves the problem, iow, why
+           the result with the change is better.
+         . alternate solutions considered but discarded, if any.
+       - describe changes in imperative mood, e.g. "make xyzzy do frotz"
+         instead of "[This patch] makes xyzzy do frotz" or "[I] changed
+         xyzzy to do frotz", as if you are giving orders to the codebase
+         to change its behaviour.
+       - try to make sure your explanation can be understood without
+         external resources. Instead of giving a URL to a mailing list
+         archive, summarize the relevant points of the discussion.
        - add a "Signed-off-by: Your Name <you@example.com>" line to the
          commit message (or just use the option "-s" when committing)
          to confirm that you agree to the Developer's Certificate of Origin
@@ -90,7 +98,10 @@ your commit head.  Instead, always make a commit with complete
 commit message and generate a series of patches from your
 repository.  It is a good discipline.
 
-Describe the technical detail of the change(s).
+Give an explanation for the change(s) that is detailed enough so
+that people can judge if it is good thing to do, without reading
+the actual patch text to determine how well the code does what
+the explanation promises to do.
 
 If your description starts to get too long, that's a sign that you
 probably need to split up your commit to finer grained pieces.
@@ -99,9 +110,8 @@ help reviewers check the patch, and future maintainers understand
 the code, are the most beautiful patches.  Descriptions that summarise
 the point in the subject well, and describe the motivation for the
 change, the approach taken by the change, and if relevant how this
-differs substantially from the prior version, can be found on Usenet
-archives back into the late 80's.  Consider it like good Netiquette,
-but for code.
+differs substantially from the prior version, are all good things
+to have.
 
 Oh, another thing.  I am picky about whitespaces.  Make sure your
 changes do not trigger errors with the sample pre-commit hook shipped
index c5e183516a104e6efb7ed597fb4498d75560ab68..1a571f41742af09f52cc31462f501521aacd00d9 100644 (file)
@@ -62,7 +62,7 @@ Internal whitespace within a variable value is retained verbatim.
 
 The values following the equals sign in variable assign are all either
 a string, an integer, or a boolean.  Boolean values may be given as yes/no,
-0/1, true/false or on/off.  Case is not significant in boolean values, when
+1/0, true/false or on/off.  Case is not significant in boolean values, when
 converting value to the canonical form using '--bool' type specifier;
 'git config' will ensure that the output is "true" or "false".
 
@@ -376,15 +376,6 @@ core.warnAmbiguousRefs::
        If true, git will warn you if the ref name you passed it is ambiguous
        and might match multiple refs in the .git/refs/ tree. True by default.
 
-core.abbrevguard::
-       Even though git makes sure that it uses enough hexdigits to show
-       an abbreviated object name unambiguously, as more objects are
-       added to the repository over time, a short name that used to be
-       unique will stop being unique.  Git uses this many extra hexdigits
-       that are more than necessary to make the object name currently
-       unique, in the hope that its output will stay unique a bit longer.
-       Defaults to 0.
-
 core.compression::
        An integer -1..9, indicating a default compression level.
        -1 is the zlib default. 0 means no compression,
@@ -1591,7 +1582,8 @@ push.default::
 * `matching` - push all matching branches.
   All branches having the same name in both ends are considered to be
   matching. This is the default.
-* `tracking` - push the current branch to its upstream branch.
+* `upstream` - push the current branch to its upstream branch.
+* `tracking` - deprecated synonym for `upstream`.
 * `current` - push the current branch to a branch of the same name.
 
 rebase.stat::
index 3ac2beac6229955dc2534c428238c3d5ff57d25d..c57460c03dd1512e1e3644d3321e87d38316befe 100644 (file)
@@ -74,10 +74,13 @@ separate lines indicate the old and the new mode.
 combined diff format
 --------------------
 
-"git-diff-tree", "git-diff-files" and "git-diff" can take '-c' or
-'--cc' option to produce 'combined diff'.  For showing a merge commit
-with "git log -p", this is the default format; you can force showing
-full diff with the '-m' option.
+Any diff-generating command can take the `-c` or `--cc` option to
+produce a 'combined diff' when showing a merge. This is the default
+format when showing merges with linkgit:git-diff[1] or
+linkgit:git-show[1]. Note also that you can give the `-m' option to any
+of these commands to force generation of diffs with individual parents
+of a merge.
+
 A 'combined diff' format looks like this:
 
 ------------
index 51297d09ecdd3468ecd87a4f7aa6fac2b8ef6224..4d37de639dd6f6deaf2c52231c0ae879cd30f23d 100644 (file)
@@ -173,9 +173,9 @@ aborts in the middle.  You can recover from this in one of two ways:
   the index file to bring it into a state that the patch should
   have produced.  Then run the command with the '--resolved' option.
 
-The command refuses to process new mailboxes while the `.git/rebase-apply`
-directory exists, so if you decide to start over from scratch,
-run `rm -f -r .git/rebase-apply` before running the command with mailbox
+The command refuses to process new mailboxes until the current
+operation is finished, so if you decide to start over from scratch,
+run `git am --abort` before running the command with mailbox
 names.
 
 Before any patches are applied, ORIG_HEAD is set to the tip of the
index c39d957c3a3a432f5e685d44066c145f03b96365..1701e42e4aa87fe6beb78c38201ae35adf1d68dd 100644 (file)
@@ -241,7 +241,12 @@ exit(3) manual page), as the value is chopped with "& 0377".
 
 The special exit code 125 should be used when the current source code
 cannot be tested. If the script exits with this code, the current
-revision will be skipped (see `git bisect skip` above).
+revision will be skipped (see `git bisect skip` above). 125 was chosen
+as the highest sensible value to use for this purpose, because 126 and 127
+are used by POSIX shells to signal specific error status (127 is for
+command not found, 126 is for command found but not executable---these
+details do not matter, as they are normal errors in the script, as far as
+"bisect run" is concerned).
 
 You may often find that during a bisect session you want to have
 temporary modifications (e.g. s/#define DEBUG 0/#define DEBUG 1/ in a
index 796e7489ff7ee573a65647f4de33df932bd1bea1..aa69b8ef1320c480bee1c6cfa715722879210c7e 100644 (file)
@@ -361,7 +361,7 @@ git filter-branch --index-filter \
        'git ls-files -s | sed "s-\t\"*-&newsubdir/-" |
                GIT_INDEX_FILE=$GIT_INDEX_FILE.new \
                        git update-index --index-info &&
-        mv $GIT_INDEX_FILE.new $GIT_INDEX_FILE' HEAD
+        mv "$GIT_INDEX_FILE.new" "$GIT_INDEX_FILE"' HEAD
 ---------------------------------------------------------------
 
 
index fac1cf55e51ff289167270de4f248dad959741c6..152e695c8178fee9daa478cdf67eae58a2f1af00 100644 (file)
@@ -123,7 +123,7 @@ EXAMPLES
 --------
 
 An example directly producing formatted text.  Show the most recent
-3 tagged commits::
+3 tagged commits:
 
 ------------
 #!/bin/sh
@@ -140,7 +140,7 @@ Ref: %(*refname)
 
 
 A simple example showing the use of shell eval on the output,
-demonstrating the use of --shell.  List the prefixes of all heads::
+demonstrating the use of --shell.  List the prefixes of all heads:
 ------------
 #!/bin/sh
 
@@ -154,7 +154,7 @@ done
 
 
 A bit more elaborate report on tags, demonstrating that the format
-may be an entire script::
+may be an entire script:
 ------------
 #!/bin/sh
 
@@ -204,3 +204,15 @@ eval=`git for-each-ref --shell --format="$fmt" \
        refs/tags`
 eval "$eval"
 ------------
+
+Author
+------
+Written by Junio C Hamano <gitster@pobox.com>.
+
+Documentation
+-------------
+Documentation by Junio C Hamano and the git-list <git@vger.kernel.org>.
+
+GIT
+---
+Part of the linkgit:git[1] suite
index dab0a78fa890d0c0cd193d89b7f4ac9ed19fb001..791d4d4871b6a285878f8c43b3b0a76c7f63f57c 100644 (file)
@@ -93,6 +93,7 @@ OPTIONS
        as a regex).
 
 -n::
+--line-number::
        Prefix the line number to matching lines.
 
 -l::
index abe7bf9ff9eb9a3ddb1924938de071291520797a..3422765827985ed86402e2a271642b3e9714c1b2 100644 (file)
@@ -10,7 +10,7 @@ SYNOPSIS
 --------
 [verse]
 'git ls-remote' [--heads] [--tags]  [-u <exec> | --upload-pack <exec>]
-             <repository> <refs>...
+             <repository> [<refs>...]
 
 DESCRIPTION
 -----------
index 65eff66afe5990efc4af4f141809f355b7111bd3..a9c373c7b514fd01064dbf05557ddbfc04b3c1ee 100644 (file)
@@ -190,9 +190,9 @@ self-contained. Use `git index-pack --fix-thin`
 (see linkgit:git-index-pack[1]) to restore the self-contained property.
 
 --delta-base-offset::
-       A packed archive can express base object of a delta as
-       either 20-byte object name or as an offset in the
-       stream, but older version of git does not understand the
+       A packed archive can express the base object of a delta as
+       either 20-byte object name or as an offset in the
+       stream, but older versions of git don't understand the
        latter.  By default, 'git pack-objects' only uses the
        former format for better compatibility.  This option
        allows the command to use the latter format for
index 2d65cfefd5d2aeaafcbc0bb6e6705f8379b2f826..68263a6a538b3d4659ca9dc0afd2253170143fb6 100644 (file)
@@ -7,17 +7,17 @@ git-remote-ext - Bridge smart transport to external command.
 
 SYNOPSIS
 --------
-git remote add nick "ext::<command>[ <arguments>...]"
+git remote add <nick> "ext::<command>[ <arguments>...]"
 
 DESCRIPTION
 -----------
-This remote helper uses the specified 'program' to connect
+This remote helper uses the specified '<command>' to connect
 to a remote git server.
 
-Data written to stdin of this specified 'program' is assumed
+Data written to stdin of the specified '<command>' is assumed
 to be sent to a git:// server, git-upload-pack, git-receive-pack
 or git-upload-archive (depending on situation), and data read
-from stdout of this program is assumed to be received from
+from stdout of <command> is assumed to be received from
 the same service.
 
 Command and arguments are separated by an unescaped space.
@@ -40,7 +40,7 @@ The following sequences have a special meaning:
        git wants to invoke.
 
 '%G' (must be the first characters in an argument)::
-       This argument will not be passed to 'program'. Instead, it
+       This argument will not be passed to '<command>'. Instead, it
        will cause the helper to start by sending git:// service requests to
        the remote side with the service field set to an appropriate value and
        the repository field set to rest of the argument. Default is not to send
@@ -50,7 +50,7 @@ This is useful if remote side is git:// server accessed over
 some tunnel.
 
 '%V' (must be first characters in argument)::
-       This argument will not be passed to 'program'. Instead it sets
+       This argument will not be passed to '<command>'. Instead it sets
        the vhost field in the git:// service request (to rest of the argument).
        Default is not to send vhost in such request (if sent).
 
@@ -76,7 +76,7 @@ EXAMPLES:
 ---------
 This remote helper is transparently used by git when
 you use commands such as "git fetch <URL>", "git clone <URL>",
-, "git push <URL>" or "git remote add nick <URL>", where <URL>
+, "git push <URL>" or "git remote add <nick> <URL>", where <URL>
 begins with `ext::`.  Examples:
 
 "ext::ssh -i /home/foo/.ssh/somekey user&#64;host.example %S 'foo/repo'"::
index 3a23477ce72763b562258a25c3777dd57ac1a962..51de895822d6d79f970012c835d68b2cd8c8e136 100644 (file)
@@ -201,12 +201,12 @@ REF LIST ATTRIBUTES
 
 OPTIONS
 -------
-'option verbosity' <N>::
+'option verbosity' <n>::
        Changes the verbosity of messages displayed by the helper.
-       A value of 0 for N means that processes operate
+       A value of 0 for <n> means that processes operate
        quietly, and the helper produces only error output.
        1 is the default level of verbosity, and higher values
-       of N correspond to the number of -v flags passed on the
+       of <n> correspond to the number of -v flags passed on the
        command line.
 
 'option progress' \{'true'|'false'\}::
index 0ade2ce54efee3cd2241fc7e3009909eef5cf8bb..e161a40a73cb57557435e94c9444935da0828f1c 100644 (file)
@@ -66,7 +66,7 @@ COMMANDS
        Set the 'rewriteRoot' option in the [svn-remote] config.
 --rewrite-uuid=<UUID>;;
        Set the 'rewriteUUID' option in the [svn-remote] config.
---username=<USER>;;
+--username=<user>;;
        For transports that SVN handles authentication for (http,
        https, and plain svn), specify the username.  For other
        transports (eg svn+ssh://), you must include the username in
@@ -443,8 +443,8 @@ OPTIONS
        Only used with the 'init' command.
        These are passed directly to 'git init'.
 
--r <ARG>::
---revision <ARG>::
+-r <arg>::
+--revision <arg>::
           Used with the 'fetch' command.
 +
 This allows revision ranges for partial/cauterized history
index 65f76c544086458ec84322c73319d8b071288a0b..fa7ac12a3db2aeed7d35ab5e460b1c204c3bec37 100644 (file)
@@ -165,13 +165,12 @@ You can test which tag you have by doing
 
 which should return 0123456789abcdef.. if you have the new version.
 
-Sorry for inconvenience.
+Sorry for the inconvenience.
 ------------
 
 Does this seem a bit complicated?  It *should* be. There is no
-way that it would be correct to just "fix" it behind peoples
-backs. People need to know that their tags might have been
-changed.
+way that it would be correct to just "fix" it automatically.
+People need to know that their tags might have been changed.
 
 
 On Automatic following
@@ -189,9 +188,10 @@ the toplevel but not limited to them.  Mere mortals when pulling
 from each other do not necessarily want to automatically get
 private anchor point tags from the other person.
 
-You would notice "please pull" messages on the mailing list says
-repo URL and branch name alone.  This is designed to be easily
-cut&pasted to a 'git fetch' command line:
+Often, "please pull" messages on the mailing list just provide
+two pieces of information: a repo URL and a branch name; this
+is designed to be easily cut&pasted at the end of a 'git fetch'
+command line:
 
 ------------
 Linus, please pull from
@@ -207,14 +207,14 @@ becomes:
 $ git pull git://git..../proj.git master
 ------------
 
-In such a case, you do not want to automatically follow other's
-tags.
+In such a case, you do not want to automatically follow the other
+person's tags.
 
-One important aspect of git is it is distributed, and being
-distributed largely means there is no inherent "upstream" or
+One important aspect of git is its distributed nature, which
+largely means there is no inherent "upstream" or
 "downstream" in the system.  On the face of it, the above
 example might seem to indicate that the tag namespace is owned
-by upper echelon of people and tags only flow downwards, but
+by the upper echelon of people and that tags only flow downwards, but
 that is not the case.  It only shows that the usage pattern
 determines who are interested in whose tags.
 
@@ -232,7 +232,7 @@ this case.
 
 It may well be that among networking people, they may want to
 exchange the tags internal to their group, but in that workflow
-they are most likely tracking with each other's progress by
+they are most likely tracking each other's progress by
 having remote-tracking branches.  Again, the heuristic to automatically
 follow such tags is a good thing.
 
@@ -242,21 +242,21 @@ On Backdating Tags
 
 If you have imported some changes from another VCS and would like
 to add tags for major releases of your work, it is useful to be able
-to specify the date to embed inside of the tag object.  The data in
+to specify the date to embed inside of the tag object; such data in
 the tag object affects, for example, the ordering of tags in the
 gitweb interface.
 
 To set the date used in future tag objects, set the environment
-variable GIT_COMMITTER_DATE to one or more of the date and time.  The
-date and time can be specified in a number of ways; the most common
-is "YYYY-MM-DD HH:MM".
+variable GIT_COMMITTER_DATE (see the later discussion of possible
+values; the most common form is "YYYY-MM-DD HH:MM").
 
-An example follows.
+For example:
 
 ------------
 $ GIT_COMMITTER_DATE="2006-10-02 10:31" git tag -s v1.0.1
 ------------
 
+include::date-formats.txt[]
 
 SEE ALSO
 --------
index 7e7e12168eb69d43f6d7eea9cde2176e06fe73d5..15aebc60623d97053aa14f3e6463d12eb8f60f26 100644 (file)
@@ -632,7 +632,7 @@ Performing a three-way merge
 `merge`
 ^^^^^^^
 
-The attribute `merge` affects how three versions of a file is
+The attribute `merge` affects how three versions of a file are
 merged when a file-level merge is necessary during `git merge`,
 and other commands such as `git revert` and `git cherry-pick`.
 
@@ -646,15 +646,15 @@ Unset::
 
        Take the version from the current branch as the
        tentative merge result, and declare that the merge has
-       conflicts.  This is suitable for binary files that does
+       conflicts.  This is suitable for binary files that do
        not have a well-defined merge semantics.
 
 Unspecified::
 
        By default, this uses the same built-in 3-way merge
-       driver as is the case the `merge` attribute is set.
-       However, `merge.default` configuration variable can name
-       different merge driver to be used for paths to which the
+       driver as is the case when the `merge` attribute is set.
+       However, the `merge.default` configuration variable can name
+       different merge driver to be used with paths for which the
        `merge` attribute is unspecified.
 
 String::
index 44a2ef1de15bdce5d67a151a1cb6150031e57c7e..9c47ad885bd7565b45b9ac4e5e4a0798653d75e8 100644 (file)
@@ -165,7 +165,7 @@ limiting may be applied.
 -n 'number'::
 --max-count=<number>::
 
-       Limit the number of commits output.
+       Limit the number of commits to output.
 
 --skip=<number>::
 
index d03e624a3730903eb53bc5d43f74f8d31c177330..0b4e960d986724bb5a0fc806371fce3fb89e2dd3 100755 (executable)
@@ -1,7 +1,7 @@
 #!/bin/sh
 
 GVF=GIT-VERSION-FILE
-DEF_VER=v1.7.4.1
+DEF_VER=v1.7.4.2
 
 LF='
 '
index 775ee838c332c7311df34a98448fc3723c6bd95e..5c2b797554a25d5cecee28aa6d18fc885aa0b3e8 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -435,6 +435,7 @@ TEST_PROGRAMS_NEED_X += test-subprocess
 TEST_PROGRAMS_NEED_X += test-svn-fe
 TEST_PROGRAMS_NEED_X += test-treap
 TEST_PROGRAMS_NEED_X += test-index-version
+TEST_PROGRAMS_NEED_X += test-mktemp
 
 TEST_PROGRAMS = $(patsubst %,%$X,$(TEST_PROGRAMS_NEED_X))
 
@@ -1041,6 +1042,7 @@ ifeq ($(uname_S),HP-UX)
        NO_UNSETENV = YesPlease
        NO_HSTRERROR = YesPlease
        NO_SYS_SELECT_H = YesPlease
+       NO_FNMATCH_CASEFOLD = YesPlease
        SNPRINTF_RETURNS_BOGUS = YesPlease
        NO_NSEC = YesPlease
        ifeq ($(uname_R),B.11.00)
index 0362cfa3799b49cd56565df62e8b030789edfdbb..9a749551266dbe523bb3699ceea5261457f6a518 120000 (symlink)
--- a/RelNotes
+++ b/RelNotes
@@ -1 +1 @@
-Documentation/RelNotes/1.7.4.1.txt
\ No newline at end of file
+Documentation/RelNotes/1.7.4.2.txt
\ No newline at end of file
index 91ca00f05f7d648fa801a36b78c749f9d691ba43..ff140689ed2453809e7c3794c9989918e90df392 100644 (file)
--- a/abspath.c
+++ b/abspath.c
@@ -24,6 +24,10 @@ const char *make_absolute_path(const char *path)
        char *last_elem = NULL;
        struct stat st;
 
+       /* We've already done it */
+       if (path == buf || path == next_buf)
+               return path;
+
        if (strlcpy(buf, path, PATH_MAX) >= PATH_MAX)
                die ("Too long path: %.*s", 60, path);
 
index 42c906ea06b3d20d88ed6ba1c83d894d4e24f163..1d74763f58d893619501427bcee0cc04c2878a02 100644 (file)
@@ -21,8 +21,7 @@ static const char * const builtin_add_usage[] = {
 static int patch_interactive, add_interactive, edit_interactive;
 static int take_worktree_changes;
 
-struct update_callback_data
-{
+struct update_callback_data {
        int flags;
        int add_errors;
 };
index a231c0c7ca1c5ae75db84b38c0038777a63ba8d0..36e150768ba88e427e6257900d7ec4c67c8303c1 100644 (file)
@@ -204,6 +204,7 @@ struct line {
        unsigned hash : 24;
        unsigned flag : 8;
 #define LINE_COMMON     1
+#define LINE_PATCHED   2
 };
 
 /*
@@ -2085,7 +2086,8 @@ static int match_fragment(struct image *img,
 
        /* Quick hash check */
        for (i = 0; i < preimage_limit; i++)
-               if (preimage->line[i].hash != img->line[try_lno + i].hash)
+               if ((img->line[try_lno + i].flag & LINE_PATCHED) ||
+                   (preimage->line[i].hash != img->line[try_lno + i].hash))
                        return 0;
 
        if (preimage_limit == preimage->nr) {
@@ -2428,6 +2430,9 @@ static void update_image(struct image *img,
        memcpy(img->line + applied_pos,
               postimage->line,
               postimage->nr * sizeof(*img->line));
+       for (i = 0; i < postimage->nr; i++)
+               img->line[applied_pos + i].flag |= LINE_PATCHED;
+
        img->nr = nr;
 }
 
index aa30ec52692558b0d8ed3dc3b6d671185682026e..f6b03f750a0b69ef835caa0a2e4988f9a08abb85 100644 (file)
@@ -1312,8 +1312,7 @@ static void pass_blame(struct scoreboard *sb, struct origin *origin, int opt)
 /*
  * Information on commits, used for output.
  */
-struct commit_info
-{
+struct commit_info {
        const char *author;
        const char *author_mail;
        unsigned long author_time;
index fe8f2fcd524cd690c8601d9370079f9d9ea21df3..b9ba011f7b3f37a9448afae909d743249c3d8e1f 100644 (file)
@@ -390,6 +390,30 @@ static int matches_merge_filter(struct commit *commit)
        return (is_merged == (merge_filter == SHOW_MERGED));
 }
 
+static void add_verbose_info(struct strbuf *out, struct ref_item *item,
+                            int verbose, int abbrev)
+{
+       struct strbuf subject = STRBUF_INIT, stat = STRBUF_INIT;
+       const char *sub = " **** invalid ref ****";
+       struct commit *commit = item->commit;
+
+       if (commit && !parse_commit(commit)) {
+               struct pretty_print_context ctx = {0};
+               pretty_print_commit(CMIT_FMT_ONELINE, commit,
+                                   &subject, &ctx);
+               sub = subject.buf;
+       }
+
+       if (item->kind == REF_LOCAL_BRANCH)
+               fill_tracking_info(&stat, item->name, verbose > 1);
+
+       strbuf_addf(out, " %s %s%s",
+               find_unique_abbrev(item->commit->object.sha1, abbrev),
+               stat.buf, sub);
+       strbuf_release(&stat);
+       strbuf_release(&subject);
+}
+
 static void print_ref_item(struct ref_item *item, int maxwidth, int verbose,
                           int abbrev, int current, char *prefix)
 {
@@ -430,27 +454,9 @@ static void print_ref_item(struct ref_item *item, int maxwidth, int verbose,
 
        if (item->dest)
                strbuf_addf(&out, " -> %s", item->dest);
-       else if (verbose) {
-               struct strbuf subject = STRBUF_INIT, stat = STRBUF_INIT;
-               const char *sub = " **** invalid ref ****";
-
-               commit = item->commit;
-               if (commit && !parse_commit(commit)) {
-                       struct pretty_print_context ctx = {0};
-                       pretty_print_commit(CMIT_FMT_ONELINE, commit,
-                                           &subject, &ctx);
-                       sub = subject.buf;
-               }
-
-               if (item->kind == REF_LOCAL_BRANCH)
-                       fill_tracking_info(&stat, item->name, verbose > 1);
-
-               strbuf_addf(&out, " %s %s%s",
-                       find_unique_abbrev(item->commit->object.sha1, abbrev),
-                       stat.buf, sub);
-               strbuf_release(&stat);
-               strbuf_release(&subject);
-       }
+       else if (verbose)
+               /* " f7c0c00 [ahead 58, behind 197] vcs-svn: drop obj_pool.h" */
+               add_verbose_info(&out, item, verbose, abbrev);
        printf("%s\n", out.buf);
        strbuf_release(&name);
        strbuf_release(&out);
index cd7f56e6c4b6e1b1059ffa0eae91b46e579b9e97..e98576f22ee3aeb9caef3b18b3775b5aabb7da4b 100644 (file)
@@ -678,7 +678,7 @@ static const char *unique_tracking_name(const char *name)
 int cmd_checkout(int argc, const char **argv, const char *prefix)
 {
        struct checkout_opts opts;
-       unsigned char rev[20];
+       unsigned char rev[20], branch_rev[20];
        const char *arg;
        struct branch_info new;
        struct tree *source_tree = NULL;
@@ -832,18 +832,21 @@ int cmd_checkout(int argc, const char **argv, const char *prefix)
                argc--;
 
                new.name = arg;
-               if ((new.commit = lookup_commit_reference_gently(rev, 1))) {
-                       setup_branch_path(&new);
+               setup_branch_path(&new);
 
-                       if ((check_ref_format(new.path) == CHECK_REF_FORMAT_OK) &&
-                           resolve_ref(new.path, rev, 1, NULL))
-                               ;
-                       else
-                               new.path = NULL;
+               if (check_ref_format(new.path) == CHECK_REF_FORMAT_OK &&
+                   resolve_ref(new.path, branch_rev, 1, NULL))
+                       hashcpy(rev, branch_rev);
+               else
+                       new.path = NULL; /* not an existing branch */
+
+               if (!(new.commit = lookup_commit_reference_gently(rev, 1))) {
+                       /* not a commit */
+                       source_tree = parse_tree_indirect(rev);
+               } else {
                        parse_commit(new.commit);
                        source_tree = new.commit->tree;
-               } else
-                       source_tree = parse_tree_indirect(rev);
+               }
 
                if (!source_tree)                   /* case (1): want a tree */
                        die("reference is not a tree: %s", arg);
index 60d9a64280b0318b1248b229d2ff99b27eb0e5c6..2ee1fa984620de4fad79ce94d4f993f5e83a053d 100644 (file)
@@ -413,7 +413,7 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
        if (path)
                repo = xstrdup(make_nonrelative_path(repo_name));
        else if (!strchr(repo_name, ':'))
-               repo = xstrdup(make_absolute_path(repo_name));
+               die("repository '%s' does not exist", repo_name);
        else
                repo = repo_name;
        is_local = path && !is_bundle;
index d7f55e3d46e215f94c94f1f40b5cc1ec6907701e..d71e1e0c9c27c4d03cd02b4deaacec67af33917a 100644 (file)
@@ -119,13 +119,13 @@ static struct option builtin_commit_options[] = {
 
        OPT_GROUP("Commit message options"),
        OPT_FILENAME('F', "file", &logfile, "read message from file"),
-       OPT_STRING(0, "author", &force_author, "AUTHOR", "override author for commit"),
-       OPT_STRING(0, "date", &force_date, "DATE", "override date for commit"),
-       OPT_CALLBACK('m', "message", &message, "MESSAGE", "commit message", opt_parse_m),
-       OPT_STRING('c', "reedit-message", &edit_message, "COMMIT", "reuse and edit message from specified commit"),
-       OPT_STRING('C', "reuse-message", &use_message, "COMMIT", "reuse message from specified commit"),
-       OPT_STRING(0, "fixup", &fixup_message, "COMMIT", "use autosquash formatted message to fixup specified commit"),
-       OPT_STRING(0, "squash", &squash_message, "COMMIT", "use autosquash formatted message to squash specified commit"),
+       OPT_STRING(0, "author", &force_author, "author", "override author for commit"),
+       OPT_STRING(0, "date", &force_date, "date", "override date for commit"),
+       OPT_CALLBACK('m', "message", &message, "message", "commit message", opt_parse_m),
+       OPT_STRING('c', "reedit-message", &edit_message, "commit", "reuse and edit message from specified commit"),
+       OPT_STRING('C', "reuse-message", &use_message, "commit", "reuse message from specified commit"),
+       OPT_STRING(0, "fixup", &fixup_message, "commit", "use autosquash formatted message to fixup specified commit"),
+       OPT_STRING(0, "squash", &squash_message, "commit", "use autosquash formatted message to squash specified commit"),
        OPT_BOOLEAN(0, "reset-author", &renew_authorship, "the commit is authored by me now (used with -C-c/--amend)"),
        OPT_BOOLEAN('s', "signoff", &signoff, "add Signed-off-by:"),
        OPT_FILENAME('t', "template", &template_file, "use specified template file"),
@@ -634,7 +634,7 @@ static int prepare_to_commit(const char *index_file, const char *prefix,
                if (strbuf_read_file(&sb, git_path("SQUASH_MSG"), 0) < 0)
                        die_errno("could not read SQUASH_MSG");
                hook_arg1 = "squash";
-       } else if (template_file && !stat(template_file, &statbuf)) {
+       } else if (template_file) {
                if (strbuf_read_file(&sb, template_file, 0) < 0)
                        die_errno("could not read '%s'", template_file);
                hook_arg1 = "template";
index ca4a0db4a79241d7ded005483b4693967eea636f..b8b18e3c94b5730afb343089821e8e622a5b00ee 100644 (file)
@@ -52,7 +52,7 @@ static struct option builtin_config_options[] = {
        OPT_BOOLEAN(0, "global", &use_global_config, "use global config file"),
        OPT_BOOLEAN(0, "system", &use_system_config, "use system config file"),
        OPT_BOOLEAN(0, "local", &use_local_config, "use repository config file"),
-       OPT_STRING('f', "file", &given_config_file, "FILE", "use given config file"),
+       OPT_STRING('f', "file", &given_config_file, "file", "use given config file"),
        OPT_GROUP("Action"),
        OPT_BIT(0, "get", &actions, "get value: name [value-regex]", ACTION_GET),
        OPT_BIT(0, "get-all", &actions, "get all values: key [value-regex]", ACTION_GET_ALL),
index 342129fdbdc534bdf9277de710f8e7b7ba11c5c4..3ba26dc8192d0a75d7e330d2f73d0d9841a6216c 100644 (file)
@@ -63,7 +63,7 @@ static inline struct commit_name *find_commit_name(const unsigned char *peeled)
        return n;
 }
 
-static int set_util(void *chain)
+static int set_util(void *chain, void *data)
 {
        struct commit_name *n;
        for (n = chain; n; n = n->next) {
@@ -289,7 +289,7 @@ static void describe(const char *arg, int last_one)
                fprintf(stderr, "searching to describe %s\n", arg);
 
        if (!have_util) {
-               for_each_hash(&names, set_util);
+               for_each_hash(&names, set_util, NULL);
                have_util = 1;
        }
 
index c8fd46b872780b27b09ad70316fa164d855f3220..b18fc85c4c1eecde36a7e953e1997bab1b97628b 100644 (file)
@@ -619,9 +619,9 @@ int cmd_fast_export(int argc, const char **argv, const char *prefix)
                OPT_CALLBACK(0, "tag-of-filtered-object", &tag_of_filtered_mode, "mode",
                             "select handling of tags that tag filtered objects",
                             parse_opt_tag_of_filtered_mode),
-               OPT_STRING(0, "export-marks", &export_filename, "FILE",
+               OPT_STRING(0, "export-marks", &export_filename, "file",
                             "Dump marks to this file"),
-               OPT_STRING(0, "import-marks", &import_filename, "FILE",
+               OPT_STRING(0, "import-marks", &import_filename, "file",
                             "Import marks from this file"),
                OPT_BOOLEAN(0, "fake-missing-tagger", &fake_missing_tagger,
                             "Fake a tagger when tags lack one"),
index 357f3cdbbfd601e2ce3f1261a4d6b30c1257cda4..7efecfe1cf6b14a53d619b4bcc4760c81a492747 100644 (file)
@@ -49,7 +49,7 @@ static struct option builtin_fetch_options[] = {
                    "fetch from all remotes"),
        OPT_BOOLEAN('a', "append", &append,
                    "append to .git/FETCH_HEAD instead of overwriting"),
-       OPT_STRING(0, "upload-pack", &upload_pack, "PATH",
+       OPT_STRING(0, "upload-pack", &upload_pack, "path",
                   "path to upload pack on remote end"),
        OPT__FORCE(&force, "force overwrite of local branch"),
        OPT_BOOLEAN('m', "multiple", &multiple,
@@ -69,9 +69,9 @@ static struct option builtin_fetch_options[] = {
        OPT_BOOLEAN('u', "update-head-ok", &update_head_ok,
                    "allow updating of HEAD ref"),
        OPT_BOOLEAN(0, "progress", &progress, "force progress reporting"),
-       OPT_STRING(0, "depth", &depth, "DEPTH",
+       OPT_STRING(0, "depth", &depth, "depth",
                   "deepen history of shallow clone"),
-       { OPTION_STRING, 0, "submodule-prefix", &submodule_prefix, "DIR",
+       { OPTION_STRING, 0, "submodule-prefix", &submodule_prefix, "dir",
                   "prepend this to submodule path output", PARSE_OPT_HIDDEN },
        OPT_END()
 };
index fdf7131efd25618250f382dff178ca38f9b42c77..bb0f93208fc6c3e418f9db5bcaec4b79c57e2bec 100644 (file)
@@ -40,8 +40,7 @@ enum work_type {WORK_SHA1, WORK_FILE};
  * threads. The producer adds struct work_items to 'todo' and the
  * consumers pick work items from the same array.
  */
-struct work_item
-{
+struct work_item {
        enum work_type type;
        char *name;
 
@@ -865,7 +864,7 @@ int cmd_grep(int argc, const char **argv, const char *prefix)
                OPT_BOOLEAN('F', "fixed-strings", &opt.fixed,
                        "interpret patterns as fixed strings"),
                OPT_GROUP(""),
-               OPT_BOOLEAN('n', NULL, &opt.linenum, "show line numbers"),
+               OPT_BOOLEAN('n', "line-number", &opt.linenum, "show line numbers"),
                OPT_NEGBIT('h', NULL, &opt.pathname, "don't show filenames", 1),
                OPT_BIT('H', NULL, &opt.pathname, "show filenames", 1),
                OPT_NEGBIT(0, "full-name", &opt.relative,
index 8dc5c0b5410d4bb57607bab690126f22d954dd7a..c7e600db4745c80fddcb14986bc192d80630aa51 100644 (file)
@@ -13,8 +13,7 @@
 static const char index_pack_usage[] =
 "git index-pack [-v] [-o <index-file>] [ --keep | --keep=<msg> ] [--strict] (<pack-file> | --stdin [--fix-thin] [<pack-file>])";
 
-struct object_entry
-{
+struct object_entry {
        struct pack_idx_entry idx;
        unsigned long size;
        unsigned int hdr_size;
@@ -44,8 +43,7 @@ struct base_data {
 #define FLAG_LINK (1u<<20)
 #define FLAG_CHECKED (1u<<21)
 
-struct delta_entry
-{
+struct delta_entry {
        union delta_base base;
        int obj_no;
 };
index d8c6c28d2fcc3bd0744f071da536215141dc0d0b..0f43d2ec78555339cfb788bc173780acdaa2139d 100644 (file)
@@ -1352,6 +1352,23 @@ static const char * const cherry_usage[] = {
        NULL
 };
 
+static void print_commit(char sign, struct commit *commit, int verbose,
+                        int abbrev)
+{
+       if (!verbose) {
+               printf("%c %s\n", sign,
+                      find_unique_abbrev(commit->object.sha1, abbrev));
+       } else {
+               struct strbuf buf = STRBUF_INIT;
+               struct pretty_print_context ctx = {0};
+               pretty_print_commit(CMIT_FMT_ONELINE, commit, &buf, &ctx);
+               printf("%c %s %s\n", sign,
+                      find_unique_abbrev(commit->object.sha1, abbrev),
+                      buf.buf);
+               strbuf_release(&buf);
+       }
+}
+
 int cmd_cherry(int argc, const char **argv, const char *prefix)
 {
        struct rev_info revs;
@@ -1436,22 +1453,7 @@ int cmd_cherry(int argc, const char **argv, const char *prefix)
                commit = list->item;
                if (has_commit_patch_id(commit, &ids))
                        sign = '-';
-
-               if (verbose) {
-                       struct strbuf buf = STRBUF_INIT;
-                       struct pretty_print_context ctx = {0};
-                       pretty_print_commit(CMIT_FMT_ONELINE, commit,
-                                           &buf, &ctx);
-                       printf("%c %s %s\n", sign,
-                              find_unique_abbrev(commit->object.sha1, abbrev),
-                              buf.buf);
-                       strbuf_release(&buf);
-               }
-               else {
-                       printf("%c %s\n", sign,
-                              find_unique_abbrev(commit->object.sha1, abbrev));
-               }
-
+               print_commit(sign, commit, verbose, abbrev);
                list = list->next;
        }
 
index a682043fe5b91317bd7e998fbb95afc9b3ccf368..f9fb26dc3319200de96181d9e30aad75693d1704 100644 (file)
@@ -194,7 +194,7 @@ static struct option builtin_merge_options[] = {
                "merge strategy to use", option_parse_strategy),
        OPT_CALLBACK('X', "strategy-option", &xopts, "option=value",
                "option for selected merge strategy", option_parse_x),
-       OPT_CALLBACK('m', "message", &merge_msg, "MESSAGE",
+       OPT_CALLBACK('m', "message", &merge_msg, "message",
                "merge commit message (for a non-fast-forward merge)",
                option_parse_message),
        OPT__VERBOSITY(&verbosity),
@@ -795,6 +795,32 @@ static void add_strategies(const char *string, unsigned attr)
 
 }
 
+static void write_merge_msg(void)
+{
+       int fd = open(git_path("MERGE_MSG"), O_WRONLY | O_CREAT, 0666);
+       if (fd < 0)
+               die_errno("Could not open '%s' for writing",
+                         git_path("MERGE_MSG"));
+       if (write_in_full(fd, merge_msg.buf, merge_msg.len) != merge_msg.len)
+               die_errno("Could not write to '%s'", git_path("MERGE_MSG"));
+       close(fd);
+}
+
+static void read_merge_msg(void)
+{
+       strbuf_reset(&merge_msg);
+       if (strbuf_read_file(&merge_msg, git_path("MERGE_MSG"), 0) < 0)
+               die_errno("Could not read from '%s'", git_path("MERGE_MSG"));
+}
+
+static void run_prepare_commit_msg(void)
+{
+       write_merge_msg();
+       run_hook(get_index_file(), "prepare-commit-msg",
+                git_path("MERGE_MSG"), "merge", NULL, NULL);
+       read_merge_msg();
+}
+
 static int merge_trivial(void)
 {
        unsigned char result_tree[20], result_commit[20];
@@ -806,6 +832,7 @@ static int merge_trivial(void)
        parent->next = xmalloc(sizeof(*parent->next));
        parent->next->item = remoteheads->item;
        parent->next->next = NULL;
+       run_prepare_commit_msg();
        commit_tree(merge_msg.buf, result_tree, parent, result_commit, NULL);
        finish(result_commit, "In-index merge");
        drop_save();
@@ -835,6 +862,7 @@ static int finish_automerge(struct commit_list *common,
        }
        free_commit_list(remoteheads);
        strbuf_addch(&merge_msg, '\n');
+       run_prepare_commit_msg();
        commit_tree(merge_msg.buf, result_tree, parents, result_commit, NULL);
        strbuf_addf(&buf, "Merge made by %s.", wt_strategy);
        finish(result_commit, buf.buf);
@@ -1316,14 +1344,7 @@ int cmd_merge(int argc, const char **argv, const char *prefix)
                        die_errno("Could not write to '%s'", git_path("MERGE_HEAD"));
                close(fd);
                strbuf_addch(&merge_msg, '\n');
-               fd = open(git_path("MERGE_MSG"), O_WRONLY | O_CREAT, 0666);
-               if (fd < 0)
-                       die_errno("Could not open '%s' for writing",
-                                 git_path("MERGE_MSG"));
-               if (write_in_full(fd, merge_msg.buf, merge_msg.len) !=
-                       merge_msg.len)
-                       die_errno("Could not write to '%s'", git_path("MERGE_MSG"));
-               close(fd);
+               write_merge_msg();
                fd = open(git_path("MERGE_MODE"), O_WRONLY | O_CREAT | O_TRUNC, 0666);
                if (fd < 0)
                        die_errno("Could not open '%s' for writing",
index 4d5556e2cb5bccaf0100d9f5019e1a1c493e35e7..0aab150c52c839512b82b5efc6e978b7a80653e3 100644 (file)
@@ -537,16 +537,16 @@ static int add(int argc, const char **argv, const char *prefix)
        const unsigned char *note;
        struct msg_arg msg = { 0, 0, STRBUF_INIT };
        struct option options[] = {
-               { OPTION_CALLBACK, 'm', "message", &msg, "MSG",
+               { OPTION_CALLBACK, 'm', "message", &msg, "msg",
                        "note contents as a string", PARSE_OPT_NONEG,
                        parse_msg_arg},
-               { OPTION_CALLBACK, 'F', "file", &msg, "FILE",
+               { OPTION_CALLBACK, 'F', "file", &msg, "file",
                        "note contents in a file", PARSE_OPT_NONEG,
                        parse_file_arg},
-               { OPTION_CALLBACK, 'c', "reedit-message", &msg, "OBJECT",
+               { OPTION_CALLBACK, 'c', "reedit-message", &msg, "object",
                        "reuse and edit specified note object", PARSE_OPT_NONEG,
                        parse_reedit_arg},
-               { OPTION_CALLBACK, 'C', "reuse-message", &msg, "OBJECT",
+               { OPTION_CALLBACK, 'C', "reuse-message", &msg, "object",
                        "reuse specified note object", PARSE_OPT_NONEG,
                        parse_reuse_arg},
                OPT__FORCE(&force, "replace existing notes"),
@@ -682,16 +682,16 @@ static int append_edit(int argc, const char **argv, const char *prefix)
        const char * const *usage;
        struct msg_arg msg = { 0, 0, STRBUF_INIT };
        struct option options[] = {
-               { OPTION_CALLBACK, 'm', "message", &msg, "MSG",
+               { OPTION_CALLBACK, 'm', "message", &msg, "msg",
                        "note contents as a string", PARSE_OPT_NONEG,
                        parse_msg_arg},
-               { OPTION_CALLBACK, 'F', "file", &msg, "FILE",
+               { OPTION_CALLBACK, 'F', "file", &msg, "file",
                        "note contents in a file", PARSE_OPT_NONEG,
                        parse_file_arg},
-               { OPTION_CALLBACK, 'c', "reedit-message", &msg, "OBJECT",
+               { OPTION_CALLBACK, 'c', "reedit-message", &msg, "object",
                        "reuse and edit specified note object", PARSE_OPT_NONEG,
                        parse_reedit_arg},
-               { OPTION_CALLBACK, 'C', "reuse-message", &msg, "OBJECT",
+               { OPTION_CALLBACK, 'C', "reuse-message", &msg, "object",
                        "reuse specified note object", PARSE_OPT_NONEG,
                        parse_reuse_arg},
                OPT_END()
index 512530022edac398f8541ee6c400c7312659e730..49a0472a9bd28274c4be1352996e700a1db4b94a 100644 (file)
@@ -73,6 +73,8 @@ int get_one_patchid(unsigned char *next_sha1, git_SHA_CTX *ctx)
                        p += 7;
                else if (!memcmp(line, "From ", 5))
                        p += 5;
+               else if (!memcmp(line, "\\ ", 2) && 12 < strlen(line))
+                       continue;
 
                if (!get_sha1_hex(p, next_sha1)) {
                        found_next = 1;
index e655eb7695faba13c4d9e8f25b9649ffec7195be..31da418cf4a9e4732edb8201c80b07f7ddadbac1 100644 (file)
@@ -64,17 +64,17 @@ static void set_refspecs(const char **refs, int nr)
        }
 }
 
-static void setup_push_tracking(void)
+static void setup_push_upstream(void)
 {
        struct strbuf refspec = STRBUF_INIT;
        struct branch *branch = branch_get(NULL);
        if (!branch)
                die("You are not currently on a branch.");
        if (!branch->merge_nr || !branch->merge)
-               die("The current branch %s is not tracking anything.",
+               die("The current branch %s has no upstream branch.",
                    branch->name);
        if (branch->merge_nr != 1)
-               die("The current branch %s is tracking multiple branches, "
+               die("The current branch %s has multiple upstream branches, "
                    "refusing to push.", branch->name);
        strbuf_addf(&refspec, "%s:%s", branch->name, branch->merge[0]->src);
        add_refspec(refspec.buf);
@@ -88,8 +88,8 @@ static void setup_default_push_refspecs(void)
                add_refspec(":");
                break;
 
-       case PUSH_DEFAULT_TRACKING:
-               setup_push_tracking();
+       case PUSH_DEFAULT_UPSTREAM:
+               setup_push_upstream();
                break;
 
        case PUSH_DEFAULT_CURRENT:
index 73c89ed15ba2fb0c470141499c3390b77cf1d81c..93c92814cf28855aee87cabf4a3b906e11a36125 100644 (file)
@@ -104,8 +104,8 @@ int cmd_read_tree(int argc, const char **argv, const char *unused_prefix)
        struct unpack_trees_options opts;
        int prefix_set = 0;
        const struct option read_tree_options[] = {
-               { OPTION_CALLBACK, 0, "index-output", NULL, "FILE",
-                 "write resulting index to <FILE>",
+               { OPTION_CALLBACK, 0, "index-output", NULL, "file",
+                 "write resulting index to <file>",
                  PARSE_OPT_NONEG, index_output_cb },
                OPT_SET_INT(0, "empty", &read_empty,
                            "only empty the index", 1),
index 246a2bc72bf9e89454a27265f6dbcd904698feab..7cf48abca857f049243dfab7c95fea70d216ea93 100644 (file)
@@ -376,7 +376,7 @@ int cmd_tag(int argc, const char **argv, const char *prefix)
                OPT_GROUP("Tag creation options"),
                OPT_BOOLEAN('a', NULL, &annotate,
                                        "annotated tag, needs a message"),
-               OPT_CALLBACK('m', NULL, &msg, "MESSAGE",
+               OPT_CALLBACK('m', NULL, &msg, "message",
                             "tag message", parse_msg_arg),
                OPT_FILENAME('F', NULL, &msgfile, "read message from file"),
                OPT_BOOLEAN('s', NULL, &sign, "annotated and GPG-signed tag"),
diff --git a/cache.h b/cache.h
index 3abf8950bdd9f950b65ee4544e0cfe6517f1912a..f2dabefd9d75fddf0eb48e42a0907db6ac162b08 100644 (file)
--- a/cache.h
+++ b/cache.h
@@ -545,7 +545,6 @@ extern int assume_unchanged;
 extern int prefer_symlink_refs;
 extern int log_all_ref_updates;
 extern int warn_ambiguous_refs;
-extern int unique_abbrev_extra_length;
 extern int shared_repository;
 extern const char *apply_default_whitespace;
 extern const char *apply_default_ignorewhitespace;
@@ -571,7 +570,7 @@ extern enum safe_crlf safe_crlf;
 enum auto_crlf {
        AUTO_CRLF_FALSE = 0,
        AUTO_CRLF_TRUE = 1,
-       AUTO_CRLF_INPUT = -1,
+       AUTO_CRLF_INPUT = -1
 };
 
 extern enum auto_crlf auto_crlf;
@@ -608,7 +607,7 @@ enum rebase_setup_type {
 enum push_default_type {
        PUSH_DEFAULT_NOTHING = 0,
        PUSH_DEFAULT_MATCHING,
-       PUSH_DEFAULT_TRACKING,
+       PUSH_DEFAULT_UPSTREAM,
        PUSH_DEFAULT_CURRENT
 };
 
@@ -899,7 +898,8 @@ extern struct packed_git {
        time_t mtime;
        int pack_fd;
        unsigned pack_local:1,
-                pack_keep:1;
+                pack_keep:1,
+                do_not_close:1;
        unsigned char sha1[20];
        /* something like ".git/objects/pack/xxxxx.pack" */
        char pack_name[FLEX_ARRAY]; /* more */
index 659c87c3ee90c23064f617e3bcf3ace12e32ea04..41985130d1473573af2cfd4ca97a579e999b0c0b 100644 (file)
--- a/commit.h
+++ b/commit.h
@@ -68,8 +68,7 @@ enum cmit_fmt {
        CMIT_FMT_UNSPECIFIED
 };
 
-struct pretty_print_context
-{
+struct pretty_print_context {
        int abbrev;
        const char *subject;
        const char *after_subject;
index 54756dbb05ba99ab1679f17a50f04c3f1cede8e6..5061214f73d2d51cfd1d49b97b4e69be913928bd 100644 (file)
@@ -21,14 +21,16 @@ static inline uint32_t default_swab32(uint32_t val)
 
 #if defined(__GNUC__) && (defined(__i386__) || defined(__x86_64__))
 
-#define bswap32(x) ({ \
-       uint32_t __res; \
-       if (__builtin_constant_p(x)) { \
-               __res = default_swab32(x); \
-       } else { \
-               __asm__("bswap %0" : "=r" (__res) : "0" ((uint32_t)(x))); \
-       } \
-       __res; })
+#define bswap32 git_bswap32
+static inline uint32_t git_bswap32(uint32_t x)
+{
+       uint32_t result;
+       if (__builtin_constant_p(x))
+               result = default_swab32(x);
+       else
+               __asm__("bswap %0" : "=r" (result) : "0" (x));
+       return result;
+}
 
 #elif defined(_MSC_VER) && (defined(_M_IX86) || defined(_M_X64))
 
index cafc1eb08a71dd60566a7389ed606e777cf17fc8..14211c6214ea4654e0bb9dd25b29d7b28ac6141d 100644 (file)
@@ -233,6 +233,22 @@ int mingw_getpagesize(void);
 #define getpagesize mingw_getpagesize
 #endif
 
+struct rlimit {
+       unsigned int rlim_cur;
+};
+#define RLIMIT_NOFILE 0
+
+static inline int getrlimit(int resource, struct rlimit *rlp)
+{
+       if (resource != RLIMIT_NOFILE) {
+               errno = EINVAL;
+               return -1;
+       }
+
+       rlp->rlim_cur = 2048;
+       return 0;
+}
+
 /* Use mingw_lstat() instead of lstat()/stat() and
  * mingw_fstat() instead of fstat() on Windows.
  */
index 625e0518767712583f917762634c2fc852c4d2eb..822ef8365ce29c48e4b04fcccc47ba2e0b3a255f 100644 (file)
--- a/config.c
+++ b/config.c
@@ -20,8 +20,7 @@ static int zlib_compression_seen;
 
 const char *config_exclusive_filename = NULL;
 
-struct config_item
-{
+struct config_item {
        struct config_item *next;
        char *name;
        char *value;
@@ -499,13 +498,6 @@ static int git_default_core_config(const char *var, const char *value)
                return 0;
        }
 
-       if (!strcmp(var, "core.abbrevguard")) {
-               unique_abbrev_extra_length = git_config_int(var, value);
-               if (unique_abbrev_extra_length < 0)
-                       unique_abbrev_extra_length = 0;
-               return 0;
-       }
-
        if (!strcmp(var, "core.bare")) {
                is_bare_repository_cfg = git_config_bool(var, value);
                return 0;
@@ -737,8 +729,10 @@ static int git_default_push_config(const char *var, const char *value)
                        push_default = PUSH_DEFAULT_NOTHING;
                else if (!strcmp(value, "matching"))
                        push_default = PUSH_DEFAULT_MATCHING;
-               else if (!strcmp(value, "tracking"))
-                       push_default = PUSH_DEFAULT_TRACKING;
+               else if (!strcmp(value, "upstream"))
+                       push_default = PUSH_DEFAULT_UPSTREAM;
+               else if (!strcmp(value, "tracking")) /* deprecated */
+                       push_default = PUSH_DEFAULT_UPSTREAM;
                else if (!strcmp(value, "current"))
                        push_default = PUSH_DEFAULT_CURRENT;
                else {
index cc518f3c890158d29e751e008436e0c3790746ee..5eb4a5164397e3a34be10690025a9cd472261db9 100755 (executable)
@@ -1,8 +1,8 @@
-#!/bin/bash
+#!/bin/sh
 # Copyright 2008 Lukas Sandström <luksan@gmail.com>
 #
 # AppendPatch - A script to be used together with ExternalEditor
-# for Mozilla Thunderbird to properly include pathes inline i e-mails.
+# for Mozilla Thunderbird to properly include patches inline in e-mails.
 
 # ExternalEditor can be downloaded at http://globs.org/articles.php?lng=en&pg=2
 
index d5aebed48df3387e966a23b6ee460dc2244f728e..7eb51b16ed03e650f3af11383c5c43c00d7d9812 100644 (file)
--- a/convert.c
+++ b/convert.c
@@ -18,7 +18,7 @@ enum action {
        CRLF_TEXT,
        CRLF_INPUT,
        CRLF_CRLF,
-       CRLF_AUTO,
+       CRLF_AUTO
 };
 
 struct text_stat {
diff --git a/diff.c b/diff.c
index 5422c438826254f36d1e00af0e8b882690661276..3fd9e0c70315727f835f39d9a0230ee9f24e7ea8 100644 (file)
--- a/diff.c
+++ b/diff.c
@@ -245,6 +245,15 @@ static int fill_mmfile(mmfile_t *mf, struct diff_filespec *one)
        return 0;
 }
 
+/* like fill_mmfile, but only for size, so we can avoid retrieving blob */
+static unsigned long diff_filespec_size(struct diff_filespec *one)
+{
+       if (!DIFF_FILE_VALID(one))
+               return 0;
+       diff_populate_filespec(one, 1);
+       return one->size;
+}
+
 static int count_trailing_blank(mmfile_t *mf, unsigned ws_rule)
 {
        char *ptr = mf->ptr;
@@ -606,16 +615,14 @@ static void diff_words_append(char *line, unsigned long len,
        buffer->text.ptr[buffer->text.size] = '\0';
 }
 
-struct diff_words_style_elem
-{
+struct diff_words_style_elem {
        const char *prefix;
        const char *suffix;
        const char *color; /* NULL; filled in by the setup code if
                            * color is enabled */
 };
 
-struct diff_words_style
-{
+struct diff_words_style {
        enum diff_words_type type;
        struct diff_words_style_elem new, old, ctx;
        const char *newline;
@@ -2079,25 +2086,28 @@ static void builtin_diffstat(const char *name_a, const char *name_b,
                data->is_unmerged = 1;
                return;
        }
-       if (complete_rewrite) {
+
+       if (diff_filespec_is_binary(one) || diff_filespec_is_binary(two)) {
+               data->is_binary = 1;
+               data->added = diff_filespec_size(two);
+               data->deleted = diff_filespec_size(one);
+       }
+
+       else if (complete_rewrite) {
                diff_populate_filespec(one, 0);
                diff_populate_filespec(two, 0);
                data->deleted = count_lines(one->data, one->size);
                data->added = count_lines(two->data, two->size);
-               goto free_and_return;
        }
-       if (fill_mmfile(&mf1, one) < 0 || fill_mmfile(&mf2, two) < 0)
-               die("unable to read files to diff");
 
-       if (diff_filespec_is_binary(one) || diff_filespec_is_binary(two)) {
-               data->is_binary = 1;
-               data->added = mf2.size;
-               data->deleted = mf1.size;
-       } else {
+       else {
                /* Crazy xdl interfaces.. */
                xpparam_t xpp;
                xdemitconf_t xecfg;
 
+               if (fill_mmfile(&mf1, one) < 0 || fill_mmfile(&mf2, two) < 0)
+                       die("unable to read files to diff");
+
                memset(&xpp, 0, sizeof(xpp));
                memset(&xecfg, 0, sizeof(xecfg));
                xpp.flags = o->xdl_opts;
@@ -2105,7 +2115,6 @@ static void builtin_diffstat(const char *name_a, const char *name_b,
                              &xpp, &xecfg);
        }
 
- free_and_return:
        diff_free_filespec_data(one);
        diff_free_filespec_data(two);
 }
index df41be56deab60d4d39a45920a1e62b05d0474f6..0cd4c1305ba82b39bb8455dd6779fec2cd692e02 100644 (file)
@@ -170,7 +170,7 @@ static int estimate_similarity(struct diff_filespec *src,
         * and the final score computation below would not have a
         * divide-by-zero issue.
         */
-       if (base_size * (MAX_SCORE-minimum_score) < delta_size * MAX_SCORE)
+       if (max_size * (MAX_SCORE-minimum_score) < delta_size * MAX_SCORE)
                return 0;
 
        if (!src->cnt_data && diff_populate_filespec(src, 0))
@@ -247,7 +247,8 @@ struct file_similarity {
 };
 
 static int find_identical_files(struct file_similarity *src,
-                               struct file_similarity *dst)
+                               struct file_similarity *dst,
+                               struct diff_options *options)
 {
        int renames = 0;
 
@@ -277,6 +278,8 @@ static int find_identical_files(struct file_similarity *src,
                        }
                        /* Give higher scores to sources that haven't been used already */
                        score = !source->rename_used;
+                       if (source->rename_used && options->detect_rename != DIFF_DETECT_COPY)
+                               continue;
                        score += basename_same(source, target);
                        if (score > best_score) {
                                best = p;
@@ -306,11 +309,12 @@ static void free_similarity_list(struct file_similarity *p)
        }
 }
 
-static int find_same_files(void *ptr)
+static int find_same_files(void *ptr, void *data)
 {
        int ret;
        struct file_similarity *p = ptr;
        struct file_similarity *src = NULL, *dst = NULL;
+       struct diff_options *options = data;
 
        /* Split the hash list up into sources and destinations */
        do {
@@ -329,7 +333,7 @@ static int find_same_files(void *ptr)
         * If we have both sources *and* destinations, see if
         * we can match them up
         */
-       ret = (src && dst) ? find_identical_files(src, dst) : 0;
+       ret = (src && dst) ? find_identical_files(src, dst, options) : 0;
 
        /* Free the hashes and return the number of renames found */
        free_similarity_list(src);
@@ -377,7 +381,7 @@ static void insert_file_table(struct hash_table *table, int src_dst, int index,
  * and then during the second round we try to match
  * cache-dirty entries as well.
  */
-static int find_exact_renames(void)
+static int find_exact_renames(struct diff_options *options)
 {
        int i;
        struct hash_table file_table;
@@ -390,7 +394,7 @@ static int find_exact_renames(void)
                insert_file_table(&file_table, 1, i, rename_dst[i].two);
 
        /* Find the renames */
-       i = for_each_hash(&file_table, find_same_files);
+       i = for_each_hash(&file_table, find_same_files, options);
 
        /* .. and free the hash data structure */
        free_hash(&file_table);
@@ -414,6 +418,27 @@ static void record_if_better(struct diff_score m[], struct diff_score *o)
                m[worst] = *o;
 }
 
+static int find_renames(struct diff_score *mx, int dst_cnt, int minimum_score, int copies)
+{
+       int count = 0, i;
+
+       for (i = 0; i < dst_cnt * NUM_CANDIDATE_PER_DST; i++) {
+               struct diff_rename_dst *dst;
+
+               if ((mx[i].dst < 0) ||
+                   (mx[i].score < minimum_score))
+                       break; /* there is no more usable pair. */
+               dst = &rename_dst[mx[i].dst];
+               if (dst->pair)
+                       continue; /* already done, either exact or fuzzy. */
+               if (!copies && rename_src[mx[i].src].one->rename_used)
+                       continue;
+               record_rename_pair(mx[i].dst, mx[i].src, mx[i].score);
+               count++;
+       }
+       return count;
+}
+
 void diffcore_rename(struct diff_options *options)
 {
        int detect_rename = options->detect_rename;
@@ -467,7 +492,7 @@ void diffcore_rename(struct diff_options *options)
         * We really want to cull the candidates list early
         * with cheap tests in order to avoid doing deltas.
         */
-       rename_count = find_exact_renames();
+       rename_count = find_exact_renames(options);
 
        /* Did we only want exact renames? */
        if (minimum_score == MAX_SCORE)
@@ -536,33 +561,9 @@ void diffcore_rename(struct diff_options *options)
        /* cost matrix sorted by most to least similar pair */
        qsort(mx, dst_cnt * NUM_CANDIDATE_PER_DST, sizeof(*mx), score_compare);
 
-       for (i = 0; i < dst_cnt * NUM_CANDIDATE_PER_DST; i++) {
-               struct diff_rename_dst *dst;
-
-               if ((mx[i].dst < 0) ||
-                   (mx[i].score < minimum_score))
-                       break; /* there is no more usable pair. */
-               dst = &rename_dst[mx[i].dst];
-               if (dst->pair)
-                       continue; /* already done, either exact or fuzzy. */
-               if (rename_src[mx[i].src].one->rename_used)
-                       continue;
-               record_rename_pair(mx[i].dst, mx[i].src, mx[i].score);
-               rename_count++;
-       }
-
-       for (i = 0; i < dst_cnt * NUM_CANDIDATE_PER_DST; i++) {
-               struct diff_rename_dst *dst;
-
-               if ((mx[i].dst < 0) ||
-                   (mx[i].score < minimum_score))
-                       break; /* there is no more usable pair. */
-               dst = &rename_dst[mx[i].dst];
-               if (dst->pair)
-                       continue; /* already done, either exact or fuzzy. */
-               record_rename_pair(mx[i].dst, mx[i].src, mx[i].score);
-               rename_count++;
-       }
+       rename_count += find_renames(mx, dst_cnt, minimum_score, 0);
+       if (detect_rename == DIFF_DETECT_COPY)
+               rename_count += find_renames(mx, dst_cnt, minimum_score, 1);
        free(mx);
 
  cleanup:
index 9564475f429312a467a020106f7443112367d5da..c3efbb96084de04465f7eff45376cadc3ab2526b 100644 (file)
@@ -21,7 +21,6 @@ int prefer_symlink_refs;
 int is_bare_repository_cfg = -1; /* unspecified */
 int log_all_ref_updates = -1; /* unspecified */
 int warn_ambiguous_refs = 1;
-int unique_abbrev_extra_length;
 int repository_format_version;
 const char *git_commit_encoding;
 const char *git_log_output_encoding;
index 970d8470ed7c350337f28570fd2c111186a7941d..b3ba778924908946a0e20ebfdae9bc2058e8a55e 100644 (file)
@@ -166,8 +166,7 @@ Format of STDIN stream:
 #define DEPTH_BITS 13
 #define MAX_DEPTH ((1<<DEPTH_BITS)-1)
 
-struct object_entry
-{
+struct object_entry {
        struct pack_idx_entry idx;
        struct object_entry *next;
        uint32_t type : TYPE_BITS,
@@ -175,16 +174,14 @@ struct object_entry
                depth : DEPTH_BITS;
 };
 
-struct object_entry_pool
-{
+struct object_entry_pool {
        struct object_entry_pool *next_pool;
        struct object_entry *next_free;
        struct object_entry *end;
        struct object_entry entries[FLEX_ARRAY]; /* more */
 };
 
-struct mark_set
-{
+struct mark_set {
        union {
                struct object_entry *marked[1024];
                struct mark_set *sets[1024];
@@ -192,57 +189,49 @@ struct mark_set
        unsigned int shift;
 };
 
-struct last_object
-{
+struct last_object {
        struct strbuf data;
        off_t offset;
        unsigned int depth;
        unsigned no_swap : 1;
 };
 
-struct mem_pool
-{
+struct mem_pool {
        struct mem_pool *next_pool;
        char *next_free;
        char *end;
        uintmax_t space[FLEX_ARRAY]; /* more */
 };
 
-struct atom_str
-{
+struct atom_str {
        struct atom_str *next_atom;
        unsigned short str_len;
        char str_dat[FLEX_ARRAY]; /* more */
 };
 
 struct tree_content;
-struct tree_entry
-{
+struct tree_entry {
        struct tree_content *tree;
        struct atom_str *name;
-       struct tree_entry_ms
-       {
+       struct tree_entry_ms {
                uint16_t mode;
                unsigned char sha1[20];
        } versions[2];
 };
 
-struct tree_content
-{
+struct tree_content {
        unsigned int entry_capacity; /* must match avail_tree_content */
        unsigned int entry_count;
        unsigned int delta_depth;
        struct tree_entry *entries[FLEX_ARRAY]; /* more */
 };
 
-struct avail_tree_content
-{
+struct avail_tree_content {
        unsigned int entry_capacity; /* must match tree_content */
        struct avail_tree_content *next_avail;
 };
 
-struct branch
-{
+struct branch {
        struct branch *table_next_branch;
        struct branch *active_next_branch;
        const char *name;
@@ -254,16 +243,14 @@ struct branch
        unsigned char sha1[20];
 };
 
-struct tag
-{
+struct tag {
        struct tag *next_tag;
        const char *name;
        unsigned int pack_id;
        unsigned char sha1[20];
 };
 
-struct hash_list
-{
+struct hash_list {
        struct hash_list *next;
        unsigned char sha1[20];
 };
@@ -274,8 +261,7 @@ typedef enum {
        WHENSPEC_NOW
 } whenspec_type;
 
-struct recent_command
-{
+struct recent_command {
        struct recent_command *prev;
        struct recent_command *next;
        char *buf;
@@ -871,6 +857,7 @@ static void start_packfile(void)
        p = xcalloc(1, sizeof(*p) + strlen(tmpfile) + 2);
        strcpy(p->pack_name, tmpfile);
        p->pack_fd = pack_fd;
+       p->do_not_close = 1;
        pack_file = sha1fd(pack_fd, p->pack_name);
 
        hdr.hdr_signature = htonl(PACK_SIGNATURE);
index fbe85ac05fd2d945d645365dc086460003fa7f27..0608edae3fe7b07b852b30281fea978806798c99 100644 (file)
@@ -1,8 +1,7 @@
 #ifndef FETCH_PACK_H
 #define FETCH_PACK_H
 
-struct fetch_pack_args
-{
+struct fetch_pack_args {
        const char *uploadpack;
        int unpacklimit;
        int depth;
index 75c68d948fd3105272f893ff2f901007519f62f5..3ef4861d04ed5fed14d31b92e047a03cf5362970 100755 (executable)
@@ -1,8 +1,7 @@
 #!/bin/sh
 
 echo "/* Automatically generated by $0 */
-struct cmdname_help
-{
+struct cmdname_help {
     char name[16];
     char help[80];
 };
index c21e33c8d133af0e9e0ae3edaffd0a5593ff4ac3..415a8d04ccc4f313eb111a3bbfbf2af2382beebd 100755 (executable)
@@ -288,10 +288,12 @@ bisect_visualize() {
 
        if test $# = 0
        then
-               case "${DISPLAY+set}${SESSIONNAME+set}${MSYSTEM+set}${SECURITYSESSIONID+set}" in
-               '')     set git log ;;
-               set*)   set gitk ;;
-               esac
+               if test -n "${DISPLAY+set}${SESSIONNAME+set}${MSYSTEM+set}${SECURITYSESSIONID+set}" &&
+                  type gitk >/dev/null 2>&1; then
+                       set gitk
+               else
+                       set git log
+               fi
        else
                case "$1" in
                git*|tig) ;;
index 9c23622ed5ee9b60d40921ae74dd1149e1d68b8c..bf947b1ec361aafeef58d43ef8eae979699b35ac 100644 (file)
@@ -214,7 +214,10 @@ extern char *gitbasename(char *);
 #define is_dir_sep(c) ((c) == '/')
 #endif
 
-#ifdef __GNUC__
+#if __HP_cc >= 61000
+#define NORETURN __attribute__((noreturn))
+#define NORETURN_PTR
+#elif defined(__GNUC__)
 #define NORETURN __attribute__((__noreturn__))
 #define NORETURN_PTR __attribute__((__noreturn__))
 #elif defined(_MSC_VER)
index 77d4aee20ee5b8b01f9a0e3d1f8dbc9f7fdf3eb9..78ce49e9846e908e0d5b262e2a12c2308ed8ac88 100644 (file)
@@ -182,7 +182,7 @@ run_merge_tool () {
                        fi
                        check_unchanged
                else
-                       "$merge_tool_path" -f -d -c "wincmd l" \
+                       "$merge_tool_path" -R -f -d -c "wincmd l" \
                                "$LOCAL" "$REMOTE"
                fi
                ;;
@@ -193,7 +193,7 @@ run_merge_tool () {
                                "$LOCAL" "$MERGED" "$REMOTE"
                        check_unchanged
                else
-                       "$merge_tool_path" -f -d -c "wincmd l" \
+                       "$merge_tool_path" -R -f -d -c "wincmd l" \
                                "$LOCAL" "$REMOTE"
                fi
                ;;
index 1cc2ba6e09614fa55ad205145a3bdacfb78bf283..9b950be28d75b173ed81d5cf83271e9a8c4e6dff 100644 (file)
@@ -55,7 +55,8 @@ get_remote_url () {
 }
 
 get_default_remote () {
-       curr_branch=$(git symbolic-ref -q HEAD | sed -e 's|^refs/heads/||')
+       curr_branch=$(git symbolic-ref -q HEAD)
+       curr_branch="${curr_branch#refs/heads/}"
        origin=$(git config --get "branch.$curr_branch.remote")
        echo ${origin:-origin}
 }
index 8b9058971767dbb4d94e996876f6ba7ed178ddd6..3a13397e057edf88d2c810490ec3d7d755be2009 100755 (executable)
@@ -423,6 +423,7 @@ cmd_update()
                cmd_init "--" "$@" || return
        fi
 
+       cloned_modules=
        module_list "$@" |
        while read mode sha1 stage path
        do
@@ -442,6 +443,7 @@ cmd_update()
                if ! test -d "$path"/.git -o -f "$path"/.git
                then
                        module_clone "$path" "$url" "$reference"|| exit
+                       cloned_modules="$cloned_modules;$name"
                        subsha1=
                else
                        subsha1=$(clear_local_git_env; cd "$path" &&
@@ -469,6 +471,13 @@ cmd_update()
                                die "Unable to fetch in submodule path '$path'"
                        fi
 
+                       # Is this something we just cloned?
+                       case ";$cloned_modules;" in
+                       *";$name;"*)
+                               # then there is no local change to integrate
+                               update_module= ;;
+                       esac
+
                        case "$update_module" in
                        rebase)
                                command="git rebase"
index 1b9369d1a72f625bcb66e021bdab8559930cb0eb..46186ab909ebe12a659bda7690ee5511a2cf7794 100755 (executable)
@@ -2913,8 +2913,10 @@ sub parse_date {
        $date{'iso-8601'}  = sprintf "%04d-%02d-%02dT%02d:%02d:%02dZ",
                             1900+$year, 1+$mon, $mday, $hour ,$min, $sec;
 
-       $tz =~ m/^([+\-][0-9][0-9])([0-9][0-9])$/;
-       my $local = $epoch + ((int $1 + ($2/60)) * 3600);
+       my ($tz_sign, $tz_hour, $tz_min) =
+               ($tz =~ m/^([-+])(\d\d)(\d\d)$/);
+       $tz_sign = ($tz_sign eq '-' ? -1 : +1);
+       my $local = $epoch + $tz_sign*((($tz_hour*60) + $tz_min)*60);
        ($sec, $min, $hour, $mday, $mon, $year, $wday, $yday) = gmtime($local);
        $date{'hour_local'} = $hour;
        $date{'minute_local'} = $min;
@@ -3468,7 +3470,7 @@ sub run_highlighter {
        close $fd;
        open $fd, quote_command(git_cmd(), "cat-file", "blob", $hash)." | ".
                  quote_command($highlight_bin).
-                 " --fragment --syntax $syntax |"
+                 " --replace-tabs=8 --fragment --syntax $syntax |"
                or die_error(500, "Couldn't open file or run syntax highlighter");
        return $fd;
 }
@@ -4906,7 +4908,6 @@ sub git_log_body {
                next if !%co;
                my $commit = $co{'id'};
                my $ref = format_ref_marker($refs, $commit);
-               my %ad = parse_date($co{'author_epoch'});
                git_print_header_div('commit',
                               "<span class=\"age\">$co{'age_string'}</span>" .
                               esc_html($co{'title'}) . $ref,
@@ -7064,7 +7065,7 @@ sub git_feed {
        if (defined($commitlist[0])) {
                %latest_commit = %{$commitlist[0]};
                my $latest_epoch = $latest_commit{'committer_epoch'};
-               %latest_date   = parse_date($latest_epoch);
+               %latest_date   = parse_date($latest_epoch, $latest_commit{'comitter_tz'});
                my $if_modified = $cgi->http('IF_MODIFIED_SINCE');
                if (defined $if_modified) {
                        my $since;
@@ -7195,7 +7196,7 @@ XML
                if (($i >= 20) && ((time - $co{'author_epoch'}) > 48*60*60)) {
                        last;
                }
-               my %cd = parse_date($co{'author_epoch'});
+               my %cd = parse_date($co{'author_epoch'}, $co{'author_tz'});
 
                # get list of changed files
                open my $fd, "-|", git_cmd(), "diff-tree", '-r', @diff_opts,
diff --git a/hash.c b/hash.c
index 1cd4c9d5c0945994b84bb25edd6e4685cf76b5c5..749ecfe4841a6a2af6ba4fdc6c540fd3016178f1 100644 (file)
--- a/hash.c
+++ b/hash.c
@@ -81,7 +81,7 @@ void **insert_hash(unsigned int hash, void *ptr, struct hash_table *table)
        return insert_hash_entry(hash, ptr, table);
 }
 
-int for_each_hash(const struct hash_table *table, int (*fn)(void *))
+int for_each_hash(const struct hash_table *table, int (*fn)(void *, void *), void *data)
 {
        int sum = 0;
        unsigned int i;
@@ -92,7 +92,7 @@ int for_each_hash(const struct hash_table *table, int (*fn)(void *))
                void *ptr = array->ptr;
                array++;
                if (ptr) {
-                       int val = fn(ptr);
+                       int val = fn(ptr, data);
                        if (val < 0)
                                return val;
                        sum += val;
diff --git a/hash.h b/hash.h
index 69e33a47b9861df9ac12c354eae180b4f8fea857..b875ce67c49eb39a8ca8ad6a688a334985db0534 100644 (file)
--- a/hash.h
+++ b/hash.h
@@ -30,7 +30,7 @@ struct hash_table {
 
 extern void *lookup_hash(unsigned int hash, const struct hash_table *table);
 extern void **insert_hash(unsigned int hash, void *ptr, struct hash_table *table);
-extern int for_each_hash(const struct hash_table *table, int (*fn)(void *));
+extern int for_each_hash(const struct hash_table *table, int (*fn)(void *, void *), void *data);
 extern void free_hash(struct hash_table *table);
 
 static inline void init_hash(struct hash_table *table)
index ff41a0e183dd3a449f5136c6d1488a31b4a8960b..d18346c0f5c9ce73f3fe9a1efc7b1b63e7380bb8 100644 (file)
@@ -82,8 +82,7 @@ static int helper_status;
 
 static struct object_list *objects;
 
-struct repo
-{
+struct repo {
        char *url;
        char *path;
        int path_len;
@@ -108,8 +107,7 @@ enum transfer_state {
        COMPLETE
 };
 
-struct transfer_request
-{
+struct transfer_request {
        struct object *obj;
        char *url;
        char *dest;
@@ -127,8 +125,7 @@ struct transfer_request
 
 static struct transfer_request *request_queue_head;
 
-struct xml_ctx
-{
+struct xml_ctx {
        char *name;
        int len;
        char *cdata;
@@ -136,8 +133,7 @@ struct xml_ctx
        void *userData;
 };
 
-struct remote_lock
-{
+struct remote_lock {
        char *url;
        char *owner;
        char *token;
@@ -156,8 +152,7 @@ struct remote_lock
 /* Flags that remote_ls passes to callback functions */
 #define IS_DIR (1u << 0)
 
-struct remote_ls_ctx
-{
+struct remote_ls_ctx {
        char *path;
        void (*userFunc)(struct remote_ls_ctx *ls);
        void *userData;
index 18bd6504beb99ab68f360c4fa93011efae42fdfb..9bc8114c3bb2f6f87f7f61962a64c4e5b012dcf8 100644 (file)
@@ -3,8 +3,7 @@
 #include "walker.h"
 #include "http.h"
 
-struct alt_base
-{
+struct alt_base {
        char *base;
        int got_indices;
        struct packed_git *packs;
@@ -18,8 +17,7 @@ enum object_request_state {
        COMPLETE
 };
 
-struct object_request
-{
+struct object_request {
        struct walker *walker;
        unsigned char sha1[20];
        struct alt_base *repo;
diff --git a/http.h b/http.h
index 5c6e243dde3c654a3c0a705146fb15395c27fb95..e9ed3c2e8272e43208e75459ec29fd8b6548ae4d 100644 (file)
--- a/http.h
+++ b/http.h
 #define NO_CURL_IOCTL
 #endif
 
-struct slot_results
-{
+struct slot_results {
        CURLcode curl_result;
        long http_code;
 };
 
-struct active_request_slot
-{
+struct active_request_slot {
        CURL *curl;
        FILE *local;
        int in_use;
@@ -62,8 +60,7 @@ struct active_request_slot
        struct active_request_slot *next;
 };
 
-struct buffer
-{
+struct buffer {
        struct strbuf buf;
        size_t posn;
 };
@@ -149,8 +146,7 @@ extern int http_fetch_ref(const char *base, struct ref *ref);
 extern int http_get_info_packs(const char *base_url,
        struct packed_git **packs_head);
 
-struct http_pack_request
-{
+struct http_pack_request {
        char *url;
        struct packed_git *target;
        struct packed_git **lst;
@@ -166,8 +162,7 @@ extern int finish_http_pack_request(struct http_pack_request *preq);
 extern void release_http_pack_request(struct http_pack_request *preq);
 
 /* Helpers for fetching object */
-struct http_object_request
-{
+struct http_object_request {
        char *url;
        char tmpfile[PATH_MAX];
        int localfile;
index 16c2dbeab95a0f4099e3de8badf688bb4dee8189..42d52cb5bc17e9bb289a6b6c3e90c97d241660a2 100644 (file)
@@ -83,10 +83,8 @@ struct rename_df_conflict_info {
  * Since we want to write the index eventually, we cannot reuse the index
  * for these (temporary) data.
  */
-struct stage_data
-{
-       struct
-       {
+struct stage_data {
+       struct {
                unsigned mode;
                unsigned char sha[20];
        } stages[4];
@@ -403,8 +401,7 @@ static void make_room_for_directories_of_df_conflicts(struct merge_options *o,
        }
 }
 
-struct rename
-{
+struct rename {
        struct diff_filepair *pair;
        struct stage_data *src_entry;
        struct stage_data *dst_entry;
@@ -717,8 +714,7 @@ static void update_file(struct merge_options *o,
 
 /* Low level file merging, update and removal */
 
-struct merge_file_info
-{
+struct merge_file_info {
        unsigned char sha[20];
        unsigned mode;
        unsigned clean:1,
index 9d0cb9a114cb3e5b0a4a4a132b9289ef18d8ae21..c3bf21dbcb4b79fdc815ef80ae5c970aafd02bbf 100644 (file)
@@ -2,8 +2,7 @@
 #include "pack.h"
 #include "pack-revindex.h"
 
-struct idx_entry
-{
+struct idx_entry {
        off_t                offset;
        const unsigned char *sha1;
        unsigned int nr;
index 31ec5d24763b13b3e97c79f7a3edd6e7799bcd91..d1b12fe979b34ac9bbf2ff637934b96f3878a53d 100644 (file)
@@ -141,7 +141,7 @@ struct option {
        { OPTION_NUMBER, 0, NULL, (v), NULL, (h), \
          PARSE_OPT_NOARG | PARSE_OPT_NONEG, (f) }
 #define OPT_FILENAME(s, l, v, h)    { OPTION_FILENAME, (s), (l), (v), \
-                                      "FILE", (h) }
+                                      "file", (h) }
 #define OPT_COLOR_FLAG(s, l, v, h) \
        { OPTION_CALLBACK, (s), (l), (v), "when", (h), PARSE_OPT_OPTARG, \
                parse_opt_color_flag_cb, (intptr_t)"always" }
index 205e48aa3a7b912005565ac9c296205a897a1476..a86ab709c25b5e110aa2708941cea560f82c1fa8 100644 (file)
@@ -99,7 +99,7 @@ increase notwithstanding).
 
 use Carp qw(carp croak); # but croak is bad - throw instead
 use Error qw(:try);
-use Cwd qw(abs_path);
+use Cwd qw(abs_path cwd);
 use IPC::Open2 qw(open2);
 use Fcntl qw(SEEK_SET SEEK_CUR);
 }
@@ -396,7 +396,16 @@ See C<command_close_bidi_pipe()> for details.
 
 sub command_bidi_pipe {
        my ($pid, $in, $out);
+       my ($self) = _maybe_self(@_);
+       local %ENV = %ENV;
+       my $cwd_save = undef;
+       if ($self) {
+               shift;
+               $cwd_save = cwd();
+               _setup_git_cmd_env($self);
+       }
        $pid = open2($in, $out, 'git', @_);
+       chdir($cwd_save) if $cwd_save;
        return ($pid, $in, $out, join(' ', @_));
 }
 
@@ -843,7 +852,7 @@ sub _open_hash_and_insert_object_if_needed {
 
        ($self->{hash_object_pid}, $self->{hash_object_in},
         $self->{hash_object_out}, $self->{hash_object_ctx}) =
-               command_bidi_pipe(qw(hash-object -w --stdin-paths --no-filters));
+               $self->command_bidi_pipe(qw(hash-object -w --stdin-paths --no-filters));
 }
 
 sub _close_hash_and_insert_object {
@@ -932,7 +941,7 @@ sub _open_cat_blob_if_needed {
 
        ($self->{cat_blob_pid}, $self->{cat_blob_in},
         $self->{cat_blob_out}, $self->{cat_blob_ctx}) =
-               command_bidi_pipe(qw(cat-file --batch));
+               $self->command_bidi_pipe(qw(cat-file --batch));
 }
 
 sub _close_cat_blob {
@@ -1279,6 +1288,14 @@ sub _command_common_pipe {
 # for the given repository and execute the git command.
 sub _cmd_exec {
        my ($self, @args) = @_;
+       _setup_git_cmd_env($self);
+       _execv_git_cmd(@args);
+       die qq[exec "@args" failed: $!];
+}
+
+# set up the appropriate state for git command
+sub _setup_git_cmd_env {
+       my $self = shift;
        if ($self) {
                $self->repo_path() and $ENV{'GIT_DIR'} = $self->repo_path();
                $self->repo_path() and $self->wc_path()
@@ -1286,8 +1303,6 @@ sub _cmd_exec {
                $self->wc_path() and chdir($self->wc_path());
                $self->wc_subdir() and chdir($self->wc_subdir());
        }
-       _execv_git_cmd(@args);
-       die qq[exec "@args" failed: $!];
 }
 
 # Execute the given Git command ($_[0]) with arguments ($_[1..])
index 27730c334cb433ef749a0efc5353a7f38032559c..e194f6a12862a4a4479fd714b550d426f8ee1313 100644 (file)
@@ -417,6 +417,8 @@ static unsigned int pack_used_ctr;
 static unsigned int pack_mmap_calls;
 static unsigned int peak_pack_open_windows;
 static unsigned int pack_open_windows;
+static unsigned int pack_open_fds;
+static unsigned int pack_max_fds;
 static size_t peak_pack_mapped;
 static size_t pack_mapped;
 struct packed_git *packed_git;
@@ -594,8 +596,10 @@ static int unuse_one_window(struct packed_git *current, int keep_fd)
                        lru_l->next = lru_w->next;
                else {
                        lru_p->windows = lru_w->next;
-                       if (!lru_p->windows && lru_p->pack_fd != keep_fd) {
+                       if (!lru_p->windows && lru_p->pack_fd != -1
+                               && lru_p->pack_fd != keep_fd) {
                                close(lru_p->pack_fd);
+                               pack_open_fds--;
                                lru_p->pack_fd = -1;
                        }
                }
@@ -680,8 +684,10 @@ void free_pack_by_name(const char *pack_name)
                if (strcmp(pack_name, p->pack_name) == 0) {
                        clear_delta_base_cache();
                        close_pack_windows(p);
-                       if (p->pack_fd != -1)
+                       if (p->pack_fd != -1) {
                                close(p->pack_fd);
+                               pack_open_fds--;
+                       }
                        close_pack_index(p);
                        free(p->bad_object_sha1);
                        *pp = p->next;
@@ -707,9 +713,29 @@ static int open_packed_git_1(struct packed_git *p)
        if (!p->index_data && open_pack_index(p))
                return error("packfile %s index unavailable", p->pack_name);
 
+       if (!pack_max_fds) {
+               struct rlimit lim;
+               unsigned int max_fds;
+
+               if (getrlimit(RLIMIT_NOFILE, &lim))
+                       die_errno("cannot get RLIMIT_NOFILE");
+
+               max_fds = lim.rlim_cur;
+
+               /* Save 3 for stdin/stdout/stderr, 22 for work */
+               if (25 < max_fds)
+                       pack_max_fds = max_fds - 25;
+               else
+                       pack_max_fds = 1;
+       }
+
+       while (pack_max_fds <= pack_open_fds && unuse_one_window(NULL, -1))
+               ; /* nothing */
+
        p->pack_fd = git_open_noatime(p->pack_name, p);
        if (p->pack_fd < 0 || fstat(p->pack_fd, &st))
                return -1;
+       pack_open_fds++;
 
        /* If we created the struct before we had the pack we lack size. */
        if (!p->pack_size) {
@@ -761,6 +787,7 @@ static int open_packed_git(struct packed_git *p)
                return 0;
        if (p->pack_fd != -1) {
                close(p->pack_fd);
+               pack_open_fds--;
                p->pack_fd = -1;
        }
        return -1;
@@ -786,14 +813,13 @@ unsigned char *use_pack(struct packed_git *p,
 {
        struct pack_window *win = *w_cursor;
 
-       if (p->pack_fd == -1 && open_packed_git(p))
-               die("packfile %s cannot be accessed", p->pack_name);
-
        /* Since packfiles end in a hash of their content and it's
         * pointless to ask for an offset into the middle of that
         * hash, and the in_window function above wouldn't match
         * don't allow an offset too close to the end of the file.
         */
+       if (!p->pack_size && p->pack_fd == -1 && open_packed_git(p))
+               die("packfile %s cannot be accessed", p->pack_name);
        if (offset > (p->pack_size - 20))
                die("offset beyond end of packfile (truncated pack?)");
 
@@ -807,6 +833,10 @@ unsigned char *use_pack(struct packed_git *p,
                if (!win) {
                        size_t window_align = packed_git_window_size / 2;
                        off_t len;
+
+                       if (p->pack_fd == -1 && open_packed_git(p))
+                               die("packfile %s cannot be accessed", p->pack_name);
+
                        win = xcalloc(1, sizeof(*win));
                        win->offset = (offset / window_align) * window_align;
                        len = p->pack_size - win->offset;
@@ -824,6 +854,12 @@ unsigned char *use_pack(struct packed_git *p,
                                die("packfile %s cannot be mapped: %s",
                                        p->pack_name,
                                        strerror(errno));
+                       if (!win->offset && win->len == p->pack_size
+                               && !p->do_not_close) {
+                               close(p->pack_fd);
+                               pack_open_fds--;
+                               p->pack_fd = -1;
+                       }
                        pack_mmap_calls++;
                        pack_open_windows++;
                        if (pack_mapped > peak_pack_mapped)
@@ -918,6 +954,9 @@ struct packed_git *parse_pack_index(unsigned char *sha1, const char *idx_path)
 
 void install_packed_git(struct packed_git *pack)
 {
+       if (pack->pack_fd != -1)
+               pack_open_fds++;
+
        pack->next = packed_git;
        packed_git = pack;
 }
@@ -935,8 +974,6 @@ static void prepare_packed_git_one(char *objdir, int local)
        sprintf(path, "%s/pack", objdir);
        len = strlen(path);
        dir = opendir(path);
-       while (!dir && errno == EMFILE && unuse_one_window(NULL, -1))
-               dir = opendir(path);
        if (!dir) {
                if (errno != ENOENT)
                        error("unable to open object pack directory: %s: %s",
@@ -1092,14 +1129,6 @@ static int git_open_noatime(const char *name, struct packed_git *p)
                if (fd >= 0)
                        return fd;
 
-               /* Might the failure be insufficient file descriptors? */
-               if (errno == EMFILE) {
-                       if (unuse_one_window(p, -1))
-                               continue;
-                       else
-                               return -1;
-               }
-
                /* Might the failure be due to O_NOATIME? */
                if (errno != ENOENT && sha1_file_open_flag) {
                        sha1_file_open_flag = 0;
@@ -1931,6 +1960,27 @@ off_t find_pack_entry_one(const unsigned char *sha1,
        return 0;
 }
 
+static int is_pack_valid(struct packed_git *p)
+{
+       /* An already open pack is known to be valid. */
+       if (p->pack_fd != -1)
+               return 1;
+
+       /* If the pack has one window completely covering the
+        * file size, the pack is known to be valid even if
+        * the descriptor is not currently open.
+        */
+       if (p->windows) {
+               struct pack_window *w = p->windows;
+
+               if (!w->offset && w->len == p->pack_size)
+                       return 1;
+       }
+
+       /* Force the pack to open to prove its valid. */
+       return !open_packed_git(p);
+}
+
 static int find_pack_entry(const unsigned char *sha1, struct pack_entry *e)
 {
        static struct packed_git *last_found = (void *)1;
@@ -1960,7 +2010,7 @@ static int find_pack_entry(const unsigned char *sha1, struct pack_entry *e)
                         * it may have been deleted since the index
                         * was loaded!
                         */
-                       if (p->pack_fd == -1 && open_packed_git(p)) {
+                       if (!is_pack_valid(p)) {
                                error("packfile %s cannot be accessed", p->pack_name);
                                goto next;
                        }
@@ -2359,8 +2409,6 @@ static int write_loose_object(const unsigned char *sha1, char *hdr, int hdrlen,
 
        filename = sha1_file_name(sha1);
        fd = create_tmpfile(tmpfile, sizeof(tmpfile), filename);
-       while (fd < 0 && errno == EMFILE && unuse_one_window(NULL, -1))
-               fd = create_tmpfile(tmpfile, sizeof(tmpfile), filename);
        if (fd < 0) {
                if (errno == EACCES)
                        return error("insufficient permission for adding an object to repository database %s\n", get_object_directory());
index 709ff2eee64cf106191ad274bede82a95d00e2a3..faea58dc8c27de23e8fbaff17b39cb9e57708510 100644 (file)
@@ -208,9 +208,7 @@ const char *find_unique_abbrev(const unsigned char *sha1, int len)
                if (exists
                    ? !status
                    : status == SHORT_NAME_NOT_FOUND) {
-                       int cut_at = len + unique_abbrev_extra_length;
-                       cut_at = (cut_at < 40) ? cut_at : 40;
-                       hex[cut_at] = 0;
+                       hex[len] = 0;
                        return hex;
                }
                len++;
index 675a91f93821421aa79de51857b22a4960da8ec1..4ce7dedee07efced23c1214de71e0687d7cb297a 100644 (file)
--- a/strbuf.h
+++ b/strbuf.h
@@ -1,42 +1,7 @@
 #ifndef STRBUF_H
 #define STRBUF_H
 
-/*
- * Strbuf's can be use in many ways: as a byte array, or to store arbitrary
- * long, overflow safe strings.
- *
- * Strbufs has some invariants that are very important to keep in mind:
- *
- * 1. the ->buf member is always malloc-ed, hence strbuf's can be used to
- *    build complex strings/buffers whose final size isn't easily known.
- *
- *    It is NOT legal to copy the ->buf pointer away.
- *    `strbuf_detach' is the operation that detaches a buffer from its shell
- *    while keeping the shell valid wrt its invariants.
- *
- * 2. the ->buf member is a byte array that has at least ->len + 1 bytes
- *    allocated. The extra byte is used to store a '\0', allowing the ->buf
- *    member to be a valid C-string. Every strbuf function ensures this
- *    invariant is preserved.
- *
- *    Note that it is OK to "play" with the buffer directly if you work it
- *    that way:
- *
- *    strbuf_grow(sb, SOME_SIZE);
- *       ... Here, the memory array starting at sb->buf, and of length
- *       ... strbuf_avail(sb) is all yours, and you are sure that
- *       ... strbuf_avail(sb) is at least SOME_SIZE.
- *    strbuf_setlen(sb, sb->len + SOME_OTHER_SIZE);
- *
- *    Of course, SOME_OTHER_SIZE must be smaller or equal to strbuf_avail(sb).
- *
- *    Doing so is safe, though if it has to be done in many places, adding the
- *    missing API to the strbuf module is the way to go.
- *
- *    XXX: do _not_ assume that the area that is yours is of size ->alloc - 1
- *         even if it's true in the current implementation. Alloc is somehow a
- *         "private" member that should not be messed with.
- */
+/* See Documentation/technical/api-strbuf.txt */
 
 #include <assert.h>
 
index 494693898b89fe2f8145b483ea7e366e9b1192c1..bda69839832d2030c15bbd86c4d8d79aa3cc4785 100644 (file)
@@ -5,8 +5,7 @@ struct string_list_item {
        char *string;
        void *util;
 };
-struct string_list
-{
+struct string_list {
        struct string_list_item *items;
        unsigned int nr, alloc;
        unsigned int strdup_strings:1;
index 6f1c10722f744f4a27f18dae4867b15ecbf57d49..e9f2b19e1c867b870b0b5f3ef3db3c871fe20689 100644 (file)
@@ -152,17 +152,69 @@ void handle_ignore_submodules_arg(struct diff_options *diffopt,
                die("bad --ignore-submodules argument: %s", arg);
 }
 
+static int prepare_submodule_summary(struct rev_info *rev, const char *path,
+               struct commit *left, struct commit *right,
+               int *fast_forward, int *fast_backward)
+{
+       struct commit_list *merge_bases, *list;
+
+       init_revisions(rev, NULL);
+       setup_revisions(0, NULL, rev, NULL);
+       rev->left_right = 1;
+       rev->first_parent_only = 1;
+       left->object.flags |= SYMMETRIC_LEFT;
+       add_pending_object(rev, &left->object, path);
+       add_pending_object(rev, &right->object, path);
+       merge_bases = get_merge_bases(left, right, 1);
+       if (merge_bases) {
+               if (merge_bases->item == left)
+                       *fast_forward = 1;
+               else if (merge_bases->item == right)
+                       *fast_backward = 1;
+       }
+       for (list = merge_bases; list; list = list->next) {
+               list->item->object.flags |= UNINTERESTING;
+               add_pending_object(rev, &list->item->object,
+                       sha1_to_hex(list->item->object.sha1));
+       }
+       return prepare_revision_walk(rev);
+}
+
+static void print_submodule_summary(struct rev_info *rev, FILE *f,
+               const char *del, const char *add, const char *reset)
+{
+       static const char format[] = "  %m %s";
+       struct strbuf sb = STRBUF_INIT;
+       struct commit *commit;
+
+       while ((commit = get_revision(rev))) {
+               struct pretty_print_context ctx = {0};
+               ctx.date_mode = rev->date_mode;
+               strbuf_setlen(&sb, 0);
+               if (commit->object.flags & SYMMETRIC_LEFT) {
+                       if (del)
+                               strbuf_addstr(&sb, del);
+               }
+               else if (add)
+                       strbuf_addstr(&sb, add);
+               format_commit_message(commit, format, &sb, &ctx);
+               if (reset)
+                       strbuf_addstr(&sb, reset);
+               strbuf_addch(&sb, '\n');
+               fprintf(f, "%s", sb.buf);
+       }
+       strbuf_release(&sb);
+}
+
 void show_submodule_summary(FILE *f, const char *path,
                unsigned char one[20], unsigned char two[20],
                unsigned dirty_submodule,
                const char *del, const char *add, const char *reset)
 {
        struct rev_info rev;
-       struct commit *commit, *left = left, *right = right;
-       struct commit_list *merge_bases, *list;
+       struct commit *left = left, *right = right;
        const char *message = NULL;
        struct strbuf sb = STRBUF_INIT;
-       static const char *format = "  %m %s";
        int fast_forward = 0, fast_backward = 0;
 
        if (is_null_sha1(two))
@@ -175,29 +227,10 @@ void show_submodule_summary(FILE *f, const char *path,
                 !(right = lookup_commit_reference(two)))
                message = "(commits not present)";
 
-       if (!message) {
-               init_revisions(&rev, NULL);
-               setup_revisions(0, NULL, &rev, NULL);
-               rev.left_right = 1;
-               rev.first_parent_only = 1;
-               left->object.flags |= SYMMETRIC_LEFT;
-               add_pending_object(&rev, &left->object, path);
-               add_pending_object(&rev, &right->object, path);
-               merge_bases = get_merge_bases(left, right, 1);
-               if (merge_bases) {
-                       if (merge_bases->item == left)
-                               fast_forward = 1;
-                       else if (merge_bases->item == right)
-                               fast_backward = 1;
-               }
-               for (list = merge_bases; list; list = list->next) {
-                       list->item->object.flags |= UNINTERESTING;
-                       add_pending_object(&rev, &list->item->object,
-                               sha1_to_hex(list->item->object.sha1));
-               }
-               if (prepare_revision_walk(&rev))
-                       message = "(revision walker failed)";
-       }
+       if (!message &&
+           prepare_submodule_summary(&rev, path, left, right,
+                                       &fast_forward, &fast_backward))
+               message = "(revision walker failed)";
 
        if (dirty_submodule & DIRTY_SUBMODULE_UNTRACKED)
                fprintf(f, "Submodule %s contains untracked content\n", path);
@@ -221,25 +254,11 @@ void show_submodule_summary(FILE *f, const char *path,
        fwrite(sb.buf, sb.len, 1, f);
 
        if (!message) {
-               while ((commit = get_revision(&rev))) {
-                       struct pretty_print_context ctx = {0};
-                       ctx.date_mode = rev.date_mode;
-                       strbuf_setlen(&sb, 0);
-                       if (commit->object.flags & SYMMETRIC_LEFT) {
-                               if (del)
-                                       strbuf_addstr(&sb, del);
-                       }
-                       else if (add)
-                               strbuf_addstr(&sb, add);
-                       format_commit_message(commit, format, &sb, &ctx);
-                       if (reset)
-                               strbuf_addstr(&sb, reset);
-                       strbuf_addch(&sb, '\n');
-                       fprintf(f, "%s", sb.buf);
-               }
+               print_submodule_summary(&rev, f, del, add, reset);
                clear_commit_marks(left, ~0);
                clear_commit_marks(right, ~0);
        }
+
        strbuf_release(&sb);
 }
 
index 3cacebd91adc2958e81d952523bd7cfe0078078c..034943bda0e8be781f4a7568f0dbb5b1958f7e15 100644 (file)
@@ -223,7 +223,7 @@ int check_leading_path(const char *name, int len)
        int flags;
        int match_len = lstat_cache_matchlen(cache, name, len, &flags,
                           FL_SYMLINK|FL_NOENT|FL_DIR, USE_ONLY_LSTAT);
-       if (flags & (FL_SYMLINK|FL_NOENT))
+       if (flags & FL_NOENT)
                return 0;
        else if (flags & FL_DIR)
                return -1;
index 25f7d2d2e3cf70d54f5b854ad4199c831a74ae2a..6122a6c73352e6986bc8f97fc803105dcd671c25 100644 (file)
--- a/t/README
+++ b/t/README
@@ -98,6 +98,13 @@ appropriately before running "make".
        not see any output, this option implies --verbose.  For
        convenience, it also implies --tee.
 
+       Note that valgrind is run with the option --leak-check=no,
+       as the git process is short-lived and some errors are not
+       interesting. In order to run a single command under the same
+       conditions manually, you should set GIT_VALGRIND to point to
+       the 't/valgrind/' directory and use the commands under
+       't/valgrind/bin/'.
+
 --tee::
        In addition to printing the test output to the terminal,
        write it to files named 't/test-results/$TEST_NAME.out'.
@@ -190,7 +197,7 @@ we are testing.
 If you create files under t/ directory (i.e. here) that is not
 the top-level test script, never name the file to match the above
 pattern.  The Makefile here considers all such files as the
-top-level test script and tries to run all of them.  A care is
+top-level test script and tries to run all of them.  Care is
 especially needed if you are creating a common test library
 file, similar to test-lib.sh, because such a library file may
 not be suitable for standalone execution.
@@ -274,9 +281,8 @@ Do:
  - Check the test coverage for your tests. See the "Test coverage"
    below.
 
-   Don't blindly follow test coverage metrics, they're a good way to
-   spot if you've missed something. If a new function you added
-   doesn't have any coverage you're probably doing something wrong,
+   Don't blindly follow test coverage metrics; if a new function you added
+   doesn't have any coverage, then you're probably doing something wrong,
    but having 100% coverage doesn't necessarily mean that you tested
    everything.
 
@@ -328,7 +334,7 @@ Keep in mind:
 Skipping tests
 --------------
 
-If you need to skip tests you should do so be using the three-arg form
+If you need to skip tests you should do so by using the three-arg form
 of the test_* functions (see the "Test harness library" section
 below), e.g.:
 
@@ -420,7 +426,7 @@ library for your script to use.
  - test_tick
 
    Make commit and tag names consistent by setting the author and
-   committer times to defined stated.  Subsequent calls will
+   committer times to defined state.  Subsequent calls will
    advance the times by a fixed amount.
 
  - test_commit <message> [<filename> [<contents>]]
index c383b57ed9d995f530004923962c45ab38c7fc8b..58d911d21b894ba05e878e6efbc234071795c600 100644 (file)
@@ -1,8 +1,24 @@
 #!/bin/sh
 
-test_expect_success 'set up terminal for tests' '
-       if
-               test_have_prereq PERL &&
+test_expect_success PERL 'set up terminal for tests' '
+       # Reading from the pty master seems to get stuck _sometimes_
+       # on Mac OS X 10.5.0, using Perl 5.10.0 or 5.8.9.
+       #
+       # Reproduction recipe: run
+       #
+       #       i=0
+       #       while ./test-terminal.perl echo hi $i
+       #       do
+       #               : $((i = $i + 1))
+       #       done
+       #
+       # After 2000 iterations or so it hangs.
+       # https://rt.cpan.org/Ticket/Display.html?id=65692
+       #
+       if test "$(uname -s)" = Darwin
+       then
+               :
+       elif
                "$PERL_PATH" "$TEST_DIRECTORY"/test-terminal.perl \
                        sh -c "test -t 1 && test -t 2"
        then
index 20924506af886c8d0ce28f3fcb2742214d80020f..ae266147b6db9e06abeb4dc30e4271b6c611deac 100755 (executable)
@@ -19,7 +19,7 @@ usage: test-parse-options <options>
     --set23               set integer to 23
     -t <time>             get timestamp of <time>
     -L, --length <str>    get length of <str>
-    -F, --file <FILE>     set file to <FILE>
+    -F, --file <file>     set file to <file>
 
 String options
     -s, --string <string>
index 680d7d68612b168a2642ab64e7bc6c15c316d5b4..9bee8bfd2e063c40bae2d76930370bd9e8ba8fa5 100755 (executable)
@@ -12,4 +12,17 @@ test_expect_success 'character classes (isspace, isalpha etc.)' '
        test-ctype
 '
 
+test_expect_success 'mktemp to nonexistent directory prints filename' '
+       test_must_fail test-mktemp doesnotexist/testXXXXXX 2>err &&
+       grep "doesnotexist/test" err
+'
+
+test_expect_success POSIXPERM 'mktemp to unwritable directory prints filename' '
+       mkdir cannotwrite &&
+       chmod -w cannotwrite &&
+       test_when_finished "chmod +w cannotwrite" &&
+       test_must_fail test-mktemp cannotwrite/testXXXXXX 2>err &&
+       grep "cannotwrite/test" err
+'
+
 test_done
diff --git a/t/t2019-checkout-ambiguous-ref.sh b/t/t2019-checkout-ambiguous-ref.sh
new file mode 100755 (executable)
index 0000000..943541d
--- /dev/null
@@ -0,0 +1,59 @@
+#!/bin/sh
+
+test_description='checkout handling of ambiguous (branch/tag) refs'
+. ./test-lib.sh
+
+test_expect_success 'setup ambiguous refs' '
+       test_commit branch file &&
+       git branch ambiguity &&
+       git branch vagueness &&
+       test_commit tag file &&
+       git tag ambiguity &&
+       git tag vagueness HEAD:file &&
+       test_commit other file
+'
+
+test_expect_success 'checkout ambiguous ref succeeds' '
+       git checkout ambiguity >stdout 2>stderr
+'
+
+test_expect_success 'checkout produces ambiguity warning' '
+       grep "warning.*ambiguous" stderr
+'
+
+test_expect_success 'checkout chooses branch over tag' '
+       echo refs/heads/ambiguity >expect &&
+       git symbolic-ref HEAD >actual &&
+       test_cmp expect actual &&
+       echo branch >expect &&
+       test_cmp expect file
+'
+
+test_expect_success 'checkout reports switch to branch' '
+       grep "Switched to branch" stderr &&
+       ! grep "^HEAD is now at" stderr
+'
+
+test_expect_success 'checkout vague ref succeeds' '
+       git checkout vagueness >stdout 2>stderr &&
+       test_set_prereq VAGUENESS_SUCCESS
+'
+
+test_expect_success VAGUENESS_SUCCESS 'checkout produces ambiguity warning' '
+       grep "warning.*ambiguous" stderr
+'
+
+test_expect_success VAGUENESS_SUCCESS 'checkout chooses branch over tag' '
+       echo refs/heads/vagueness >expect &&
+       git symbolic-ref HEAD >actual &&
+       test_cmp expect actual &&
+       echo branch >expect &&
+       test_cmp expect file
+'
+
+test_expect_success VAGUENESS_SUCCESS 'checkout reports switch to branch' '
+       grep "Switched to branch" stderr &&
+       ! grep "^HEAD is now at" stderr
+'
+
+test_done
diff --git a/t/t2021-checkout-overwrite.sh b/t/t2021-checkout-overwrite.sh
new file mode 100755 (executable)
index 0000000..27db2ad
--- /dev/null
@@ -0,0 +1,50 @@
+#!/bin/sh
+
+test_description='checkout must not overwrite an untracked objects'
+. ./test-lib.sh
+
+test_expect_success 'setup' '
+
+       mkdir -p a/b/c &&
+       >a/b/c/d &&
+       git add -A &&
+       git commit -m base &&
+       git tag start
+'
+
+test_expect_success 'create a commit where dir a/b changed to file' '
+
+       git checkout -b file &&
+       rm -rf a/b &&
+       >a/b &&
+       git add -A &&
+       git commit -m "dir to file"
+'
+
+test_expect_success 'checkout commit with dir must not remove untracked a/b' '
+
+       git rm --cached a/b &&
+       git commit -m "un-track the file" &&
+       test_must_fail git checkout start &&
+       test -f a/b
+'
+
+test_expect_success SYMLINKS 'create a commit where dir a/b changed to symlink' '
+
+       rm -rf a/b &&   # cleanup if previous test failed
+       git checkout -f -b symlink start &&
+       rm -rf a/b &&
+       ln -s foo a/b &&
+       git add -A &&
+       git commit -m "dir to symlink"
+'
+
+test_expect_failure SYMLINKS 'checkout commit with dir must not remove untracked a/b' '
+
+       git rm --cached a/b &&
+       git commit -m "un-track the symlink" &&
+       test_must_fail git checkout start &&
+       test -h a/b
+'
+
+test_done
index c6130c40198ad5ed5ec8a0342341a4ec5cc49d7d..bfa88356382ab9f37e6e510516bf1fc6a3811961 100755 (executable)
@@ -29,7 +29,7 @@ test_expect_success \
 # copy-and-edit one, and rename-and-edit the other.  We do not say
 # anything about rezrov.
 
-GIT_DIFF_OPTS=--unified=0 git diff-index -M -p $tree >current
+GIT_DIFF_OPTS=--unified=0 git diff-index -C -p $tree >current
 cat >expected <<\EOF
 diff --git a/COPYING b/COPYING.1
 copy from COPYING
index 92a65f4852b8eca089fb9de617e0cdc8b55e1475..6e562c80d12f9f58353c8f6444c0d7a0737dbae4 100755 (executable)
@@ -35,7 +35,7 @@ test_expect_success SYMLINKS \
 # a new creation.
 
 test_expect_success SYMLINKS 'setup diff output' "
-    GIT_DIFF_OPTS=--unified=0 git diff-index -M -p $tree >current &&
+    GIT_DIFF_OPTS=--unified=0 git diff-index -C -p $tree >current &&
     cat >expected <<\EOF
 diff --git a/bozbar b/bozbar
 new file mode 120000
index 1ba359d478e3d3491aed5f622932382767c8f4dc..77d7f4946fb51a766399549e3c7364033d7668f0 100755 (executable)
@@ -29,7 +29,7 @@ test_expect_success \
 # and COPYING.2 are based on COPYING, and do not say anything about
 # rezrov.
 
-git diff-index -M $tree >current
+git diff-index -C $tree >current
 
 cat >expected <<\EOF
 :100644 100644 6ff87c4664981e4397625791c8ea3bbb5f2279a3 0603b3238a076dc6c8022aedc6648fa523a17178 C1234 COPYING COPYING.1
index d79d9e1e71ec38b4a82f1bf36dbbff5c3247a4d4..73b4a24f5ef676b8fa9fb3dc83183437710853c3 100755 (executable)
@@ -173,8 +173,8 @@ test_expect_success \
     'compare_diff_raw expected current'
 
 test_expect_success \
-    'run diff with -B -M' \
-    'git diff-index -B -M "$tree" >current'
+    'run diff with -B -C' \
+    'git diff-index -B -C "$tree" >current'
 
 cat >expected <<\EOF
 :100644 100644 f5deac7be59e7eeab8657fd9ae706fd6a57daed2 08bb2fb671deff4c03a4d4a0a1315dff98d5732c C095  file0   file1
index de3f17478efcaf008340a7ab81cb049f9a9e9a3a..f22c8e3dbaee8882160b6132160fcc3ccd7db057 100755 (executable)
@@ -29,7 +29,7 @@ test_expect_success \
 # and COPYING.2 are based on COPYING, and do not say anything about
 # rezrov.
 
-git diff-index -z -M $tree >current
+git diff-index -z -C $tree >current
 
 cat >expected <<\EOF
 :100644 100644 6ff87c4664981e4397625791c8ea3bbb5f2279a3 0603b3238a076dc6c8022aedc6648fa523a17178 C1234
index 7e7b307a24606131b4880817a0056af11973f3d2..7d7470f21b66a937e7414f4fe5419f8830fd8e86 100755 (executable)
@@ -44,6 +44,13 @@ test_expect_success 'rewrite diff can show binary patch' '
        grep "GIT binary patch" diff
 '
 
+test_expect_success 'rewrite diff --stat shows binary changes' '
+       git diff -B --stat --summary >diff &&
+       grep "Bin" diff &&
+       grep "0 insertions.*0 deletions" diff &&
+       grep " rewrite file" diff
+'
+
 {
        echo "#!$SHELL_PATH"
        cat <<'EOF'
index 68e2652814c6a52265407b0fdfb70162eb634d53..d2c930de87f721a0e876351e511295ae0b094108 100755 (executable)
@@ -63,4 +63,40 @@ test_expect_success 'patch-id supports git-format-patch MIME output' '
        test_cmp patch-id_master patch-id_same
 '
 
+cat >nonl <<\EOF
+diff --git i/a w/a
+index e69de29..2e65efe 100644
+--- i/a
++++ w/a
+@@ -0,0 +1 @@
++a
+\ No newline at end of file
+diff --git i/b w/b
+index e69de29..6178079 100644
+--- i/b
++++ w/b
+@@ -0,0 +1 @@
++b
+EOF
+
+cat >withnl <<\EOF
+diff --git i/a w/a
+index e69de29..7898192 100644
+--- i/a
++++ w/a
+@@ -0,0 +1 @@
++a
+diff --git i/b w/b
+index e69de29..6178079 100644
+--- i/b
++++ w/b
+@@ -0,0 +1 @@
++b
+EOF
+
+test_expect_success 'patch-id handles no-nl-at-eof markers' '
+       cat nonl | calc_patch_id nonl &&
+       cat withnl | calc_patch_id withnl &&
+       test_cmp patch-id_nonl patch-id_withnl
+'
 test_done
index 0f4d487be34d22820bcc63619e6e85b96f18c609..6972258b27f6039e05f6bd2129f9c18ca45404d4 100755 (executable)
@@ -144,4 +144,17 @@ test_expect_success 'clone empty repository, and then push should not segfault.'
        test_must_fail git push)
 '
 
+test_expect_success 'cloning non-existent directory fails' '
+       cd "$D" &&
+       rm -rf does-not-exist &&
+       test_must_fail git clone does-not-exist
+'
+
+test_expect_success 'cloning non-git directory fails' '
+       cd "$D" &&
+       rm -rf not-a-git-repo not-a-git-repo-clone &&
+       mkdir not-a-git-repo &&
+       test_must_fail git clone not-a-git-repo not-a-git-repo-clone
+'
+
 test_done
index 92e02d5d77501b2a3ff52069931a534fc7bb24fd..2599ae50eb94051f66b4dc1de603aaf8cd1f79eb 100755 (executable)
@@ -17,13 +17,21 @@ test_expect_success SYMLINKS 'create a commit where dir a/b changed to symlink'
        git commit -m "dir to symlink"
 '
 
-test_expect_success SYMLINKS 'keep a/b-2/c/d across checkout' '
+test_expect_success SYMLINKS 'checkout does not clobber untracked symlink' '
        git checkout HEAD^0 &&
        git reset --hard master &&
        git rm --cached a/b &&
        git commit -m "untracked symlink remains" &&
-        git checkout start^0 &&
-        test -f a/b-2/c/d
+       test_must_fail git checkout start^0
+'
+
+test_expect_success SYMLINKS 'a/b-2/c/d is kept when clobbering symlink b' '
+       git checkout HEAD^0 &&
+       git reset --hard master &&
+       git rm --cached a/b &&
+       git commit -m "untracked symlink remains" &&
+       git checkout -f start^0 &&
+       test -f a/b-2/c/d
 '
 
 test_expect_success SYMLINKS 'checkout should not have deleted a/b-2/c/d' '
index bfb4975e940e29edf3b06e5c074b8e963cfbbdcf..fa9d23aa31302f53cc1c39473492cf545ca5ae87 100755 (executable)
@@ -203,4 +203,56 @@ test_expect_success 'submodule init picks up merge' '
        )
 '
 
+test_expect_success 'submodule update --merge  - ignores --merge  for new submodules' '
+       (cd super &&
+        rm -rf submodule &&
+        git submodule update submodule &&
+        git status -s submodule >expect &&
+        rm -rf submodule &&
+        git submodule update --merge submodule &&
+        git status -s submodule >actual &&
+        test_cmp expect actual
+       )
+'
+
+test_expect_success 'submodule update --rebase - ignores --rebase for new submodules' '
+       (cd super &&
+        rm -rf submodule &&
+        git submodule update submodule &&
+        git status -s submodule >expect &&
+        rm -rf submodule &&
+        git submodule update --rebase submodule &&
+        git status -s submodule >actual &&
+        test_cmp expect actual
+       )
+'
+
+test_expect_success 'submodule update ignores update=merge config for new submodules' '
+       (cd super &&
+        rm -rf submodule &&
+        git submodule update submodule &&
+        git status -s submodule >expect &&
+        rm -rf submodule &&
+        git config submodule.submodule.update merge &&
+        git submodule update submodule &&
+        git status -s submodule >actual &&
+        git config --unset submodule.submodule.update &&
+        test_cmp expect actual
+       )
+'
+
+test_expect_success 'submodule update ignores update=rebase config for new submodules' '
+       (cd super &&
+        rm -rf submodule &&
+        git submodule update submodule &&
+        git status -s submodule >expect &&
+        rm -rf submodule &&
+        git config submodule.submodule.update rebase &&
+        git submodule update submodule &&
+        git status -s submodule >actual &&
+        git config --unset submodule.submodule.update &&
+        test_cmp expect actual
+       )
+'
+
 test_done
index d551b77ce6d94acce80069f2197f0169ee59e6d5..5976f598fc7bf48120865eca3ceef74a151e717a 100755 (executable)
@@ -28,13 +28,21 @@ test_expect_success 'a basic commit in an empty tree should succeed' '
 test_expect_success 'nonexistent template file should return error' '
        echo changes >> foo &&
        git add foo &&
-       test_must_fail git commit --template "$PWD"/notexist
+       (
+               GIT_EDITOR="echo hello >\"\$1\"" &&
+               export GIT_EDITOR &&
+               test_must_fail git commit --template "$PWD"/notexist
+       )
 '
 
 test_expect_success 'nonexistent template file in config should return error' '
        git config commit.template "$PWD"/notexist &&
-       test_must_fail git commit &&
-       git config --unset commit.template
+       test_when_finished "git config --unset commit.template" &&
+       (
+               GIT_EDITOR="echo hello >\"\$1\"" &&
+               export GIT_EDITOR &&
+               test_must_fail git commit
+       )
 '
 
 # From now on we'll use a template file that exists.
index ff189624d48fb9f68997395d121d4e7056511245..5b4b694f1801f5c2284346f882cb496df9e7d74e 100755 (executable)
@@ -132,6 +132,18 @@ test_expect_success 'with hook (-c)' '
 
 '
 
+test_expect_success 'with hook (merge)' '
+
+       head=`git rev-parse HEAD` &&
+       git checkout -b other HEAD@{1} &&
+       echo "more" >> file &&
+       git add file &&
+       git commit -m other &&
+       git checkout - &&
+       git merge other &&
+       test "`git log -1 --pretty=format:%s`" = merge
+'
+
 cat > "$HOOK" <<'EOF'
 #!/bin/sh
 exit 1
index 45cb60ea4b167676b07ae1c847c0467f2a5e3d69..41962f04a715ea5250360766dc64986c4ecf7981 100755 (executable)
@@ -6,10 +6,11 @@ test_description='git annotate'
 PROG='git annotate'
 . "$TEST_DIRECTORY"/annotate-tests.sh
 
-test_expect_success \
-    'Annotating an old revision works' \
-    '[ $(git annotate file master | awk "{print \$3}" | grep -c "^A$") -eq 2 ] && \
-     [ $(git annotate file master | awk "{print \$3}" | grep -c "^B$") -eq 2 ]'
-
+test_expect_success 'Annotating an old revision works' '
+       git annotate file master >result &&
+       awk "{ print \$3; }" <result >authors &&
+       test 2 = $(grep A <authors | wc -l) &&
+       test 2 = $(grep B <authors | wc -l)
+'
 
 test_done
index ea64cd8d0f02a3a08dca7742a29331c85e7da384..32ec82ad678d56bbf27f525fc8588b3391d9117d 100755 (executable)
@@ -25,7 +25,8 @@ test_expect_success 'setup ' '
        echo "bin: test 1 version 2" >one.bin &&
        echo "bin: test number 2 version 2" >>two.bin &&
        if test_have_prereq SYMLINKS; then
-               ln -sf two.bin symlink.bin
+               rm symlink.bin &&
+               ln -s two.bin symlink.bin
        fi &&
        GIT_AUTHOR_NAME=Number2 git commit -a -m Second --date="2010-01-01 20:00:00"
 '
index c15ca2d6479a814d7649a38a671a554b6ed8b68f..13ba96e21a9295805aed40c89ecd5178db6bfae4 100755 (executable)
@@ -113,6 +113,16 @@ like($last_commit, qr/^[0-9a-fA-F]{40}$/, 'rev-parse returned hash');
 my $dir_commit = $r2->command_oneline('log', '-n1', '--pretty=format:%H', '.');
 isnt($last_commit, $dir_commit, 'log . does not show last commit');
 
+# commands outside working tree
+chdir($abs_repo_dir . '/..');
+my $r3 = Git->repository(Directory => $abs_repo_dir);
+my $tmpfile3 = "$abs_repo_dir/file3.tmp";
+open TEMPFILE3, "+>$tmpfile3" or die "Can't open $tmpfile3: $!";
+is($r3->cat_blob($file1hash, \*TEMPFILE3), 15, "cat_blob(outside): size");
+close TEMPFILE3;
+unlink $tmpfile3;
+chdir($abs_repo_dir);
+
 printf "1..%d\n", Test::More->builder->current_test;
 
 my $is_passing = eval { Test::More->is_passing };
index 0fdc541a7cd7d6b694c4f4a3fd06b6cf21dc7380..c91e2324371edee46ebe3a49b540915e96469387 100644 (file)
@@ -1004,14 +1004,14 @@ rm -fr "$test" || {
        exit 1
 }
 
+HOME="$TRASH_DIRECTORY"
+export HOME
+
 test_create_repo "$test"
 # Use -P to resolve symlinks in our working directory so that the cwd
 # in subprocesses like git equals our $PWD (for pathname comparisons).
 cd -P "$test" || exit 1
 
-HOME=$(pwd)
-export HOME
-
 this_test=${0##*/}
 this_test=${this_test%%-*}
 for skp in $GIT_SKIP_TESTS
index 9e013fa3b25b82a10b71ceabfa664c796c4d7a3f..0a6724fcc45eed89d612b0e641fd3fe6d4231fcb 100644 (file)
@@ -43,3 +43,9 @@
        fun:write_buffer
        fun:write_loose_object
 }
+
+{
+       ignore-sse-strlen-invalid-read-size
+       Memcheck:Addr4
+       fun:copy_ref
+}
diff --git a/test-mktemp.c b/test-mktemp.c
new file mode 100644 (file)
index 0000000..c8c5421
--- /dev/null
@@ -0,0 +1,14 @@
+/*
+ * test-mktemp.c: code to exercise the creation of temporary files
+ */
+#include "git-compat-util.h"
+
+int main(int argc, char *argv[])
+{
+       if (argc != 2)
+               usage("Expected 1 parameter defining the temporary file template");
+
+       xmkstemp(xstrdup(argv[1]));
+
+       return 0;
+}
index 0828592162cc7c61f0d025ba4d83fc29bc4c2067..4e3710b9a8fc868642e1e0e8f4af37eeb1ce0ce4 100644 (file)
@@ -46,7 +46,7 @@ int main(int argc, const char **argv)
                OPT_DATE('t', NULL, &timestamp, "get timestamp of <time>"),
                OPT_CALLBACK('L', "length", &integer, "str",
                        "get length of <str>", length_callback),
-               OPT_FILENAME('F', "file", &file, "set file to <FILE>"),
+               OPT_FILENAME('F', "file", &file, "set file to <file>"),
                OPT_GROUP("String options"),
                OPT_STRING('s', "string", &string, "string", "get a string"),
                OPT_STRING(0, "string2", &string, "str", "get another string"),
index 4e4754c32bd53f28f9335c2a4529f5804f3086f2..8866adf08898f5855dd1dea1db4286021ffb880c 100644 (file)
@@ -12,8 +12,7 @@
 
 static int debug;
 
-struct helper_data
-{
+struct helper_data {
        const char *name;
        struct child_process *helper;
        FILE *out;
index 79635f2e1628a1ac25d62ca502c9ee4d0a2b61d6..4c147d6c48c000bab636fad3edc2fe7da6670948 100644 (file)
--- a/wrapper.c
+++ b/wrapper.c
@@ -198,10 +198,22 @@ FILE *xfdopen(int fd, const char *mode)
 int xmkstemp(char *template)
 {
        int fd;
+       char origtemplate[PATH_MAX];
+       strlcpy(origtemplate, template, sizeof(origtemplate));
 
        fd = mkstemp(template);
-       if (fd < 0)
-               die_errno("Unable to create temporary file");
+       if (fd < 0) {
+               int saved_errno = errno;
+               const char *nonrelative_template;
+
+               if (!template[0])
+                       template = origtemplate;
+
+               nonrelative_template = make_nonrelative_path(template);
+               errno = saved_errno;
+               die_errno("Unable to create temporary file '%s'",
+                       nonrelative_template);
+       }
        return fd;
 }
 
@@ -321,10 +333,22 @@ int gitmkstemps(char *pattern, int suffix_len)
 int xmkstemp_mode(char *template, int mode)
 {
        int fd;
+       char origtemplate[PATH_MAX];
+       strlcpy(origtemplate, template, sizeof(origtemplate));
 
        fd = git_mkstemp_mode(template, mode);
-       if (fd < 0)
-               die_errno("Unable to create temporary file");
+       if (fd < 0) {
+               int saved_errno = errno;
+               const char *nonrelative_template;
+
+               if (!template[0])
+                       template = origtemplate;
+
+               nonrelative_template = make_nonrelative_path(template);
+               errno = saved_errno;
+               die_errno("Unable to create temporary file '%s'",
+                       nonrelative_template);
+       }
        return fd;
 }