Skip to content
Commits on Oct 28, 2014
  1. @gitster

    use child_process_init() to initialize struct child_process variables

    René Scharfe committed with gitster
    Call child_process_init() instead of zeroing the memory of variables of
    type struct child_process by hand before use because the former is both
    clearer and shorter.
    
    Signed-off-by: Rene Scharfe <l.s.r@web.de>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
Commits on Sep 18, 2014
  1. @gitster

    use REALLOC_ARRAY for changing the allocation size of arrays

    René Scharfe committed with gitster
    Signed-off-by: Rene Scharfe <l.s.r@web.de>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
Commits on Aug 20, 2014
  1. @gitster

    run-command: introduce CHILD_PROCESS_INIT

    René Scharfe committed with gitster
    Most struct child_process variables are cleared using memset first after
    declaration.  Provide a macro, CHILD_PROCESS_INIT, that can be used to
    initialize them statically instead.  That's shorter, doesn't require a
    function call and is slightly more readable (especially given that we
    already have STRBUF_INIT, ARGV_ARRAY_INIT etc.).
    
    Helped-by: Johannes Sixt <j6t@kdbg.org>
    Signed-off-by: Rene Scharfe <l.s.r@web.de>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
Commits on Jun 20, 2014
  1. @peff @gitster

    refactor skip_prefix to return a boolean

    peff committed with gitster
    The skip_prefix() function returns a pointer to the content
    past the prefix, or NULL if the prefix was not found. While
    this is nice and simple, in practice it makes it hard to use
    for two reasons:
    
      1. When you want to conditionally skip or keep the string
         as-is, you have to introduce a temporary variable.
         For example:
    
           tmp = skip_prefix(buf, "foo");
           if (tmp)
    	       buf = tmp;
    
      2. It is verbose to check the outcome in a conditional, as
         you need extra parentheses to silence compiler
         warnings. For example:
    
           if ((cp = skip_prefix(buf, "foo"))
    	       /* do something with cp */
    
    Both of these make it harder to use for long if-chains, and
    we tend to use starts_with() instead. However, the first line
    of "do something" is often to then skip forward in buf past
    the prefix, either using a magic constant or with an extra
    strlen(3) (which is generally computed at compile time, but
    means we are repeating ourselves).
    
    This patch refactors skip_prefix() to return a simple boolean,
    and to provide the pointer value as an out-parameter. If the
    prefix is not found, the out-parameter is untouched. This
    lets you write:
    
      if (skip_prefix(arg, "foo ", &arg))
    	  do_foo(arg);
      else if (skip_prefix(arg, "bar ", &arg))
    	  do_bar(arg);
    
    Signed-off-by: Jeff King <peff@peff.net>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
Commits on May 15, 2014
  1. @peff @gitster

    run_column_filter: use argv_array

    peff committed with gitster
    We currently set up the argv array by hand in a fixed-size
    stack-local array. Using an argv array is more readable, as
    it handles buffer allocation us (not to mention makes it
    obvious we do not overflow the array).
    
    However, there's a more subtle benefit, too. We leave the
    function having run start_command (with the child_process
    in a static global), and then later run finish_command from
    another function. That means when we run finish_command,
    neither column_process.argv nor the memory it points to is
    valid any longer.
    
    Most of the time finish_command does not bother looking at
    argv, but it may if it encounters an error (e.g., waitpid
    failure or signal death). This is unusual, which is why
    nobody has noticed. But by using run-command's built-in
    argv_array, the memory ownership is handled for us
    automatically.
    
    Signed-off-by: Jeff King <peff@peff.net>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
Commits on Mar 31, 2014
  1. @jlebar @gitster

    comments: fix misuses of "nor"

    jlebar committed with gitster
    Signed-off-by: Justin Lebar <jlebar@google.com>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
Commits on Apr 27, 2012
  1. @pclouds @gitster

    column: support piping stdout to external git-column process

    pclouds committed with gitster
    For too complicated output handling, it'd be easier to just spawn
    git-column and redirect stdout to it. This patch provides helpers
    to do that.
    
    Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
  2. @pclouds @gitster

    column: add dense layout support

    pclouds committed with gitster
    Normally all cells (and in turn columns) share the same width. This
    layout mode can waste space because one long item can stretch our all
    columns.
    
    With COL_DENSE enabled, column width is calculated indepdendently. All
    columns are shrunk to minimum, then it attempts to push cells of the
    last row over to the next column with hope that everything still fits
    even there's one row less. The process is repeated until the new layout
    cannot fit in given width any more, or there's only one row left
    (perfect!).
    
    Apparently, this mode consumes more cpu than the old one, but it makes
    better use of terminal space. For layouting one or two screens, cpu
    usage should not be detectable.
    
    This patch introduces option handling code besides layout modes and
    enable/disable to expose this feature as "dense". The feature can be
    turned off by specifying "nodense".
    
    Thanks-to: Ramsay Jones <ramsay@ramsay1.demon.co.uk>
    Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
  3. @pclouds @gitster

    column: add columnar layout

    pclouds committed with gitster
    COL_COLUMN and COL_ROW fill column by column (or row by row
    respectively), given the terminal width and how many space between
    columns. All cells have equal width.
    
    Strings are supposed to be in UTF-8. Valid ANSI escape strings are OK.
    
    Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
  4. @pclouds @gitster

    Add column layout skeleton and git-column

    pclouds committed with gitster
    A column option string consists of many token separated by either
    a space or a  comma. A token belongs to one of three groups:
    
     - enabling: always, never and auto
     - layout mode: currently plain (which does not layout at all)
     - other future tuning flags
    
    git-column can be used to pipe output to from a command that wants
    column layout, but not to mess with its own output code. Simpler output
    code can be changed to use column layout code directly.
    
    Thanks-to: Ramsay Jones <ramsay@ramsay1.demon.co.uk>
    Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
Something went wrong with that request. Please try again.