Commit graph

41376 commits

Author SHA1 Message Date
Xue Fuqiao a3e1fa97bc Documentation: fix header markup
Asciidoctor is stricter than AsciiDoc when deciding if underlining
is a section title or the start of preformatted text.  Make the
length of the underlining match the text to ensure that it renders
correctly in all implementations.

Signed-off-by: Xue Fuqiao <xfq.free@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2015-10-22 09:35:36 -07:00
Junio C Hamano 6ac617a321 mailinfo: remove calls to exit() and die() deep in the callchain
The top-level mailinfo() would instead punt when the code in the
deeper part of the callchain detects an unrecoverable error in the
input.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
2015-10-21 15:59:34 -07:00
Junio C Hamano 4b98bae2cb am: make direct call to mailinfo
And finally the endgame.  Instead of spawning "git mailinfo" via the
run_command() API the same number of times as there are incoming
patches, make direct internal call to the libified mailinfo() from
"git am" to reduce the spawning overhead, which would matter on some
platforms.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
2015-10-21 15:59:34 -07:00
Junio C Hamano 669b963af2 mailinfo: handle charset conversion errors in the caller
Instead of dying in convert_to_utf8(), just report an error and let
the callers handle it.  Between the two callers:

 - decode_header() silently punts when it cannot parse a broken
   RFC2047 encoded text (e.g. when it sees anything other than B or
   Q after it sees "=?<charset>") by jumping to release_return,
   returning the string it successfully parsed out so far, to the
   caller.  A piece of string that convert_to_utf8() cannot handle
   can be treated the same way.

 - handle_commit_msg() doesn't cope with a malformed line well, so
   die there for now.  We'll lift this even higher in later changes
   in this series.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
2015-10-21 15:59:34 -07:00
Junio C Hamano c6905e45f0 mailinfo: libify
Move the bulk of the code from builtin/mailinfo.c to mailinfo.c
so that new callers can start calling mailinfo() directly.

Note that a few calls to exit() and die() need to be cleaned up
for the API to be truly useful, which will come in later steps.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
2015-10-21 15:59:34 -07:00
Junio C Hamano 05e625e5bf mailinfo: keep the parsed log message in a strbuf
When mailinfo() is eventually libified, the calling "git am" still
will have to write out the log message in the "msg" file for hooks
and other users of the information, but it does not have to reopen
and reread what it wrote earlier if the function kept it in a strbuf.

This also removes the need for seeking and truncating the output
file when we see a scissors mark in the input, which in turn allows
us to lose two callsites of die_errno().

Signed-off-by: Junio C Hamano <gitster@pobox.com>
2015-10-21 15:57:17 -07:00
Junio C Hamano 4933910ab7 mailinfo: handle_commit_msg() shouldn't be called after finding patchbreak
There is a strange "if (!mi->cmitmsg) return 0" at the very beginning
of handle_commit_msg(), but the condition should never trigger, because:

 * The only place cmitmsg is set to NULL is after this function sees
   a patch break, closes the FILE * to write the commit log message
   and returns 1.  This function returns non-zero only from that
   codepath.

 * The caller of this function, upon seeing a non-zero return,
   increments filter_stage, starts treating the input as patch text
   and will never call handle_commit_msg() again.

Replace it with an assert(!mi->filter_stage) to ensure the above
observation will stay to be true.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
2015-10-21 15:57:17 -07:00
Junio C Hamano 8e919277e0 mailinfo: move content/content_top to struct mailinfo
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2015-10-21 15:57:17 -07:00
Junio C Hamano d895bf0f57 mailinfo: move [ps]_hdr_data to struct mailinfo
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2015-10-21 15:56:17 -07:00
Junio C Hamano 8f63588a6e mailinfo: move cmitmsg and patchfile to struct mailinfo
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2015-10-21 15:55:01 -07:00
Junio C Hamano f1e037b9af mailinfo: move charset to struct mailinfo
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2015-10-21 15:55:01 -07:00
Junio C Hamano ab50e38b5d mailinfo: move transfer_encoding to struct mailinfo
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2015-10-21 15:53:25 -07:00
Junio C Hamano 28c6bfe94c mailinfo: move check for metainfo_charset to convert_to_utf8()
All callers of this function refrain from calling it when
mi->metainfo_charset is NULL; move the check to the callee,
as it already has a few conditions at its beginning to turn
it into a no-op.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
2015-10-21 15:50:17 -07:00
Junio C Hamano 28be2d083c mailinfo: move metainfo_charset to struct mailinfo
This requires us to pass the struct down to decode_header() and
convert_to_utf8() callchain.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
2015-10-21 15:50:17 -07:00
Junio C Hamano ad57ef9da9 mailinfo: move use_scissors and use_inbody_headers to struct mailinfo
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2015-10-21 15:42:57 -07:00
Junio C Hamano 6200b751bb mailinfo: move add_message_id and message_id to struct mailinfo
This requires us to pass the structure into check_header() codepath.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
2015-10-21 15:42:57 -07:00
Junio C Hamano 43550efa71 mailinfo: move patch_lines to struct mailinfo
This one is trivial thanks to previous steps that started passing
the structure throughout the input codepaths.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
2015-10-21 15:39:01 -07:00
Junio C Hamano 13c6df2642 mailinfo: move filter/header stage to struct mailinfo
Earlier we got rid of two function-scope static variables that kept
track of the states of helper functions by making them extra arguments
that are passed throughout the callchain.  Now we have a convenient
place to store and pass them around in the form of "struct mailinfo",
change them into two fields in the struct.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
2015-10-21 15:39:01 -07:00
Junio C Hamano 173aef7c2e mailinfo: move global "FILE *fin, *fout" to struct mailinfo
This requires us to pass "struct mailinfo" to more functions
throughout the codepath that read input lines.  Incidentally,
later steps are helped by this patch passing the struct to
more callchains.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
2015-10-21 15:39:01 -07:00
Junio C Hamano 849106d511 mailinfo: move keep_subject & keep_non_patch_bracket to struct mailinfo
These two are the only easy ones that do not require passing the
structure around to deep corners of the callchain.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
2015-10-21 15:37:53 -07:00
Junio C Hamano c69f2395ba mailinfo: introduce "struct mailinfo" to hold globals
In this first step, move only 'email' and 'name' fields in there and
remove the corresponding globals.  In subsequent patches, more
globals will be moved to this and the structure will be passed
around as a new parameter to more functions.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
2015-10-21 15:37:52 -07:00
Junio C Hamano 6e21b5089f mailinfo: move global "line" into mailinfo() function
With the previous steps, it becomes clear that the mailinfo()
function is the only one that wants the "line" to be directly
touchable.  Move it to the function scope of this function.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
2015-10-21 15:37:52 -07:00
Junio C Hamano fbbcafd060 mailinfo: do not let find_boundary() touch global "line" directly
With the previous two commits, we established that the local
variable "line" in handle_body() and handle_boundary() functions
always refer to the global "line" that is used as the common and
shared "current line from the input".  They are the only callers of
the last function that refers to the global line directly, i.e.
find_boundary().  Pass "line" as a parameter to this leaf function
to complete the clean-up.  Now the only function that directly refers
to the global "line" is the caller of handle_body() at the very
beginning of this whole callchain.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
2015-10-21 15:37:50 -07:00
Junio C Hamano 69e24defd6 mailinfo: do not let handle_boundary() touch global "line" directly
This function has a single caller, and called with the global "line"
holding the multi-part boundary line the caller saw while processing
the e-mail body.  The function then goes into a loop to process each
line of the input, and fills the same global "line" variable from
the input as it needs to read more lines to process the multi-part
headers.

Let the caller explicitly pass a pointer to this global "line"
variable as an argument, and have the function itself use that
strbuf throughout, instead of referring to the global "line" itself.

There still is a helper function that this function calls that still
touches the global directly; it will be updated as the series progresses.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
2015-10-21 15:36:37 -07:00
Junio C Hamano fde00d50f6 mailinfo: do not let handle_body() touch global "line" directly
This function has a single caller, and called with the global "line"
holding the first line of the e-mail body after the caller finished
processing the e-mail headers.  The function then goes into a loop
to process each line of the input, starting from what was given by
its caller, and fills the same global "line" variable from the input
as it needs to process more lines.

Let the caller explicitly pass a pointer to this global "line"
variable as an argument, and have the function itself use that
strbuf throughout, instead of referring to the global "line" itself.

There are helper functions that this function calls that still touch
the global directly; they will be updated as the series progresses.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
2015-10-21 15:36:37 -07:00
Junio C Hamano 269e239c48 mailinfo: get rid of function-local static states
Two helper functions use "static int" in their scope to keep track
of the state while repeatedly getting called once for each input
line.  Move these state variables to their ultimate caller and pass
down pointers to them along the callchain, as a small step in
preparation for making this entire callchain more reentrant.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
2015-10-21 15:36:37 -07:00
Junio C Hamano c1b40bd7b6 mailinfo: move definition of MAX_HDR_PARSED closer to its use
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2015-10-21 15:34:49 -07:00
Junio C Hamano 30f50c3426 mailinfo: move cleanup_space() before its users
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2015-10-21 15:33:39 -07:00
Junio C Hamano 4f0f9d46c7 mailinfo: move check_header() after the helpers it uses
This way, we can lose a forward decl for decode_header().

Signed-off-by: Junio C Hamano <gitster@pobox.com>
2015-10-21 15:32:43 -07:00
Junio C Hamano 9cc243f7a9 mailinfo: move read_one_header_line() closer to its callers
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2015-10-21 15:30:15 -07:00
Junio C Hamano 39afcd3819 mailinfo: move handle_boundary() lower
This function wants to call find_boundary() and is called only from
one place without any recursing, so it becomes easier to read if it
appears after the called function.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
2015-10-21 15:20:49 -07:00
Junio C Hamano 12d19e80b0 mailinfo: plug strbuf leak during continuation line handling
Whether this loop is left via EOF/break or upon finding a
non-continuation line, the storage used for the contination line
handling is left behind.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
2015-10-21 15:18:50 -07:00
David Turner 41284eb0f9 name-hash: don't reuse cache_entry in dir_entry
Stop reusing cache_entry in dir_entry; doing so causes a
use-after-free bug.

During merges, we free entries that we no longer need in the
destination index.  But those entries might have also been stored in
the dir_entry cache, and when a later call to add_to_index found them,
they would be used after being freed.

To prevent this, change dir_entry to store a copy of the name instead
of a pointer to a cache_entry.  This entails some refactoring of code
that expects the cache_entry.

Keith McGuigan <kmcguigan@twitter.com> diagnosed this bug and wrote
the initial patch, but this version does not use any of Keith's code.

Helped-by: Keith McGuigan <kmcguigan@twitter.com>
Helped-by: Junio C Hamano <gitster@pobox.com>
Signed-off-by: David Turner <dturner@twopensource.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2015-10-21 12:47:38 -07:00
Remi Pommarel 7e91e8d73a configure.ac: detect ssl need with libcurl
When libcurl has been statically compiled with openssl support they both
need to be linked in everytime libcurl is used.

During configuration this can be detected by looking for Curl_ssl_init
function symbol in libcurl, which will only be present if libcurl has been
compiled statically built with openssl.

configure.ac checks for Curl_ssl_init function in libcurl and if such function
exists; it sets NEEDS_SSL_WITH_CURL that is used by the Makefile to include
-lssl alongside with -lcurl.

Signed-off-by: Remi Pommarel <repk@triplefau.lt>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2015-10-21 12:44:44 -07:00
Remi Pommarel f89158760d Makefile: make curl-config path configurable
There are situations, e.g. during cross compilation, where curl-config
program is not present in the PATH.

Make the makefile use a configurable curl-config program passed through
CURL_CONFIG variable which can be set through config.mak.

Also make this variable tunable through use of autoconf/configure. Configure
will set CURL_CONFIG variable in config.mak.autogen to whatever value has been
passed to ac_cv_prog_CURL_CONFIG.

Signed-off-by: Remi Pommarel <repk@triplefau.lt>
Reviewed-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2015-10-21 12:43:31 -07:00
Remi Pommarel 9eaa78b0b0 Makefile: link libcurl before zlib
For static linking especially library order while linking is important. For
example, libcurl wants symbols from zlib when building http-push, http-fetch
and remote-curl. So for these programs libcurl has to be linked before zlib.

Signed-off-by: Remi Pommarel <repk@triplefau.lt>
Reviewed-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2015-10-21 12:43:03 -07:00
Junio C Hamano 74301d6ede Sync with maint
* maint:
2015-10-20 15:29:57 -07:00
Junio C Hamano bca92e88e7 Sixth batch for 2.7
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2015-10-20 15:29:50 -07:00
Junio C Hamano f0d2f73866 Merge branch 'tb/t0027-crlf'
The test for various line-ending conversions has been enhanced.

* tb/t0027-crlf:
  t0027: improve test for not-normalized files
2015-10-20 15:26:18 -07:00
Junio C Hamano d94447d3b6 Merge branch 'ls/p4-test-updates'
A few test scripts around "git p4" have been improved for
portability.

* ls/p4-test-updates:
  git-p4: skip t9819 test case on case insensitive file systems
  git-p4: avoid "stat" command in t9815 git-p4-submit-fail
2015-10-20 15:26:09 -07:00
Junio C Hamano 78891795df Merge branch 'jk/war-on-sprintf'
Many allocations that is manually counted (correctly) that are
followed by strcpy/sprintf have been replaced with a less error
prone constructs such as xstrfmt.

Macintosh-specific breakage was noticed and corrected in this
reroll.

* jk/war-on-sprintf: (70 commits)
  name-rev: use strip_suffix to avoid magic numbers
  use strbuf_complete to conditionally append slash
  fsck: use for_each_loose_file_in_objdir
  Makefile: drop D_INO_IN_DIRENT build knob
  fsck: drop inode-sorting code
  convert strncpy to memcpy
  notes: document length of fanout path with a constant
  color: add color_set helper for copying raw colors
  prefer memcpy to strcpy
  help: clean up kfmclient munging
  receive-pack: simplify keep_arg computation
  avoid sprintf and strcpy with flex arrays
  use alloc_ref rather than hand-allocating "struct ref"
  color: add overflow checks for parsing colors
  drop strcpy in favor of raw sha1_to_hex
  use sha1_to_hex_r() instead of strcpy
  daemon: use cld->env_array when re-spawning
  stat_tracking_info: convert to argv_array
  http-push: use an argv_array for setup_revisions
  fetch-pack: use argv_array for index-pack / unpack-objects
  ...
2015-10-20 15:24:01 -07:00
Junio C Hamano b05c2f9ed4 Merge branch 'js/gc-with-stale-symref' into maint
"git gc" used to barf when a symbolic ref has gone dangling
(e.g. the branch that used to be your upstream's default when you
cloned from it is now gone, and you did "fetch --prune").

* js/gc-with-stale-symref:
  pack-objects: do not get distracted by broken symrefs
  gc: demonstrate failure with stale remote HEAD
2015-10-20 15:22:42 -07:00
Junio C Hamano 3b7c49e9a3 Merge branch 'rd/test-path-utils' into maint
The normalize_ceiling_entry() function does not muck with the end
of the path it accepts, and the real world callers do rely on that,
but a test insisted that the function drops a trailing slash.

* rd/test-path-utils:
  test-path-utils.c: remove incorrect assumption
2015-10-20 15:22:41 -07:00
Junio C Hamano ce555f3842 Merge branch 'jc/doc-gc-prune-now' into maint
"git gc" is safe to run anytime only because it has the built-in
grace period to protect young objects.  In order to run with no
grace period, the user must make sure that the repository is
quiescent.

* jc/doc-gc-prune-now:
  Documentation/gc: warn against --prune=<now>
2015-10-20 15:22:40 -07:00
Junio C Hamano 44a9b53c59 Merge branch 'jk/filter-branch-use-of-sed-on-incomplete-line' into maint
A recent "filter-branch --msg-filter" broke skipping of the commit
object header, which is fixed.

* jk/filter-branch-use-of-sed-on-incomplete-line:
  filter-branch: remove multi-line headers in msg filter
2015-10-20 15:22:39 -07:00
Dennis Kaarsemaker 4b07cd230a git-p4: import the ctypes module
The ctypes module is used on windows to calculate free disk space,
so it must be imported.  We won't need it on other platforms, but
the module is available in Python 2.5 and newer, so importing it
unconditionally is harmless.

Signed-off-by: Dennis Kaarsemaker <dennis@kaarsemaker.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2015-10-20 12:55:22 -07:00
David Turner 9b680fbd3b t7063: fix flaky untracked-cache test
Dirty the test worktree's root directory, as the test expects.

When testing the untracked-cache, we previously assumed that checking
out master would be sufficient to mark the mtime of the worktree's
root directory as racily-dirty.  But sometimes, the checkout would
happen at 12345.999 seconds and the status at 12346.001 seconds,
meaning that the worktree's root directory would not be racily-dirty.
And since it was not truly dirty, occasionally the test would fail.
By making the root truly dirty, the test will always succeed.

Tested by running a few hundred times.

Signed-off-by: David Turner <dturner@twopensource.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2015-10-19 18:32:28 -07:00
Junio C Hamano 614a2aced1 Sync with maint for Russian translation
* maint:
  l10n: ru.po: update Russian translation
2015-10-18 23:39:20 -07:00
Junio C Hamano 1b5ffa36cb Merge branch 'maint' of git://github.com/git-l10n/git-po into maint
* 'maint' of git://github.com/git-l10n/git-po:
  l10n: ru.po: update Russian translation
2015-10-18 23:37:35 -07:00
Sidhant Sharma ae9f2745be worktree: usage: denote <branch> as optional with 'add'
Although 1eb07d8 (worktree: add: auto-vivify new branch when
<branch> is omitted, 2015-07-06) updated the documentation when
<branch> became optional, it neglected to update the in-code
usage message. Fix this oversight.

Reported-by: ch3cooli@gmail.com
Signed-off-by: Sidhant Sharma <tigerkid001@gmail.com>
Helped-by: Eric Sunshine <sunshine@sunshineco.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2015-10-18 23:35:58 -07:00