1
0
mirror of https://github.com/git/git.git synced 2024-10-04 15:42:22 +02:00
Commit Graph

1356 Commits

Author SHA1 Message Date
Steffen Prohaska
e509db990b cvsserver: Fix for histories with multiple roots
Git histories may have multiple roots, which can cause
git merge-base to fail and this caused git cvsserver to die.

This commit teaches git cvsserver to handle a failing git
merge-base gracefully, and modifies the test case to verify this.
All the test cases now use a history with two roots.

Signed-off-by: Steffen Prohaska <prohaska@zib.de>

 git-cvsserver.perl              |    9 ++++++++-
 t/t9400-git-cvsserver-server.sh |   10 +++++++++-
 2 files changed, 17 insertions(+), 2 deletions(-)
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-01-26 17:58:18 -08:00
Steffen Prohaska
7549376587 t9400-git-cvsserver-server: Wrap setup into test case
It is preferable to have the test setup in a test case.  The
setup itself may fail and having it as a test case handles this
situation more gracefully.

Signed-off-by: Steffen Prohaska <prohaska@zib.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-01-26 17:44:05 -08:00
Pierre Habouzit
3a9f0f41db parse-options: catch likely typo in presense of aggregated options.
If options are aggregated, and that the whole token is an exact
prefix of a long option that is longer than 2 letters, reject
it.  This is to prevent a common typo:

	$ git commit -amend

to get interpreted as "commit all with message 'end'".

The typo check isn't performed if there is no aggregation,
because the stuck form is the recommended one.  If we have `-o`
being a valid short option that takes an argument, and --option
a long one, then we _MUST_ accept -option as "'o' option with
argument 'ption'", which is our official recommended form.

Signed-off-by: Pierre Habouzit <madcoder@debian.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-01-26 10:53:31 -08:00
Alex Riesen
9288bedafa Make t5710 more strict when creating nested repos
The test 'creating too deep nesting' can fail even when cloning the repos,
but is not its main purpose (it has to prepare nested repos and ensure
the last one is invalid). So split the test into the creation and
invalidity checking parts.

Signed-off-by: Alex Riesen <raa.lkml@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-01-21 17:24:12 -08:00
Junio C Hamano
7fec10b7f4 index: be careful when handling long names
We currently use lower 12-bit (masked with CE_NAMEMASK) in the
ce_flags field to store the length of the name in cache_entry,
without checking the length parameter given to
create_ce_flags().  This can make us store incorrect length.

Currently we are mostly protected by the fact that many
codepaths first copy the path in a variable of size PATH_MAX,
which typically is 4096 that happens to match the limit, but
that feels like a bug waiting to happen.  Besides, that would
not allow us to shorten the width of CE_NAMEMASK to use the bits
for new flags.

This redefines the meaning of the name length stored in the
cache_entry.  A name that does not fit is represented by storing
CE_NAMEMASK in the field, and the actual length needs to be
computed by actually counting the bytes in the name[] field.
This way, only the unusually long paths need to suffer.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2008-01-21 12:44:31 -08:00
Junio C Hamano
a2d93aea25 git-submodule: add test for the subcommand parser fix
This modifies the existing t7400 test to use 'init' as the
pathname that a submodule is bound to.  Without the earlier
subcommand parser fix, this fails.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-01-20 20:57:42 -08:00
Jeff King
c764a0c2b6 send-email: add no-validate option
Since we are now sanity-checking the contents of patches and
refusing to send ones with long lines, this knob provides a
way for the user to override the new behavior (if, e.g., he
knows his SMTP path will handle it).

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-01-18 13:33:57 -08:00
Jeff King
747bbff9b9 send-email: validate patches before sending anything
We try to catch errors early so that we don't end up sending
half of a broken patch series. Right now the only validation
is checking that line-lengths are under the SMTP-mandated
limit of 998.

The validation parsing is very crude (it just checks each
line length without understanding the mailbox format) but
should work fine for this simple check.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-01-18 13:33:08 -08:00
Junio C Hamano
5c66d0d458 Officially deprecate repo-config.
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-01-17 22:52:40 -08:00
Linus Torvalds
c3b0dec509 Be more careful about updating refs
This makes write_ref_sha1() more careful: it actually checks the SHA1 of
the ref it is updating, and refuses to update a ref with an object that it
cannot find.

Perhaps more importantly, it also refuses to update a branch head with a
non-commit object. I don't quite know *how* the stable series maintainers
were able to corrupt their repository to have a HEAD that pointed to a tag
rather than a commit object, but they did. Which results in a totally
broken repository that cannot be cloned or committed on.

So make it harder for people to shoot themselves in the foot like that.

The test t1400-update-ref.sh is fixed at the same time, as it
assumed that the commands involved in the particular test would
not care about corrupted repositories whose refs point at
nonexistant bogus objects.  That assumption does not hold true
anymore.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-01-16 11:53:35 -08:00
Junio C Hamano
23707811c5 diff: do not chomp hunk-header in the middle of a character
We truncate hunk-header line at 80 bytes, but that 80th byte
could be in the middle of a character, which is bad.  This uses
pick_one_utf8_char() function to make sure we do not cut a character
in the middle.

This assumes that the internal representation of the text is
UTF-8.  This needs to be extended in the future but the optimal
direction has not been decided yet.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-01-06 22:44:44 -08:00
Junio C Hamano
f7ab5c7937 custom pretty format: tolerate empty e-mail address
When e-mail address is empty (e.g. "A U Thor <>"), --pretty=format
misparsed the commit header and did not pick up the date field correctly.

Noticed by Marco, fixed slightly differently with additional sanity
check and with a test.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-01-06 18:41:43 -08:00
Junio C Hamano
e9b20943b7 t/t3800: do not use a temporary file to hold expected result.
It is a good practice to write program output to a temporary file
during the test, as it would allow easier postmortem when the tested
program does break.  But there is no benefit in writing the expected
output out to the temporary.

This actually fixes a bug in check_verify_failure() routine.
The intention of the test seems to make sure the "git mktag" command
fails, and it spits out the expected error message.  But if the
command did not fail as expected, the shell function as originally
written would not have detected the failure.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-01-05 00:07:57 -08:00
Junio C Hamano
0feb4d1c99 t/t{3600,3800,5401}: do not use egrep when grep would do
There is nothing _wrong_ with egrep per se, but this way we
would have less dependency on external tools.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-01-05 00:07:57 -08:00
Miklos Vajna
90ed6c0576 t/t7001: avoid unnecessary ERE when using grep
As pointed out by Junio, it's unnecessary to use "grep -E" and ".+" when we can
just use "grep" and "..*".

Signed-off-by: Miklos Vajna <vmiklos@frugalware.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-01-05 00:07:57 -08:00
Junio C Hamano
7ee906694c t/t7600: avoid GNUism in grep
Using \+ to mean "one or more" in grep without -E is a GNU
extension outside POSIX.  Avoid it.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-01-05 00:07:51 -08:00
Jeff King
49b9362fd3 git-reset: refuse to do hard reset in a bare repository
It makes no sense since there is no working tree. A soft
reset should be fine, though.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-01-02 02:28:54 -08:00
Jeff King
02e5ba4ae6 config: handle lack of newline at end of file better
The config parsing routines use the static global
'config_file' to store the FILE* pointing to the current
config file being parsed. The function get_next_char()
automatically converts an EOF on this file to a newline for
the convenience of its callers, and it sets config_file to
NULL to indicate that EOF was reached.

This throws away useful information, though, since some
routines want to call ftell on 'config_file' to find out
exactly _where_ the routine ended. In the case of a key
ending at EOF boundary, we ended up segfaulting in some
cases (changing that key or adding another key in its
section), or failing to provide the necessary newline
(adding a new section).

This patch adds a new flag to indicate EOF and uses that
instead of setting config_file to NULL. It also makes sure
to add newlines where necessary for truncated input. All
three included tests fail without the patch.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-01-02 02:28:54 -08:00
Junio C Hamano
97d0c52980 Merge branch 'ar/commit-cleanup'
* ar/commit-cleanup:
  Allow selection of different cleanup modes for commit messages
  builtin-commit: avoid double-negation in the code.
  builtin-commit: fix amending of the initial commit
  t7005: do not exit inside test.
2007-12-26 17:35:38 -08:00
Arjen Laarhoven
0faf2da7e5 Fix "git log --diff-filter" bug
In commit b7bb760d5ed4881422673d32f869d140221d3564 (Fix revision
log diff setup, avoid unnecessary diff generation) an optimization was
made to avoid unnecessary diff generation.  This was partly fixed in
99516e35d096f41e7133cacde8fbed8ee9a3ecd0 (Fix embarrassing "git log
--follow" bug).  The '--diff-filter' option also needs the diff machinery
in action.

Signed-off-by: Arjen Laarhoven <arjen@yaph.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2007-12-26 11:57:36 -08:00
Shawn O. Pearce
c8deb5a146 Improve error messages when int/long cannot be parsed from config
If a config file has become mildly corrupted due to a missing LF
we may discover some other option joined up against the end of a
numeric value.  For example:

	[section]
	number = 1auto

where the "auto" flag was meant to occur on the next line, below
"number", but the missing LF has caused it to no longer be its
own option.  Instead the word "auto" is parsed as a 'unit factor'
for the value of "number".

Before this change we got the confusing error message:

  fatal: unknown unit: 'auto'

which told us nothing about where the problem appeared.  Now we get:

  fatal: bad config value for 'aninvalid.unit'

which at least points the user in the right direction of where to
search for the incorrectly formatted configuration file.

Noticed by erikh on #git, which received the original error from
a simple `git checkout -b` due to a midly corrupted config.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2007-12-26 11:37:45 -08:00
Alex Riesen
5f06573743 Allow selection of different cleanup modes for commit messages
Although we traditionally stripped away excess blank lines, trailing
whitespaces and lines that begin with "#" from the commit log message,
sometimes the message just has to be the way user wants it.

For instance, a commit message template can contain lines that begin with
"#", the message must be kept as close to its original source as possible
if you are converting from a foreign SCM, or maybe the message has a shell
script including its comments for future reference.

The cleanup modes are default, verbatim, whitespace and strip. The
default mode depends on if the message is being edited and will either
strip whitespace and comments (if editor active) or just strip the
whitespace (for where the message is given explicitely).

Signed-off-by: Alex Riesen <raa.lkml@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2007-12-22 19:55:07 -08:00
Junio C Hamano
7263881253 t7005: do not exit inside test.
The way to signal failure is to leave non-zero in $?, not abort
the entire test.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
2007-12-22 19:45:06 -08:00
Pierre Habouzit
c43a24834a Force the sticked form for options with optional arguments.
This forbids "git tag -n <number> -l" we allowed earlier, so
adjust t7004 while at it.

Signed-off-by: Pierre Habouzit <madcoder@debian.org>
2007-12-22 10:26:08 -08:00
Pierre Habouzit
78d776a969 git-tag: fix -l switch handling regression.
The command itself takes an optional <pattern> argument that
limits the shown tags to the ones that match when in listing
mode that is triggered with '-l' option.  The <pattern> is not
an optional option-argument to '-l'.

With this fix, "git tag -l -n 4 v0.99" works as expected.

It also removes a few bogus tests in t7004.

Signed-off-by: Pierre Habouzit <madcoder@debian.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2007-12-22 00:05:02 -08:00
Junio C Hamano
885ed372d0 t4024: fix test script to use simpler sed pattern
The earlier test stripped away expected number of 'z' but the output
would have been very hard to read once somebody broke the common tail
optimization.  Instead, count the number of 'z' and show it, to help
diagnosing the problem better in the future.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
2007-12-20 01:11:37 -08:00
Jeff King
ecaa0cff44 test "git clone -o"
This tests a recently fixed regression in which "git clone
-o" didn't work at all.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2007-12-19 14:59:18 -08:00
Johannes Schindelin
34454e858d rebase -p -i: handle "no changes" gracefully
Since commit 376ccb8cbb453343998e734d8a1ce79f57a4e092 (rebase -i: style
fixes and minor cleanups), unchanged SHA-1s are no longer mapped via
$REWRITTEN.  But the updating phase was not prepared for the old head
not being rewritten.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2007-12-17 20:49:18 -08:00
H.Merijn Brand
3175b0cfc1 the use of 'tr' in the test suite isn't really portable
Some versions of 'tr' only accept octal codes if entered with three digits,
and therefor misinterpret the '\0' in the test suite.

Some versions of 'tr' reject the (needless) use of character classes.

Signed-off-by: H.Merijn Brand <h.m.brand@xs4all.nl>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2007-12-17 20:49:18 -08:00
Junio C Hamano
079fe1dae8 Re-re-re-fix common tail optimization
We need to be extra careful recovering the removed common section, so
that we do not break context nor the changed incomplete line (i.e. the
last line that does not end with LF).

Signed-off-by: Junio C Hamano <gitster@pobox.com>
2007-12-16 14:00:30 -08:00
J. Bruce Fields
9afa2d4aa9 whitespace: fix initial-indent checking
After this patch, "written" counts the number of bytes up to and
including the most recently seen tab.  This allows us to detect (and
count) spaces by comparing to "i".

This allows catching initial indents like '\t        ' (a tab followed
by 8 spaces), while previously indent-with-non-tab caught only indents
that consisted entirely of spaces.

This also allows fixing an indent-with-non-tab regression, so we can
again detect indents like '\t \t'.

Also update tests to catch these cases.

Signed-off-by: J. Bruce Fields <bfields@citi.umich.edu>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2007-12-16 13:07:49 -08:00
J. Bruce Fields
4d9697c787 whitespace: fix off-by-one error in non-space-in-indent checking
If there were no tabs, and the last space was at position 7, then
positions 0..7 had spaces, so there were 8 spaces.

Update test to check exactly this case.

Signed-off-by: J. Bruce Fields <bfields@citi.umich.edu>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2007-12-16 13:07:14 -08:00
Petr Baudis
bc8b95ae4a gitweb: Make config_to_multi return [] instead of [undef]
This is important for the list of clone urls, where if there are
no per-repository clone URL configured, the default base URLs
are never used for URL construction without this patch.

Add tests for different ways of setting project URLs, just in case.
Note that those tests in current form wouldn't detect breakage fixed
by this patch, as it only checks for errors and not for expected
output.

Signed-off-by: Petr Baudis <pasky@suse.cz>
Signed-off-by: Jakub Narebski <jnareb@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2007-12-16 11:56:27 -08:00
Junio C Hamano
dfaf75b469 Merge branch 'wc/diff'
* wc/diff:
  Test interaction between diff --check and --exit-code
  Use shorter error messages for whitespace problems
  Add tests for "git diff --check" with core.whitespace options
  Make "diff --check" output match "git apply"
  Unify whitespace checking
  diff --check: minor fixups
  "diff --check" should affect exit status
2007-12-14 21:42:53 -08:00
Wincent Colaiuta
5973a07937 Test interaction between diff --check and --exit-code
Make sure that it works as advertised in the man page.

Signed-off-by: Wincent Colaiuta <win@wincent.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2007-12-14 20:52:26 -08:00
Wincent Colaiuta
420f4f04de Use shorter error messages for whitespace problems
The initial version of the whitespace_error_string() function took the
messages from builtin-apply.c rather than the shorter messages from
diff.c.

This commit addresses Junio's concern that these messages might be too
long (now that we can emit multiple warnings per line).

Signed-off-by: Wincent Colaiuta <win@wincent.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2007-12-14 20:51:58 -08:00
Junio C Hamano
1eb1e9eea4 commit: allow --amend to reuse message from another commit
After tentatively applying a patch from a contributor, you can get a
replacement patch with corrected code and unusable commit log message.
In such a case, this sequence ought to give you an editor based on the
message in the earlier commit, to let you describe an incremental
improvement:

    git reset --hard HEAD^ ;# discard the earlier one
    git am <corrected-patch
    git commit --amend -c HEAD@{1}

Unfortunately, --amend insisted reusing the message from the commit
being amended, ignoring the -c option.  This corrects it.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
2007-12-14 15:39:54 -08:00
Eric Wong
12a6d752fb git-svn: handle our top-level path being deleted and later re-added
Previously, git-svn would ignore cases where the path we're
tracking is removed from the repository.  This was to prevent
heads with follow-parent from ending up with a tree full of
empty revisions (and thus breaking rename detection).

The previous behavior is fine until the path we're tracking
is re-added later on, leading to the old files being merged
in with the new files in the directory (because the old
files were never marked as deleted)

We will now only remove all the old files locally that were
deleted remotely iff we detect the directory we're in is being
created from scratch.

Thanks for Marcus D. Hanwell for the bug report and
Peter Baumann for the analysis.

Signed-off-by: Eric Wong <normalperson@yhbt.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2007-12-14 12:06:23 -08:00
Wincent Colaiuta
f817546652 Add tests for "git diff --check" with core.whitespace options
Make sure that "git diff --check" does the right thing when the
core.whitespace options are set.

While we are at it, correct many uses of test_expect_failure that
ran sequence of commands.

Signed-off-by: Wincent Colaiuta <win@wincent.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2007-12-13 23:53:20 -08:00
Wincent Colaiuta
c1795bb08a Unify whitespace checking
This commit unifies three separate places where whitespace checking was
performed:

 - the whitespace checking previously done in builtin-apply.c is
extracted into a function in ws.c

 - the equivalent logic in "git diff" is removed

 - the emit_line_with_ws() function is also removed because that also
rechecks the whitespace, and its functionality is rolled into ws.c

The new function is called check_and_emit_line() and it does two things:
checks a line for whitespace errors and optionally emits it. The checking
is based on lines of content rather than patch lines (in other words, the
caller must strip the leading "+" or "-"); this was suggested by Junio on
the mailing list to allow for a future extension to "git show" to display
whitespace errors in blobs.

At the same time we teach it to report all classes of whitespace errors
found for a given line rather than reporting only the first found error.

Signed-off-by: Wincent Colaiuta <win@wincent.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2007-12-13 23:43:58 -08:00
Junio C Hamano
da31b358fb diff --check: minor fixups
There is no reason --exit-code and --check-diff must be mutually
exclusive, so assign different bits to different results and allow them
to be returned from the command.  Introduce diff_result_code() to factor
out the common code to decide final status code based on diffopt
settings and use it everywhere.

Update tests to match the above fix.

Turning pager off when "diff --check" is used is a regression.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
2007-12-13 23:40:27 -08:00
Wincent Colaiuta
62c64895cf "diff --check" should affect exit status
"git diff" has a --check option that can be used to check for whitespace
problems but it only reported by printing warnings to the
console.

Now when the --check option is used we give a non-zero exit status,
making "git diff --check" nicer to use in scripts and hooks.

Signed-off-by: Wincent Colaiuta <win@wincent.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2007-12-13 23:05:42 -08:00
Junio C Hamano
3e5f260144 Merge branch 'ew/svn-rev-db'
* ew/svn-rev-db:
  git-svn: reinstate old rev_db optimization in new rev_map
  git-svn: replace .rev_db with a more space-efficient .rev_map format
2007-12-12 16:53:06 -08:00
Junio C Hamano
8d08f2d81a disable t9119 for now.
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2007-12-12 11:53:29 -08:00
Wincent Colaiuta
86f8c23685 Fix "diff --check" whitespace detection
"diff --check" would only detect spaces before tabs if a tab was the
last character in the leading indent. Fix that and add a test case to
make sure the bug doesn't regress in the future.

Signed-off-by: Wincent Colaiuta <win@wincent.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2007-12-12 11:24:33 -08:00
Linus Torvalds
be15f50538 "git tag -u keyname" broken
Commit 396865859918e9c7bf8ce74aae137c57da134610 broke signed tags using
the "-u" flag when it made builtin-tag.c use parse_options() to parse its
arguments (but it quite possibly was broken even before that, by the
builtin rewrite).

It used to be that passing the signing ID with the -u parameter also
(obviously!) implied that you wanted to sign and annotate the tag, but
that logic got dropped. It also totally ignored the actual key ID that was
passed in.

This reinstates it all.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2007-12-11 00:38:46 -08:00
Eric Wong
060610c572 git-svn: replace .rev_db with a more space-efficient .rev_map format
Migrations are done automatically on an as-needed basis when new
revisions are to be fetched.  Stale remote branches do not get
migrated, yet.

However, unless you set noMetadata or useSvkProps it's safe to
just do:

  find $GIT_DIR/svn -name '.rev_db*' -print0 | xargs rm -f

to purge all the old .rev_db files.

The new format is a one-way migration and is NOT compatible with
old versions of git-svn.

This is the replacement for the rev_db format, which was too big
and inefficient for large repositories with a lot of sparse history
(mainly tags).

The format is this:

  - 24 bytes for every record,
    * 4 bytes for the integer representing an SVN revision number
    * 20 bytes representing the sha1 of a git commit

  - No empty padding records like the old format

  - new records are written append-only since SVN revision numbers
    increase monotonically

  - lookups on SVN revision number are done via a binary search

  - Piping the file to xxd(1) -c24 is a good way of dumping it for
    viewing or editing, should the need ever arise.

As with .rev_db, these files are disposable unless noMetadata or
useSvmProps is set.

Signed-off-by: Eric Wong <normalperson@yhbt.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2007-12-10 21:28:25 -08:00
Daniel Barkalow
c07c7bf630 Add more checkout tests
If you have local changes that don't conflict with the
branch-switching changes, these should be kept, not cause errors even
without -m, and be reported afterwards in name-status format.

With -m, the changes carried across should be listed as well. And, for
now, include the merge-recursive output from this process.

Also test the detatched head message in at least one case.

Signed-off-by: Daniel Barkalow <barkalow@iabervon.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2007-12-10 11:24:56 -08:00
Wincent Colaiuta
cf7e147cce Style fixes for pre-commit hook tests
As pointed out by Junio on the mailing list, surrounding tests in
double quotes can lead to bugs wherein variables get substituted away,
so this isn't just style churn but important to prevent others from
looking at these tests in the future and thinking that this is "the
way" that Git tests should be written.

Signed-off-by: Wincent Colaiuta <win@wincent.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2007-12-10 00:05:52 -08:00
Wincent Colaiuta
80f86605ba Interactive editor tests for commit-msg hook
Supplement the existing tests for the commit-msg hook (which all use
"git commit -m") with tests which use an interactive editor (no -m
switch) to ensure that all code paths get tested.

At the same time the quoting of some of the existing tests is changed
to conform to Junio's recommendations for test style (single quotes
used around the test unless there is a compelling reason not to, and
the opening quote on the same line as the test_expect and the closing
quote in column 1).

Signed-off-by: Wincent Colaiuta <win@wincent.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2007-12-10 00:05:52 -08:00
Junio C Hamano
4eb39e9bcc Merge branch 'jc/spht'
* jc/spht:
  Use gitattributes to define per-path whitespace rule
  core.whitespace: documentation updates.
  builtin-apply: teach whitespace_rules
  builtin-apply: rename "whitespace" variables and fix styles
  core.whitespace: add test for diff whitespace error highlighting
  git-diff: complain about >=8 consecutive spaces in initial indent
  War on whitespace: first, a bit of retreat.

Conflicts:

	cache.h
	config.c
	diff.c
2007-12-09 01:23:48 -08:00
Wincent Colaiuta
264474f29a Add tests for pre-commit and commit-msg hooks
As desired, these pass for git-commit.sh, fail for builtin-commit (prior
to the fixes), and succeeded for builtin-commit (after the fixes).

Signed-off-by: Wincent Colaiuta <win@wincent.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2007-12-09 00:55:55 -08:00
Jeff King
46f721c8fe add status.relativePaths config variable
The output of git-status was recently changed to output relative
paths. Setting this variable to false restores the old behavior for
any old-timers that prefer it.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2007-12-08 03:33:24 -08:00
Junio C Hamano
a43aa4cec8 Merge branch 'jc/clean-fix'
* jc/clean-fix:
  t7300: add test for clean with wildcard pathspec
  git-clean: Honor pathspec.
2007-12-06 23:43:35 -08:00
Johannes Sixt
c9ecf4f12a for-each-ref: Fix quoting style constants.
for-each-ref can accept only one quoting style. For this reason it uses
OPT_BIT for the quoting style switches so that it is easy to check for
more than one bit being set. However, not all symbolic constants were
actually single bit values. In particular:

    $ git for-each-ref --python
    error: more than one quoting style ?

This fixes it.

While we are here, let's also remove the space before the question mark.

Signed-off-by: Johannes Sixt <johannes.sixt@telecom.at>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2007-12-06 07:53:20 -08:00
Junio C Hamano
cf1b7869f0 Use gitattributes to define per-path whitespace rule
The `core.whitespace` configuration variable allows you to define what
`diff` and `apply` should consider whitespace errors for all paths in
the project (See gitlink:git-config[1]).  This attribute gives you finer
control per path.

For example, if you have these in the .gitattributes:

    frotz   whitespace
    nitfol  -whitespace
    xyzzy   whitespace=-trailing

all types of whitespace problems known to git are noticed in path 'frotz'
(i.e. diff shows them in diff.whitespace color, and apply warns about
them), no whitespace problem is noticed in path 'nitfol', and the
default types of whitespace problems except "trailing whitespace" are
noticed for path 'xyzzy'.  A project with mixed Python and C might want
to have:

    *.c    whitespace
    *.py   whitespace=-indent-with-non-tab

in its toplevel .gitattributes file.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
2007-12-06 00:45:30 -08:00
Jeff King
d3357ab873 t7300: add test for clean with wildcard pathspec
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2007-12-05 22:47:45 -08:00
Junio C Hamano
27ee189163 Merge branch 'maint'
* maint:
  git-am -i: report rewritten title
  git grep shows the same hit repeatedly for unmerged paths
  Do check_repository_format() early (re-fix)
  Do check_repository_format() early
  Add missing inside_work_tree setting in setup_git_directory_gently
2007-12-05 17:49:13 -08:00
Junio C Hamano
9d25acc49a Merge branch 'nd/maint-work-tree-fix' into maint
* nd/maint-work-tree-fix:
  Do check_repository_format() early (re-fix)
  Do check_repository_format() early
  Add missing inside_work_tree setting in setup_git_directory_gently
2007-12-05 15:07:23 -08:00
Nguyễn Thái Ngọc Duy
9459aa77a0 Do check_repository_format() early (re-fix)
This pushes check_repository_format() (actually _gently() version)
to setup_git_directory_gently() in order to prevent from
using unsupported repositories.

New setup_git_directory_gently()'s behaviour is stop searching
for a valid gitdir and return as if there is no gitdir if a
unsupported repository is found. Warning will be thrown in these
cases.

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2007-12-05 15:06:37 -08:00
Junio C Hamano
c701596199 t5510: add a bit more tests for fetch
"git pull/fetch" that gets explicit refspecs from the command line should
not update configured tracking refs.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
2007-12-04 21:58:42 -08:00
Junio C Hamano
31cbb5d961 Merge branch 'kh/commit'
* kh/commit: (33 commits)
  git-commit --allow-empty
  git-commit: Allow to amend a merge commit that does not change the tree
  quote_path: fix collapsing of relative paths
  Make git status usage say git status instead of git commit
  Fix --signoff in builtin-commit differently.
  git-commit: clean up die messages
  Do not generate full commit log message if it is not going to be used
  Remove git-status from list of scripts as it is builtin
  Fix off-by-one error when truncating the diff out of the commit message.
  builtin-commit.c: export GIT_INDEX_FILE for launch_editor as well.
  Add a few more tests for git-commit
  builtin-commit: Include the diff in the commit message when verbose.
  builtin-commit: fix partial-commit support
  Fix add_files_to_cache() to take pathspec, not user specified list of files
  Export three helper functions from ls-files
  builtin-commit: run commit-msg hook with correct message file
  builtin-commit: do not color status output shown in the message template
  file_exists(): dangling symlinks do exist
  Replace "runstatus" with "status" in the tests
  t7501-commit: Add test for git commit <file> with dirty index.
  ...
2007-12-04 17:16:33 -08:00
Junio C Hamano
9bbe6db85f Merge branch 'sp/refspec-match'
* sp/refspec-match:
  refactor fetch's ref matching to use refname_match()
  push: use same rules as git-rev-parse to resolve refspecs
  add refname_match()
  push: support pushing HEAD to real branch name
2007-12-04 17:07:10 -08:00
H.Merijn Brand
5188408057 Do not rely on the exit status of "unset" for unset variables
POSIX says that exit status "0" means that "unset" successfully unset
the variable.  However, it is kind of ambiguous if an environment
variable which was not set could be successfully unset.

At least the default shell on HP-UX insists on reporting an error in
such a case, so just ignore the exit status of "unset".

[Dscho: extended the patch to git-submodule.sh, as Junio realized that
 this is the only other place where we check the exit status of "unset".]

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2007-12-04 14:48:45 -08:00
Jeff King
dcbcb707c3 t9600: require cvsps 2.1 to perform tests
git-cvsimport won't run at all with less than cvsps 2.1, because it
lacks the -A flag. But there's no point in preventing people who have an
old cvsps from running the full testsuite.

Tested-by: A Large Angry SCM <gitzilla@gmail.com>
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2007-12-04 14:43:05 -08:00
Johannes Schindelin
ee4bc3715f fast-export: rename the signed tag mode 'ignore' to 'verbatim'
The name 'verbatim' describes much better what this mode does with
signed tags.  While at it, fix the documentation what it actually
does.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2007-12-03 23:43:07 -08:00
Junio C Hamano
36863af16e git-commit --allow-empty
It does not usually make sense to record a commit that has the exact
same tree as its sole parent commit and that is why git-commit prevents
you from making such a mistake, but when data from foreign scm is
involved, it is a different story.  We are equipped to represent such an
(perhaps insane, perhaps by mistake, or perhaps done on purpose) empty
change, and it is better to represent it bypassing the safety valve for
native use.

This is primarily for use by foreign scm interface scripts.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
2007-12-03 00:36:49 -08:00
Johannes Sixt
13aba1e514 git-commit: Allow to amend a merge commit that does not change the tree
Normally, it should not be allowed to generate an empty commit. A merge
commit generated with git 'merge -s ours' does not change the tree (along
the first parent), but merges are not "empty" even if they do not change
the tree. Hence, commit 8588452ceb7 allowed to amend a merge commit that
does not change the tree, but 4fb5fd5d301 disallowed it again in an
attempt to avoid that an existing commit is amended such that it becomes
empty. With this change, a commit can be edited (create a new one or amend
an existing one) either if there are changes or if there are at least two
parents.

Signed-off-by: Johannes Sixt <johannes.sixt@telecom.at>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2007-12-03 00:25:26 -08:00
Jeff King
69e7491835 quote_path: fix collapsing of relative paths
The code tries to collapse identical leading components
between the prefix and the path. So if we're in "dir1", the
path "dir1/file" should become just "file". However, we were
ending up with "../dir1/file". The included test expected
the wrong output.

The "len" parameter to quote_path can be negative to mean
"this is a NUL terminated string".  Simply count it so that
the loop can rely on it being the length of the path.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2007-12-02 23:35:46 -08:00
Junio C Hamano
afcc4f7767 Merge branch 'js/prune-expire'
* js/prune-expire:
  Add "--expire <time>" option to 'git prune'
2007-12-02 23:03:38 -08:00
Junio C Hamano
de4c6011d2 Merge branch 'js/fast-export'
* js/fast-export:
  Add 'git fast-export', the sister of 'git fast-import'
2007-12-02 23:01:15 -08:00
Junio C Hamano
0ebd5d7186 Merge branch 'js/pull-rebase'
* js/pull-rebase:
  Teach 'git pull' about --rebase
2007-12-02 23:00:43 -08:00
Junio C Hamano
a1d3b0cae1 Merge branch 'jc/typebreak'
* jc/typebreak:
  Enable rewrite as well as rename detection in git-status
  rename: Break filepairs with different types.
2007-12-02 22:59:28 -08:00
Johannes Schindelin
f2dc849e9c Add 'git fast-export', the sister of 'git fast-import'
This program dumps (parts of) a git repository in the format that
fast-import understands.

For clarity's sake, it does not use the 'inline' method of specifying
blobs in the commits, but builds the blobs before building the commits.

Since signed tags' signatures will not necessarily be valid (think
transformations after the export, or excluding revisions, changing
the history), there are 4 modes to handle them: abort (default),
ignore, warn and strip.  The latter just turns the tags into
unsigned ones.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2007-12-02 19:22:12 -08:00
Junio C Hamano
ada59fcd32 Merge branch 'maint'
* maint:
  t9600: test cvsimport from CVS working tree
2007-12-02 11:00:45 -08:00
Jeff King
4e596e988a t9600: test cvsimport from CVS working tree
This test passes with v1.5.3.7, but not with v1.5.3.6.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2007-12-02 10:59:59 -08:00
Junio C Hamano
b45563a229 rename: Break filepairs with different types.
When we consider if a path has been totally rewritten, we did not
touch changes from symlinks to files or vice versa.  But a change
that modifies even the type of a blob surely should count as a
complete rewrite.

While we are at it, modernise diffcore-break to be aware of gitlinks (we
do not want to touch them).

Signed-off-by: Junio C Hamano <gitster@pobox.com>
2007-12-02 02:24:46 -08:00
Junio C Hamano
5fa00a4dcf Merge branch 'jc/branch-contains'
* jc/branch-contains:
  git-branch --contains: doc and test
  git-branch --contains=commit
  parse-options: Allow to hide options from the default usage.
2007-12-01 13:58:54 -08:00
Junio C Hamano
c4d48ab5af Merge branch 'cr/tag-options'
* cr/tag-options:
  git-tag: test that -s implies an annotated tag
  "git-tag -s" should create a signed annotated tag
  builtin-tag: accept and process multiple -m just like git-commit
  Make builtin-tag.c use parse_options.
2007-12-01 13:58:46 -08:00
Junio C Hamano
b52e985a4f Merge 1.5.3.7 in
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2007-12-01 12:49:51 -08:00
Junio C Hamano
74e3f97be8 Fix typo in t4008 test title
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2007-12-01 11:06:41 -08:00
Junio C Hamano
65c6a4696a Merge branch 'maint'
* maint:
  Replace the word 'update-cache' by 'update-index' everywhere
  cvsimport: fix usage of cvsimport.module
  t7003-filter-branch: Fix test of a failing --msg-filter.
  cvsimport: miscellaneous packed-ref fixes
  cvsimport: use rev-parse to support packed refs
  Add basic cvsimport tests
2007-11-30 16:21:33 -08:00
Johannes Schindelin
f01913e419 Add "--expire <time>" option to 'git prune'
Earlier, 'git prune' would prune all loose unreachable objects.
This could be quite dangerous, as the objects could be used in
an ongoing operation.

This patch adds a mode to expire only loose, unreachable objects
which are older than a certain time.  For example, by

	git prune --expire 14.days

you can prune only those objects which are loose, unreachable
and older than 14 days (and thus probably outdated).

The implementation uses st.st_mtime rather than st.st_ctime,
because it can be tested better, using 'touch -d <time>' (and
omitting the test when the platform does not support that
command line switch).

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2007-11-30 15:47:01 -08:00
Johannes Schindelin
10455d2a95 Replace the word 'update-cache' by 'update-index' everywhere
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2007-11-30 15:09:40 -08:00
Jeff King
67d232426b cvsimport: fix usage of cvsimport.module
There were two problems:

  1. We only look at the config variable if there is no module
     given on the command line. We checked this by comparing
     @ARGV == 0. However, at the time of the comparison, we
     have not yet parsed the dashed options, meaning that
     "git cvsimport" would read the variable but "git
     cvsimport -a" would not. This is fixed by simply moving
     the check after the call to getopt.

  2. If the config variable did not exist, we were adding an
     empty string to @ARGV. The rest of the script, rather
     than barfing for insufficient input, would then try to
     import the module '', leading to rather confusing error
     messages. Based on patch from Emanuele Giaquinta.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2007-11-30 15:00:31 -08:00
Johannes Schindelin
28391a80a9 receive-pack: allow deletion of corrupt refs
Occasionally, in some setups (*cough* forks on repo.or.cz *cough*) some
refs go stale, e.g. when the forkee rebased and lost some objects needed
by the fork.  The quick & dirty way to deal with those refs is to delete
them and push them again.

However, git-push first would first fetch the current commit name for the
ref, would receive a null sha1 since the ref does not point to a valid
object, then tell receive-pack that it should delete the ref with this
commit name.  delete_ref() would be subsequently be called, and check that
resolve_ref() (which does _not_ check for validity of the object) returns
the same commit name.  Which would fail.

The proper fix is to avoid corrupting repositories, but in the meantime
this is a good fix in any case.

Incidentally, some instances of "cd .." in the test cases were fixed, so
that subsequent test cases run in t/trash/ irrespective of the outcome of
the previous test cases.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2007-11-30 14:59:43 -08:00
Junio C Hamano
a6214fe06e Merge branch 'jk/maint-cvsimport-fix' into maint
* jk/maint-cvsimport-fix:
  cvsimport: miscellaneous packed-ref fixes
  cvsimport: use rev-parse to support packed refs
  Add basic cvsimport tests
2007-11-30 14:22:54 -08:00
Johannes Sixt
fdd7d48d6a t7003-filter-branch: Fix test of a failing --msg-filter.
The test passed for the wrong reason: If the script given to --msg-filter
fails, it is expected that git-filter-branch aborts. But the test forgot
to tell the branch name to rewrite, and so git-filter-branch failed due to
incorrect usage.

Signed-off-by: Johannes Sixt <johannes.sixt@telecom.at>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2007-11-30 14:16:52 -08:00
Johannes Schindelin
cd67e4d46b Teach 'git pull' about --rebase
When calling 'git pull' with the '--rebase' option, it performs a
fetch + rebase instead of a fetch + merge.

This behavior is more desirable than fetch + pull when a topic branch
is ready to be submitted and needs to be update.

fetch + rebase might also be considered a better workflow with shared
repositories in any case, or for contributors to a centrally managed
repository, such as WINE's.

As a convenience, you can set the default behavior for a branch by
defining the config variable branch.<name>.rebase, which is
interpreted as a bool.  This setting can be overridden on the command
line by --rebase and --no-rebase.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2007-11-28 17:32:23 -08:00
Jeff King
0673c96db9 Revert "t5516: test update of local refs on push"
This reverts commit 09fba7a59d38d1cafaf33eadaf1d409c4113b30c.

These tests are superseded by the ones in t5404 (added in
6fa92bf3 and 8736a848), which are more extensive and better
organized.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2007-11-28 15:52:23 -08:00
Jeff King
9da0dabcd9 cvsimport: use rev-parse to support packed refs
Previously, if refs were packed, git-cvsimport would assume
that particular refs did not exist. This could lead to, for
example, overwriting previous 'origin' commits that were
packed.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2007-11-28 14:38:06 -08:00
Jeff King
795c7c0b08 Add basic cvsimport tests
We weren't even testing basic things before, so let's at
least try importing and updating a trivial repository, which
will catch total breakage.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2007-11-28 14:14:21 -08:00
Jeff King
10507857fe git-tag: test that -s implies an annotated tag
This detects a regression introduced while moving git-tag to a C
builtin.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2007-11-25 21:23:28 -08:00
Junio C Hamano
788ea12d43 Merge branch 'rv/maint-index-commit' into maint
* rv/maint-index-commit:
  Make GIT_INDEX_FILE apply to git-commit
2007-11-24 18:03:29 -08:00
Junio C Hamano
be4b37b9ad Merge branch 'lt/maint-rev-list-gitlink' into maint
* lt/maint-rev-list-gitlink:
  Fix rev-list when showing objects involving submodules
2007-11-24 18:03:20 -08:00
Junio C Hamano
bc2b8eafaf Merge branch 'jc/maint-add-sync-stat' into maint
* jc/maint-add-sync-stat:
  t2200: test more cases of "add -u"
  git-add: make the entry stat-clean after re-adding the same contents
  ce_match_stat, run_diff_files: use symbolic constants for readability
2007-11-24 18:03:04 -08:00
Junio C Hamano
d1c7cd13dc Merge branch 'jc/maint-format-patch-encoding' into maint
* jc/maint-format-patch-encoding:
  test format-patch -s: make sure MIME content type is shown as needed
  format-patch -s: add MIME encoding header if signer's name requires so
2007-11-24 18:02:30 -08:00
Junio C Hamano
18a135f419 Merge branch 'bs/maint-t7005' into maint
* bs/maint-t7005:
  t7005-editor.sh: Don't invoke real vi when it is in GIT_EXEC_PATH
2007-11-24 18:01:46 -08:00
Junio C Hamano
89919f4f57 Merge branch 'bs/maint-commit-options' into maint
* bs/maint-commit-options:
  git-commit: Add tests for invalid usage of -a/--interactive with paths
  git-commit.sh: Fix usage checks regarding paths given when they do not make sense
2007-11-24 17:54:08 -08:00
Junio C Hamano
d5a4164140 builtin-apply: teach whitespace_rules
We earlier introduced core.whitespace to allow users to tweak the
definition of what the "whitespace errors" are, for the purpose of diff
output highlighting.  This teaches the same to git-apply, so that the
command can both detect (when --whitespace=warn option is given) and fix
(when --whitespace=fix option is given) as configured.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
2007-11-24 16:47:08 -08:00
Junio C Hamano
29cc0ef1ab t4119: correct overeager war-on-whitespace
Earlier a6080a0a44d5ead84db3dabbbc80e82df838533d (War on whitespace)
dropped a necessary trailing whitespace from the test vector.
2007-11-24 16:46:42 -08:00
Junio C Hamano
fd200790dc Merge branch 'jk/send-pack'
* jk/send-pack: (24 commits)
  send-pack: cluster ref status reporting
  send-pack: fix "everything up-to-date" message
  send-pack: tighten remote error reporting
  make "find_ref_by_name" a public function
  Fix warning about bitfield in struct ref
  send-pack: assign remote errors to each ref
  send-pack: check ref->status before updating tracking refs
  send-pack: track errors for each ref
  git-push: add documentation for the newly added --mirror mode
  Add tests for git push'es mirror mode
  Update the tracking references only if they were succesfully updated on remote
  Add a test checking if send-pack updated local tracking branches correctly
  git-push: plumb in --mirror mode
  Teach send-pack a mirror mode
  send-pack: segfault fix on forced push
  Reteach builtin-ls-remote to understand remotes
  send-pack: require --verbose to show update of tracking refs
  receive-pack: don't mention successful updates
  more terse push output
  Build in ls-remote
  ...
2007-11-24 16:45:37 -08:00
Junio C Hamano
ab002e34e2 Merge branch 'js/mingw-fallouts'
* js/mingw-fallouts:
  fetch-pack: Prepare for a side-band demultiplexer in a thread.
  rehabilitate some t5302 tests on 32-bit off_t machines
  Allow ETC_GITCONFIG to be a relative path.
  Introduce git_etc_gitconfig() that encapsulates access of ETC_GITCONFIG.
  Allow a relative builtin template directory.
  Close files opened by lock_file() before unlinking.
  builtin run_command: do not exit with -1.
  Move #include <sys/select.h> and <sys/ioctl.h> to git-compat-util.h.
  Use is_absolute_path() in sha1_file.c.
  Skip t3902-quoted.sh if the file system does not support funny names.
  t5302-pack-index: Skip tests of 64-bit offsets if necessary.
  t7501-commit.sh: Not all seds understand option -i
  t5300-pack-object.sh: Split the big verify-pack test into smaller parts.
2007-11-24 16:31:25 -08:00
Junio C Hamano
25f3cd527d Merge branch 'mh/rebase-skip-hard'
* mh/rebase-skip-hard:
  Do git reset --hard HEAD when using git rebase --skip
2007-11-24 16:31:08 -08:00
Junio C Hamano
faf8280850 Merge branch 'cc/bisect'
* cc/bisect:
  Bisect reset: do nothing when not bisecting.
  Bisect: use "$GIT_DIR/BISECT_NAMES" to check if we are bisecting.
  Bisect visualize: use "for-each-ref" to list all good refs.
  git-bisect: modernize branch shuffling hack
  git-bisect: use update-ref to mark good/bad commits
  git-bisect: war on "sed"
  Bisect reset: remove bisect refs that may have been packed.
2007-11-24 16:31:02 -08:00
Junio C Hamano
b468f0ce48 Add a few more tests for git-commit
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2007-11-22 23:20:59 -08:00
Junio C Hamano
3f7dfe77b7 git-branch --contains: doc and test
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2007-11-22 22:11:28 -08:00
Johannes Schindelin
637efc3456 Replace "runstatus" with "status" in the tests
We no longer have "runstatus", but running "status" is no longer that
expensive anyway; it is a builtin.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2007-11-22 17:05:04 -08:00
Kristian Høgsberg
1200993a1e t7501-commit: Add test for git commit <file> with dirty index.
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2007-11-22 17:05:04 -08:00
Johannes Schindelin
2150554b0e builtin-commit --s: add a newline if the last line was not a S-o-b
The rule is this: if the last line already contains the sign off by the
current committer, do nothing.  If it contains another sign off, just
add the sign off of the current committer.  If the last line does not
contain a sign off, add a new line before adding the sign off.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2007-11-22 17:05:03 -08:00
Johannes Schindelin
13208572fb builtin-commit: fix --signoff
The Signed-off-by: line contained a spurious timestamp.  The reason was
a call to git_committer_info(1), which automatically added the
timestamp.

Instead, fmt_ident() was taught to interpret an empty string for the
date (as opposed to NULL, which still triggers the default behavior)
as "do not bother with the timestamp", and builtin-commit.c uses it.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2007-11-22 17:05:03 -08:00
Johannes Schindelin
367c98866c git status: show relative paths when run in a subdirectory
To show the relative paths, the function formerly called quote_crlf()
(now called quote_path()) takes the prefix as an additional argument.

While at it, the static buffers were replaced by strbufs.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2007-11-22 17:05:03 -08:00
Kristian Høgsberg
d63c2fd192 Add testcase for amending and fixing author in git commit.
We used to clobber author time, but we shouldn't.

Signed-off-by: Kristian Høgsberg <krh@redhat.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2007-11-22 17:04:56 -08:00
Junio C Hamano
193f7e98da Make test scripts executable. 2007-11-22 16:52:17 -08:00
Junio C Hamano
fa30383642 Merge branch 'maint'
* maint:
  Make test scripts executable.
  bundle create: keep symbolic refs' names instead of resolving them
2007-11-22 16:51:18 -08:00
Junio C Hamano
958e67c0a8 Make test scripts executable. 2007-11-22 16:48:55 -08:00
Johannes Schindelin
6047a234c5 rebase -i: move help to end of todo file
[PATCH] rebase -i: move help to end of todo file

Many editors start in the first line, so the 9-line help text was an
annoyance.  So move it to the end.

Requested by Junio.

While at it, add a hint how to abort the rebase.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2007-11-22 15:35:06 -08:00
Johannes Schindelin
c5546e88fe bundle create: keep symbolic refs' names instead of resolving them
When creating a bundle, symbolic refs used to be resolved to the
non-symbolic refs they point to before being written to the list
of contained refs.  I.e. "git bundle create a1.bundle HEAD master"
would show something like

388afe7881b33102fada216dd07806728773c011        refs/heads/master
388afe7881b33102fada216dd07806728773c011        refs/heads/master

instead of

388afe7881b33102fada216dd07806728773c011        HEAD
388afe7881b33102fada216dd07806728773c011        refs/heads/master

Introduce a special handling so that the symbolic refs are listed
with the names passed on the command line.

Noticed by Santi Béjar.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2007-11-22 15:15:25 -08:00
Junio C Hamano
060009b419 Merge git://git.bogomips.org/git-svn
* git://git.bogomips.org/git-svn:
  git-svn: allow `info' command to work offline
  git-svn: info --url [path]
  git-svn info: implement info command
  git-svn: extract reusable code into utility functions
  t9106: fix a race condition that caused svn to miss modifications
2007-11-22 00:34:49 -08:00
Junio C Hamano
f8b6809d52 Fix "quote" misconversion for rewrite diff output.
663af3422a648e87945e4d8c0cc3e13671f2bbde (Full rework of
quote_c_style and write_name_quoted.) mistakenly used puts()
when writing out a fixed string when it did not want to add a
terminating LF.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
2007-11-21 23:06:44 -08:00
David D. Kilzer
8b014d7157 git-svn: info --url [path]
Return the svn URL for the given path, or return the svn
repository URL if no path is given.

Added 18 tests to t/t9119-git-svn-info.sh.

Signed-off-by: David D. Kilzer <ddkilzer@kilzer.net>
Acked-by: Eric Wong <normalperson@yhbt.net>
2007-11-21 20:11:11 -08:00
David D. Kilzer
e6fefa926d git-svn info: implement info command
Implement "git-svn info" for files and directories based on the
"svn info" command.  Note that the -r/--revision argument is not
supported yet.

Added 18 tests in t/t9119-git-svn-info.sh.

[ew: small fix to work without arguments on all working directories]

Signed-off-by: David D. Kilzer <ddkilzer@kilzer.net>
Acked-by: Eric Wong <normalperson@yhbt.net>
2007-11-21 20:11:11 -08:00
Eric Wong
8d92f24852 t9106: fix a race condition that caused svn to miss modifications
carbonated beverage noticed this test was occasionally failing.

Signed-off-by: Eric Wong <normalperson@yhbt.net>
2007-11-21 20:11:11 -08:00
Christian Couder
fce0499fad Bisect reset: do nothing when not bisecting.
Before this patch, using "git bisect reset" when not bisecting
did a "git checkout master" for no good reason.

This also happened using "git bisect replay" when not bisecting
because "bisect_replay" starts by calling "bisect_reset".

Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2007-11-20 01:01:46 -08:00
David D. Kilzer
b7f30e0a97 git-send-email: show all headers when sending mail
As a git newbie, it was confusing to set an In-Reply-To header but then
not see it printed when the git-send-email command was run.

This patch prints all headers that would be sent to sendmail or an SMTP
server instead of only printing From, Subject, Cc, To.  It also removes
the now-extraneous Date header after the "Log says" line.

Added test to t/t9001-send-email.sh.

Signed-off-by: David D. Kilzer <ddkilzer@kilzer.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2007-11-19 00:19:46 -08:00
Carlos Rica
3968658599 Make builtin-tag.c use parse_options.
Also, this removes those tests ensuring that repeated
-m options don't allocate memory more than once, because now
this is done after parsing options, using the last one
when more are given. The same for -F.

Signed-off-by: Carlos Rica <jasampler@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2007-11-18 19:19:20 -08:00
Steffen Prohaska
605b4978a1 refactor fetch's ref matching to use refname_match()
The old rules used by fetch were coded as a series of ifs.  The old
rules are:
1) match full refname if it starts with "refs/" or matches "HEAD"
2) verify that full refname starts with "refs/"
3) match abbreviated name in "refs/" if it starts with "heads/",
    "tags/", or "remotes/".
4) match abbreviated name in "refs/heads/"

This is replaced by the new rules
a) match full refname
b) match abbreviated name prefixed with "refs/"
c) match abbreviated name prefixed with "refs/heads/"

The details of the new rules are different from the old rules.  We no
longer verify that the full refname starts with "refs/".  The new rule
(a) matches any full string.  The old rules (1) and (2) were stricter.
Now, the caller is responsible for using sensible full refnames.  This
should be the case for the current code.  The new rule (b) is less
strict than old rule (3).  The new rule accepts abbreviated names that
start with a non-standard prefix below "refs/".

Despite this modifications the new rules should handle all cases as
expected.  Two tests are added to verify that fetch does not resolve
short tags or HEAD in remotes.

We may even think about loosening the rules a bit more and unify them
with the rev-parse rules.  This would be done by replacing
ref_ref_fetch_rules with ref_ref_parse_rules.  Note, the two new test
would break.

Signed-off-by: Steffen Prohaska <prohaska@zib.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2007-11-18 18:39:01 -08:00
Steffen Prohaska
ae36bdcf51 push: use same rules as git-rev-parse to resolve refspecs
This commit changes the rules for resolving refspecs to match the
rules for resolving refs in rev-parse. git-rev-parse uses clear rules
to resolve a short ref to its full name, which are well documented.
The rules for resolving refspecs documented in git-send-pack were
less strict and harder to understand. This commit replaces them by
the rules of git-rev-parse.

The unified rules are easier to understand and better resolve ambiguous
cases. You can now push from a repository containing several branches
ending on the same short name.

Note, this may break existing setups. For example, "master" will no longer
resolve to "origin/master" even when there is no other "master" elsewhere.

Signed-off-by: Steffen Prohaska <prohaska@zib.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2007-11-18 18:39:01 -08:00
Steffen Prohaska
47d996a20c push: support pushing HEAD to real branch name
This teaches "push <remote> HEAD" to resolve HEAD on the local
side to its real branch name, e.g. master, and then act as if
the real branch name was specified. So we have a shorthand for
pushing the current branch. Besides HEAD, no other symbolic ref
is resolved.

Thanks to Daniel Barkalow <barkalow@iabervon.org> for suggesting
this implementation, which is much simpler than the
implementation proposed before.

Signed-off-by: Steffen Prohaska <prohaska@zib.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2007-11-18 18:39:00 -08:00
Junio C Hamano
5d3d1cacc1 Merge branch 'lt/rev-list-gitlink'
* lt/rev-list-gitlink:
  Fix rev-list when showing objects involving submodules
2007-11-18 16:16:37 -08:00
Junio C Hamano
d577bc58a3 Merge branch 'ds/checkout-upper'
* ds/checkout-upper:
  git-checkout: Test for relative path use.
  git-checkout: Support relative paths containing "..".
2007-11-18 16:04:17 -08:00
Junio C Hamano
9716f21b48 Merge git://git.bogomips.org/git-svn
* git://git.bogomips.org/git-svn:
  git-svn: Fix a typo and add a comma in an error message in git-svn
  git-svn log: handle unreachable revisions like "svn log"
  git-svn log: include commit log for the smallest revision in a range
  git-svn log: fix ascending revision ranges
  git-svn's dcommit must use subversion's config
  git-svn: add tests for command-line usage of init and clone commands
2007-11-17 16:40:03 -08:00
David D Kilzer
111947ef8c git-svn log: handle unreachable revisions like "svn log"
When unreachable revisions are given to "svn log", it displays all commit
logs in the given range that exist in the current tree.  (If no commit
logs are found in the current tree, it simply prints a single commit log
separator.)  This patch makes "git-svn log" behave the same way.

Ten tests added to t/t9116-git-svn-log.sh.

Signed-off-by: David D Kilzer <ddkilzer@kilzer.net>
Acked-by: Eric Wong <normalperson@yhbt.net>
2007-11-17 13:28:21 -08:00
David D Kilzer
60f3ff1257 git-svn log: include commit log for the smallest revision in a range
The "svn log -rM:N" command shows commit logs inclusive in the range [M,N].
Previously "git-svn log" always excluded the commit log for the smallest
revision in a range, whether the range was ascending or descending.  With
this patch, the smallest revision in a range is always shown.

Updated tests for ascending and descending revision ranges.

Signed-off-by: David D Kilzer <ddkilzer@kilzer.net>
Acked-by: Eric Wong <normalperson@yhbt.net>
2007-11-17 13:28:21 -08:00
David D Kilzer
fede44b2e1 git-svn log: fix ascending revision ranges
Fixed typo in Git::SVN::Log::git_svn_log_cmd().  Previously a command like
"git-svn log -r1:4" would only show a commit log separator.

Added tests for ascending and descending revision ranges.

Signed-off-by: David D Kilzer <ddkilzer@kilzer.net>
Acked-by: Eric Wong <normalperson@yhbt.net>
2007-11-17 13:28:21 -08:00
Eric Wong
41337e22f0 git-svn: add tests for command-line usage of init and clone commands
Some patches broke these commands in certain cases and were only
caught by manual testing.

Signed-off-by: Eric Wong <normalperson@yhbt.net>
2007-11-17 13:28:21 -08:00
Jeff King
ca74c458a3 send-pack: assign remote errors to each ref
This lets us show remote errors (e.g., a denied hook) along
with the usual push output.

There is a slightly clever optimization in receive_status
that bears explanation. We need to correlate the returned
status and our ref objects, which naively could be an O(m*n)
operation. However, since the current implementation of
receive-pack returns the errors to us in the same order that
we sent them, we optimistically look for the next ref to be
looked up to come after the last one we have found. So it
should be an O(m+n) merge if the receive-pack behavior
holds, but we fall back to a correct but slower behavior if
it should change.

Signed-off-by: Jeff King <peff@peff.net>
Acked-by: Daniel Barkalow <barkalow@iabervon.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2007-11-17 12:10:50 -08:00
Jeff King
1f0e2a1a65 send-pack: check ref->status before updating tracking refs
Previously, we manually checked the 'NONE' and 'UPTODATE'
conditions. Now that we have ref->status, we can easily
say "only update if we pushed successfully".

This adds a test for and fixes a regression introduced in
ed31df31 where deleted refs did not have their tracking
branches removed. This was due to a bogus per-ref error test
that is superseded by the more accurate ref->status flag.

Signed-off-by: Jeff King <peff@peff.net>
Completely-Acked-By: Alex "Sleepy" Riesen <raa.lkml@gmail.com>
Acked-by: Daniel Barkalow <barkalow@iabervon.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2007-11-17 12:10:50 -08:00
Jeff King
8736a84890 send-pack: track errors for each ref
Instead of keeping the 'ret' variable, we instead have a
status flag for each ref that tracks what happened to it.
We then print the ref status after all of the refs have
been examined.

This paves the way for three improvements:
  - updating tracking refs only for non-error refs
  - incorporating remote rejection into the printed status
  - printing errors in a different order than we processed
    (e.g., consolidating non-ff errors near the end with
    a special message)

Signed-off-by: Jeff King <peff@peff.net>
Acked-by: Alex Riesen <raa.lkml@gmail.com>
Acked-by: Daniel Barkalow <barkalow@iabervon.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2007-11-17 12:10:50 -08:00
Mike Hommey
eb9d2b91cf Fix and improve t7004 (git-tag tests)
Brown paper bag fix to avoid using non portable sed syntax. The
test by itself didn't catch what it was supposed to, anyways.

The new test first checks if git-tag correctly errors out when
the user exited the editor without editing the file.  Then it
checks if what the user was presented in the editor was any
useful, which we define as the following:

 * It begins with a single blank line, where the invoked editor
   would typically place the editing curser at, so that the user
   can immediately start typing;

 * It has some instruction but that comes after that initial
   blank line, all lines prefixed with "#".  We specifically do
   not check for the wording of this instruction.

 * And it has nothing else, as the expected behaviour is "Hey
   you did not leave any message".

Signed-off-by: Mike Hommey <mh@glandium.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2007-11-17 00:57:05 -08:00
Linus Torvalds
481f0ee60e Fix rev-list when showing objects involving submodules
The function mark_tree_uninteresting() assumed that the tree entries
are blob when they are not trees.  This is not so.  Since we do
not traverse into submodules (yet), the gitlinks should be ignored.

In general, we should try to start moving away from using the
"S_ISLNK()" like things for internal git state. It was a mistake to
just assume the numbers all were same across all systems in the first
place.  This implementation converts to the "object_type", and then
uses a case statement.

Noticed by Ilari on IRC.
Test script taken from an earlier version by Dscho.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2007-11-16 22:05:33 -08:00
Junio C Hamano
f1a82fe9a3 Merge branch 'maint'
* maint:
  Update draft release notes for 1.5.3.6
  Fix per-directory exclude handing for "git add"
  core.excludesfile clean-up
  Fix t9101 test failure caused by Subversion "auto-props"
  git-send-email: add charset header if we add encoded 'From'
2007-11-16 21:30:06 -08:00
Junio C Hamano
0e06cc8b82 Fix per-directory exclude handing for "git add"
In "dir_struct", each exclusion element in the exclusion stack records a
base string (pointer to the beginning with length) so that we can tell
where it came from, but this pointer is just pointing at the parameter
that is given by the caller to the push_exclude_per_directory()
function.

While read_directory_recursive() runs, calls to excluded() makes use
the data in the exclusion elements, including this base string.  The
caller of read_directory_recursive() is not supposed to free the
buffer it gave to push_exclude_per_directory() earlier, until it
returns.

The test case Bruce Stephens gave in the mailing list discussion
was simplified and added to the t3700 test.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
2007-11-16 17:05:13 -08:00
Wincent Colaiuta
2587d67966 Fix t9101 test failure caused by Subversion "auto-props"
If a user has an "auto-prop" in his/her ~/.subversion/config file for
automatically setting the svn:keyword Id property on all ".c" files
(a reasonably common configuration in the Subversion world) then one
of the "svn propset" operations in the very first test would become a
no-op, which in turn would make the next commit a no-op.

This then caused the 25th test ('test propget') to fail because it
expects a certain number of commits to have taken place but the actual
number of commits was off by one.

Björn Steinbrink identified the "auto-prop" feature as the cause
of the failure. This patch avoids it by passing the "--no-auto-prop"
flag to "svn import" when setting up the test repository, thus ensuring
that the "svn propset" operation is no longer a no-op, regardless of the
users' settings in their config.

Signed-off-by: Wincent Colaiuta <win@wincent.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2007-11-16 16:55:46 -08:00
Christian Couder
947a604b01 Bisect reset: remove bisect refs that may have been packed.
If refs were ever packed in the middle of bisection, the bisect
refs were not removed from the "packed-refs" file.

This patch fixes this problem by using "git update-ref -d $ref $hash"
in "bisect_clean_state".

Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2007-11-16 01:35:58 -08:00
Junio C Hamano
41a7aa588f Fix per-directory exclude handing for "git add"
In "dir_struct", each exclusion element in the exclusion stack records a
base string (pointer to the beginning with length) so that we can tell
where it came from, but this pointer is just pointing at the parameter
that is given by the caller to the push_exclude_per_directory()
function.

While read_directory_recursive() runs, calls to excluded() makes use
the data in the exclusion elements, including this base string.  The
caller of read_directory_recursive() is not supposed to free the
buffer it gave to push_exclude_per_directory() earlier, until it
returns.

The test case Bruce Stephens gave in the mailing list discussion
was simplified and added to the t3700 test.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
2007-11-16 01:16:22 -08:00
Nicolas Pitre
5f9ffff308 rehabilitate some t5302 tests on 32-bit off_t machines
Commit 8ed2fca458d085f12c3c6808ef4ddab6aa40ef14 was a bit draconian in
skipping certain tests which should be perfectly valid even on platform
with a 32-bit off_t.

Signed-off-by: Nicolas Pitre <nico@cam.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2007-11-15 21:18:07 -08:00
Johannes Sixt
25482a3c0c Skip t3902-quoted.sh if the file system does not support funny names.
Signed-off-by: Johannes Sixt <johannes.sixt@telecom.at>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2007-11-14 15:18:39 -08:00
Johannes Sixt
8ed2fca458 t5302-pack-index: Skip tests of 64-bit offsets if necessary.
There are platforms where off_t is not 64 bits wide. In this case many tests
are doomed to fail. Let's skip them.

Signed-off-by: Johannes Sixt <johannes.sixt@telecom.at>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2007-11-14 15:18:39 -08:00
Johannes Sixt
41ec097aea t7501-commit.sh: Not all seds understand option -i
Use mv instead.

Signed-off-by: Johannes Sixt <johannes.sixt@telecom.at>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2007-11-14 15:18:39 -08:00