Compare commits

...

59 Commits

Author SHA1 Message Date
fcd424011b Git 1.7.0.5
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-04-11 13:42:33 -07:00
c512b03555 Merge branch 'rc/maint-reflog-msg-for-forced-branch' into maint
* rc/maint-reflog-msg-for-forced-branch:
  branch: say "Reset to" in reflog entries for 'git branch -f' operations
2010-04-11 13:39:47 -07:00
d8c416b251 blame documentation: -M/-C notice copied lines as well as moved ones
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-04-11 12:17:42 -07:00
54fd955c21 Let check_preimage() use memset() to initialize "struct checkout"
Every code site except check_preimage() uses either memset() or declares
a static instance of "struct checkout" to achieve proper initialization.
Lets use memset() instead of explicit initialization of all members here
too to be on the safe side in case this structure is expanded someday.

Signed-off-by: Jens Lehmann <Jens.Lehmann@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-04-09 22:42:57 -07:00
408dee5222 Merge branch 'ef/maint-empty-commit-log' into maint
* ef/maint-empty-commit-log:
  rev-list: fix --pretty=oneline with empty message
2010-04-09 22:38:53 -07:00
daaf2e8892 Merge branch 'jc/conflict-marker-size' into maint
* jc/conflict-marker-size:
  diff --check: honor conflict-marker-size attribute
2010-04-09 22:38:34 -07:00
326bea47cb Merge branch 'sp/maint-http-backend-die-triggers-die-recursively' into maint
* sp/maint-http-backend-die-triggers-die-recursively:
  http-backend: Don't infinite loop during die()
2010-04-09 22:38:16 -07:00
fe7e37235d Merge branch 'mg/maint-send-email-lazy-editor' into maint
* mg/maint-send-email-lazy-editor:
  send-email: lazily assign editor variable
2010-04-09 22:23:04 -07:00
2e5a40f0b5 Merge branch 'rr/imap-send-unconfuse-from-line' into maint
* rr/imap-send-unconfuse-from-line:
  imap-send: Remove limitation on message body
2010-04-09 22:22:44 -07:00
581b26c82d Merge branch 'rb/maint-python-path' into maint
* rb/maint-python-path:
  Correct references to /usr/bin/python which does not exist on FreeBSD
2010-04-09 22:22:19 -07:00
5d4bd79d80 Merge branch 'gh/maint-stash-show-error-message' into maint
* gh/maint-stash-show-error-message:
  Improve error messages from 'git stash show'
2010-04-09 22:22:14 -07:00
e80014a13e Merge branch 'mg/mailmap-update' into maint
* mg/mailmap-update:
  .mailmap: Entries for Alex Bennée, Deskin Miller, Vitaly "_Vi" Shukela
2010-04-09 22:22:06 -07:00
2870695be0 Merge branch 'bc/maint-daemon-sans-ss-family' into maint
* bc/maint-daemon-sans-ss-family:
  daemon.c: avoid accessing ss_family member of struct sockaddr_storage
2010-04-09 22:22:00 -07:00
e3163c7515 fetch/push: fix usage strings
- use "<options>" instead of just "options".
 - use "[<repository> [<refspec>...]]" to indicate that <repository> and
   <refspec> are optional, and that <refspec> cannot be specified
   without specifying <repository>.

Note that when called without specifying <repository> (eg. "git fetch
-f"), it is accurate to say that the "git fetch [<options>]
[<repository> ...]" case takes precedence over "git fetch [<options>]
<group>".

Signed-off-by: Tay Ray Chuan <rctay89@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-04-09 21:23:10 -07:00
936db184f0 branch: say "Reset to" in reflog entries for 'git branch -f' operations
In 5f856dd (fix reflog entries for "git-branch"), it is mentioned that
'git branch -f' is intended to be equivalent to 'git reset'. Since we
usually say "reset to <commit>" in the git-reset Documentation and
elsewhere, it would make sense to say "Reset to" here as well, instead
of "Reset from" previously.

Signed-off-by: Tay Ray Chuan <rctay89@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-04-09 20:40:54 -07:00
4c35f0dbc4 docs: clarify "branch -l"
This option is mostly useless these days because we turn on
reflogs by default in non-bare repos.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-04-08 13:42:36 -07:00
c8a97906ba pack-protocol.txt: fix pkt-line lengths
Previously, the lengths were 4-bytes short. Fix it such that the lengths
reflect the total length of the pkt-line, as per spec.

Signed-off-by: Tay Ray Chuan <rctay89@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-04-04 10:18:21 -07:00
8e50175d94 pack-protocol.txt: fix spelling
s/paramater/parameter/.

Signed-off-by: Tay Ray Chuan <rctay89@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-04-04 10:18:19 -07:00
2be10bb5c1 Git 1.7.0.4
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-03-31 15:12:08 -07:00
970957dbad Merge branch 'jc/maint-refs-dangling' into maint
* jc/maint-refs-dangling:
  refs: ref entry with NULL sha1 is can be a dangling symref
2010-03-31 15:09:32 -07:00
4318d3ba8f Documentation: show-ref <pattern>s are optional
Specifying one or more <pattern> parameters is optional when calling
show-ref, so mark them as such using brackets in the manual.

Signed-off-by: Holger Weiß <holger@zedat.fu-berlin.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-03-31 14:22:17 -07:00
2170422790 Link against libiconv on IRIX
On IRIX, "-liconv" must be added to the linker command line in order to
get iconv(3) support; set the according Makefile variable appropriately.

Signed-off-by: Holger Weiß <holger@zedat.fu-berlin.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-03-31 14:22:06 -07:00
21e403a7b9 Don't redefine htonl and ntohl on big-endian
Since commit 0fcabdeb52, compat/bswap.h
redefined htonl and ntohl to bswap32 not only if bswap32 has been
defined earlier in compat/bswap.h (which is done only on selected
platforms), but also if bswap32 has been defined anywhere else.  This
broke Git at least for NetBSD systems running on big-endian machines
(where ntohl and htonl should, of course, be NOOPs), since NetBSD
defines a bswap32 macro in the system headers.

So, we now undefine any previously defined bswap32 in compat/bswap.h
before defining our own.

Signed-off-by: Holger Weiß <holger@zedat.fu-berlin.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-03-31 14:21:39 -07:00
7a49c254cd gitweb: git_get_project_config requires only $git_dir, not also $project
Fix overeager early return in git_get_project_config, introduced in 9be3614
(gitweb: Fix project-specific feature override behavior, 2010-03-01).  When
git_get_project_config is called from projects list page via
git_get_project_owner($path) etc., it is called with $git_dir defined (in
git_get_project_owner($path) etc.), but $project variable is not defined.
git_get_project_config doesn't use $project variable anyway.

Reported-by: Tobias Heinlein <keytoaster@gentoo.org>
Signed-off-by: Jakub Narebski <jnareb@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-03-31 10:57:04 -07:00
e4762865c8 Updated the usage string of git reset
Make git reset usage string reflect the command's behaviour and contents of
the man page.

Signed-off-by: Jan Stępień <jstepien@users.sourceforge.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-03-31 08:15:02 -07:00
09f53b16bc Documentation: Clarify support for smart HTTP backend
In the description of http.getanyfile, replace the vague "older Git
clients" with the earliest release whose client is able to use the
upload pack service.

Signed-off-by: Greg Bacon <gbacon@dbresearch.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-03-30 16:49:19 -07:00
852f098c06 Windows: fix utime() for read-only files
Starting with 5256b00 (Use git_mkstemp_mode instead of plain mkstemp to
create object files, 2010-02-22) utime() is invoked on read-only files.
This is not allowed on Windows and results in many warnings of the form

failed utime() on .git/objects/23/tmp_obj_VlgHlc: Permission denied

during a repack.  Fix it by making the file temporarily writable.

Signed-off-by: Johannes Sixt <j6t@kdbg.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-03-30 16:34:04 -07:00
da1fbed3ff diff: fix textconv error zombies
To make the code simpler, run_textconv lumps all of its
error checking into one conditional. However, the
short-circuit means that an error in reading will prevent us
from calling finish_command, leaving a zombie child.
Clean up properly after errors.

Based-on-work-by: Jeff King <peff@peff.net>
Signed-off-by: Johannes Sixt <j6t@kdbg.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-03-30 14:46:33 -07:00
657ab61efa format-patch: Squelch 'fatal: Not a range." error
Don't output an error on `git format-patch --ignore-if-in-upstream HEAD`.
This matches the behavior of `git format-patch HEAD`.

Signed-off-by: Kevin Ballard <kevin@sb.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-03-29 21:22:37 -07:00
e07665e524 Prepare for 1.7.0.4
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-03-28 21:32:25 -07:00
cc64c6970a Merge branch 'cp/add-u-pathspec' into maint
* cp/add-u-pathspec:
  test for add with non-existent pathspec
  git add -u: die on unmatched pathspec
2010-03-28 21:21:42 -07:00
4c367c6ae9 t9350: fix careless use of "cd"
Upon failure of any of these tests (or when a test that is marked as
expecting a failure is fixed), we will end up running later tests in
random places.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-03-28 17:42:11 -07:00
42accaec01 difftool: Fix '--gui' when diff.guitool is unconfigured
When diff.guitool is unconfigured and "--gui" is specified
git-difftool dies with the following error message:

	config diff.guitool: command returned error: 1

Catch the error so that the "--gui" flag is a no-op when
diff.guitool is unconfigured.

Signed-off-by: David Aguilar <davvid@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-03-28 09:29:12 -07:00
bb6ad28c23 fast-export: don't segfault when marks file cannot be opened
The error function only prints an error message, resulting in a
segfault if we later on try to fprintf to a NULL handle.

Fix this by using die_errno instead.

Signed-off-by: Sverre Rabbelier <srabbelier@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-03-28 09:26:16 -07:00
0ce142c944 send-email: lazily assign editor variable
b4479f0 (add -i, send-email, svn, p4, etc: use "git var GIT_EDITOR",
2009-10-30) introduced the use of "git var GIT_EDITOR" to obtain the
preferred editor program, instead of reading environment variables
themselves.

However, "git var GIT_EDITOR" run without a tty (think "cron job") would
give a fatal error "Terminal is dumb, but EDITOR unset".  This is not a
problem for add-i, svn, p4 and callers of git_editor() defined in
git-sh-setup, as all of these call it just before launching the editor.
At that point, we know the caller wants to edit.

But send-email ran this near the beginning of the program, even if it is
not going to use any editor (e.g. run without --compose).  Fix this by
calling the command only when we edit a file.

Reported-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Signed-off-by: Michael J Gruber <git@drmicha.warpmail.net>
Acked-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Acked-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-03-25 03:07:31 -07:00
a757c646ee diff --check: honor conflict-marker-size attribute
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-03-24 19:35:34 -07:00
0476228de5 Merge branch 'jc/color-attrs' into maint
* jc/color-attrs:
  color: allow multiple attributes
2010-03-24 16:24:13 -07:00
bcbbe4f9d9 Merge branch 'jk/maint-add-ignored-dir' into maint
* jk/maint-add-ignored-dir:
  tests for "git add ignored-dir/file" without -f
  dir: fix COLLECT_IGNORED on excluded prefixes
  t0050: mark non-working test as such
2010-03-24 16:24:03 -07:00
7b676b1bb5 Merge branch 'bg/apply-fix-blank-at-eof' into maint
* bg/apply-fix-blank-at-eof:
  t3417: Add test cases for "rebase --whitespace=fix"
  t4124: Add additional tests of --whitespace=fix
  apply: Allow blank context lines to match beyond EOF
  apply: Remove the quick rejection test
  apply: Don't unnecessarily update line lengths in the preimage
2010-03-24 16:23:50 -07:00
5856b5f568 http-backend: Don't infinite loop during die()
If stdout has already been closed by the CGI and die() gets called,
the CGI will fail to write the "Status: 500 Internal Server Error" to
the pipe, which results in die() being called again (via safe_write).
This goes on in an infinite loop until the stack overflows and the
process is killed by SIGSEGV.

Instead set a flag on the first die() invocation and if we came back to
the handler, just die silently, as it only means we failed to report the
failure---we cannot report anything anyway in such a case.  This way
failures to write the error messages to the stdout pipe do not result in
an infinite loop.

We also now report on the death to stderr before we report to stdout,
to increase the chances that the cause of the die() invocation will
appear in the server's error log.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

fixup! http-backend.c: Don't infinite loop

Now die_webcgi() actually can return during a recursive call into it,
causing

    http-backend.c:554: error: 'noreturn' function does return

The only reason we would come back to the die handler is because we
failed during it, so we cannot report anything anyway.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-03-24 14:40:56 -07:00
44211e8c2e Correct references to /usr/bin/python which does not exist on FreeBSD
On FreeBSD, Python does not ship as part of the base system but is available
via the ports system, which install the binary in /usr/local/bin.

Signed-off-by: R. Tyler Ballance <tyler@monkeypox.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-03-24 14:33:54 -07:00
846b8f681a Documentation: explain the meaning of "-g" in git-describe output
Signed-off-by: Markus Heidelberg <markus.heidelberg@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-03-24 11:31:45 -07:00
4916c8f953 imap-send: Remove limitation on message body
There is a documented limitation on the body of any email not being
able to contain lines starting with "From ". This patch removes that
limitation by improving the parser to search for "From", "Date", and
"Subject" fields in the email before considering it to be an email.

Signed-off-by: Ramkumar Ramachandra <artagnon@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-03-24 11:00:25 -07:00
1fb5fdd25f rev-list: fix --pretty=oneline with empty message
55246aa (Dont use "<unknown>" for placeholders and suppress printing
of empty user formats) introduced a check to prevent empty
user-formats from being printed. This test didn't take empty commit
messages into account, and prevented the line-termination from being
output. This lead to multiple commits on a single line.

Correct it by guarding the check with a check for user-format. A
similar correction for the --graph code-path has been included.

Signed-off-by: Erik Faye-Lund <kusmabite@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-03-21 11:44:27 -07:00
08bb03e475 .mailmap: Entries for Alex Bennée, Deskin Miller, Vitaly "_Vi" Shukela
With the current .mailmap, git shortlog shows the following for these:

    11	Deskin Miller
     3	Vitaly \"_Vi\" Shukela
     1	Alex Bennee
     1	Alex Bennée
     1	Deskin Miler
     1	Vitaly _Vi Shukela

Add (e-mail based qualified) entries to .mailmap to get:

    12	Deskin Miller
     4	Vitaly "_Vi" Shukela
     2	Alex Bennée

The Shukela spelling is based on the version used consistently in the s-o-b
lines of all his patches.

Signed-off-by: Michael J Gruber <git@drmicha.warpmail.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-03-20 19:26:35 -07:00
14cd458126 Improve error messages from 'git stash show'
The previous error message "fatal: Needed a single revision" is not
very informative.

Signed-off-by: Gustaf Hendeby <hendeby@isy.liu.se>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-03-16 19:23:24 -07:00
3aff874af2 daemon.c: avoid accessing ss_family member of struct sockaddr_storage
When NO_SOCKADDR_STORAGE is set for a platform, either sockaddr_in or
sockaddr_in6 is used intead.  Neither of which has an ss_family member.
They have an sin_family and sin6_family member respectively.  Since the
addrcmp() function accesses the ss_family member of a sockaddr_storage
struct, compilation fails on platforms which define NO_SOCKADDR_STORAGE.

Since any sockaddr_* structure can be cast to a struct sockaddr and
have its sa_family member read, do so here to workaround this issue.

Thanks to Martin Storsjö for pointing out the fix, and Gary Vaughan
for drawing attention to the issue.

Signed-off-by: Brandon Casey <casey@nrlssc.navy.mil>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-03-16 19:07:09 -07:00
e01de1c912 refs: ref entry with NULL sha1 is can be a dangling symref
Brandon Casey noticed that t5505 had accidentally broken its && chain,
hiding inconsistency between the code that writes the warning to the
standard output and the test that expects to see the warning on the
standard error, which was introduced by f8948e2 (remote prune: warn
dangling symrefs, 2009-02-08).

It turns out that the issue is deeper than that.  After f8948e2, a symref
that is dangling is marked with a NULL sha1, and the idea of using NULL
sha1 to mean a deleted ref was scrapped, but somehow a follow-up eafb452
(do_one_ref(): null_sha1 check is not about broken ref, 2009-07-22)
incorrectly reorganized do_one_ref(), still thinking NULL sha1 is never
used in the code.

Fix this by:

 - adopt Brandon's fix to t5505 test;

 - introduce REF_BROKEN flag to mark a ref that fails to resolve (dangling
   symref);

 - move the check for broken ref back inside the "if we are skipping
   dangling refs" code block.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-03-15 23:37:42 -07:00
b75aea8f5b tests for "git add ignored-dir/file" without -f
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-03-13 23:23:22 -08:00
29209cbe58 dir: fix COLLECT_IGNORED on excluded prefixes
As we walk the directory tree, if we see an ignored path, we
want to add it to the ignored list only if it matches any
pathspec that we were given. We used to check for the
pathspec to appear explicitly. E.g., if we see "subdir/file"
and it is excluded, we check to see if we have "subdir/file"
in our pathspec.

However, this interacts badly with the optimization to avoid
recursing into ignored subdirectories. If "subdir" as a
whole is ignored, then we never recurse, and consider only
whether "subdir" itself is in our pathspec.  It would not
match a pathspec of "subdir/file" explicitly, even though it
is the reason that subdir/file would be excluded.

This manifests itself to the user as "git add subdir/file"
failing to correctly note that the pathspec was ignored.

This patch extends the in_pathspec logic to include prefix
directory case.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-03-13 23:23:08 -08:00
0d7c2430ab t0050: mark non-working test as such
The test is to prepare an empty file "camelcase" in the index, remove
and replace it with another file "CamelCase" with "1" as its contents
in the working tree, and add it to the index, in a repository configured
to be case insensitive.

However, the test actually checked ls-files knows about a pathname that
matches "camelcase" case insensitively.  It didn't check if the added
contents actually was the updated one.

Mark the test as non-working.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-03-13 23:22:50 -08:00
8b124135a9 color: allow multiple attributes
In configuration files (and "git config --color" command line), we
supported one and only one attribute after foreground and background
color.  Accept combinations of attributes, e.g.

    [diff.color]
            old = red reverse bold

Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-03-07 12:00:36 -08:00
59f5ced65b t3417: Add test cases for "rebase --whitespace=fix"
The command "git rebase --whitespace=fix HEAD~<N>" is supposed to
only clean up trailing whitespace, and the expectation is that it
cannot fail.

Unfortunately, if one commit adds a blank line at the end of a file
and a subsequent commit adds more non-blank lines after the blank
line, "git apply" (used indirectly by "git rebase") will fail to apply
the patch of the second commit.

Signed-off-by: Björn Gustavsson <bgustavsson@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-03-06 23:53:00 -08:00
c1376c12b7 t4124: Add additional tests of --whitespace=fix
Signed-off-by: Björn Gustavsson <bgustavsson@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-03-06 23:53:00 -08:00
51667147be apply: Allow blank context lines to match beyond EOF
"git apply --whitespace=fix" will not always succeed when used
on a series of patches in the following circumstances:

* One patch adds a blank line at the end of a file. (Since
  --whitespace=fix is used, the blank line will *not* be added.)

* The next patch adds non-blank lines after the blank line
  introduced in the first patch. That patch will not apply
  because the blank line that is expected to be found at end
  of the file is no longer there.

A patch series that starts by deleting lines at the end
will fail in a similar way.

Fix this problem by allowing a blank context line at the beginning
of a hunk to match if parts of it falls beyond end of the file.
We still require that at least one non-blank context line match
before the end of the file.

If the --ignore-space-change option is given (as well as the
--whitespace=fix option), blank context lines falling beyond the end
of the file will be copied unchanged to the target file (i.e. they
will have the same line terminators and extra spaces will not be
removed).

Signed-off-by: Björn Gustavsson <bgustavsson@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-03-06 23:53:00 -08:00
24ff4d56cf apply: Remove the quick rejection test
In the next commit, we will make it possible for blank context
lines to match beyond the end of the file. That means that a hunk
with a preimage that has more lines than present in the file may
be possible to successfully apply. Therefore, we must remove
the quick rejection test in find_pos().

find_pos() will already work correctly without the quick
rejection test, but that might not be obvious. Therefore,
comment the test for handling out-of-range line numbers in
find_pos() and cast the "line" variable to the same (unsigned)
type as img->nr.

What are performance implications of removing the quick
rejection test?

It can only help "git apply" to reject a patch faster. For example,
if I have a file with one million lines and a patch that removes
slightly more than 50 percent of the lines and try to apply that
patch twice, the second attempt will fail slightly faster
with the test than without (based on actual measurements).

However, there is the pathological case of a patch with many
more context lines than the default three, and applying that patch
using "git apply -C1". Without the rejection test, the running
time will be roughly proportional to the number of context lines
times the size of the file. That could be handled by writing
a more complicated rejection test (it would have to count the
number of blanks at the end of the preimage), but I don't find
that worth doing until there is a real-world use case that
would benfit from it.

It would be possible to keep the quick rejection test if
--whitespace=fix is not given, but I don't like that from
a testing point of view.

Signed-off-by: Björn Gustavsson <bgustavsson@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-03-06 23:53:00 -08:00
9b25949a07 apply: Don't unnecessarily update line lengths in the preimage
In match_fragment(), the line lengths in the preimage are updated
just before calling update_pre_post_images(). That is not
necessary, since update_pre_post_images() itself will
update the line lengths based on the buffer passed to it.

Signed-off-by: Björn Gustavsson <bgustavsson@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-03-06 23:53:00 -08:00
1e7ef746d3 test for add with non-existent pathspec
Add a test for 'git add -u pathspec' and 'git add pathspec' where
pathspec does not exist. The expected result is that git add exits with
an error message and an appropriate exit code.

Signed-off-by: Chris Packham <judge.packham@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-02-16 22:53:40 -08:00
81f45e7dc4 git add -u: die on unmatched pathspec
If a pathspec is supplied to 'git add -u' and no path matches
the pattern, fail with an approriate error message and exit code.

Tested-by: Chris Packham <judge.packham@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-02-16 22:53:33 -08:00
57 changed files with 934 additions and 200 deletions

View File

@ -5,6 +5,7 @@
# same person appearing not to be so. # same person appearing not to be so.
# #
Alex Bennée <kernel-hacker@bennee.com>
Alexander Gavrilov <angavrilov@gmail.com> Alexander Gavrilov <angavrilov@gmail.com>
Aneesh Kumar K.V <aneesh.kumar@gmail.com> Aneesh Kumar K.V <aneesh.kumar@gmail.com>
Brian M. Carlson <sandals@crustytoothpaste.ath.cx> Brian M. Carlson <sandals@crustytoothpaste.ath.cx>
@ -15,6 +16,7 @@ Daniel Barkalow <barkalow@iabervon.org>
David D. Kilzer <ddkilzer@kilzer.net> David D. Kilzer <ddkilzer@kilzer.net>
David Kågedal <davidk@lysator.liu.se> David Kågedal <davidk@lysator.liu.se>
David S. Miller <davem@davemloft.net> David S. Miller <davem@davemloft.net>
Deskin Miller <deskinm@umich.edu>
Dirk Süsserott <newsletter@dirk.my1.cc> Dirk Süsserott <newsletter@dirk.my1.cc>
Fredrik Kuivinen <freku045@student.liu.se> Fredrik Kuivinen <freku045@student.liu.se>
H. Peter Anvin <hpa@bonde.sc.orionmulti.com> H. Peter Anvin <hpa@bonde.sc.orionmulti.com>
@ -60,6 +62,7 @@ Uwe Kleine-König <ukleinek@informatik.uni-freiburg.de>
Uwe Kleine-König <uzeisberger@io.fsforth.de> Uwe Kleine-König <uzeisberger@io.fsforth.de>
Uwe Kleine-König <zeisberg@informatik.uni-freiburg.de> Uwe Kleine-König <zeisberg@informatik.uni-freiburg.de>
Ville Skyttä <scop@xemacs.org> Ville Skyttä <scop@xemacs.org>
Vitaly "_Vi" Shukela <public_vi@tut.by>
William Pursell <bill.pursell@gmail.com> William Pursell <bill.pursell@gmail.com>
YOSHIFUJI Hideaki <yoshfuji@linux-ipv6.org> YOSHIFUJI Hideaki <yoshfuji@linux-ipv6.org>
anonymous <linux@horizon.com> anonymous <linux@horizon.com>

View File

@ -0,0 +1,27 @@
Git v1.7.0.4 Release Notes
==========================
Fixes since v1.7.0.3
--------------------
* Optimized ntohl/htonl on big-endian machines were broken.
* Color values given to "color.<cmd>.<slot>" configuration can now have
more than one attributes (e.g. "bold ul").
* "git add -u nonexistent-path" did not complain.
* "git apply --whitespace=fix" didn't work well when an early patch in
a patch series adds trailing blank lines and a later one depended on
such a block of blank lines at the end.
* "git fast-export" didn't check error status and stop when marks file
cannot be opened.
* "git format-patch --ignore-if-in-upstream" gave unwarranted errors
when the range was empty, instead of silently finishing.
* "git remote prune" did not detect remote tracking refs that became
dangling correctly.
And other minor fixes and documentation updates.

View File

@ -0,0 +1,26 @@
Git v1.7.0.5 Release Notes
==========================
Fixes since v1.7.0.4
--------------------
* "git daemon" failed to compile on platforms without sockaddr_storage type.
* Output from "git rev-list --pretty=oneline" was unparsable when a
commit did not have any message, which is abnormal but possible in a
repository converted from foreign scm.
* "git stash show <commit-that-is-not-a-stash>" gave an error message
that was not so useful. Reworded the message to "<it> is not a
stash".
* Python scripts in contrib/ area now start with "#!/usr/bin/env python"
to honor user's PATH.
* "git imap-send" used to mistake any line that begins with "From " as a
message separator in format-patch output.
* Smart http server backend failed to report an internal server error and
infinitely looped instead after output pipe was closed.
And other minor fixes and documentation updates.

View File

@ -79,14 +79,15 @@ of lines before or after the line given by <start>.
of the --date option at linkgit:git-log[1]. of the --date option at linkgit:git-log[1].
-M|<num>|:: -M|<num>|::
Detect moving lines in the file as well. When a commit Detect moved or copied lines within a file. When a commit
moves a block of lines in a file (e.g. the original file moves or copies a block of lines (e.g. the original file
has A and then B, and the commit changes it to B and has A and then B, and the commit changes it to B and then
then A), the traditional 'blame' algorithm typically blames A), the traditional 'blame' algorithm notices only half of
the lines that were moved up (i.e. B) to the parent and the movement and typically blames the lines that were moved
assigns blame to the lines that were moved down (i.e. A) up (i.e. B) to the parent and assigns blame to the lines that
to the child commit. With this option, both groups of lines were moved down (i.e. A) to the child commit. With this
are blamed on the parent. option, both groups of lines are blamed on the parent by
running extra passes of inspection.
+ +
<num> is optional but it is the lower bound on the number of <num> is optional but it is the lower bound on the number of
alphanumeric characters that git must detect as moving alphanumeric characters that git must detect as moving
@ -94,7 +95,7 @@ within a file for it to associate those lines with the parent
commit. commit.
-C|<num>|:: -C|<num>|::
In addition to `-M`, detect lines copied from other In addition to `-M`, detect lines moved or copied from other
files that were modified in the same commit. This is files that were modified in the same commit. This is
useful when you reorganize your program and move code useful when you reorganize your program and move code
around across files. When this option is given twice, around across files. When this option is given twice,

View File

@ -72,6 +72,8 @@ OPTIONS
Create the branch's reflog. This activates recording of Create the branch's reflog. This activates recording of
all changes made to the branch ref, enabling use of date all changes made to the branch ref, enabling use of date
based sha1 expressions such as "<branchname>@\{yesterday}". based sha1 expressions such as "<branchname>@\{yesterday}".
Note that in non-bare repositories, reflogs are usually
enabled by default by the `core.logallrefupdates` config option.
-f:: -f::
--force:: --force::

View File

@ -105,6 +105,9 @@ The number of additional commits is the number
of commits which would be displayed by "git log v1.0.4..parent". of commits which would be displayed by "git log v1.0.4..parent".
The hash suffix is "-g" + 7-char abbreviation for the tip commit The hash suffix is "-g" + 7-char abbreviation for the tip commit
of parent (which was `2414721b194453f058079d897d13c4e377f92dc6`). of parent (which was `2414721b194453f058079d897d13c4e377f92dc6`).
The "g" prefix stands for "git" and is used to allow describing the version of
a software depending on the SCM the software is managed with. This is useful
in an environment where people may use different SCMs.
Doing a 'git describe' on a tag-name will just show the tag name: Doing a 'git describe' on a tag-name will just show the tag name:

View File

@ -8,13 +8,13 @@ git-fetch - Download objects and refs from another repository
SYNOPSIS SYNOPSIS
-------- --------
'git fetch' <options> <repository> <refspec>... 'git fetch' [<options>] [<repository> [<refspec>...]]
'git fetch' <options> <group> 'git fetch' [<options>] <group>
'git fetch' --multiple <options> [<repository> | <group>]... 'git fetch' --multiple [<options>] [<repository> | <group>]...
'git fetch' --all <options> 'git fetch' --all [<options>]
DESCRIPTION DESCRIPTION

View File

@ -35,7 +35,7 @@ These services can be enabled/disabled using the per-repository
configuration file: configuration file:
http.getanyfile:: http.getanyfile::
This serves older Git clients which are unable to use the This serves Git clients older than version 1.6.6 that are unable to use the
upload pack service. When enabled, clients are able to read upload pack service. When enabled, clients are able to read
any file within the repository, including objects that are any file within the repository, including objects that are
no longer reachable from a branch but are still present. no longer reachable from a branch but are still present.

View File

@ -16,7 +16,9 @@ DESCRIPTION
This command uploads a mailbox generated with 'git format-patch' This command uploads a mailbox generated with 'git format-patch'
into an IMAP drafts folder. This allows patches to be sent as into an IMAP drafts folder. This allows patches to be sent as
other email is when using mail clients that cannot read mailbox other email is when using mail clients that cannot read mailbox
files directly. files directly. The command also works with any general mailbox
in which emails have the fields "From", "Date", and "Subject" in
that order.
Typical usage is something like: Typical usage is something like:
@ -118,12 +120,6 @@ Thunderbird in particular is known to be problematic. Thunderbird
users may wish to visit this web page for more information: users may wish to visit this web page for more information:
http://kb.mozillazine.org/Plain_text_e-mail_-_Thunderbird#Completely_plain_email http://kb.mozillazine.org/Plain_text_e-mail_-_Thunderbird#Completely_plain_email
BUGS
----
Doesn't handle lines starting with "From " in the message body.
Author Author
------ ------
Derived from isync 1.0.1 by Mike McCormack. Derived from isync 1.0.1 by Mike McCormack.

View File

@ -11,7 +11,7 @@ SYNOPSIS
[verse] [verse]
'git push' [--all | --mirror | --tags] [-n | --dry-run] [--receive-pack=<git-receive-pack>] 'git push' [--all | --mirror | --tags] [-n | --dry-run] [--receive-pack=<git-receive-pack>]
[--repo=<repository>] [-f | --force] [-v | --verbose] [-u | --set-upstream] [--repo=<repository>] [-f | --force] [-v | --verbose] [-u | --set-upstream]
[<repository> <refspec>...] [<repository> [<refspec>...]]
DESCRIPTION DESCRIPTION
----------- -----------

View File

@ -10,7 +10,7 @@ SYNOPSIS
[verse] [verse]
'git show-ref' [-q|--quiet] [--verify] [--head] [-d|--dereference] 'git show-ref' [-q|--quiet] [--verify] [--head] [-d|--dereference]
[-s|--hash[=<n>]] [--abbrev[=<n>]] [--tags] [-s|--hash[=<n>]] [--abbrev[=<n>]] [--tags]
[--heads] [--] <pattern>... [--heads] [--] [<pattern>...]
'git show-ref' --exclude-existing[=<pattern>] < ref-list 'git show-ref' --exclude-existing[=<pattern>] < ref-list
DESCRIPTION DESCRIPTION

View File

@ -43,9 +43,11 @@ unreleased) version of git, that is available from 'master'
branch of the `git.git` repository. branch of the `git.git` repository.
Documentation for older releases are available here: Documentation for older releases are available here:
* link:v1.7.0.3/git.html[documentation for release 1.7.0.3] * link:v1.7.0.5/git.html[documentation for release 1.7.0.5]
* release notes for * release notes for
link:RelNotes-1.7.0.5.txt[1.7.0.5],
link:RelNotes-1.7.0.4.txt[1.7.0.4],
link:RelNotes-1.7.0.3.txt[1.7.0.3], link:RelNotes-1.7.0.3.txt[1.7.0.3],
link:RelNotes-1.7.0.2.txt[1.7.0.2], link:RelNotes-1.7.0.2.txt[1.7.0.2],
link:RelNotes-1.7.0.1.txt[1.7.0.1], link:RelNotes-1.7.0.1.txt[1.7.0.1],

View File

@ -36,7 +36,7 @@ Git Transport
The Git transport starts off by sending the command and repository The Git transport starts off by sending the command and repository
on the wire using the pkt-line format, followed by a NUL byte and a on the wire using the pkt-line format, followed by a NUL byte and a
hostname paramater, terminated by a NUL byte. hostname parameter, terminated by a NUL byte.
0032git-upload-pack /project.git\0host=myserver.com\0 0032git-upload-pack /project.git\0host=myserver.com\0
@ -331,7 +331,7 @@ An incremental update (fetch) response might look like this:
C: 0009done\n C: 0009done\n
S: 003aACK 74730d410fcb6603ace96f1dc55ea6196122532d\n S: 0031ACK 74730d410fcb6603ace96f1dc55ea6196122532d\n
S: [PACKFILE] S: [PACKFILE]
---- ----
@ -488,7 +488,7 @@ An example client/server communication might look like this:
C: 0000 C: 0000
C: [PACKDATA] C: [PACKDATA]
S: 000aunpack ok\n S: 000eunpack ok\n
S: 0014ok refs/heads/debug\n S: 0018ok refs/heads/debug\n
S: 0026ng refs/heads/master non-fast-forward\n S: 002ang refs/heads/master non-fast-forward\n
---- ----

View File

@ -1,7 +1,7 @@
#!/bin/sh #!/bin/sh
GVF=GIT-VERSION-FILE GVF=GIT-VERSION-FILE
DEF_VER=v1.7.0.3 DEF_VER=v1.7.0.5
LF=' LF='
' '

View File

@ -831,6 +831,7 @@ ifeq ($(uname_S),FreeBSD)
NO_UINTMAX_T = YesPlease NO_UINTMAX_T = YesPlease
NO_STRTOUMAX = YesPlease NO_STRTOUMAX = YesPlease
endif endif
PYTHON_PATH = /usr/local/bin/python
endif endif
ifeq ($(uname_S),OpenBSD) ifeq ($(uname_S),OpenBSD)
NO_STRCASESTR = YesPlease NO_STRCASESTR = YesPlease
@ -886,6 +887,7 @@ ifeq ($(uname_S),IRIX)
SNPRINTF_RETURNS_BOGUS = YesPlease SNPRINTF_RETURNS_BOGUS = YesPlease
SHELL_PATH = /usr/gnu/bin/bash SHELL_PATH = /usr/gnu/bin/bash
NEEDS_LIBGEN = YesPlease NEEDS_LIBGEN = YesPlease
NEEDS_LIBICONV = YesPlease
endif endif
ifeq ($(uname_S),IRIX64) ifeq ($(uname_S),IRIX64)
NO_SETENV=YesPlease NO_SETENV=YesPlease
@ -904,6 +906,7 @@ ifeq ($(uname_S),IRIX64)
SNPRINTF_RETURNS_BOGUS = YesPlease SNPRINTF_RETURNS_BOGUS = YesPlease
SHELL_PATH=/usr/gnu/bin/bash SHELL_PATH=/usr/gnu/bin/bash
NEEDS_LIBGEN = YesPlease NEEDS_LIBGEN = YesPlease
NEEDS_LIBICONV = YesPlease
endif endif
ifeq ($(uname_S),HP-UX) ifeq ($(uname_S),HP-UX)
NO_IPV6=YesPlease NO_IPV6=YesPlease

View File

@ -1 +1 @@
Documentation/RelNotes-1.7.0.3.txt Documentation/RelNotes-1.7.0.5.txt

View File

@ -198,7 +198,7 @@ void create_branch(const char *head,
log_all_ref_updates = 1; log_all_ref_updates = 1;
if (forcing) if (forcing)
snprintf(msg, sizeof msg, "branch: Reset from %s", snprintf(msg, sizeof msg, "branch: Reset to %s",
start_name); start_name);
else if (!dont_change_ref) else if (!dont_change_ref)
snprintf(msg, sizeof msg, "branch: Created from %s", snprintf(msg, sizeof msg, "branch: Created from %s",

View File

@ -117,7 +117,19 @@ static void fill_pathspec_matches(const char **pathspec, char *seen, int specs)
} }
} }
static void prune_directory(struct dir_struct *dir, const char **pathspec, int prefix) static char *find_used_pathspec(const char **pathspec)
{
char *seen;
int i;
for (i = 0; pathspec[i]; i++)
; /* just counting */
seen = xcalloc(i, 1);
fill_pathspec_matches(pathspec, seen, i);
return seen;
}
static char *prune_directory(struct dir_struct *dir, const char **pathspec, int prefix)
{ {
char *seen; char *seen;
int i, specs; int i, specs;
@ -137,13 +149,7 @@ static void prune_directory(struct dir_struct *dir, const char **pathspec, int p
} }
dir->nr = dst - dir->entries; dir->nr = dst - dir->entries;
fill_pathspec_matches(pathspec, seen, specs); fill_pathspec_matches(pathspec, seen, specs);
return seen;
for (i = 0; i < specs; i++) {
if (!seen[i] && pathspec[i][0] && !file_exists(pathspec[i]))
die("pathspec '%s' did not match any files",
pathspec[i]);
}
free(seen);
} }
static void treat_gitlinks(const char **pathspec) static void treat_gitlinks(const char **pathspec)
@ -359,6 +365,7 @@ int cmd_add(int argc, const char **argv, const char *prefix)
int flags; int flags;
int add_new_files; int add_new_files;
int require_pathspec; int require_pathspec;
char *seen = NULL;
git_config(add_config, NULL); git_config(add_config, NULL);
@ -418,7 +425,7 @@ int cmd_add(int argc, const char **argv, const char *prefix)
/* This picks up the paths that are not tracked */ /* This picks up the paths that are not tracked */
baselen = fill_directory(&dir, pathspec); baselen = fill_directory(&dir, pathspec);
if (pathspec) if (pathspec)
prune_directory(&dir, pathspec, baselen); seen = prune_directory(&dir, pathspec, baselen);
} }
if (refresh_only) { if (refresh_only) {
@ -426,6 +433,19 @@ int cmd_add(int argc, const char **argv, const char *prefix)
goto finish; goto finish;
} }
if (pathspec) {
int i;
if (!seen)
seen = find_used_pathspec(pathspec);
for (i = 0; pathspec[i]; i++) {
if (!seen[i] && pathspec[i][0]
&& !file_exists(pathspec[i]))
die("pathspec '%s' did not match any files",
pathspec[i]);
}
free(seen);
}
exit_status |= add_files_to_cache(prefix, pathspec, flags); exit_status |= add_files_to_cache(prefix, pathspec, flags);
if (add_new_files) if (add_new_files)

View File

@ -1854,33 +1854,76 @@ static int match_fragment(struct image *img,
{ {
int i; int i;
char *fixed_buf, *buf, *orig, *target; char *fixed_buf, *buf, *orig, *target;
int preimage_limit;
if (preimage->nr + try_lno > img->nr) if (preimage->nr + try_lno <= img->nr) {
/*
* The hunk falls within the boundaries of img.
*/
preimage_limit = preimage->nr;
if (match_end && (preimage->nr + try_lno != img->nr))
return 0;
} else if (ws_error_action == correct_ws_error &&
(ws_rule & WS_BLANK_AT_EOF) && match_end) {
/*
* This hunk that matches at the end extends beyond
* the end of img, and we are removing blank lines
* at the end of the file. This many lines from the
* beginning of the preimage must match with img, and
* the remainder of the preimage must be blank.
*/
preimage_limit = img->nr - try_lno;
} else {
/*
* The hunk extends beyond the end of the img and
* we are not removing blanks at the end, so we
* should reject the hunk at this position.
*/
return 0; return 0;
}
if (match_beginning && try_lno) if (match_beginning && try_lno)
return 0; return 0;
if (match_end && preimage->nr + try_lno != img->nr)
return 0;
/* Quick hash check */ /* Quick hash check */
for (i = 0; i < preimage->nr; i++) for (i = 0; i < preimage_limit; i++)
if (preimage->line[i].hash != img->line[try_lno + i].hash) if (preimage->line[i].hash != img->line[try_lno + i].hash)
return 0; return 0;
/* if (preimage_limit == preimage->nr) {
* Do we have an exact match? If we were told to match /*
* at the end, size must be exactly at try+fragsize, * Do we have an exact match? If we were told to match
* otherwise try+fragsize must be still within the preimage, * at the end, size must be exactly at try+fragsize,
* and either case, the old piece should match the preimage * otherwise try+fragsize must be still within the preimage,
* exactly. * and either case, the old piece should match the preimage
*/ * exactly.
if ((match_end */
? (try + preimage->len == img->len) if ((match_end
: (try + preimage->len <= img->len)) && ? (try + preimage->len == img->len)
!memcmp(img->buf + try, preimage->buf, preimage->len)) : (try + preimage->len <= img->len)) &&
return 1; !memcmp(img->buf + try, preimage->buf, preimage->len))
return 1;
} else {
/*
* The preimage extends beyond the end of img, so
* there cannot be an exact match.
*
* There must be one non-blank context line that match
* a line before the end of img.
*/
char *buf_end;
buf = preimage->buf;
buf_end = buf;
for (i = 0; i < preimage_limit; i++)
buf_end += preimage->line[i].len;
for ( ; buf < buf_end; buf++)
if (!isspace(*buf))
break;
if (buf == buf_end)
return 0;
}
/* /*
* No exact match. If we are ignoring whitespace, run a line-by-line * No exact match. If we are ignoring whitespace, run a line-by-line
@ -1891,7 +1934,10 @@ static int match_fragment(struct image *img,
size_t imgoff = 0; size_t imgoff = 0;
size_t preoff = 0; size_t preoff = 0;
size_t postlen = postimage->len; size_t postlen = postimage->len;
for (i = 0; i < preimage->nr; i++) { size_t extra_chars;
char *preimage_eof;
char *preimage_end;
for (i = 0; i < preimage_limit; i++) {
size_t prelen = preimage->line[i].len; size_t prelen = preimage->line[i].len;
size_t imglen = img->line[try_lno+i].len; size_t imglen = img->line[try_lno+i].len;
@ -1905,20 +1951,36 @@ static int match_fragment(struct image *img,
} }
/* /*
* Ok, the preimage matches with whitespace fuzz. Update it and * Ok, the preimage matches with whitespace fuzz.
* the common postimage lines to use the same whitespace as the *
* target. imgoff now holds the true length of the target that * imgoff now holds the true length of the target that
* matches the preimage, and we need to update the line lengths * matches the preimage before the end of the file.
* of the preimage to match the target ones. *
* Count the number of characters in the preimage that fall
* beyond the end of the file and make sure that all of them
* are whitespace characters. (This can only happen if
* we are removing blank lines at the end of the file.)
*/ */
fixed_buf = xmalloc(imgoff); buf = preimage_eof = preimage->buf + preoff;
memcpy(fixed_buf, img->buf + try, imgoff); for ( ; i < preimage->nr; i++)
for (i = 0; i < preimage->nr; i++) preoff += preimage->line[i].len;
preimage->line[i].len = img->line[try_lno+i].len; preimage_end = preimage->buf + preoff;
for ( ; buf < preimage_end; buf++)
if (!isspace(*buf))
return 0;
/* /*
* Update the preimage buffer and the postimage context lines. * Update the preimage and the common postimage context
* lines to use the same whitespace as the target.
* If whitespace is missing in the target (i.e.
* if the preimage extends beyond the end of the file),
* use the whitespace from the preimage.
*/ */
extra_chars = preimage_end - preimage_eof;
fixed_buf = xmalloc(imgoff + extra_chars);
memcpy(fixed_buf, img->buf + try, imgoff);
memcpy(fixed_buf + imgoff, preimage_eof, extra_chars);
imgoff += extra_chars;
update_pre_post_images(preimage, postimage, update_pre_post_images(preimage, postimage,
fixed_buf, imgoff, postlen); fixed_buf, imgoff, postlen);
return 1; return 1;
@ -1932,12 +1994,16 @@ static int match_fragment(struct image *img,
* it might with whitespace fuzz. We haven't been asked to * it might with whitespace fuzz. We haven't been asked to
* ignore whitespace, we were asked to correct whitespace * ignore whitespace, we were asked to correct whitespace
* errors, so let's try matching after whitespace correction. * errors, so let's try matching after whitespace correction.
*
* The preimage may extend beyond the end of the file,
* but in this loop we will only handle the part of the
* preimage that falls within the file.
*/ */
fixed_buf = xmalloc(preimage->len + 1); fixed_buf = xmalloc(preimage->len + 1);
buf = fixed_buf; buf = fixed_buf;
orig = preimage->buf; orig = preimage->buf;
target = img->buf + try; target = img->buf + try;
for (i = 0; i < preimage->nr; i++) { for (i = 0; i < preimage_limit; i++) {
size_t fixlen; /* length after fixing the preimage */ size_t fixlen; /* length after fixing the preimage */
size_t oldlen = preimage->line[i].len; size_t oldlen = preimage->line[i].len;
size_t tgtlen = img->line[try_lno + i].len; size_t tgtlen = img->line[try_lno + i].len;
@ -1977,6 +2043,29 @@ static int match_fragment(struct image *img,
target += tgtlen; target += tgtlen;
} }
/*
* Now handle the lines in the preimage that falls beyond the
* end of the file (if any). They will only match if they are
* empty or only contain whitespace (if WS_BLANK_AT_EOL is
* false).
*/
for ( ; i < preimage->nr; i++) {
size_t fixlen; /* length after fixing the preimage */
size_t oldlen = preimage->line[i].len;
int j;
/* Try fixing the line in the preimage */
fixlen = ws_fix_copy(buf, orig, oldlen, ws_rule, NULL);
for (j = 0; j < fixlen; j++)
if (!isspace(buf[j]))
goto unmatch_exit;
orig += oldlen;
buf += fixlen;
}
/* /*
* Yes, the preimage is based on an older version that still * Yes, the preimage is based on an older version that still
* has whitespace breakages unfixed, and fixing them makes the * has whitespace breakages unfixed, and fixing them makes the
@ -2002,9 +2091,6 @@ static int find_pos(struct image *img,
unsigned long backwards, forwards, try; unsigned long backwards, forwards, try;
int backwards_lno, forwards_lno, try_lno; int backwards_lno, forwards_lno, try_lno;
if (preimage->nr > img->nr)
return -1;
/* /*
* If match_beginning or match_end is specified, there is no * If match_beginning or match_end is specified, there is no
* point starting from a wrong line that will never match and * point starting from a wrong line that will never match and
@ -2015,7 +2101,12 @@ static int find_pos(struct image *img,
else if (match_end) else if (match_end)
line = img->nr - preimage->nr; line = img->nr - preimage->nr;
if (line > img->nr) /*
* Because the comparison is unsigned, the following test
* will also take care of a negative line number that can
* result when match_end and preimage is larger than the target.
*/
if ((size_t) line > img->nr)
line = img->nr; line = img->nr;
try = 0; try = 0;
@ -2091,12 +2182,26 @@ static void update_image(struct image *img,
int i, nr; int i, nr;
size_t remove_count, insert_count, applied_at = 0; size_t remove_count, insert_count, applied_at = 0;
char *result; char *result;
int preimage_limit;
/*
* If we are removing blank lines at the end of img,
* the preimage may extend beyond the end.
* If that is the case, we must be careful only to
* remove the part of the preimage that falls within
* the boundaries of img. Initialize preimage_limit
* to the number of lines in the preimage that falls
* within the boundaries.
*/
preimage_limit = preimage->nr;
if (preimage_limit > img->nr - applied_pos)
preimage_limit = img->nr - applied_pos;
for (i = 0; i < applied_pos; i++) for (i = 0; i < applied_pos; i++)
applied_at += img->line[i].len; applied_at += img->line[i].len;
remove_count = 0; remove_count = 0;
for (i = 0; i < preimage->nr; i++) for (i = 0; i < preimage_limit; i++)
remove_count += img->line[applied_pos + i].len; remove_count += img->line[applied_pos + i].len;
insert_count = postimage->len; insert_count = postimage->len;
@ -2113,8 +2218,8 @@ static void update_image(struct image *img,
result[img->len] = '\0'; result[img->len] = '\0';
/* Adjust the line table */ /* Adjust the line table */
nr = img->nr + postimage->nr - preimage->nr; nr = img->nr + postimage->nr - preimage_limit;
if (preimage->nr < postimage->nr) { if (preimage_limit < postimage->nr) {
/* /*
* NOTE: this knows that we never call remove_first_line() * NOTE: this knows that we never call remove_first_line()
* on anything other than pre/post image. * on anything other than pre/post image.
@ -2122,10 +2227,10 @@ static void update_image(struct image *img,
img->line = xrealloc(img->line, nr * sizeof(*img->line)); img->line = xrealloc(img->line, nr * sizeof(*img->line));
img->line_allocated = img->line; img->line_allocated = img->line;
} }
if (preimage->nr != postimage->nr) if (preimage_limit != postimage->nr)
memmove(img->line + applied_pos + postimage->nr, memmove(img->line + applied_pos + postimage->nr,
img->line + applied_pos + preimage->nr, img->line + applied_pos + preimage_limit,
(img->nr - (applied_pos + preimage->nr)) * (img->nr - (applied_pos + preimage_limit)) *
sizeof(*img->line)); sizeof(*img->line));
memcpy(img->line + applied_pos, memcpy(img->line + applied_pos,
postimage->line, postimage->line,
@ -2321,7 +2426,7 @@ static int apply_one_fragment(struct image *img, struct fragment *frag,
if (applied_pos >= 0) { if (applied_pos >= 0) {
if (new_blank_lines_at_end && if (new_blank_lines_at_end &&
preimage.nr + applied_pos == img->nr && preimage.nr + applied_pos >= img->nr &&
(ws_rule & WS_BLANK_AT_EOF) && (ws_rule & WS_BLANK_AT_EOF) &&
ws_error_action != nowarn_ws_error) { ws_error_action != nowarn_ws_error) {
record_ws_error(WS_BLANK_AT_EOF, "+", 1, frag->linenr); record_ws_error(WS_BLANK_AT_EOF, "+", 1, frag->linenr);
@ -2719,11 +2824,8 @@ static int check_preimage(struct patch *patch, struct cache_entry **ce, struct s
if (stat_ret < 0) { if (stat_ret < 0) {
struct checkout costate; struct checkout costate;
/* checkout */ /* checkout */
memset(&costate, 0, sizeof(costate));
costate.base_dir = ""; costate.base_dir = "";
costate.base_dir_len = 0;
costate.force = 0;
costate.quiet = 0;
costate.not_new = 0;
costate.refresh_cache = 1; costate.refresh_cache = 1;
if (checkout_entry(*ce, &costate, NULL) || if (checkout_entry(*ce, &costate, NULL) ||
lstat(old_name, st)) lstat(old_name, st))

View File

@ -503,7 +503,7 @@ static void export_marks(char *file)
f = fopen(file, "w"); f = fopen(file, "w");
if (!f) if (!f)
error("Unable to open marks file %s for writing.", file); die_errno("Unable to open marks file %s for writing.", file);
for (i = 0; i < idnums.size; i++) { for (i = 0; i < idnums.size; i++) {
if (deco->base && deco->base->type == 1) { if (deco->base && deco->base->type == 1) {

View File

@ -13,10 +13,10 @@
#include "sigchain.h" #include "sigchain.h"
static const char * const builtin_fetch_usage[] = { static const char * const builtin_fetch_usage[] = {
"git fetch [options] [<repository> <refspec>...]", "git fetch [<options>] [<repository> [<refspec>...]]",
"git fetch [options] <group>", "git fetch [<options>] <group>",
"git fetch --multiple [options] [<repository> | <group>]...", "git fetch --multiple [<options>] [<repository> | <group>]...",
"git fetch --all [options]", "git fetch --all [<options>]",
NULL NULL
}; };

View File

@ -1106,8 +1106,15 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)
return 0; return 0;
} }
if (ignore_if_in_upstream) if (ignore_if_in_upstream) {
/* Don't say anything if head and upstream are the same. */
if (rev.pending.nr == 2) {
struct object_array_entry *o = rev.pending.objects;
if (hashcmp(o[0].item->sha1, o[1].item->sha1) == 0)
return 0;
}
get_patch_ids(&rev, &ids, prefix); get_patch_ids(&rev, &ids, prefix);
}
if (!use_stdout) if (!use_stdout)
realstdout = xfdopen(xdup(1), "w"); realstdout = xfdopen(xdup(1), "w");

View File

@ -10,7 +10,7 @@
#include "parse-options.h" #include "parse-options.h"
static const char * const push_usage[] = { static const char * const push_usage[] = {
"git push [<options>] [<repository> <refspec>...]", "git push [<options>] [<repository> [<refspec>...]]",
NULL, NULL,
}; };

View File

@ -23,7 +23,8 @@
static const char * const git_reset_usage[] = { static const char * const git_reset_usage[] = {
"git reset [--mixed | --soft | --hard | --merge] [-q] [<commit>]", "git reset [--mixed | --soft | --hard | --merge] [-q] [<commit>]",
"git reset [--mixed] <commit> [--] <paths>...", "git reset [-q] <commit> [--] <paths>...",
"git reset --patch [<commit>] [--] [<paths>...]",
NULL NULL
}; };

View File

@ -133,9 +133,12 @@ static void show_commit(struct commit *commit, void *data)
*/ */
if (graph_show_remainder(revs->graph)) if (graph_show_remainder(revs->graph))
putchar('\n'); putchar('\n');
if (revs->commit_format == CMIT_FMT_ONELINE)
putchar('\n');
} }
} else { } else {
if (buf.len) if (revs->commit_format != CMIT_FMT_USERFORMAT ||
buf.len)
printf("%s%c", buf.buf, info->hdr_termination); printf("%s%c", buf.buf, info->hdr_termination);
} }
strbuf_release(&buf); strbuf_release(&buf);

24
color.c
View File

@ -47,7 +47,7 @@ void color_parse_mem(const char *value, int value_len, const char *var,
{ {
const char *ptr = value; const char *ptr = value;
int len = value_len; int len = value_len;
int attr = -1; unsigned int attr = 0;
int fg = -2; int fg = -2;
int bg = -2; int bg = -2;
@ -56,7 +56,7 @@ void color_parse_mem(const char *value, int value_len, const char *var,
return; return;
} }
/* [fg [bg]] [attr] */ /* [fg [bg]] [attr]... */
while (len > 0) { while (len > 0) {
const char *word = ptr; const char *word = ptr;
int val, wordlen = 0; int val, wordlen = 0;
@ -85,19 +85,27 @@ void color_parse_mem(const char *value, int value_len, const char *var,
goto bad; goto bad;
} }
val = parse_attr(word, wordlen); val = parse_attr(word, wordlen);
if (val < 0 || attr != -1) if (0 <= val)
attr |= (1 << val);
else
goto bad; goto bad;
attr = val;
} }
if (attr >= 0 || fg >= 0 || bg >= 0) { if (attr || fg >= 0 || bg >= 0) {
int sep = 0; int sep = 0;
int i;
*dst++ = '\033'; *dst++ = '\033';
*dst++ = '['; *dst++ = '[';
if (attr >= 0) {
*dst++ = '0' + attr; for (i = 0; attr; i++) {
sep++; unsigned bit = (1 << i);
if (!(attr & bit))
continue;
attr &= ~bit;
if (sep++)
*dst++ = ';';
*dst++ = '0' + i;
} }
if (fg >= 0) { if (fg >= 0) {
if (sep++) if (sep++)

16
color.h
View File

@ -1,8 +1,20 @@
#ifndef COLOR_H #ifndef COLOR_H
#define COLOR_H #define COLOR_H
/* "\033[1;38;5;2xx;48;5;2xxm\0" is 23 bytes */ /* 2 + (2 * num_attrs) + 8 + 1 + 8 + 'm' + NUL */
#define COLOR_MAXLEN 24 /* "\033[1;2;4;5;7;38;5;2xx;48;5;2xxm\0" */
/*
* The maximum length of ANSI color sequence we would generate:
* - leading ESC '[' 2
* - attr + ';' 2 * 8 (e.g. "1;")
* - fg color + ';' 9 (e.g. "38;5;2xx;")
* - fg color + ';' 9 (e.g. "48;5;2xx;")
* - terminating 'm' NUL 2
*
* The above overcounts attr (we only use 5 not 8) and one semicolon
* but it is close enough.
*/
#define COLOR_MAXLEN 40
/* /*
* IMPORTANT: Due to the way these color codes are emulated on Windows, * IMPORTANT: Due to the way these color codes are emulated on Windows,

View File

@ -17,6 +17,8 @@ static inline uint32_t default_swab32(uint32_t val)
((val & 0x000000ff) << 24)); ((val & 0x000000ff) << 24));
} }
#undef bswap32
#if defined(__GNUC__) && (defined(__i386__) || defined(__x86_64__)) #if defined(__GNUC__) && (defined(__i386__) || defined(__x86_64__))
#define bswap32(x) ({ \ #define bswap32(x) ({ \

View File

@ -259,8 +259,17 @@ int mingw_utime (const char *file_name, const struct utimbuf *times)
int fh, rc; int fh, rc;
/* must have write permission */ /* must have write permission */
if ((fh = open(file_name, O_RDWR | O_BINARY)) < 0) DWORD attrs = GetFileAttributes(file_name);
return -1; if (attrs != INVALID_FILE_ATTRIBUTES &&
(attrs & FILE_ATTRIBUTE_READONLY)) {
/* ignore errors here; open() will report them */
SetFileAttributes(file_name, attrs & ~FILE_ATTRIBUTE_READONLY);
}
if ((fh = open(file_name, O_RDWR | O_BINARY)) < 0) {
rc = -1;
goto revert_attrs;
}
time_t_to_filetime(times->modtime, &mft); time_t_to_filetime(times->modtime, &mft);
time_t_to_filetime(times->actime, &aft); time_t_to_filetime(times->actime, &aft);
@ -270,6 +279,13 @@ int mingw_utime (const char *file_name, const struct utimbuf *times)
} else } else
rc = 0; rc = 0;
close(fh); close(fh);
revert_attrs:
if (attrs != INVALID_FILE_ATTRIBUTES &&
(attrs & FILE_ATTRIBUTE_READONLY)) {
/* ignore errors again */
SetFileAttributes(file_name, attrs);
}
return rc; return rc;
} }

View File

@ -1,4 +1,4 @@
#!/usr/bin/python #!/usr/bin/env python
## zip archive frontend for git-fast-import ## zip archive frontend for git-fast-import
## ##

View File

@ -1,4 +1,4 @@
#! /usr/bin/python #!/usr/bin/env python
""" hg-to-git.py - A Mercurial to GIT converter """ hg-to-git.py - A Mercurial to GIT converter

View File

@ -1,4 +1,4 @@
#!/usr/bin/python #!/usr/bin/env python
# #
# This tool is copyright (c) 2006, Sean Estabrooks. # This tool is copyright (c) 2006, Sean Estabrooks.
# It is released under the Gnu Public License, version 2. # It is released under the Gnu Public License, version 2.

View File

@ -590,14 +590,17 @@ static int execute(struct sockaddr *addr)
static int addrcmp(const struct sockaddr_storage *s1, static int addrcmp(const struct sockaddr_storage *s1,
const struct sockaddr_storage *s2) const struct sockaddr_storage *s2)
{ {
if (s1->ss_family != s2->ss_family) const struct sockaddr *sa1 = (const struct sockaddr*) s1;
return s1->ss_family - s2->ss_family; const struct sockaddr *sa2 = (const struct sockaddr*) s2;
if (s1->ss_family == AF_INET)
if (sa1->sa_family != sa2->sa_family)
return sa1->sa_family - sa2->sa_family;
if (sa1->sa_family == AF_INET)
return memcmp(&((struct sockaddr_in *)s1)->sin_addr, return memcmp(&((struct sockaddr_in *)s1)->sin_addr,
&((struct sockaddr_in *)s2)->sin_addr, &((struct sockaddr_in *)s2)->sin_addr,
sizeof(struct in_addr)); sizeof(struct in_addr));
#ifndef NO_IPV6 #ifndef NO_IPV6
if (s1->ss_family == AF_INET6) if (sa1->sa_family == AF_INET6)
return memcmp(&((struct sockaddr_in6 *)s1)->sin6_addr, return memcmp(&((struct sockaddr_in6 *)s1)->sin6_addr,
&((struct sockaddr_in6 *)s2)->sin6_addr, &((struct sockaddr_in6 *)s2)->sin6_addr,
sizeof(struct in6_addr)); sizeof(struct in6_addr));

41
diff.c
View File

@ -14,6 +14,7 @@
#include "userdiff.h" #include "userdiff.h"
#include "sigchain.h" #include "sigchain.h"
#include "submodule.h" #include "submodule.h"
#include "ll-merge.h"
#ifdef NO_FAST_WORKING_DIRECTORY #ifdef NO_FAST_WORKING_DIRECTORY
#define FAST_WORKING_DIRECTORY 0 #define FAST_WORKING_DIRECTORY 0
@ -1370,37 +1371,32 @@ static void free_diffstat_info(struct diffstat_t *diffstat)
struct checkdiff_t { struct checkdiff_t {
const char *filename; const char *filename;
int lineno; int lineno;
int conflict_marker_size;
struct diff_options *o; struct diff_options *o;
unsigned ws_rule; unsigned ws_rule;
unsigned status; unsigned status;
}; };
static int is_conflict_marker(const char *line, unsigned long len) static int is_conflict_marker(const char *line, int marker_size, unsigned long len)
{ {
char firstchar; char firstchar;
int cnt; int cnt;
if (len < 8) if (len < marker_size + 1)
return 0; return 0;
firstchar = line[0]; firstchar = line[0];
switch (firstchar) { switch (firstchar) {
case '=': case '>': case '<': case '=': case '>': case '<': case '|':
break; break;
default: default:
return 0; return 0;
} }
for (cnt = 1; cnt < 7; cnt++) for (cnt = 1; cnt < marker_size; cnt++)
if (line[cnt] != firstchar) if (line[cnt] != firstchar)
return 0; return 0;
/* line[0] thru line[6] are same as firstchar */ /* line[1] thru line[marker_size-1] are same as firstchar */
if (firstchar == '=') { if (len < marker_size + 1 || !isspace(line[marker_size]))
/* divider between ours and theirs? */
if (len != 8 || line[7] != '\n')
return 0;
} else if (len < 8 || !isspace(line[7])) {
/* not divider before ours nor after theirs */
return 0; return 0;
}
return 1; return 1;
} }
@ -1408,6 +1404,7 @@ static void checkdiff_consume(void *priv, char *line, unsigned long len)
{ {
struct checkdiff_t *data = priv; struct checkdiff_t *data = priv;
int color_diff = DIFF_OPT_TST(data->o, COLOR_DIFF); int color_diff = DIFF_OPT_TST(data->o, COLOR_DIFF);
int marker_size = data->conflict_marker_size;
const char *ws = diff_get_color(color_diff, DIFF_WHITESPACE); const char *ws = diff_get_color(color_diff, DIFF_WHITESPACE);
const char *reset = diff_get_color(color_diff, DIFF_RESET); const char *reset = diff_get_color(color_diff, DIFF_RESET);
const char *set = diff_get_color(color_diff, DIFF_FILE_NEW); const char *set = diff_get_color(color_diff, DIFF_FILE_NEW);
@ -1416,7 +1413,7 @@ static void checkdiff_consume(void *priv, char *line, unsigned long len)
if (line[0] == '+') { if (line[0] == '+') {
unsigned bad; unsigned bad;
data->lineno++; data->lineno++;
if (is_conflict_marker(line + 1, len - 1)) { if (is_conflict_marker(line + 1, marker_size, len - 1)) {
data->status |= 1; data->status |= 1;
fprintf(data->o->file, fprintf(data->o->file,
"%s:%d: leftover conflict marker\n", "%s:%d: leftover conflict marker\n",
@ -1860,6 +1857,7 @@ static void builtin_checkdiff(const char *name_a, const char *name_b,
data.lineno = 0; data.lineno = 0;
data.o = o; data.o = o;
data.ws_rule = whitespace_rule(attr_path); data.ws_rule = whitespace_rule(attr_path);
data.conflict_marker_size = ll_merge_marker_size(attr_path);
if (fill_mmfile(&mf1, one) < 0 || fill_mmfile(&mf2, two) < 0) if (fill_mmfile(&mf1, one) < 0 || fill_mmfile(&mf2, two) < 0)
die("unable to read files to diff"); die("unable to read files to diff");
@ -3865,6 +3863,7 @@ static char *run_textconv(const char *pgm, struct diff_filespec *spec,
const char **arg = argv; const char **arg = argv;
struct child_process child; struct child_process child;
struct strbuf buf = STRBUF_INIT; struct strbuf buf = STRBUF_INIT;
int err = 0;
temp = prepare_temp_file(spec->path, spec); temp = prepare_temp_file(spec->path, spec);
*arg++ = pgm; *arg++ = pgm;
@ -3875,16 +3874,20 @@ static char *run_textconv(const char *pgm, struct diff_filespec *spec,
child.use_shell = 1; child.use_shell = 1;
child.argv = argv; child.argv = argv;
child.out = -1; child.out = -1;
if (start_command(&child) != 0 || if (start_command(&child)) {
strbuf_read(&buf, child.out, 0) < 0 ||
finish_command(&child) != 0) {
close(child.out);
strbuf_release(&buf);
remove_tempfile(); remove_tempfile();
error("error running textconv command '%s'", pgm);
return NULL; return NULL;
} }
if (strbuf_read(&buf, child.out, 0) < 0)
err = error("error reading from textconv command '%s'", pgm);
close(child.out); close(child.out);
if (finish_command(&child) || err) {
strbuf_release(&buf);
remove_tempfile();
return NULL;
}
remove_tempfile(); remove_tempfile();
return strbuf_detach(&buf, outsize); return strbuf_detach(&buf, outsize);

20
dir.c
View File

@ -594,13 +594,29 @@ static int simplify_away(const char *path, int pathlen, const struct path_simpli
return 0; return 0;
} }
static int in_pathspec(const char *path, int len, const struct path_simplify *simplify) /*
* This function tells us whether an excluded path matches a
* list of "interesting" pathspecs. That is, whether a path matched
* by any of the pathspecs could possibly be ignored by excluding
* the specified path. This can happen if:
*
* 1. the path is mentioned explicitly in the pathspec
*
* 2. the path is a directory prefix of some element in the
* pathspec
*/
static int exclude_matches_pathspec(const char *path, int len,
const struct path_simplify *simplify)
{ {
if (simplify) { if (simplify) {
for (; simplify->path; simplify++) { for (; simplify->path; simplify++) {
if (len == simplify->len if (len == simplify->len
&& !memcmp(path, simplify->path, len)) && !memcmp(path, simplify->path, len))
return 1; return 1;
if (len < simplify->len
&& simplify->path[len] == '/'
&& !memcmp(path, simplify->path, len))
return 1;
} }
} }
return 0; return 0;
@ -678,7 +694,7 @@ static enum path_treatment treat_one_path(struct dir_struct *dir,
{ {
int exclude = excluded(dir, path, &dtype); int exclude = excluded(dir, path, &dtype);
if (exclude && (dir->flags & DIR_COLLECT_IGNORED) if (exclude && (dir->flags & DIR_COLLECT_IGNORED)
&& in_pathspec(path, *len, simplify)) && exclude_matches_pathspec(path, *len, simplify))
dir_add_ignored(dir, path, *len); dir_add_ignored(dir, path, *len);
/* /*

View File

@ -78,11 +78,13 @@ sub generate_command
next; next;
} }
if ($arg eq '-g' || $arg eq '--gui') { if ($arg eq '-g' || $arg eq '--gui') {
my $tool = Git::command_oneline('config', eval {
'diff.guitool'); my $tool = Git::command_oneline('config',
if (length($tool)) { 'diff.guitool');
$ENV{GIT_DIFF_TOOL} = $tool; if (length($tool)) {
} $ENV{GIT_DIFF_TOOL} = $tool;
}
};
next; next;
} }
if ($arg eq '-y' || $arg eq '--no-prompt') { if ($arg eq '-y' || $arg eq '--no-prompt') {

View File

@ -162,9 +162,12 @@ my $compose_filename;
# Handle interactive edition of files. # Handle interactive edition of files.
my $multiedit; my $multiedit;
my $editor = Git::command_oneline('var', 'GIT_EDITOR'); my $editor;
sub do_edit { sub do_edit {
if (!defined($editor)) {
$editor = Git::command_oneline('var', 'GIT_EDITOR');
}
if (defined($multiedit) && !$multiedit) { if (defined($multiedit) && !$multiedit) {
map { map {
system('sh', '-c', $editor.' "$@"', $editor, $_); system('sh', '-c', $editor.' "$@"', $editor, $_);

View File

@ -210,14 +210,18 @@ list_stash () {
} }
show_stash () { show_stash () {
have_stash || die 'No stash found'
flags=$(git rev-parse --no-revs --flags "$@") flags=$(git rev-parse --no-revs --flags "$@")
if test -z "$flags" if test -z "$flags"
then then
flags=--stat flags=--stat
fi fi
w_commit=$(git rev-parse --verify --default $ref_stash "$@") && w_commit=$(git rev-parse --quiet --verify --default $ref_stash "$@") &&
b_commit=$(git rev-parse --verify "$w_commit^") && b_commit=$(git rev-parse --quiet --verify "$w_commit^") ||
die "'$*' is not a stash"
git diff $flags $b_commit $w_commit git diff $flags $b_commit $w_commit
} }

View File

@ -7,7 +7,11 @@ pysetupfile:=setup.py
DESTDIR_SQ = $(subst ','\'',$(DESTDIR)) DESTDIR_SQ = $(subst ','\'',$(DESTDIR))
ifndef PYTHON_PATH ifndef PYTHON_PATH
PYTHON_PATH = /usr/bin/python ifeq ($(uname_S),FreeBSD)
PYTHON_PATH = /usr/local/bin/python
else
PYTHON_PATH = /usr/bin/python
endif
endif endif
ifndef prefix ifndef prefix
prefix = $(HOME) prefix = $(HOME)

View File

@ -2209,8 +2209,7 @@ sub config_to_multi {
sub git_get_project_config { sub git_get_project_config {
my ($key, $type) = @_; my ($key, $type) = @_;
# do we have project return unless defined $git_dir;
return unless (defined $project && defined $git_dir);
# key sanity check # key sanity check
return unless ($key); return unless ($key);

View File

@ -538,15 +538,19 @@ static void service_rpc(char *service_name)
static NORETURN void die_webcgi(const char *err, va_list params) static NORETURN void die_webcgi(const char *err, va_list params)
{ {
char buffer[1000]; static int dead;
http_status(500, "Internal Server Error"); if (!dead) {
hdr_nocache(); char buffer[1000];
end_headers(); dead = 1;
vsnprintf(buffer, sizeof(buffer), err, params); vsnprintf(buffer, sizeof(buffer), err, params);
fprintf(stderr, "fatal: %s\n", buffer); fprintf(stderr, "fatal: %s\n", buffer);
exit(0); http_status(500, "Internal Server Error");
hdr_nocache();
end_headers();
}
exit(0); /* we successfully reported a failure ;-) */
} }
static char* getdir(void) static char* getdir(void)

View File

@ -1306,8 +1306,14 @@ static int count_messages(struct msg_data *msg)
while (1) { while (1) {
if (!prefixcmp(p, "From ")) { if (!prefixcmp(p, "From ")) {
p = strstr(p+5, "\nFrom: ");
if (!p) break;
p = strstr(p+7, "\nDate: ");
if (!p) break;
p = strstr(p+7, "\nSubject: ");
if (!p) break;
p += 10;
count++; count++;
p += 5;
} }
p = strstr(p+5, "\nFrom "); p = strstr(p+5, "\nFrom ");
if (!p) if (!p)

11
refs.c
View File

@ -6,6 +6,7 @@
/* ISSYMREF=01 and ISPACKED=02 are public interfaces */ /* ISSYMREF=01 and ISPACKED=02 are public interfaces */
#define REF_KNOWS_PEELED 04 #define REF_KNOWS_PEELED 04
#define REF_BROKEN 010
struct ref_list { struct ref_list {
struct ref_list *next; struct ref_list *next;
@ -275,8 +276,10 @@ static struct ref_list *get_ref_dir(const char *base, struct ref_list *list)
list = get_ref_dir(ref, list); list = get_ref_dir(ref, list);
continue; continue;
} }
if (!resolve_ref(ref, sha1, 1, &flag)) if (!resolve_ref(ref, sha1, 1, &flag)) {
hashclr(sha1); hashclr(sha1);
flag |= REF_BROKEN;
}
list = add_ref(ref, sha1, flag, list, NULL); list = add_ref(ref, sha1, flag, list, NULL);
} }
free(ref); free(ref);
@ -539,10 +542,10 @@ static int do_one_ref(const char *base, each_ref_fn fn, int trim,
{ {
if (strncmp(base, entry->name, trim)) if (strncmp(base, entry->name, trim))
return 0; return 0;
/* Is this a "negative ref" that represents a deleted ref? */
if (is_null_sha1(entry->sha1))
return 0;
if (!(flags & DO_FOR_EACH_INCLUDE_BROKEN)) { if (!(flags & DO_FOR_EACH_INCLUDE_BROKEN)) {
if (entry->flag & REF_BROKEN)
return 0; /* ignore dangling symref */
if (!has_sha1_file(entry->sha1)) { if (!has_sha1_file(entry->sha1)) {
error("%s does not point to a valid object!", entry->name); error("%s does not point to a valid object!", entry->name);
return 0; return 0;

View File

@ -108,13 +108,17 @@ $test_case 'merge (case change)' '
' '
$test_case 'add (with different case)' '
test_expect_failure 'add (with different case)' '
git reset --hard initial && git reset --hard initial &&
rm camelcase && rm camelcase &&
echo 1 >CamelCase && echo 1 >CamelCase &&
git add CamelCase && git add CamelCase &&
test $(git ls-files | grep -i camelcase | wc -l) = 1 camel=$(git ls-files | grep -i camelcase) &&
test $(echo "$camel" | wc -l) = 1 &&
test "z$(git cat-file blob :$camel)" = z1
' '

View File

@ -176,4 +176,9 @@ test_expect_success 'add -u resolves unmerged paths' '
' '
test_expect_success '"add -u non-existent" should fail' '
test_must_fail git add -u non-existent &&
! (git ls-files | grep "non-existent")
'
test_done test_done

79
t/t2204-add-ignored.sh Executable file
View File

@ -0,0 +1,79 @@
#!/bin/sh
test_description='giving ignored paths to git add'
. ./test-lib.sh
test_expect_success setup '
mkdir sub dir dir/sub &&
echo sub >.gitignore &&
echo ign >>.gitignore &&
for p in . sub dir dir/sub
do
>"$p/ign" &&
>"$p/file" || exit 1
done
'
for i in file dir/file dir 'd*'
do
test_expect_success "no complaints for unignored $i" '
rm -f .git/index &&
git add "$i" &&
git ls-files "$i" >out &&
test -s out
'
done
for i in ign dir/ign dir/sub dir/sub/*ign sub/file sub sub/*
do
test_expect_success "complaints for ignored $i" '
rm -f .git/index &&
test_must_fail git add "$i" 2>err &&
git ls-files "$i" >out &&
! test -s out &&
grep -e "Use -f if" err &&
cat err
'
test_expect_success "complaints for ignored $i with unignored file" '
rm -f .git/index &&
test_must_fail git add "$i" file 2>err &&
git ls-files "$i" >out &&
! test -s out &&
grep -e "Use -f if" err &&
cat err
'
done
for i in sub sub/*
do
test_expect_success "complaints for ignored $i in dir" '
rm -f .git/index &&
(
cd dir &&
test_must_fail git add "$i" 2>err &&
git ls-files "$i" >out &&
! test -s out &&
grep -e "Use -f if" err &&
cat err
)
'
done
for i in ign file
do
test_expect_success "complaints for ignored $i in sub" '
rm -f .git/index &&
(
cd sub &&
test_must_fail git add "$i" 2>err &&
git ls-files "$i" >out &&
! test -s out &&
grep -e "Use -f if" err &&
cat err
)
'
done
test_done

126
t/t3417-rebase-whitespace-fix.sh Executable file
View File

@ -0,0 +1,126 @@
#!/bin/sh
test_description='git rebase --whitespace=fix
This test runs git rebase --whitespace=fix and make sure that it works.
'
. ./test-lib.sh
# prepare initial revision of "file" with a blank line at the end
cat >file <<EOF
a
b
c
EOF
# expected contents in "file" after rebase
cat >expect-first <<EOF
a
b
c
EOF
# prepare second revision of "file"
cat >second <<EOF
a
b
c
d
e
f
EOF
# expected contents in second revision after rebase
cat >expect-second <<EOF
a
b
c
d
e
f
EOF
test_expect_success 'blank line at end of file; extend at end of file' '
git commit --allow-empty -m "Initial empty commit" &&
git add file && git commit -m first &&
mv second file &&
git add file && git commit -m second &&
git rebase --whitespace=fix HEAD^^ &&
git diff --exit-code HEAD^:file expect-first &&
test_cmp file expect-second
'
# prepare third revision of "file"
sed -e's/Z//' >third <<EOF
a
b
c
d
e
f
Z
Z
h
i
j
k
l
EOF
sed -e's/ //g' <third >expect-third
test_expect_success 'two blanks line at end of file; extend at end of file' '
cp third file && git add file && git commit -m third &&
git rebase --whitespace=fix HEAD^^ &&
git diff --exit-code HEAD^:file expect-second &&
test_cmp file expect-third
'
test_expect_success 'same, but do not remove trailing spaces' '
git config core.whitespace "-blank-at-eol" &&
git reset --hard HEAD^ &&
cp third file && git add file && git commit -m third &&
git rebase --whitespace=fix HEAD^^
git diff --exit-code HEAD^:file expect-second &&
test_cmp file third
'
sed -e's/Z//' >beginning <<EOF
a
Z
Z
EOF
cat >expect-beginning <<EOF
a
1
2
3
4
5
EOF
test_expect_success 'at beginning of file' '
git config core.whitespace "blank-at-eol" &&
cp beginning file &&
git commit -m beginning file &&
for i in 1 2 3 4 5; do
echo $i
done >> file &&
git commit -m more file &&
git rebase --whitespace=fix HEAD^^ &&
test_cmp file expect-beginning
'
test_done

View File

@ -255,4 +255,9 @@ test_expect_success 'git add to resolve conflicts on otherwise ignored path' '
git add track-this git add track-this
' '
test_expect_success '"add non-existent" should fail' '
test_must_fail git add non-existent &&
! (git ls-files | grep "non-existent")
'
test_done test_done

View File

@ -557,4 +557,8 @@ test_expect_success 'format-patch -- <path>' '
! grep "Use .--" error ! grep "Use .--" error
' '
test_expect_success 'format-patch --ignore-if-in-upstream HEAD' '
git format-patch --ignore-if-in-upstream HEAD
'
test_done test_done

View File

@ -120,7 +120,6 @@ test_expect_success '--check with --no-pager returns 2 for dirty difference' '
' '
test_expect_success 'check should test not just the last line' ' test_expect_success 'check should test not just the last line' '
echo "" >>a && echo "" >>a &&
git --no-pager diff --check git --no-pager diff --check
@ -142,4 +141,26 @@ test_expect_success 'check detects leftover conflict markers' '
git reset --hard git reset --hard
' '
test_expect_success 'check honors conflict marker length' '
git reset --hard &&
echo ">>>>>>> boo" >>b &&
echo "======" >>a &&
git diff --check a &&
(
git diff --check b
test $? = 2
) &&
git reset --hard &&
echo ">>>>>>>> boo" >>b &&
echo "========" >>a &&
git diff --check &&
echo "b conflict-marker-size=8" >.gitattributes &&
(
git diff --check b
test $? = 2
) &&
git diff --check a &&
git reset --hard
'
test_done test_done

View File

@ -8,14 +8,13 @@ test_description='Test diff/status color escape codes'
color() color()
{ {
git config diff.color.new "$1" && actual=$(git config --get-color no.such.slot "$1") &&
test "`git config --get-color diff.color.new`" = "$2" test "$actual" = "$2"
} }
invalid_color() invalid_color()
{ {
git config diff.color.new "$1" && test_must_fail git config --get-color no.such.slot "$1"
test -z "`git config --get-color diff.color.new 2>/dev/null`"
} }
test_expect_success 'reset' ' test_expect_success 'reset' '
@ -42,6 +41,14 @@ test_expect_success 'fg bg attr' '
color "blue red ul" "[4;34;41m" color "blue red ul" "[4;34;41m"
' '
test_expect_success 'fg bg attr...' '
color "blue bold dim ul blink reverse" "[1;2;4;5;7;34m"
'
test_expect_success 'long color specification' '
color "254 255 bold dim ul blink reverse" "[1;2;4;5;7;38;5;254;48;5;255m"
'
test_expect_success '256 colors' ' test_expect_success '256 colors' '
color "254 bold 255" "[1;38;5;254;48;5;255m" color "254 bold 255" "[1;38;5;254;48;5;255m"
' '

View File

@ -134,4 +134,13 @@ test_expect_success 'two lines' '
' '
test_expect_success 'apply patch with 3 context lines matching at end' '
{ echo a; echo b; echo c; echo d; } >file &&
git add file &&
echo e >>file &&
git diff >patch &&
>file &&
test_must_fail git apply patch
'
test_done test_done

View File

@ -261,4 +261,174 @@ test_expect_success 'blank but not empty at EOF' '
grep "new blank line at EOF" error grep "new blank line at EOF" error
' '
test_expect_success 'applying beyond EOF requires one non-blank context line' '
{ echo; echo; echo; echo; } >one &&
git add one &&
{ echo b; } >>one &&
git diff -- one >patch &&
git checkout one &&
{ echo a; echo; } >one &&
cp one expect &&
test_must_fail git apply --whitespace=fix patch &&
test_cmp one expect &&
test_must_fail git apply --ignore-space-change --whitespace=fix patch &&
test_cmp one expect
'
test_expect_success 'tons of blanks at EOF should not apply' '
for i in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16; do
echo; echo; echo; echo;
done >one &&
git add one &&
echo a >>one &&
git diff -- one >patch &&
>one &&
test_must_fail git apply --whitespace=fix patch &&
test_must_fail git apply --ignore-space-change --whitespace=fix patch
'
test_expect_success 'missing blank line at end with --whitespace=fix' '
echo a >one &&
echo >>one &&
git add one &&
echo b >>one &&
cp one expect &&
git diff -- one >patch &&
echo a >one &&
cp one saved-one &&
test_must_fail git apply patch &&
git apply --whitespace=fix patch &&
test_cmp one expect &&
mv saved-one one &&
git apply --ignore-space-change --whitespace=fix patch &&
test_cmp one expect
'
test_expect_success 'two missing blank lines at end with --whitespace=fix' '
{ echo a; echo; echo b; echo c; } >one &&
cp one no-blank-lines &&
{ echo; echo; } >>one &&
git add one &&
echo d >>one &&
cp one expect &&
echo >>one &&
git diff -- one >patch &&
cp no-blank-lines one &&
test_must_fail git apply patch &&
git apply --whitespace=fix patch &&
test_cmp one expect &&
mv no-blank-lines one &&
test_must_fail git apply patch &&
git apply --ignore-space-change --whitespace=fix patch &&
test_cmp one expect
'
test_expect_success 'shrink file with tons of missing blanks at end of file' '
{ echo a; echo b; echo c; } >one &&
cp one no-blank-lines &&
for i in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16; do
echo; echo; echo; echo;
done >>one &&
git add one &&
echo a >one &&
cp one expect &&
git diff -- one >patch &&
cp no-blank-lines one &&
test_must_fail git apply patch &&
git apply --whitespace=fix patch &&
test_cmp one expect &&
mv no-blank-lines one &&
git apply --ignore-space-change --whitespace=fix patch &&
test_cmp one expect
'
test_expect_success 'missing blanks at EOF must only match blank lines' '
{ echo a; echo b; } >one &&
git add one &&
{ echo c; echo d; } >>one &&
git diff -- one >patch &&
echo a >one &&
test_must_fail git apply patch
test_must_fail git apply --whitespace=fix patch &&
test_must_fail git apply --ignore-space-change --whitespace=fix patch
'
sed -e's/Z//' >one <<EOF
a
b
c
Z
EOF
test_expect_success 'missing blank line should match context line with spaces' '
git add one &&
echo d >>one &&
git diff -- one >patch &&
{ echo a; echo b; echo c; } >one &&
cp one expect &&
{ echo; echo d; } >>expect &&
git add one &&
git apply --whitespace=fix patch &&
test_cmp one expect
'
sed -e's/Z//' >one <<EOF
a
b
c
Z
EOF
test_expect_success 'same, but with the --ignore-space-option' '
git add one &&
echo d >>one &&
cp one expect &&
git diff -- one >patch &&
{ echo a; echo b; echo c; } >one &&
git add one &&
git checkout-index -f one &&
git apply --ignore-space-change --whitespace=fix patch &&
test_cmp one expect
'
test_expect_success 'same, but with CR-LF line endings && cr-at-eol set' '
git config core.whitespace cr-at-eol &&
printf "a\r\n" >one &&
printf "b\r\n" >>one &&
printf "c\r\n" >>one &&
cp one save-one &&
printf " \r\n" >>one
git add one &&
printf "d\r\n" >>one &&
cp one expect &&
git diff -- one >patch &&
mv save-one one &&
git apply --ignore-space-change --whitespace=fix patch &&
test_cmp one expect
'
test_expect_success 'same, but with CR-LF line endings && cr-at-eol unset' '
git config --unset core.whitespace &&
printf "a\r\n" >one &&
printf "b\r\n" >>one &&
printf "c\r\n" >>one &&
cp one save-one &&
printf " \r\n" >>one
git add one &&
cp one expect &&
printf "d\r\n" >>one &&
git diff -- one >patch &&
mv save-one one &&
echo d >>expect &&
git apply --ignore-space-change --whitespace=fix patch &&
test_cmp one expect
'
test_done test_done

View File

@ -507,15 +507,15 @@ test_expect_success 'remote prune to cause a dangling symref' '
( (
cd seven && cd seven &&
git remote prune origin git remote prune origin
) 2>err && ) >err 2>&1 &&
grep "has become dangling" err && grep "has become dangling" err &&
: And the dangling symref will not cause other annoying errors : And the dangling symref will not cause other annoying errors &&
( (
cd seven && cd seven &&
git branch -a git branch -a
) 2>err && ) 2>err &&
! grep "points nowhere" err ! grep "points nowhere" err &&
( (
cd seven && cd seven &&
test_must_fail git branch nomore origin test_must_fail git branch nomore origin

View File

@ -209,4 +209,13 @@ test_expect_success '%gd shortens ref name' '
test_cmp expect.gd-short actual.gd-short test_cmp expect.gd-short actual.gd-short
' '
test_expect_success 'oneline with empty message' '
git commit -m "dummy" --allow-empty &&
git commit -m "dummy" --allow-empty &&
git filter-branch --msg-filter "sed -e s/dummy//" HEAD^^.. &&
git rev-list --oneline HEAD > /tmp/test.txt &&
test $(git rev-list --oneline HEAD | wc -l) -eq 5 &&
test $(git rev-list --oneline --graph HEAD | wc -l) -eq 5
'
test_done test_done

View File

@ -92,6 +92,15 @@ test_expect_success 'difftool honors --gui' '
restore_test_defaults restore_test_defaults
' '
test_expect_success 'difftool --gui works without configured diff.guitool' '
git config diff.tool test-tool &&
diff=$(git difftool --no-prompt --gui branch) &&
test "$diff" = "branch" &&
restore_test_defaults
'
# Specify the diff tool using $GIT_DIFF_TOOL # Specify the diff tool using $GIT_DIFF_TOOL
test_expect_success 'GIT_DIFF_TOOL variable' ' test_expect_success 'GIT_DIFF_TOOL variable' '
git config --unset diff.tool git config --unset diff.tool

View File

@ -150,20 +150,22 @@ test_expect_success 'setup submodule' '
git checkout -f master && git checkout -f master &&
mkdir sub && mkdir sub &&
cd sub && (
git init && cd sub &&
echo test file > file && git init &&
git add file && echo test file > file &&
git commit -m sub_initial && git add file &&
cd .. && git commit -m sub_initial
) &&
git submodule add "`pwd`/sub" sub && git submodule add "`pwd`/sub" sub &&
git commit -m initial && git commit -m initial &&
test_tick && test_tick &&
cd sub && (
echo more data >> file && cd sub &&
git add file && echo more data >> file &&
git commit -m sub_second && git add file &&
cd .. && git commit -m sub_second
) &&
git add sub && git add sub &&
git commit -m second git commit -m second
@ -264,19 +266,20 @@ test_expect_success 'cope with tagger-less tags' '
test_expect_success 'setup for limiting exports by PATH' ' test_expect_success 'setup for limiting exports by PATH' '
mkdir limit-by-paths && mkdir limit-by-paths &&
cd limit-by-paths && (
git init && cd limit-by-paths &&
echo hi > there && git init &&
git add there && echo hi > there &&
git commit -m "First file" && git add there &&
echo foo > bar && git commit -m "First file" &&
git add bar && echo foo > bar &&
git commit -m "Second file" && git add bar &&
git tag -a -m msg mytag && git commit -m "Second file" &&
echo morefoo >> bar && git tag -a -m msg mytag &&
git add bar && echo morefoo >> bar &&
git commit -m "Change to second file" && git add bar &&
cd .. git commit -m "Change to second file"
)
' '
cat > limit-by-paths/expected << EOF cat > limit-by-paths/expected << EOF
@ -297,10 +300,11 @@ M 100644 :1 there
EOF EOF
test_expect_success 'dropping tag of filtered out object' ' test_expect_success 'dropping tag of filtered out object' '
(
cd limit-by-paths && cd limit-by-paths &&
git fast-export --tag-of-filtered-object=drop mytag -- there > output && git fast-export --tag-of-filtered-object=drop mytag -- there > output &&
test_cmp output expected && test_cmp output expected
cd .. )
' '
cat >> limit-by-paths/expected << EOF cat >> limit-by-paths/expected << EOF
@ -313,10 +317,11 @@ msg
EOF EOF
test_expect_success 'rewriting tag of filtered out object' ' test_expect_success 'rewriting tag of filtered out object' '
(
cd limit-by-paths && cd limit-by-paths &&
git fast-export --tag-of-filtered-object=rewrite mytag -- there > output && git fast-export --tag-of-filtered-object=rewrite mytag -- there > output &&
test_cmp output expected && test_cmp output expected
cd .. )
' '
cat > limit-by-paths/expected << EOF cat > limit-by-paths/expected << EOF
@ -343,13 +348,13 @@ M 100644 :2 there
EOF EOF
test_expect_failure 'no exact-ref revisions included' ' test_expect_failure 'no exact-ref revisions included' '
cd limit-by-paths && (
git fast-export master~2..master~1 > output && cd limit-by-paths &&
test_cmp output expected && git fast-export master~2..master~1 > output &&
cd .. test_cmp output expected
)
' '
test_expect_success 'set-up a few more tags for tag export tests' ' test_expect_success 'set-up a few more tags for tag export tests' '
git checkout -f master && git checkout -f master &&
HEAD_TREE=`git show -s --pretty=raw HEAD | grep tree | sed "s/tree //"` && HEAD_TREE=`git show -s --pretty=raw HEAD | grep tree | sed "s/tree //"` &&