Commit Graph

3301 Commits

Author SHA1 Message Date
Christian Couder
6f53c3b21e t7111: fix bad HEAD in tests with unmerged entries
When testing what happens on unmerged entries, the HEAD is the
commit we are starting from before the merge that fails and create
the unmerged entries. It is not the commit before.

Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-01-16 08:54:36 -08:00
Christian Couder
d7eed8cbef t7111: check that reset options work as described in the tables
Some previous patches added some tables to the "git reset"
documentation. These tables describe the behavior of "git reset"
depending on the option it is passed and the state of the files
in the working tree, the index, HEAD and the target commit.

This patch adds some tests to make sure that the tables describe
the behavior of "git reset".

Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-01-09 23:38:43 -08:00
Junio C Hamano
e11d7b5969 "reset --merge": fix unmerged case
Commit 9e8ecea (Add 'merge' mode to 'git reset', 2008-12-01) disallowed
"git reset --merge" when there was unmerged entries.  But it wished if
unmerged entries were reset as if --hard (instead of --merge) has been
used.  This makes sense because all "mergy" operations makes sure that
any path involved in the merge does not have local modifications before
starting, so resetting such a path away won't lose any information.

The previous commit changed the behavior of --merge to accept resetting
unmerged entries if they are reset to a different state than HEAD, but it
did not reset the changes in the work tree, leaving the conflict markers
in the resulting file in the work tree.

Fix it by doing three things:

 - Update the documentation to match the wish of original "reset --merge"
   better, namely, "An unmerged entry is a sign that the path didn't have
   any local modification and can be safely resetted to whatever the new
   HEAD records";

 - Update read_index_unmerged(), which reads the index file into the cache
   while dropping any higher-stage entries down to stage #0, not to copy
   the object name from the higher stage entry.  The code used to take the
   object name from the a stage entry ("base" if you happened to have
   stage #1, or "ours" if both sides added, etc.), which essentially meant
   that you are getting random results depending on what the merge did.

   The _only_ reason we want to keep a previously unmerged entry in the
   index at stage #0 is so that we don't forget the fact that we have
   corresponding file in the work tree in order to be able to remove it
   when the tree we are resetting to does not have the path.  In order to
   differentiate such an entry from ordinary cache entry, the cache entry
   added by read_index_unmerged() is marked as CE_CONFLICTED.

 - Update merged_entry() and deleted_entry() so that they pay attention to
   cache entries marked as CE_CONFLICTED.  They are previously unmerged
   entries, and the files in the work tree that correspond to them are
   resetted away by oneway_merge() to the version from the tree we are
   resetting to.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-01-03 16:01:05 -08:00
Stephan Beyer
d0f379c2dc reset: use "unpack_trees()" directly instead of "git read-tree"
This patch makes "reset_index_file()" call "unpack_trees()" directly
instead of forking and execing "git read-tree". So the code is more
efficient.

And it's also easier to see which unpack_tree() options will be used,
as we don't need to follow "git read-tree"'s command line parsing
which is quite complex.

As Daniel Barkalow found, there is a difference between this new
version and the old one. The old version gives an error for
"git reset --merge" with unmerged entries, and the new version does
not when we reset the entries to some states that differ from HEAD.
Instead, it resets the index entry and succeeds, while leaving the
conflict markers in the corresponding file in the work tree (which
will be corrected by the next patch).

The code comes from the sequencer GSoC project:

git://repo.or.cz/git/sbeyer.git

(at commit 5a78908b70ceb5a4ea9fd4b82f07ceba1f019079)

Mentored-by: Daniel Barkalow <barkalow@iabervon.org>
Mentored-by: Christian Couder <chriscool@tuxfamily.org>
Signed-off-by: Stephan Beyer <s-beyer@gmx.net>
Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-01-03 15:59:14 -08:00
Christian Couder
c93966906f reset: add a few tests for "git reset --merge"
Commit 9e8eceab ("Add 'merge' mode to 'git reset'", 2008-12-01),
added the --merge option to git reset, but there were no test cases
for it.

This was not a big problem because "git reset" was just forking and
execing "git read-tree", but this will change in a following patch.

So let's add a few test cases to make sure that there will be no
regression.

Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2009-12-30 01:09:46 -08:00
Robert Zeh
b7f44fdf27 git svn: add test for a git svn gc followed by a git svn mkdirs
git svn gc will compress the unhandled.log files that git svn mkdirs reads,
causing git svn mkdirs to skip directory creation.

[ew: trivial whitespace cleanups]
Acked-by: Eric Wong <normalperson@yhbt.net>
Signed-off-by: Robert Zeh <robert.a.zeh@gmail.com>
2009-12-23 11:58:05 -08:00
Junio C Hamano
129a5a6dea Merge branch 'maint'
* maint:
  Prevent git blame from segfaulting on a missing author name
2009-12-22 12:32:39 -08:00
David Reiss
c8cba79181 Prevent git blame from segfaulting on a missing author name
The human-readable author and committer name can be missing from
commits imported from foreign SCM interfaces.  Make sure we parse
the "author" and "committer" line a bit more leniently and avoid
segfaulting by assuming the name always exists.

Signed-off-by: David Reiss <dreiss@facebook.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2009-12-22 11:51:17 -08:00
Sam Vilain
7a955a5365 git-svn: detect cherry-picks correctly.
The old function was incorrect; in some instances it marks a cherry picked
range as a merged branch (because of an incorrect assumption that
'rev-list COMMIT --not RANGE' would work).  This is replaced with a
function which should detect them correctly, memoized to limit the expense
of dealing with branches with many cherry picks to one 'merge-base' call
per merge, per branch which used cherry picking.

Signed-off-by: Sam Vilain <sam@vilain.net>
Acked-by: Eric Wong <normalperson@yhbt.net>
2009-12-21 02:32:53 -08:00
Sam Vilain
33973a5b17 git-svn: fix some mistakes with interpreting SVN mergeinfo commit ranges
SVN's list of commit ranges in mergeinfo tickets is inclusive, whereas
git commit ranges are exclusive on the left hand side.  Also, the end
points of the commit ranges may not exist; they simply delineate
ranges of commits which may or may not exist.  Fix these two mistakes.

Signed-off-by: Sam Vilain <sam@vilain.net>
Acked-by: Eric Wong <normalperson@yhbt.net>
2009-12-21 02:32:50 -08:00
Sam Vilain
1d144aa25e git-svn: expand the svn mergeinfo test suite, highlighting some failures
As shown, git-svn has some problems; not all svn merges are correctly
detected, and cherry picks may incorrectly be detected as real merges.
These test cases will be marked as _success once the relevant fixes are in.

Signed-off-by: Sam Vilain <sam@vilain.net>
Acked-by: Eric Wong <normalperson@yhbt.net>
2009-12-21 02:32:46 -08:00
Eric Wong
8eca03c861 t9146: use 'svn_cmd' wrapper
Using 'svn' directly may not work for all users.

Signed-off-by: Eric Wong <normalperson@yhbt.net>
2009-12-19 23:06:20 -08:00
Eric Wong
a5b80d9263 git svn: make empty directory creation gc-aware
The "git svn gc" command creates and appends to unhandled.log.gz
files which should be parsed before the uncompressed
unhandled.log files.

Reported-by: Robert Zeh
Signed-off-by: Eric Wong <normalperson@yhbt.net>
2009-12-19 14:07:24 -08:00
Junio C Hamano
a1bb8f45f1 Merge branch 'maint' to sync with 1.6.5.7
* maint:
  Git 1.6.5.7
  worktree: don't segfault with an absolute pathspec without a work tree
  ignore unknown color configuration
  help.autocorrect: do not run a command if the command given is junk
  Illustrate "filter" attribute with an example
2009-12-16 12:47:15 -08:00
Junio C Hamano
b3100fd555 worktree: don't segfault with an absolute pathspec without a work tree
If a command is run with an absolute path as a pathspec inside a bare
repository, e.g. "rev-list HEAD -- /home", the code tried to run strlen()
on NULL, which is the result of get_git_work_tree(), and segfaulted.  It
should just fail instead.

Currently the function returns NULL even inside .git/ in a repository
with a work tree, but that is a separate issue.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
2009-12-16 12:45:25 -08:00
Jeff King
8b8e862490 ignore unknown color configuration
When parsing the config file, if there is a value that is
syntactically correct but unused, we generally ignore it.
This lets non-core porcelains store arbitrary information in
the config file, and it means that configuration files can
be shared between new and old versions of git (the old
versions might simply ignore certain configuration).

The one exception to this is color configuration; if we
encounter a color.{diff,branch,status}.$slot variable, we
die if it is not one of the recognized slots (presumably as
a safety valve for user misconfiguration). This behavior
has existed since 801235c (diff --color: use
$GIT_DIR/config, 2006-06-24), but hasn't yet caused a
problem. No porcelain has wanted to store extra colors, and
we once a color area (like color.diff) has been introduced,
we've never changed the set of color slots.

However, that changed recently with the addition of
color.diff.func. Now a user with color.diff.func in their
config can no longer freely switch between v1.6.6 and older
versions; the old versions will complain about the existence
of the variable.

This patch loosens the check to match the rest of
git-config; unknown color slots are simply ignored. This
doesn't fix this particular problem, as the older version
(without this patch) is the problem, but it at least
prevents it from happening again in the future.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2009-12-16 12:45:16 -08:00
Junio C Hamano
4cb51a65a4 Sync with 1.6.5.6
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2009-12-10 16:20:59 -08:00
Junio C Hamano
1456b043fc Remove post-upload-hook
This hook runs after "git fetch" in the repository the objects are
fetched from as the user who fetched, and has security implications.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
2009-12-10 12:21:40 -08:00
Junio C Hamano
ff86bdd5ca Merge branch 'maint'
* maint:
  add-interactive: fix deletion of non-empty files
  pull: clarify advice for the unconfigured error case
2009-12-08 22:47:09 -08:00
Junio C Hamano
a876433c5f Merge branch 'jk/maint-add-p-delete-fix' into maint
* jk/maint-add-p-delete-fix:
  add-interactive: fix deletion of non-empty files
2009-12-08 22:37:50 -08:00
Jeff King
8947fdd598 add-interactive: fix deletion of non-empty files
Commit 24ab81a fixed the deletion of empty files, but broke
deletion of non-empty files. The approach it took was to
factor out the "deleted" line from the patch header into its
own hunk, the same way we do for mode changes. However,
unlike mode changes, we only showed the special "delete this
file" hunk if there were no other hunks. Otherwise, the user
would annoyingly be presented with _two_ hunks: one for
deleting the file and one for deleting the content.

This meant that in the non-empty case, we forgot about the
deleted line entirely, and we submitted a bogus patch to
git-apply (with "/dev/null" as the destination file, but not
marked as a deletion).

Instead, this patch combines the file deletion hunk and the
content deletion hunk (if there is one) into a single
deletion hunk which is either staged or not.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2009-12-07 23:52:46 -08:00
Eric Wong
f9ad77a739 git svn: log removals of empty directories
This also adds a test case for:
  "git svn: Don't create empty directories whose parents were deleted"
which was the reason we found this bug in the first place.

Signed-off-by: Eric Wong <normalperson@yhbt.net>
2009-12-07 20:49:44 -08:00
Junio C Hamano
3880c18336 Sync with 1.6.5.5
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2009-12-05 11:39:13 -08:00
Jeff King
952dfc6944 reset: improve worktree safety valves
The existing code checked to make sure we were not in a bare
repository when doing a hard reset. However, we should take
this one step further, and make sure we are in a worktree.
Otherwise, we can end up munging files inside of '.git'.

Furthermore, we should do the same check for --merge resets,
which have the same properties. Actually, a merge reset of
HEAD^ would already complain, since further down in the code
we want a worktree. However, it is nicer to check up-front;
then we are sure we cover all cases ("git reset --merge"
would run, even though it wasn't doing anything) and we can
give a more specific message.

Add tests to t7103 to cover these cases and some missing ones.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2009-12-05 10:28:20 -08:00
Junio C Hamano
1a56be134f Merge branch 'maint'
* maint:
  Prepare for 1.6.5.5
  Documentation: xmlto 0.0.18 does not know --stringparam
  t4201: use ISO8859-1 rather than ISO-8859-1
2009-12-03 14:07:46 -08:00
Junio C Hamano
dda8f4bf2b Merge branch 'uk/maint-shortlog-encoding' into maint
* uk/maint-shortlog-encoding:
  t4201: use ISO8859-1 rather than ISO-8859-1
  shortlog: respect commit encoding
2009-12-03 13:56:50 -08:00
Junio C Hamano
c8b1d761f6 Merge branch 'fc/maint-format-patch-pathspec-dashes' into maint
* fc/maint-format-patch-pathspec-dashes:
  format-patch: add test for parsing of "--"
  format-patch: fix parsing of "--" on the command line
2009-12-03 13:54:25 -08:00
Junio C Hamano
3920917861 Merge branch 'rj/maint-t9700' into maint
* rj/maint-t9700:
  t9700-perl-git.sh: Fix a test failure on Cygwin
2009-12-03 13:52:22 -08:00
Junio C Hamano
2936824af2 Merge branch 'ls/maint-mailinfo-no-inbody' into maint
* ls/maint-mailinfo-no-inbody:
  git am/mailinfo: Don't look at in-body headers when rebasing
2009-12-03 13:52:16 -08:00
Junio C Hamano
9c1506af6a Merge branch 'pb/maint-use-custom-perl' into maint
* pb/maint-use-custom-perl:
  Make sure $PERL_PATH is defined when the test suite is run.
2009-12-03 13:51:41 -08:00
Junio C Hamano
f2c0ca4fae Merge branch 'bc/grep-i-F' into maint
* bc/grep-i-F:
  grep: Allow case insensitive search of fixed-strings
2009-12-03 13:51:26 -08:00
Johan Herland
488bdf2ebe Fix crasher on encountering SHA1-like non-note in notes tree
When loading a notes tree, the code primarily looks for SHA1-like paths
whose total length (discounting directory separators) are 40 chars
(interpreted as valid note entries) or less (interpreted as subtree
entries that may in turn contain note entries when unpacked).

However, there is an additional condition that must hold for valid
subtree entries: They must be _tree_ objects (duh).

This patch adds an appropriate test for this condition, thereby fixing
the crash that occured when passing a non-tree object to the tree-walk
API.

The patch also adds another selftest verifying correct behaviour of
non-notes in note trees.

Signed-off-by: Johan Herland <johan@herland.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2009-12-03 10:10:35 -08:00
Brandon Casey
907a0b1e04 t9001: use older Getopt::Long boolean prefix '--no' rather than '--no-'
The '--no-chain-reply-to' option is a Getopt::Long boolean option. The
'--no-' prefix (as in --no-chain-reply-to) for boolean options is not
supported in Getopt::Long version 2.32 which was released with Perl 5.8.0.
This version only supports '--no' as in '--nochain-reply-to'.  More recent
versions of Getopt::Long, such as version 2.34, support either prefix. So
use the older form in the tests.

Signed-off-by: Brandon Casey <casey@nrlssc.navy.mil>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2009-12-03 10:07:17 -08:00
Brandon Casey
3994e8a98d t4201: use ISO8859-1 rather than ISO-8859-1
Some ancient platforms do not have an extensive list of alternate names for
character encodings.  For example, Solaris 7 and IRIX 6.5 do not know that
ISO-8859-1 is the same as ISO8859-1.  Modern platforms do know this, so use
the older name.

Signed-off-by: Brandon Casey <casey@nrlssc.navy.mil>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2009-12-03 10:06:13 -08:00
Junio C Hamano
0748494e86 Merge branch 'maint'
* maint:
  Prepare for 1.6.5.4
  merge: do not add standard message when message is given with -m option
  Do not misidentify "git merge foo HEAD" as an old-style invocation

Conflicts:
	RelNotes
2009-12-02 10:30:12 -08:00
Junio C Hamano
ce9d823b91 merge: do not add standard message when message is given with -m option
Even if the user explicitly gave her own message to "git merge", the
command still added its standard merge message.  It resulted in a
useless repetition like this:

    % git merge -m "Merge early part of side branch" `git rev-parse side~2`
    % git show -s
    commit 37217141e7519629353738d5e4e677a15096206f
    Merge: e68e646 a1d2374
    Author: しらいし ななこ <nanako3@lavabit.com>
    Date:   Wed Dec 2 14:33:20 2009 +0900

	Merge early part of side branch

	Merge commit 'a1d2374f8f52f4e8a53171601a920b538a6cec23'

The gave her own message because she didn't want git to add the
standard message (if she wanted to, she wouldn't have given one,
or she would have prepared it using git-fmt-merge-msg command).

Noticed by Nanako Shiraishi

Signed-off-by: Junio C Hamano <gitster@pobox.com>
2009-12-02 10:02:08 -08:00
Junio C Hamano
9eba92f684 Merge branch 'fc/maint-format-patch-pathspec-dashes'
Conflicts:
	t/t4014-format-patch.sh
2009-11-30 14:46:09 -08:00
Junio C Hamano
684d0d8dcf Merge branch 'jc/pretty-lf'
Conflicts:
	pretty.c
	t/t6006-rev-list-format.sh
2009-11-30 14:44:22 -08:00
Junio C Hamano
c142465c07 Merge branch 'em/commit-claim' 2009-11-30 14:43:26 -08:00
Junio C Hamano
0c7cc135c5 Merge branch 'fc/send-email-envelope' 2009-11-30 14:42:50 -08:00
Junio C Hamano
a689faeb58 Merge branch 'uk/maint-shortlog-encoding'
Conflicts:
	builtin-shortlog.c
2009-11-30 14:42:28 -08:00
Junio C Hamano
1bab4bba54 Merge branch 'ns/send-email-no-chain-reply-to' 2009-11-30 14:35:18 -08:00
Junio C Hamano
b918eb6c2a Merge branch 'bw/diff-color-hunk-header' 2009-11-30 14:34:45 -08:00
Matthew Ogilvie
e160da7f60 t/README: Document GIT_TEST_INSTALLED and GIT_TEST_EXEC_PATH
These were added without documentation in 2009-03-16 (6720721).

Signed-off-by: Matthew Ogilvie <mmogilvi_git@miniinfo.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2009-11-29 23:09:56 -08:00
Matthew Ogilvie
5d59a4016b t3409 t4107 t7406 t9150: use dashless commands
This is needed to allow test suite to run against a standard
install bin directory instead of GIT_EXEC_PATH.

Signed-off-by: Matthew Ogilvie <mmogilvi_git@miniinfo.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2009-11-29 23:09:47 -08:00
Matthew Ogilvie
42ac496edc t2300: use documented technique to invoke git-sh-setup
This is needed to allow the test suite to run against a standard
install bin directory instead of GIT_EXEC_PATH.

Signed-off-by: Matthew Ogilvie <mmogilvi_git@miniinfo.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2009-11-29 18:00:14 -08:00
Nanako Shiraishi
528fb08732 prepare send-email for smoother change of --chain-reply-to default
Give a warning message when send-email uses chain-reply-to to thread the
messages because of the current default, not because the user explicitly
asked to, either from the command line or from the configuration.

This way, by the time 1.7.0 switches the default, everybody will be ready.

Signed-off-by: Nanako Shiraishi <nanako3@lavabit.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2009-11-29 00:51:35 -08:00
Bert Wesarg
89cb73a19a Give the hunk comment its own color
Inspired by the coloring of quilt.

Introduce a separate color and paint the hunk comment part, i.e. the name
of the function, in a separate color "diff.func" (defaults to plain).

Whitespace between hunk header and hunk comment is printed in plain color.

Signed-off-by: Bert Wesarg <bert.wesarg@googlemail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2009-11-28 10:05:44 -08:00
Felipe Contreras
c89e324145 send-email: automatic envelope sender
This adds the option to specify the envelope sender as "auto" which
would pick the 'from' address. This is good because now we can specify
the address only in one place in $HOME/.gitconfig and change it easily.

[jc: added tests]

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2009-11-27 23:45:24 -08:00
Junio C Hamano
06a4755270 emit_line(): don't emit an empty <SET><RESET> followed by a newline
When emit_line() is called with an empty line (but non-zero length, as we
send line terminating LF or CRLF to the function), it used to emit
<SET><RESET> followed by a newline.  Stop the wastefulness.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
2009-11-27 22:33:53 -08:00