summaryrefslogtreecommitdiff
path: root/builtin
Commit message (Collapse)AuthorAgeFilesLines
* mailinfo: libifyJunio C Hamano2015-10-211-1048/+1
| | | | | | | | | | 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>
* mailinfo: keep the parsed log message in a strbufJunio C Hamano2015-10-211-12/+16
| | | | | | | | | | | | | 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>
* mailinfo: handle_commit_msg() shouldn't be called after finding patchbreakJunio C Hamano2015-10-211-2/+1
| | | | | | | | | | | | | | | | | | | 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>
* mailinfo: move content/content_top to struct mailinfoJunio C Hamano2015-10-211-20/+26
| | | | Signed-off-by: Junio C Hamano <gitster@pobox.com>
* mailinfo: move [ps]_hdr_data to struct mailinfoJunio C Hamano2015-10-211-14/+23
| | | | Signed-off-by: Junio C Hamano <gitster@pobox.com>
* mailinfo: move cmitmsg and patchfile to struct mailinfoJunio C Hamano2015-10-211-16/+16
| | | | Signed-off-by: Junio C Hamano <gitster@pobox.com>
* mailinfo: move charset to struct mailinfoJunio C Hamano2015-10-211-7/+8
| | | | Signed-off-by: Junio C Hamano <gitster@pobox.com>
* mailinfo: move transfer_encoding to struct mailinfoJunio C Hamano2015-10-211-13/+14
| | | | Signed-off-by: Junio C Hamano <gitster@pobox.com>
* mailinfo: move check for metainfo_charset to convert_to_utf8()Junio C Hamano2015-10-211-5/+3
| | | | | | | | | 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>
* mailinfo: move metainfo_charset to struct mailinfoJunio C Hamano2015-10-211-19/+19
| | | | | | | 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>
* mailinfo: move use_scissors and use_inbody_headers to struct mailinfoJunio C Hamano2015-10-211-10/+13
| | | | Signed-off-by: Junio C Hamano <gitster@pobox.com>
* mailinfo: move add_message_id and message_id to struct mailinfoJunio C Hamano2015-10-211-14/+17
| | | | | | This requires us to pass the structure into check_header() codepath. Signed-off-by: Junio C Hamano <gitster@pobox.com>
* mailinfo: move patch_lines to struct mailinfoJunio C Hamano2015-10-211-5/+5
| | | | | | | 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>
* mailinfo: move filter/header stage to struct mailinfoJunio C Hamano2015-10-211-20/+21
| | | | | | | | | | 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>
* mailinfo: move global "FILE *fin, *fout" to struct mailinfoJunio C Hamano2015-10-211-26/+28
| | | | | | | | | 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>
* mailinfo: move keep_subject & keep_non_patch_bracket to struct mailinfoJunio C Hamano2015-10-211-8/+8
| | | | | | | 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>
* mailinfo: introduce "struct mailinfo" to hold globalsJunio C Hamano2015-10-211-24/+47
| | | | | | | | | 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>
* mailinfo: move global "line" into mailinfo() functionJunio C Hamano2015-10-211-2/+3
| | | | | | | | 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>
* mailinfo: do not let find_boundary() touch global "line" directlyJunio C Hamano2015-10-211-5/+5
| | | | | | | | | | | | | | 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>
* mailinfo: do not let handle_boundary() touch global "line" directlyJunio C Hamano2015-10-211-8/+8
| | | | | | | | | | | | | | | | | | 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>
* mailinfo: do not let handle_body() touch global "line" directlyJunio C Hamano2015-10-211-8/+8
| | | | | | | | | | | | | | | | | | 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>
* mailinfo: get rid of function-local static statesJunio C Hamano2015-10-211-22/+19
| | | | | | | | | | 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>
* mailinfo: move definition of MAX_HDR_PARSED closer to its useJunio C Hamano2015-10-211-1/+1
| | | | Signed-off-by: Junio C Hamano <gitster@pobox.com>
* mailinfo: move cleanup_space() before its usersJunio C Hamano2015-10-211-14/+11
| | | | Signed-off-by: Junio C Hamano <gitster@pobox.com>
* mailinfo: move check_header() after the helpers it usesJunio C Hamano2015-10-211-68/+67
| | | | | | This way, we can lose a forward decl for decode_header(). Signed-off-by: Junio C Hamano <gitster@pobox.com>
* mailinfo: move read_one_header_line() closer to its callersJunio C Hamano2015-10-211-68/+68
| | | | Signed-off-by: Junio C Hamano <gitster@pobox.com>
* mailinfo: move handle_boundary() lowerJunio C Hamano2015-10-211-58/+56
| | | | | | | | 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>
* mailinfo: plug strbuf leak during continuation line handlingJunio C Hamano2015-10-211-1/+3
| | | | | | | | 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>
* mailinfo: explicitly close file handle to the patch outputJunio C Hamano2015-10-181-0/+2
| | | | | | | | | | | This does not make a difference within the context of "git mailinfo" that runs once and exits, as flushing and closing would happen upon process termination. It however will matter when we eventually make it callable as an API function. Besides, cleaning after yourself once you are done is a good hygiene. Signed-off-by: Junio C Hamano <gitster@pobox.com>
* mailinfo: fix an off-by-one error in the boundary stackJunio C Hamano2015-10-181-1/+1
| | | | | | | | We pre-increment the pointer that we will use to store something at, so the pointer is already beyond the end of the array if it points at content[MAX_BOUNDARIES]. Signed-off-by: Junio C Hamano <gitster@pobox.com>
* mailinfo: fold decode_header_bq() into decode_header()Junio C Hamano2015-10-181-16/+7
| | | | | | | | | In olden days we might have wanted to behave differently in decode_header() if the header line was encoded with RFC2047, but we apparently do not do so, hence this helper function can go, together with its return value. Signed-off-by: Junio C Hamano <gitster@pobox.com>
* mailinfo: remove a no-op call convert_to_utf8(it, "")Junio C Hamano2015-10-181-5/+0
| | | | | | | | The called function checks if the second parameter is either a NULL or an empty string at the very beginning and returns without doing anything. Remove the useless call. Signed-off-by: Junio C Hamano <gitster@pobox.com>
* Sync with v2.5.4Junio C Hamano2015-09-284-8/+17
|\
| * Sync with 2.4.10Junio C Hamano2015-09-284-8/+17
| |\
| | * Sync with 2.3.10Junio C Hamano2015-09-284-8/+17
| | |\
| | | * merge-file: enforce MAX_XDIFF_SIZE on incoming filesJeff King2015-09-281-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The previous commit enforces MAX_XDIFF_SIZE at the interfaces to xdiff: xdi_diff (which calls xdl_diff) and ll_xdl_merge (which calls xdl_merge). But we have another direct call to xdl_merge in merge-file.c. If it were written today, this probably would just use the ll_merge machinery. But it predates that code, and uses slightly different options to xdl_merge (e.g., ZEALOUS_ALNUM). We could try to abstract out an xdi_merge to match the existing xdi_diff, but even that is difficult. Rather than simply report error, we try to treat large files as binary, and that distinction would happen outside of xdi_merge. The simplest fix is to just replicate the MAX_XDIFF_SIZE check in merge-file.c. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
| | | * react to errors in xdi_diffJeff King2015-09-283-7/+15
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When we call into xdiff to perform a diff, we generally lose the return code completely. Typically by ignoring the return of our xdi_diff wrapper, but sometimes we even propagate that return value up and then ignore it later. This can lead to us silently producing incorrect diffs (e.g., "git log" might produce no output at all, not even a diff header, for a content-level diff). In practice this does not happen very often, because the typical reason for xdiff to report failure is that it malloc() failed (it uses straight malloc, and not our xmalloc wrapper). But it could also happen when xdiff triggers one our callbacks, which returns an error (e.g., outf() in builtin/rerere.c tries to report a write failure in this way). And the next patch also plans to add more failure modes. Let's notice an error return from xdiff and react appropriately. In most of the diff.c code, we can simply die(), which matches the surrounding code (e.g., that is what we do if we fail to load a file for diffing in the first place). This is not that elegant, but we are probably better off dying to let the user know there was a problem, rather than simply generating bogus output. We could also just die() directly in xdi_diff, but the callers typically have a bit more context, and can provide a better message (and if we do later decide to pass errors up, we're one step closer to doing so). There is one interesting case, which is in diff_grep(). Here if we cannot generate the diff, there is nothing to match, and we silently return "no hits". This is actually what the existing code does already, but we make it a little more explicit. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* | | | Merge branch 'ah/show-ref-usage-string'Junio C Hamano2015-09-141-1/+1
|\ \ \ \ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Both "git show-ref -h" and "git show-ref --help" illustrated that the "--exclude-existing" option makes the command read list of refs from its standard input. Change only the "show-ref -h" output to have a pair of "<>" around the placeholder that designate an input file, i.e. "git show-ref --exclude-existing < <ref-list>". * ah/show-ref-usage-string: show-ref: place angle brackets around variables in usage string
| * | | | show-ref: place angle brackets around variables in usage stringah/show-ref-usage-stringAlex Henrie2015-08-311-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | Signed-off-by: Alex Henrie <alexhenrie24@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* | | | | Merge branch 'rt/help-strings-fix'Junio C Hamano2015-09-143-3/+3
|\ \ \ \ \ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * rt/help-strings-fix: tag, update-ref: improve description of option "create-reflog" pull: don't mark values for option "rebase" for translation
| * | | | | tag, update-ref: improve description of option "create-reflog"rt/help-strings-fixRalf Thielow2015-09-112-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The description of option "create-reflog" is "create_reflog", which is neither a good description, nor a sensible string to translate. Change it to a more meaningful message. Signed-off-by: Ralf Thielow <ralf.thielow@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
| * | | | | pull: don't mark values for option "rebase" for translationRalf Thielow2015-09-111-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | "false|true|preserve" are actual values for option "rebase" of the "git-pull" command and should therefore not be marked for translation. Signed-off-by: Ralf Thielow <ralf.thielow@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* | | | | | Merge branch 'gb/apply-comment-typofix'Junio C Hamano2015-09-141-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * gb/apply-comment-typofix: apply: comment grammar fix
* | | | | | Sync with 2.5.2Junio C Hamano2015-09-091-2/+4
|\ \ \ \ \ \ | |/ / / / / |/| | / / / | | |/ / / | |/| | |
| * | | | Sync with 2.4.9Junio C Hamano2015-09-041-2/+4
| |\ \ \ \ | | | |/ / | | |/| |
| | * | | Sync with 2.3.9Junio C Hamano2015-09-041-2/+4
| | |\ \ \ | | | | |/ | | | |/|
| | | * | Sync with 2.2.3Junio C Hamano2015-09-041-2/+4
| | | |\ \
| | | | * | show-branch: use a strbuf for reflog descriptionsJeff King2015-09-041-2/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When we show "branch@{0}", we format into a fixed-size buffer using sprintf. This can overflow if you have long branch names. We can fix it by using a temporary strbuf. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
| * | | | | Merge branch ↵Junio C Hamano2015-09-031-3/+1
| |\ \ \ \ \ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 'dt/commit-preserve-base-index-upon-opportunistic-cache-tree-update' into maint When re-priming the cache-tree opportunistically while committing the in-core index as-is, we mistakenly invalidated the in-core index too aggressively, causing the experimental split-index code to unnecessarily rewrite the on-disk index file(s). * dt/commit-preserve-base-index-upon-opportunistic-cache-tree-update: commit: don't rewrite shared index unnecessarily
| * \ \ \ \ \ Merge branch 'jc/calloc-pathspec' into maintJunio C Hamano2015-09-032-2/+2
| |\ \ \ \ \ \ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Minor code cleanup. * jc/calloc-pathspec: ps_matched: xcalloc() takes nmemb and then element size