summaryrefslogtreecommitdiff
path: root/builtin
AgeCommit message (Collapse)Author
2015-11-03Merge branch 'rs/show-branch-argv-array'Junio C Hamano
Code simplification. * rs/show-branch-argv-array: show-branch: use argv_array for default arguments
2015-11-01show-branch: use argv_array for default argumentsRené Scharfe
Use argv_array instead of open-coding it. Signed-off-by: Rene Scharfe <l.s.r@web.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2015-10-30Merge branch 'jk/merge-file-exit-code'Junio C Hamano
"git merge-file" tried to signal how many conflicts it found, which obviously would not work well when there are too many of them. * jk/merge-file-exit-code: merge-file: clamp exit code to maximum 127
2015-10-30Merge branch 'rs/pop-commit'Junio C Hamano
Code simplification. * rs/pop-commit: use pop_commit() for consuming the first entry of a struct commit_list
2015-10-30Merge branch 'mk/blame-error-message'Junio C Hamano
The error message from "git blame --contents --reverse" incorrectly talked about "--contents --children". * mk/blame-error-message: blame: fix option name in error message
2015-10-30Merge branch 'js/misc-fixes'Junio C Hamano
Various compilation fixes and squelching of warnings. * js/misc-fixes: Correct fscanf formatting string for I64u values Silence GCC's "cast of pointer to integer of a different size" warning Squelch warning about an integer overflow
2015-10-30Merge branch 'jc/add-u-A-default-to-top'Junio C Hamano
"git --literal-pathspecs add -u/-A" without any command line argument misbehaved ever since Git 2.0. * jc/add-u-A-default-to-top: add: simplify -u/-A without pathspec
2015-10-30Merge branch 'ar/clone-dissociate'Junio C Hamano
"git clone --dissociate" used to require that "--reference" was used at the same time, but you can create a new repository that borrows objects from another without using "--reference", namely with "clone --local" from a repository that borrows objects from other repositories. * ar/clone-dissociate: clone: allow "--dissociate" without reference
2015-10-29Merge branch 'jc/am-mailinfo-direct'Junio C Hamano
"git am" used to spawn "git mailinfo" via run_command() API once per each patch, but learned to make a direct call to mailinfo() instead. * jc/am-mailinfo-direct: am: make direct call to mailinfo
2015-10-29Merge branch 'jc/mailinfo-lib'Junio C Hamano
The implementation of "git mailinfo" was refactored so that a mailinfo() function can be directly called from inside a process. * jc/mailinfo-lib: (34 commits) mailinfo: remove calls to exit() and die() deep in the callchain mailinfo: handle charset conversion errors in the caller mailinfo: libify mailinfo: keep the parsed log message in a strbuf mailinfo: handle_commit_msg() shouldn't be called after finding patchbreak mailinfo: move content/content_top to struct mailinfo mailinfo: move [ps]_hdr_data to struct mailinfo mailinfo: move cmitmsg and patchfile to struct mailinfo mailinfo: move charset to struct mailinfo mailinfo: move transfer_encoding to struct mailinfo mailinfo: move check for metainfo_charset to convert_to_utf8() mailinfo: move metainfo_charset to struct mailinfo mailinfo: move use_scissors and use_inbody_headers to struct mailinfo mailinfo: move add_message_id and message_id to struct mailinfo mailinfo: move patch_lines to struct mailinfo mailinfo: move filter/header stage to struct mailinfo mailinfo: move global "FILE *fin, *fout" to struct mailinfo mailinfo: move keep_subject & keep_non_patch_bracket to struct mailinfo mailinfo: introduce "struct mailinfo" to hold globals mailinfo: move global "line" into mailinfo() function ...
2015-10-29merge-file: clamp exit code to maximum 127Jeff King
Git-merge-file is documented to return one of three exit codes: - zero means the merge was successful - a negative number means an error occurred - a positive number indicates the number of conflicts Unfortunately, this all gets stuffed into an 8-bit return code. Which means that if you have 256 conflicts, this wraps to zero, and the merge appears to succeed (and commits a blob full of conflict-marker cruft!). This patch clamps the return value to a maximum of 127, which we should be able to safely represent everywhere. This also leaves 128-255 for other values. Shells (and some parts of git) will typically represent signal death as 128 plus the signal number. And negative values are typically coerced to an 8-bit unsigned value (so "return -1" ends up as 255). Technically negative returns have the same problem (e.g., "-256" wraps back to 0), but this is not a problem in practice, as the only negative value we use is "-1". Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2015-10-26Merge branch 'jk/repository-extension'Junio C Hamano
Prepare for Git on-disk repository representation to undergo backward incompatible changes by introducing a new repository format version "1", with an extension mechanism. * jk/repository-extension: introduce "preciousObjects" repository extension introduce "extensions" form of core.repositoryformatversion
2015-10-26Merge branch 'kn/for-each-tag'Junio C Hamano
Recent update to "git tag --contains" caused a performance regression. * kn/for-each-tag: tag.c: use the correct algorithm for the '--contains' option
2015-10-26Merge branch 'es/worktree-add'Junio C Hamano
* es/worktree-add: worktree: usage: denote <branch> as optional with 'add'
2015-10-26Merge branch 'tk/stripspace'Junio C Hamano
The internal stripspace() function has been moved to where it logically belongs to, i.e. strbuf API, and the command line parser of "git stripspace" has been updated to use the parse_options API. * tk/stripspace: stripspace: use parse-options for command-line parsing strbuf: make stripspace() part of strbuf
2015-10-26Merge branch 'rt/placeholder-in-usage'Junio C Hamano
A couple of commands still showed "[options]" in their usage string to note where options should come on their command line, but we spell that "[<options>]" in most places these days. * rt/placeholder-in-usage: am, credential-cache: add angle brackets to usage string
2015-10-26Merge branch 'jc/usage-stdin'Junio C Hamano
The synopsis text and the usage string of subcommands that read list of things from the standard input are often shown as if they only take input from a file on a filesystem, which was misleading. * jc/usage-stdin: usage: do not insist that standard input must come from a file
2015-10-26Merge branch 'mr/worktree-list'Junio C Hamano
Add the "list" subcommand to "git worktree". * mr/worktree-list: worktree: add 'list' command worktree: add details to the worktree struct worktree: add a function to get worktree details worktree: refactor find_linked_symref function worktree: add top-level worktree.c
2015-10-26Merge branch 'jc/am-3-fallback-regression-fix'Junio C Hamano
"git am -3" had a small regression where it is aborted in its error handling codepath when underlying merge-recursive failed in certain ways, as it assumed that the internal call to merge-recursive will never die, which is not the case (yet). * jc/am-3-fallback-regression-fix: am -3: do not let failed merge from completing the error codepath
2015-10-26use pop_commit() for consuming the first entry of a struct commit_listRené Scharfe
Instead of open-coding the function pop_commit() just call it. This makes the intent clearer and reduces code size. Signed-off-by: Rene Scharfe <l.s.r@web.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2015-10-26Correct fscanf formatting string for I64u valuesWaldek Maleska
This fix is probably purely cosmetic because PRIuMAX is likely identical to SCNuMAX. Nevertheless, when using a function of the scanf() family, the correct interpolation to use is the latter, not the former. Signed-off-by: Waldek Maleska <w.maleska@gmail.com> Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2015-10-26blame: fix option name in error messageMax Kirillov
The option name used in blame's UI is `--reverse`. Signed-off-by: Max Kirillov <max@max630.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2015-10-25add: simplify -u/-A without pathspecJunio C Hamano
Since Git 2.0, "add -u" and "add -A" run from a subdirectory without any pathspec mean "everything in the working tree" (before 2.0, they were limited to the current directory). The limiting to the current directory was implemented by inserting "." to the command line when the end user did not give us any pathspec. At 2.0, we updated the code to insert ":/" (instead of '.') to consider everything from the top-level, by using a pathspec magic "top". The call to parse_pathspec() using the command line arguments is, however, made with PATHSPEC_PREFER_FULL option since 5a76aff1 (add: convert to use parse_pathspec, 2013-07-14), which predates Git 2.0. In retrospect, there was no need to turn "adding . to limit to the directory" into "adding :/ to unlimit to everywhere" in Git 2.0; instead we could just have done "if there is no pathspec on the command line, just let it be". The parse_pathspec() then would give us a pathspec that matches everything and all is well. Incidentally such a simplification also fixes a corner case bug that stems from the fact that ":/" does not necessarily mean any magic. A user would say "git --literal-pathspecs add -u :/" from the command line when she has a directory ':' and wants to add everything in it (and she knows that her :/ will be taken as 'everything under the sun' magic pathspec unless she disables the magic with --literal-pathspecs). The internal use of ':/' would behave the same way as such an explicitly given ":/" when run with "--literal-pathspecs", and will not add everything under the sun as the code originally intended. Signed-off-by: Junio C Hamano <gitster@pobox.com>
2015-10-22clone: allow "--dissociate" without referenceAlex Riesen
The "--reference" option is not the only way to provide a repository to borrow objects from. A repository that borrows from another repository can be cloned with "clone --local" and the resulting repository will borrow from the same repository, which the user may want to "--dissociate" from. Signed-off-by: Alex Riesen <raa.lkml@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2015-10-21am: make direct call to mailinfoJunio C Hamano
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-21mailinfo: libifyJunio C Hamano
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-21mailinfo: keep the parsed log message in a strbufJunio C Hamano
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-21mailinfo: handle_commit_msg() shouldn't be called after finding patchbreakJunio C Hamano
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-21mailinfo: move content/content_top to struct mailinfoJunio C Hamano
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2015-10-21mailinfo: move [ps]_hdr_data to struct mailinfoJunio C Hamano
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2015-10-21mailinfo: move cmitmsg and patchfile to struct mailinfoJunio C Hamano
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2015-10-21mailinfo: move charset to struct mailinfoJunio C Hamano
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2015-10-21mailinfo: move transfer_encoding to struct mailinfoJunio C Hamano
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2015-10-21mailinfo: move check for metainfo_charset to convert_to_utf8()Junio C Hamano
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-21mailinfo: move metainfo_charset to struct mailinfoJunio C Hamano
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-21mailinfo: move use_scissors and use_inbody_headers to struct mailinfoJunio C Hamano
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2015-10-21mailinfo: move add_message_id and message_id to struct mailinfoJunio C Hamano
This requires us to pass the structure into check_header() codepath. Signed-off-by: Junio C Hamano <gitster@pobox.com>
2015-10-21mailinfo: move patch_lines to struct mailinfoJunio C Hamano
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-21mailinfo: move filter/header stage to struct mailinfoJunio C Hamano
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-21mailinfo: move global "FILE *fin, *fout" to struct mailinfoJunio C Hamano
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-21mailinfo: move keep_subject & keep_non_patch_bracket to struct mailinfoJunio C Hamano
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-21mailinfo: introduce "struct mailinfo" to hold globalsJunio C Hamano
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-21mailinfo: move global "line" into mailinfo() functionJunio C Hamano
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-21mailinfo: do not let find_boundary() touch global "line" directlyJunio C Hamano
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-21mailinfo: do not let handle_boundary() touch global "line" directlyJunio C Hamano
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-21mailinfo: do not let handle_body() touch global "line" directlyJunio C Hamano
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-21mailinfo: get rid of function-local static statesJunio C Hamano
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-21mailinfo: move definition of MAX_HDR_PARSED closer to its useJunio C Hamano
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2015-10-21mailinfo: move cleanup_space() before its usersJunio C Hamano
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2015-10-21mailinfo: move check_header() after the helpers it usesJunio C Hamano
This way, we can lose a forward decl for decode_header(). Signed-off-by: Junio C Hamano <gitster@pobox.com>