Commit graph

4281 commits

Author SHA1 Message Date
Junio C Hamano 654b986dec Merge branch 'rs/show-branch-argv-array'
Code simplification.

* rs/show-branch-argv-array:
  show-branch: use argv_array for default arguments
2015-11-03 15:13:07 -08:00
René Scharfe c949b00fb8 show-branch: use argv_array for default arguments
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-11-01 10:24:29 -08:00
Junio C Hamano 54bc41416c Merge branch 'jk/merge-file-exit-code'
"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-30 13:07:08 -07:00
Junio C Hamano 0692a6c22c Merge branch 'rs/pop-commit'
Code simplification.

* rs/pop-commit:
  use pop_commit() for consuming the first entry of a struct commit_list
2015-10-30 13:07:03 -07:00
Junio C Hamano 23d58a00e5 Merge branch 'mk/blame-error-message'
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-30 13:07:02 -07:00
Junio C Hamano 808d119263 Merge branch 'js/misc-fixes'
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-30 13:07:00 -07:00
Junio C Hamano f7722a447a Merge branch 'jc/add-u-A-default-to-top'
"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-30 13:06:55 -07:00
Junio C Hamano 908700c008 Merge branch 'ar/clone-dissociate'
"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-30 13:06:53 -07:00
Junio C Hamano 95b86a60cf Merge branch 'jc/am-mailinfo-direct'
"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-29 13:59:23 -07:00
Junio C Hamano ba5312da19 Merge branch 'jc/mailinfo-lib'
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-29 13:59:22 -07:00
Jeff King e34f80278e merge-file: clamp exit code to maximum 127
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-29 12:10:23 -07:00
Junio C Hamano fa46579555 Merge branch 'jk/repository-extension'
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-26 15:55:25 -07:00
Junio C Hamano 2be421dbb6 Merge branch 'kn/for-each-tag'
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-26 15:55:22 -07:00
Junio C Hamano 522e2f4515 Merge branch 'es/worktree-add'
* es/worktree-add:
  worktree: usage: denote <branch> as optional with 'add'
2015-10-26 15:55:21 -07:00
Junio C Hamano 1ad7c0f689 Merge branch 'tk/stripspace'
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-26 15:55:20 -07:00
Junio C Hamano 0884726b43 Merge branch 'rt/placeholder-in-usage'
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-26 15:55:18 -07:00
Junio C Hamano 97a9e546a2 Merge branch 'jc/usage-stdin'
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-26 15:55:17 -07:00
Junio C Hamano a46dcfb840 Merge branch 'mr/worktree-list'
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-26 15:55:16 -07:00
Junio C Hamano 9c53de7de1 Merge branch 'jc/am-3-fallback-regression-fix'
"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-26 15:55:15 -07:00
René Scharfe e510ab8988 use pop_commit() for consuming the first entry of a struct commit_list
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-26 14:06:46 -07:00
Waldek Maleska fdcdb77855 Correct fscanf formatting string for I64u values
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-26 13:24:03 -07:00
Max Kirillov 95261974bb blame: fix option name in error message
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-26 13:08:21 -07:00
Junio C Hamano 29abb33978 add: simplify -u/-A without pathspec
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-24 19:32:47 -07:00
Alex Riesen 0181681e92 clone: allow "--dissociate" without reference
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-22 12:13:29 -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 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