Commit graph

3115 commits

Author SHA1 Message Date
Jeff King 34dc6e73b0 tests: add date printing and parsing tests
Until now, there was no coverage of relative date printing
or approxidate parsing routines (mainly because we had no
way of faking the "now" time for relative date calculations,
which made consistent testing impossible).

This new script tries to exercise the basic features of
show_date and approxidate. Most of the tests are just "this
obvious thing works" to prevent future regressions, with a
few exceptions:

  - We confirm the fix in 607a9e8 that relative year/month
    dates in the latter half of a year round correctly.

  - We confirm that the improvements in b5373e9 and 1bddb25
    work.

  - A few tests are marked to expect failure, which are
    regressions recently introduced by the two commits
    above.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2009-08-30 22:04:56 -07:00
Junio C Hamano f324cb50be Sync with 1.6.4.2 2009-08-29 14:52:03 -07:00
Nanako Shiraishi e71c008dce Remove unused t/t8005/iso8859-5.txt
This file is no longer used since 54bc13c (t8005: Nobody writes Russian in
shift_jis, 2009-06-18).

Signed-off-by: Nanako Shiraishi <nanako3@lavabit.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2009-08-29 00:50:31 -07:00
Junio C Hamano 11cae066b2 upload-pack: feed "kind [clone|fetch]" to post-upload-pack hook
A request to clone the repository does not give any "have" but asks for
all the refs we offer with "want".  When a request does not ask to clone
the repository fully, but asks to fetch some refs into an empty
repository, it will not give any "have" but its "want" won't ask for all
the refs we offer.

If we suppose (and I would say this is a rather big if) that it makes
sense to distinguish these two cases, a hook cannot reliably do this
alone.  The hook can detect lack of "have" and bunch of "want", but there
is no direct way to tell if the other end asked for all refs we offered,
or merely most of them.

Between the time we talked with the other end and the time the hook got
called, we may have acquired more refs or lost some refs in the repository
by concurrent operations.  Given that we plan to introduce selective
advertisement of refs with a protocol extension, it would become even more
difficult for hooks to guess between these two cases.

This adds "kind [clone|fetch]" to hook's input, as a stable interface to
allow the hooks to tell these cases apart.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
2009-08-28 22:39:24 -07:00
Junio C Hamano a8563ec851 upload-pack: add a trigger for post-upload-pack hook
After upload-pack successfully finishes its operation, post-upload-pack
hook can be called for logging purposes.

The hook is passed various pieces of information, one per line, from its
standard input.  Currently the following items can be fed to the hook, but
more types of information may be added in the future:

    want SHA-1::
        40-byte hexadecimal object name the client asked to include in the
        resulting pack.  Can occur one or more times in the input.

    have SHA-1::
        40-byte hexadecimal object name the client asked to exclude from
        the resulting pack, claiming to have them already.  Can occur zero
        or more times in the input.

    time float::
        Number of seconds spent for creating the packfile.

    size decimal::
        Size of the resulting packfile in bytes.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
2009-08-28 22:39:17 -07:00
Junio C Hamano 235db154f8 Merge branch 'mm/reset-report'
* mm/reset-report:
  reset: make the reminder output consistent with "checkout"
  Rename REFRESH_SAY_CHANGED to REFRESH_IN_PORCELAIN.
2009-08-28 19:39:26 -07:00
Junio C Hamano 4a224a9bbe Merge branch 'jk/maint-1.6.3-checkout-unborn'
* jk/maint-1.6.3-checkout-unborn:
  checkout: do not imply "-f" on unborn branches
2009-08-28 19:39:07 -07:00
Junio C Hamano 232d453766 Merge branch 'np/maint-1.6.3-deepen'
* np/maint-1.6.3-deepen:
  fix simple deepening of a repo

Conflicts:
	t/t5500-fetch-pack.sh
2009-08-28 19:38:56 -07:00
Junio C Hamano 433233e0b6 Merge branch 'jc/shortstatus'
* jc/shortstatus:
  git commit --dry-run -v: show diff in color when asked
  Documentation/git-commit.txt: describe --dry-run
  wt-status: collect untracked files in a separate "collect" phase
  Make git_status_config() file scope static to builtin-commit.c
  wt-status: move wt_status_colors[] into wt_status structure
  wt-status: move many global settings to wt_status structure
  commit: --dry-run
  status: show worktree status of conflicted paths separately
  wt-status.c: rework the way changes to the index and work tree are summarized
  diff-index: keep the original index intact
  diff-index: report unmerged new entries
2009-08-28 19:38:19 -07:00
Brandon Casey 8648732e29 t/test-lib.sh: provide a shell implementation of the 'yes' utility
Some platforms (IRIX 6.5, Solaris 7) do not provide the 'yes' utility.
Currently, some tests, including t7610 and t9001, try to call this program.
Due to the way the tests are structured, the tests still pass even though
this program is missing.  Rather than succeeding by chance, let's provide
an implementation of the simple 'yes' utility in shell for all platforms to
use.

Signed-off-by: Brandon Casey <casey@nrlssc.navy.mil>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2009-08-28 16:36:24 -07:00
Junio C Hamano a1eb73d917 Merge branch 'maint-1.5.6' into maint-1.6.0
* maint-1.5.6:
  revision traversal and pack: notice and die on missing commit
2009-08-27 20:03:35 -07:00
Mark Rada e39e0d375d gitweb: add t9501 tests for checking HTTP status codes
Adds a new test file, t9501, that checks HTTP status codes and messages
from gitweb.

Currently, the only tests are for the snapshot feature.

Signed-off-by: Mark Rada <marada@uwaterloo.ca>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2009-08-27 19:56:28 -07:00
Mark Rada 05526071cb gitweb: split test suite into library and tests
To accommodate additions to the test cases for gitweb, the preamble
from t9500 is now in its own library so that new sets of tests for
gitweb can use the same setup without copying the code.

Signed-off-by: Mark Rada <marada@uwaterloo.ca>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2009-08-27 19:56:02 -07:00
Junio C Hamano 24343c6099 Merge branch 'as/maint-graph-interesting-fix'
* as/maint-graph-interesting-fix:
  Add tests for rev-list --graph with options that simplify history
  graph API: fix bug in graph_is_interesting()
2009-08-27 16:59:56 -07:00
Junio C Hamano adc5423531 Merge branch 'jh/submodule-foreach'
* jh/submodule-foreach:
  git clone: Add --recursive to automatically checkout (nested) submodules
  t7407: Use 'rev-parse --short' rather than bash's substring expansion notation
  git submodule status: Add --recursive to recurse into nested submodules
  git submodule update: Introduce --recursive to update nested submodules
  git submodule foreach: Add --recursive to recurse into nested submodules
  git submodule foreach: test access to submodule name as '$name'
  Add selftest for 'git submodule foreach'
  git submodule: Cleanup usage string and add option parsing to cmd_foreach()
  git submodule foreach: Provide access to submodule name, as '$name'

Conflicts:
	Documentation/git-submodule.txt
	git-submodule.sh
2009-08-27 16:59:25 -07:00
Junio C Hamano ab36d06f12 Merge branch 'jc/maint-unpack-objects-strict'
* jc/maint-unpack-objects-strict:
  Fix "unpack-objects --strict"

Conflicts:
	builtin-unpack-objects.c
2009-08-27 16:59:08 -07:00
Junio C Hamano e7c693a8e1 Merge branch 'nd/sparse' (early part)
* 'nd/sparse' (early part):
  Prevent diff machinery from examining assume-unchanged entries on worktree
2009-08-27 16:56:33 -07:00
Johannes Sixt 14c674e9dc Make test case number unique
Signed-off-by: Johannes Sixt <j6t@kdbg.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2009-08-27 16:44:47 -07:00
Junio C Hamano 017678b4f4 am/mailinfo: Disable scissors processing by default
You can enable it by giving --scissors to "git am".

Signed-off-by: Junio C Hamano <gitster@pobox.com>
2009-08-26 22:22:22 -07:00
Junio C Hamano 200c75f0d6 Teach mailinfo to ignore everything before -- >8 -- mark
This teaches mailinfo the scissors -- >8 -- mark; the command ignores
everything before it in the message body.

For lefties among us, we also support -- 8< -- ;-)

Signed-off-by: Junio C Hamano <gitster@pobox.com>
2009-08-26 22:21:32 -07:00
Jeff King 7a4ee28f41 clone: add --branch option to select a different HEAD
We currently point the HEAD of a newly cloned repo to the
same ref as the parent repo's HEAD. While a user can then
"git checkout -b foo origin/foo" whichever branch they
choose, it is more convenient and more efficient to tell
clone which branch you want in the first place.

Based on a patch by Kirill A. Korinskiy.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2009-08-26 19:36:20 -07:00
Junio C Hamano 68ea474164 Merge branch 'maint'
* maint:
  git-log: allow --decorate[=short|full]
  Minor improvement to the write-tree documentation
  git-bisect: call the found commit "*the* first bad commit"
2009-08-26 12:15:15 -07:00
Lars Hjemli d8526a4c3b git-log: allow --decorate[=short|full]
Commit de435ac0 changed the behavior of --decorate from printing the
full ref (e.g., "refs/heads/master") to a shorter, more human-readable
version (e.g., just "master"). While this is nice for human readers,
external tools using the output from "git log" may prefer the full
version.

This patch introduces an extension to --decorate to allow the caller to
specify either the short or the full versions.

Signed-off-by: Lars Hjemli <hjemli@gmail.com>
Acked-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2009-08-26 12:05:58 -07:00
Nanako Shiraishi 21d0bc2f9a git-bisect: call the found commit "*the* first bad commit"
Signed-off-by: Nanako Shiraishi <nanako3@lavabit.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2009-08-26 12:05:57 -07:00
Junio C Hamano b8132342e9 Merge branch 'jc/maint-clean-nested-dir-safety' into maint
* jc/maint-clean-nested-dir-safety:
  clean: require double -f options to nuke nested git repository and work tree
2009-08-26 12:05:57 -07:00
Junio C Hamano bd30037e65 Merge branch 'jk/maint-merge-msg-fix' into maint
* jk/maint-merge-msg-fix:
  merge: indicate remote tracking branches in merge message
  merge: fix incorrect merge message for ambiguous tag/branch
  add tests for merge message headings
2009-08-26 12:05:57 -07:00
Junio C Hamano 6b37b3d873 Merge branch 'jc/apply-epoch-patch' into maint
* jc/apply-epoch-patch:
  apply: notice creation/removal patches produced by GNU diff
2009-08-26 12:05:57 -07:00
Junio C Hamano 6dfa21309f Merge branch 'jp/symlink-dirs' into maint
* jp/symlink-dirs:
  t6035-merge-dir-to-symlink depends on SYMLINKS prerequisite
  git-checkout: be careful about untracked symlinks
  lstat_cache: guard against full match of length of 'name' parameter
  Demonstrate bugs when a directory is replaced with a symlink
2009-08-26 12:05:57 -07:00
Junio C Hamano bb0c8065f1 Merge branch 'maint-1.6.3' into maint
* maint-1.6.3:
  add -p: do not attempt to coalesce mode changes
  git add -p: demonstrate failure when staging both mode and hunk
2009-08-26 12:05:57 -07:00
Junio C Hamano 9e4a90ba19 Merge branch 'tr/maint-1.6.3-add-p-modeonly-fix' into maint-1.6.3
* tr/maint-1.6.3-add-p-modeonly-fix:
  add -p: do not attempt to coalesce mode changes
  git add -p: demonstrate failure when staging both mode and hunk
2009-08-26 11:22:00 -07:00
Junio C Hamano 31f0bce853 Merge branch 'aj/fix-read-tree-from-scratch'
* aj/fix-read-tree-from-scratch:
  read-tree: Fix regression with creation of a new index file.
2009-08-25 14:48:15 -07:00
Junio C Hamano 3613339eaf Merge branch 'jc/maint-checkout-index-to-prefix'
* jc/maint-checkout-index-to-prefix:
  check_path(): allow symlinked directories to checkout-index --prefix
2009-08-25 14:47:56 -07:00
Junio C Hamano 079f298513 Merge branch 'jl/submodule-summary-diff-files'
* jl/submodule-summary-diff-files:
  Documentaqtion/git-submodule.txt: Typofix
  git submodule summary: add --files option
2009-08-25 14:46:43 -07:00
Junio C Hamano d6d994d911 Merge branch 'lh/short-decorate'
* lh/short-decorate:
  git-log: allow --decorate[=short|full]
2009-08-25 14:46:12 -07:00
Jeff King cc580af885 checkout: do not imply "-f" on unborn branches
When checkout sees that HEAD points to a non-existent ref,
it currently acts as if "-f" was given; this behavior dates
back to 5a03e7f, which enabled checkout from unborn branches
in the shell version of "git-checkout". The reasoning given
is to avoid the code path which tries to merge the tree
contents. When checkout was converted to C, this code
remained intact.

The unfortunate side effect of this strategy is that the
"force" code path will overwrite working tree and index
state that may be precious to the user. Instead of enabling
"force", this patch uses the normal "merge" codepath for an
unborn branch, but substitutes the empty tree for the "old"
commit.

This means that in the absence of an index, any files in the
working tree will be treated as untracked files, and a
checkout which would overwrite them is aborted. Similarly,
any paths in the index will be merged with an empty entry
as the base, meaning that unless the new branch's content is
identical to what's in the index, there will be a conflict
and the checkout will be aborted.

The user is then free to correct the situation or proceed
with "-f" as appropriate.

This patch also removes the "warning: you are on a branch
yet to be born" message. Its function was to warn the user
that we were enabling the "-f" option. Since we are no
longer doing that, there is no reason for the user to care
whether we are switching away from an unborn branch.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2009-08-25 00:02:38 -07:00
Nicolas Pitre 86386829d4 fix simple deepening of a repo
If all refs sent by the remote repo during a fetch are reachable
locally, then no further conversation is performed with the remote. This
check is skipped when the --depth argument is provided to allow the
deepening of a shallow clone which corresponding remote repo has no
changed.

However, some additional filtering was added in commit c29727d5 to
remove those refs which are equal on both sides.  If the remote repo has
not changed, then the list of refs to give the remote process becomes
empty and simply attempting to deepen a shallow repo always fails.

Let's stop being smart in that case and simply send the whole list over
when that condition is met.  The remote will do the right thing anyways.

Test cases for this issue are also provided.

Signed-off-by: Nicolas Pitre <nico@cam.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2009-08-24 15:03:56 -07:00
Adam Simpkins b97c470b57 Add tests for rev-list --graph with options that simplify history
These tests help make sure graph_is_interesting() is doing the right
thing.

Signed-off-by: Adam Simpkins <simpkins@facebook.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2009-08-24 14:39:29 -07:00
Matthieu Moy 3deffc52d8 reset: make the reminder output consistent with "checkout"
git reset without argument displays a summary of the local modification,
like this:

    $ git reset
    Makefile: locally modified

Some people have problems with this; they look like an error message.

This patch makes its output mimic how "git checkout $another_branch"
reports the paths with local modifications.  "git add --refresh --verbose"
is changed in the same way.

It also adds a header to make it clear that the output is informative,
and not an error.

Signed-off-by: Matthieu Moy <Matthieu.Moy@imag.fr>
2009-08-21 21:19:35 -07:00
Junio C Hamano f47af92594 Merge branch 'bc/maint-am-email' into maint
* bc/maint-am-email:
  git-am: print fair error message when format detection fails
  am: allow individual e-mail files as input
2009-08-21 18:51:30 -07:00
Junio C Hamano f00ecbe42b Merge branch 'cc/replace'
* cc/replace:
  t6050: check pushing something based on a replaced commit
  Documentation: add documentation for "git replace"
  Add git-replace to .gitignore
  builtin-replace: use "usage_msg_opt" to give better error messages
  parse-options: add new function "usage_msg_opt"
  builtin-replace: teach "git replace" to actually replace
  Add new "git replace" command
  environment: add global variable to disable replacement
  mktag: call "check_sha1_signature" with the replacement sha1
  replace_object: add a test case
  object: call "check_sha1_signature" with the replacement sha1
  sha1_file: add a "read_sha1_file_repl" function
  replace_object: add mechanism to replace objects found in "refs/replace/"
  refs: add a "for_each_replace_ref" function
2009-08-21 18:47:53 -07:00
Junio C Hamano 5e092b5bce Merge branch 'gb/apply-ignore-whitespace'
* gb/apply-ignore-whitespace:
  git apply: option to ignore whitespace differences
2009-08-21 18:47:48 -07:00
Junio C Hamano bcd45e27d8 Merge branch 'bc/mailsplit-cr-at-eol'
* bc/mailsplit-cr-at-eol:
  Allow mailsplit (and hence git-am) to handle mails with CRLF line-endings
  builtin-mailsplit.c: remove read_line_with_nul() since it is no longer used
  builtin-mailinfo,builtin-mailsplit: use strbufs
  strbuf: add new function strbuf_getwholeline()
2009-08-21 18:47:44 -07:00
Adam Simpkins beb5af43a6 graph API: fix bug in graph_is_interesting()
Previously, graph_is_interesting() did not behave quite the same way as
the code in get_revision().  As a result, it would sometimes think
commits were uninteresting, even though get_revision() would return
them.  This resulted in incorrect lines in the graph output.

This change creates a get_commit_action() function, which
graph_is_interesting() and simplify_commit() both now use to determine
if a commit will be shown.  It is identical to the old simplify_commit()
behavior, except that it never calls rewrite_parents().

This problem was reported by Santi Béjar.  The following command
would exhibit the problem before, but now works correctly:

  git log --graph --simplify-by-decoration --oneline v1.6.3.3

Previously git graph did not display the output for this command
correctly between f29ac4f and 66996ec, among other places.

Signed-off-by: Adam Simpkins <simpkins@facebook.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2009-08-21 12:41:25 -07:00
Junio C Hamano 3a2dd481e5 Merge branch 'jc/maint-merge-recursive-fix' into maint
* jc/maint-merge-recursive-fix:
  merge-recursive: don't segfault while handling rename clashes
2009-08-21 11:34:24 -07:00
Junio C Hamano 07d6309e63 Merge branch 'sb/maint-pull-rebase' into maint
* sb/maint-pull-rebase:
  pull: support rebased upstream + fetch + pull --rebase
  t5520-pull: Test for rebased upstream + fetch + pull --rebase
2009-08-21 11:33:08 -07:00
Johannes Sixt f5d5ea525b Make test number t7406- unique
We skip t7407 because a patch series is cooking that uses is.

Signed-off-by: Johannes Sixt <j6t@kdbg.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2009-08-21 09:56:31 -07:00
Johan Herland e7fed18a89 git clone: Add --recursive to automatically checkout (nested) submodules
Many projects using submodules expect all submodules to be checked out
in order to build/work correctly. A common command sequence for
developers on such projects is:

	git clone url/to/project
	cd project
	git submodule update --init (--recursive)

This patch introduces the --recursive option to git-clone. The new
option causes git-clone to recursively clone and checkout all
submodules of the cloned project. Hence, the above command sequence
can be reduced to:

	git clone --recursive url/to/project

--recursive is ignored if no checkout is done by the git-clone.

The patch also includes documentation and a selftest.

Signed-off-by: Johan Herland <johan@herland.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2009-08-20 16:59:50 -07:00
Johan Herland e3ae4a8613 t7407: Use 'rev-parse --short' rather than bash's substring expansion notation
The substring expansion notation is a bashism that we have not so far
adopted.  Use 'git rev-parse --short' instead, as this also handles
the case where the unique abbreviation is longer than 7 characters.

Also fix the typo; the object name for submodule #2 was copied from
submodule #1's by mistake.

Suggested-by: Brandon Casey <casey@nrlssc.navy.mil>
Signed-off-by: Johan Herland <johan@herland.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2009-08-20 16:59:45 -07:00
Junio C Hamano 09ba7b2d9f Merge branch 'tr/maint-1.6.3-add-p-modeonly-fix'
* tr/maint-1.6.3-add-p-modeonly-fix:
  add -p: do not attempt to coalesce mode changes
  git add -p: demonstrate failure when staging both mode and hunk
2009-08-18 23:32:58 -07:00
Johan Herland 64b19ffedd git submodule status: Add --recursive to recurse into nested submodules
In very large and hierarchically structured projects, one may encounter
nested submodules. In these situations, it is valuable to not only show
status for all the submodules in the current repo (which is what is
currently done by 'git submodule status'), but also to show status for
all submodules at all levels (i.e. recursing into nested submodules as
well).

This patch teaches the new --recursive option to the 'git submodule status'
command. The patch also includes documentation and selftests.

Signed-off-by: Johan Herland <johan@herland.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2009-08-18 22:59:58 -07:00
Johan Herland b13fd5c1a2 git submodule update: Introduce --recursive to update nested submodules
In very large and hierarchically structured projects, one may encounter
nested submodules. In these situations, it is valuable to not only update
the submodules in the current repo (which is what is currently done by
'git submodule update'), but also to operate on all submodules at all
levels (i.e. recursing into nested submodules as well).

This patch teaches the new --recursive option to the 'git submodule update'
command. The patch also includes documentation and selftests.

Signed-off-by: Johan Herland <johan@herland.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2009-08-18 22:59:12 -07:00
Johan Herland 15fc56a853 git submodule foreach: Add --recursive to recurse into nested submodules
In very large and hierarchically structured projects, one may encounter
nested submodules. In these situations, it is valuable to not only operate
on all the submodules in the current repo (which is what is currently done
by 'git submodule foreach'), but also to operate on all submodules at all
levels (i.e. recursing into nested submodules as well).

This patch teaches the new --recursive option to the 'git submodule foreach'
command. The patch also includes documentation and selftests.

Signed-off-by: Johan Herland <johan@herland.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2009-08-18 22:57:37 -07:00
Johan Herland 9aec7e0ba6 git submodule foreach: test access to submodule name as '$name'
Add verification of the behaviour of '$name' to the git submodule
foreach selftest.

Signed-off-by: Johan Herland <johan@herland.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2009-08-18 22:51:31 -07:00
Johan Herland d69ecf6f0e Add selftest for 'git submodule foreach'
The selftest verifies that:
- only checked out submodules are visited by 'git submodule foreach'
- the $path, and $sha1 variables are set correctly for each submodule

Signed-off-by: Johan Herland <johan@herland.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2009-08-18 22:50:40 -07:00
Eric Wong 5268f9edc3 svn: assume URLs from the command-line are URI-encoded
And then unescape them when writing to $GIT_CONFIG.

SVN has different rules for repository URLs (usually the root)
and for paths within that repository (below the HTTP layer).
Thus, for the request URI path at the HTTP level, the URI needs
to be encoded.  However, in the body of the HTTP request (the
with underlying SVN XML protocol), those paths should not be
URI-encoded[1].  For non-HTTP(S) requests, SVN appears to be
more flexible and will except weird characters in the URL as
well as URI-encoded ones.

Since users are used to using URLs being entirely URI-encoded,
git svn will now attempt to unescape the path portion of URLs
while leaving the actual repository URL untouched.

This change will be reflected in newly-created $GIT_CONFIG files
only.  This allows users to switch between svn(+ssh)://, file://
and http(s):// urls without changing the fetch/branches/tags
config keys.  This won't affect existing imports at all (since
things didn't work before this commit anyways), and will allow
users to force escaping into repository paths that look like
they're escaped (but are not).

Thanks to Mike Smullin for the original bug report and Björn
Steinbrink for summarizing it into testable cases for me.

[1] Except when committing copies/renames, see
    commit 29633bb91c

Signed-off-by: Eric Wong <normalperson@yhbt.net>
2009-08-18 20:47:37 -07:00
Lars Hjemli 33e7018c45 git-log: allow --decorate[=short|full]
Commit de435ac0 changed the behavior of --decorate from printing the
full ref (e.g., "refs/heads/master") to a shorter, more human-readable
version (e.g., just "master"). While this is nice for human readers,
external tools using the output from "git log" may prefer the full
version.

This patch introduces an extension to --decorate to allow the caller to
specify either the short or the full versions.

Signed-off-by: Lars Hjemli <hjemli@gmail.com>
Acked-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2009-08-18 13:14:17 -07:00
Jeff King 933766c1a9 tests: disable interactive hunk selection tests if perl is not available
These are all backed by git-add--interactive.perl under the hood.

Signed-off-by: Jeff King <peff@peff.net>
Acked-By: Thomas Rast <trast@student.ethz.ch>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2009-08-18 12:28:42 -07:00
Junio C Hamano da02ca508b check_path(): allow symlinked directories to checkout-index --prefix
Merlyn noticed that Documentation/install-doc-quick.sh no longer correctly
removes old installed documents when the target directory has a leading
path that is a symlink.  It turns out that "checkout-index --prefix" was
broken by recent b6986d8 (git-checkout: be careful about untracked
symlinks, 2009-07-29).

I suspect has_symlink_leading_path() could learn the third parameter
(prefix that is allowed to be symlinked directories) to allow us to retire
a similar function has_dirs_only_path().

Another avenue of fixing this I considered was to get rid of base_dir and
base_dir_len from "struct checkout", and instead make "git checkout-index"
when run with --prefix mkdir the leading path and chdir in there.  It
might be the best longer term solution to this issue, as the base_dir
feature is used only by that rather obscure codepath as far as I know.

But at least this patch should fix this breakage.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
2009-08-18 03:32:45 -07:00
Alexandre Julliard db137fe91e read-tree: Fix regression with creation of a new index file.
Reading the index into an empty file has been broken by
5a56da5806, since it causes the existing
index to always be loaded first, and dies if it's an empty file:

$ GIT_INDEX_FILE=`mktemp` git read-tree master
fatal: index file smaller than expected

It breaks for instance committing from git.el. This patch reverts to the
previous behavior of only loading the index when merging it.

Signed-off-by: Alexandre Julliard <julliard@winehq.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2009-08-17 09:20:52 -07:00
Junio C Hamano 14683af812 Merge branch 'jc/maint-clean-nested-dir-safety'
* jc/maint-clean-nested-dir-safety:
  clean: require double -f options to nuke nested git repository and work tree
2009-08-16 04:13:13 -07:00
Junio C Hamano b21f9e7f86 Merge branch 'jk/maint-merge-msg-fix'
* jk/maint-merge-msg-fix:
  merge: indicate remote tracking branches in merge message
  merge: fix incorrect merge message for ambiguous tag/branch
  add tests for merge message headings
2009-08-16 04:13:04 -07:00
Junio C Hamano 367ea191e6 Merge branch 'js/stash-dwim' into tr/reset-checkout-patch
* commit 'tr/reset-checkout-patch^^2':
  Make 'git stash -k' a short form for 'git stash save --keep-index'
2009-08-15 15:20:28 -07:00
Thomas Rast dda1f2a5c3 Implement 'git stash save --patch'
This adds a hunk-based mode to git-stash.  You can select hunks from
the difference between HEAD and worktree, and git-stash will build a
stash that reflects these changes.  The index state of the stash is
the same as your current index, and we also let --patch imply
--keep-index.

Note that because the selected hunks are rolled back from the worktree
but not the index, the resulting state may appear somewhat confusing
if you had also staged these changes.  This is not entirely
satisfactory, but due to the way stashes are applied, other solutions
would require a change to the stash format.

Signed-off-by: Thomas Rast <trast@student.ethz.ch>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2009-08-15 15:19:31 -07:00
Thomas Rast 4f353658b9 Implement 'git checkout --patch'
This introduces a --patch mode for git-checkout.  In the index usage

  git checkout --patch -- [files...]

it lets the user discard edits from the <files> at the granularity of
hunks (by selecting hunks from 'git diff' and then reverse applying
them to the worktree).

We also accept a revision argument.  In the case

  git checkout --patch HEAD -- [files...]

we offer hunks from the difference between HEAD and the worktree, and
reverse applies them to both index and worktree, allowing you to
discard staged changes completely.  In the non-HEAD usage

  git checkout --patch <revision> -- [files...]

it offers hunks from the difference between the worktree and
<revision>.  The chosen hunks are then applied to both index and
worktree.

The application to worktree and index is done "atomically" in the
sense that we first check if the patch applies to the index (it should
always apply to the worktree).  If it does not, we give the user a
choice to either abort or apply to the worktree anyway.

Signed-off-by: Thomas Rast <trast@student.ethz.ch>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2009-08-15 15:18:05 -07:00
Thomas Rast d002ef4d94 Implement 'git reset --patch'
This introduces a --patch mode for git-reset.  The basic case is

  git reset --patch -- [files...]

which acts as the opposite of 'git add --patch -- [files...]': it
offers hunks for *un*staging.  Advanced usage is

  git reset --patch <revision> -- [files...]

which offers hunks from the diff between the index and <revision> for
forward application to the index.  (That is, the basic case is just
<revision> = HEAD.)

Signed-off-by: Thomas Rast <trast@student.ethz.ch>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2009-08-15 15:17:47 -07:00
Thomas Rast 3d792161b1 add -p: do not attempt to coalesce mode changes
In 0392513 (add-interactive: refactor mode hunk handling, 2009-04-16),
we merged the interaction loops for mode changes and hunk staging.
This was fine at the time, because 0beee4c (git-add--interactive:
remove hunk coalescing, 2008-07-02) removed hunk coalescing.

However, in 7a26e65 (Revert "git-add--interactive: remove hunk
coalescing", 2009-05-16), we resurrected it.  Since then, the code
would attempt in vain to merge mode changes with diff hunks,
corrupting both in the process.

We add a check to the coalescing loop to ensure it only looks at diff
hunks, thus skipping mode changes.

Noticed-by: Kirill Smelkov <kirr@mns.spb.ru>
Signed-off-by: Thomas Rast <trast@student.ethz.ch>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2009-08-15 10:36:59 -07:00
Kirill Smelkov 87ca2eaade git add -p: demonstrate failure when staging both mode and hunk
When trying to stage changes to file which has also pending `chmod +x`,
`git add -p` produces lots of 'Use of uninitialized value ...' warnings
and fails to do the job:

    $ echo content >> file
    $ chmod +x file
    $ git add -p
    diff --git a/file b/file
    index e69de29..d95f3ad
    --- a/file
    +++ b/file
    old mode 100644
    new mode 100755
    Stage mode change [y,n,q,a,d,/,j,J,g,?]? y
    @@ -0,0 +1 @@
    +content
    Stage this hunk [y,n,q,a,d,/,K,g,e,?]? y
    Use of uninitialized value $o_ofs in addition (+) at .../git-add--interactive line 776.
    Use of uninitialized value $ofs in numeric le (<=) at .../git-add--interactive line 806.
    Use of uninitialized value $o0_ofs in concatenation (.) or string at .../git-add--interactive line 830.
    Use of uninitialized value $n0_ofs in concatenation (.) or string at .../git-add--interactive line 830.
    Use of uninitialized value $o_ofs in addition (+) at .../git-add--interactive line 776.
    fatal: corrupt patch at line 5
    diff --git a/file b/file
    index e69de29..d95f3ad
    --- a/file
    +++ b/file
    @@ -,0 + @@
    +content

Signed-off-by: Kirill Smelkov <kirr@mns.spb.ru>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2009-08-15 10:36:29 -07:00
Jens Lehmann 1c244f6ee5 git submodule summary: add --files option
git submodule summary is providing similar functionality for submodules as
git diff-index does for a git project (including the meaning of --cached).
But the analogon to git diff-files is missing, so add a --files option to
summarize the differences between the index of the super project and the
last commit checked out in the working tree of the submodule.

Signed-off-by: Jens Lehmann <Jens.Lehmann@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2009-08-14 19:50:11 -07:00
Thomas Rast b319ef70a9 Add a small patch-mode testing library
The tests for {reset,commit,stash} -p will frequently have to set both
worktree and index states to known values, and verify that the outcome
(again both worktree and index) are what was expected.

Add a small helper library that lets us do these tasks more easily.

Signed-off-by: Thomas Rast <trast@student.ethz.ch>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2009-08-14 12:40:09 -07:00
Junio C Hamano 9a217391e9 Fix "unpack-objects --strict"
When unpack-objects is run under the --strict option, objects that have
pointers to other objects are verified for the reachability at the end, by
calling check_object() on each of them, and letting check_object to walk
the reachable objects from them using fsck_walk() recursively.

The function however misunderstands the semantics of fsck_walk() function
when it makes a call to it, setting itself as the callback.  fsck_walk()
expects the callback function to return a non-zero value to signal an
error (negative value causes an immediate abort, positive value is still
an error but allows further checks on sibling objects) and return zero to
signal a success.  The function however returned 1 on some non error
cases, and to cover up this mistake, complained only when fsck_walk() did
not detect any error.

To fix this double-bug, make the function return zero on all success
cases, and also check for non-zero return from fsck_walk() for an error.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
2009-08-14 00:52:08 -07:00
Adam Brewster 6f5748e14c svn: allow branches outside of refs/remotes
It may be convenient for some users to store svn remote tracking
branches outside of the refs/remotes/ heirarchy.

To accomplish this feat, this patch includes the entire path to
the ref in $r->{'refname'} in &read_all_remotes and tries to change
references to this entry so the new value makes sense.

[ew: fixed backwards compatibility, long lines]

Signed-off-by: Adam Brewster <adambrewster@gmail.com>
Signed-off-by: Eric Wong <normalperson@yhbt.net>
2009-08-12 22:17:56 -07:00
Eric Wong b186a261b1 svn: initial "master" points to trunk if possible
Since "trunk" is a convention for the main development branch in
the SVN world, try to make that the master branch upon initial
checkout if it exists.  This is probably less surprising based
on user requests.

t9135 was the only test which relied on the previous behavior
and thus needed to be modified.

Signed-off-by: Eric Wong <normalperson@yhbt.net>
2009-08-12 21:41:09 -07:00
Jeff King 19a7fcbf16 allow pull --rebase on branch yet to be born
When doing a "pull --rebase", we check to make sure that the index and
working tree are clean. The index-clean check compares the index against
HEAD. The test erroneously reports dirtiness if we don't have a HEAD yet.

In such an "unborn branch" case, by definition, a non-empty index won't
be based on whatever we are pulling down from the remote, and will lose
the local change.  Just check if $GIT_DIR/index exists and error out.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2009-08-12 15:50:09 -07:00
Nguyễn Thái Ngọc Duy 540e694b13 Prevent diff machinery from examining assume-unchanged entries on worktree
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2009-08-11 23:17:55 -07:00
Junio C Hamano 14468ab45b Merge branch 'jc/maint-merge-recursive-fix'
* jc/maint-merge-recursive-fix:
  merge-recursive: don't segfault while handling rename clashes
2009-08-10 22:17:01 -07:00
Junio C Hamano 38a9f35d1f Merge branch 'ns/am-raw-email'
* ns/am-raw-email:
  git-am: print fair error message when format detection fails
  am: allow individual e-mail files as input
2009-08-10 22:16:42 -07:00
Junio C Hamano 6eedee514e Merge branch 'jp/symlink-dirs'
* jp/symlink-dirs:
  t6035-merge-dir-to-symlink depends on SYMLINKS prerequisite
  git-checkout: be careful about untracked symlinks
  lstat_cache: guard against full match of length of 'name' parameter
  Demonstrate bugs when a directory is replaced with a symlink
2009-08-10 22:15:41 -07:00
Junio C Hamano 67f272c2f2 Merge branch 'mk/grep-max-depth'
* mk/grep-max-depth:
  grep: Add --max-depth option.
2009-08-10 22:15:12 -07:00
Junio C Hamano 08ac69685a Merge branch 'js/run-command-updates'
* js/run-command-updates:
  api-run-command.txt: describe error behavior of run_command functions
  run-command.c: squelch a "use before assignment" warning
  receive-pack: remove unnecessary run_status report
  run_command: report failure to execute the program, but optionally don't
  run_command: encode deadly signal number in the return value
  run_command: report system call errors instead of returning error codes
  run_command: return exit code as positive value
  MinGW: simplify waitpid() emulation macros
2009-08-10 22:14:57 -07:00
Junio C Hamano 584c43567b am: allow individual e-mail files as input
We traditionally allowed a mbox file or a directory name of a maildir (but
never an individual file inside a maildir) to be given to "git am".  Even
though an individual file in a maildir (or more generally, a piece of
RFC2822 e-mail) is not a mbox file, it contains enough information to
create a commit out of it, so there is no reason to reject one.  Running
mailsplit on such a file feels stupid, but it does not hurt.

This builds on top of a5a6755 (git-am foreign patch support: introduce
patch_format, 2009-05-27) that introduced mailbox format detection.  The
codepath to deal with a mbox requires it to begin with "From " line and
also allows it to begin with "From: ", but a random piece of e-mail can
and often do begin with any valid RFC2822 header lines.

Instead of checking the first line, we extract all the lines up to the
first empty line, and make sure they look like e-mail headers.

A test is added to t4150 to demonstrate this feature.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
Signed-off-by: Brandon Casey <drafnel@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2009-08-10 16:54:23 -07:00
Michael Haggerty a7d72544b1 git-svn: ignore leading blank lines in svn:ignore
Subversion ignores all blank lines in svn:ignore properties.  The old
git-svn code ignored blank lines everywhere except for the first line
of the svn:ignore property.  This patch makes the "git svn
show-ignore" and "git svn create-ignore" commands ignore leading blank
lines, too.

Also include leading blank lines in the test suite.

Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
Acked-by: Eric Wong <normalperson@yhbt.net>
2009-08-10 02:35:55 -07:00
Adam Brewster 4ebe6e92c3 svn: Add && to t9107-git-svn-migrate.sh
It was probably intended for the test to fail unless all of the
commands succeed.

[ew: fixed tests to actually work]

Signed-off-by: Eric Wong <normalperson@yhbt.net>
2009-08-10 01:29:40 -07:00
Jeff King 69a8b7c741 merge: indicate remote tracking branches in merge message
Previously when merging directly from a local tracking
branch like:

  git merge origin/master

The merge message said:

   Merge commit 'origin/master'

     * commit 'origin/master':
       ...

Instead, let's be more explicit about what we are merging:

   Merge remote branch 'origin/master'

     * origin/master:
       ...

We accomplish this by recognizing remote tracking branches
in git-merge when we build the simulated FETCH_HEAD output
that we feed to fmt-merge-msg.

In addition to a new test in t7608, we have to tweak the
expected output of t3409, which does such a merge.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2009-08-09 12:34:21 -07:00
Jeff King 751c59746c merge: fix incorrect merge message for ambiguous tag/branch
If we have both a tag and a branch named "foo", then calling
"git merge foo" will warn about the ambiguous ref, but merge
the tag.

When generating the commit message, though, we simply
checked whether "refs/heads/foo" existed, and if it did,
assumed it was a branch. This led to the statement "Merge
branch 'foo'" in the commit message, which is quite wrong.

Instead, we should use dwim_ref to find the actual ref used,
and describe it appropriately.

In addition to the test in t7608, we must also tweak the
expected output of t4202, which was accidentally triggering
this bug.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2009-08-09 12:34:20 -07:00
Jeff King ce06461846 add tests for merge message headings
When calling "git merge $X", we automatically generate a
commit message containing something like "Merge branch
'$X'". This test script checks that those messages say what
they should, and exposes a failure when merging a refname
that is ambiguous between a tag and a branch.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2009-08-09 12:34:19 -07:00
Jeff King c14417c4f5 t/Makefile: include config.mak
This is useful if you want to specify GIT_TEST_OPTS that you
always use.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2009-08-09 10:51:47 -07:00
Jeff King f423ef5f2b tests: allow user to specify trash directory location
The tests generate a large amount of I/O activity creating
and destroying repositories and files. We can improve the
time it takes to run the test suite by creating trash
directories on filesystems with better performance
characteristic, even though we may not want the rest of the
git repository on those filesystems (e.g., because they are
not network connected, or because they are temporary
ramdisks).

For example, on a dual processor system:

  $ cd t && time make -j32
  real    1m51.562s
  user    0m59.260s
  sys     1m20.933s

  # /dev/shm is tmpfs
  $ cd t && time make -j32 GIT_TEST_OPTS="--root=/dev/shm"
  real    1m1.484s
  user    0m53.555s
  sys     1m5.264s

We almost halve the wall clock time, and we utilize the
dual processors much better.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2009-08-09 10:50:32 -07:00
Jeff King 91c8b825ce tests: provide $TRASH_DIRECTORY variable
Most scripts don't care about the absolute path to the trash
directory. The one exception was t4014 script, which pieced
together $TEST_DIRECTORY and $test itself to get an absolute
directory.

Instead, let's provide a $TRASH_DIRECTORY which specifies
the same thing. This keeps the $test variable internal to
test-lib.sh and paves the way for trash directories in other
locations.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2009-08-09 10:49:34 -07:00
Jeff King eaf0551d56 tests: use "$TEST_DIRECTORY" instead of ".."
The $TEST_DIRECTORY variable allows tests to find the
top-level test directory regardless of the current working
directory.

In the past, this has been used to accomodate tests which
change directories, but it is also the first step to being
able to move trash directories outside of the
$TEST_DIRECTORY hierarchy.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2009-08-09 10:48:39 -07:00
Johannes Sixt d82e75e86c t0001-init: split the existence test from the permission test
The test for correct permissions after init created a deep directory
must be guarded by POSIXPERM. But testing that the deep dirctory exists
is good even on platforms that do not provide the POSIXPERM prerequiste.

Signed-off-by: Johannes Sixt <j6t@kdbg.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2009-08-09 10:43:24 -07:00
Johannes Sixt 7d53a07a28 t0001-init: fix a file name
Without this change, grep fails because it does not find the file
instead of because it does not find the text in the file.

Signed-off-by: Johannes Sixt <j6t@kdbg.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2009-08-09 10:41:37 -07:00
Johannes Sixt b6b0737d02 t6035-merge-dir-to-symlink depends on SYMLINKS prerequisite
Signed-off-by: Johannes Sixt <j6t@kdbg.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2009-08-09 10:37:24 -07:00
Junio C Hamano ea5b1f6e12 Merge branch 'maint'
* maint:
  verify-pack -v: do not report "chain length 0"
  t5510: harden the way verify-pack is used
2009-08-07 22:35:17 -07:00
Junio C Hamano 5dc36a5888 Merge branch 'maint-1.6.3' into maint
* maint-1.6.3:
  verify-pack -v: do not report "chain length 0"
  t5510: harden the way verify-pack is used
2009-08-07 20:44:26 -07:00
Junio C Hamano 39836a2e3c Merge branch 'maint-1.6.2' into maint-1.6.3
* maint-1.6.2:
  verify-pack -v: do not report "chain length 0"
  t5510: harden the way verify-pack is used
2009-08-07 20:44:15 -07:00
Junio C Hamano e72263a1f8 Merge branch 'maint-1.6.1' into maint-1.6.2
* maint-1.6.1:
  verify-pack -v: do not report "chain length 0"
  t5510: harden the way verify-pack is used
2009-08-07 20:44:09 -07:00
Junio C Hamano 0d5055665c Merge branch 'maint-1.6.0' into maint-1.6.1
* maint-1.6.0:
  verify-pack -v: do not report "chain length 0"
  t5510: harden the way verify-pack is used
2009-08-07 20:44:02 -07:00
Junio C Hamano 2e674a9d09 t5510: harden the way verify-pack is used
The test ignored the exit status from verify pack command, and also relied
on not seeing any delta chain statistics.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
2009-08-07 20:42:45 -07:00
Junio C Hamano 4d4d5726ae status: show worktree status of conflicted paths separately
When a path is unmerged in the index, we used to always say "unmerged" in
the "Changed but not updated" section, even when the path was deleted in
the work tree.

Remove unmerged entries from the "Updated" section, and create a new
section "Unmerged paths".  Describe how the different stages conflict
in more detail in this new section.

Note that with the current 3-way merge policy (with or without recursive),
certain combinations of index stages should never happen.  For example,
having only stage #2 means that a path that did not exist in the common
ancestor was added by us while the other branch did not do anything to it,
which would have autoresolved to take our addition.  The code nevertheless
prepares for the possibility that future merge policies may leave a path
in such a state.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
2009-08-06 21:16:01 -07:00
Junio C Hamano 0fcb2caf29 am: allow individual e-mail files as input
We traditionally allowed a mbox file or a directory name of a maildir (but
never an individual file inside a maildir) to be given to "git am".  Even
though an individual file in a maildir (or more generally, a piece of
RFC2822 e-mail) is not a mbox file, it contains enough information to
create a commit out of it, so there is no reason to reject one.  Running
mailsplit on such a file feels stupid, but it does not hurt.

This builds on top of a5a6755 (git-am foreign patch support: introduce
patch_format, 2009-05-27) that introduced mailbox format detection.  The
codepath to deal with a mbox requires it to begin with "From " line and
also allows it to begin with "From: ", but a random piece of e-mail can
and often do begin with any valid RFC2822 header lines.

Instead of checking the first line, we extract all the lines up to the
first empty line, and make sure they look like e-mail headers.

A test is added to t4150 to demonstrate this feature.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
Signed-off-by: Brandon Casey <drafnel@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2009-08-06 20:50:15 -07:00