Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Commits on Dec 4, 2014
  1. @stefanbeller @gitster

    mailmap: use higher level string list functions

    stefanbeller authored gitster committed
    No functional changes intended. This commit makes use of higher level
    and better documented functions of the string list API, so the code is
    more understandable.
    
    Note that also the required computational amount should not change
    in principal as we need to look up the item no matter if it is already
    part of the list or not. Once looked up, insertion comes for free.
    
    Signed-off-by: Stefan Beller <sbeller@google.com>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
Commits on Sep 25, 2013
  1. @jrn

    Merge branch 'jc/strcasecmp-pure-inline'

    jrn authored
    * jc/strcasecmp-pure-inline:
      mailmap: work around implementations with pure inline strcasecmp
Commits on Sep 12, 2013
  1. @gitster

    mailmap: work around implementations with pure inline strcasecmp

    gitster authored
    On some systems (e.g. MinGW 4.0), string.h has only inline
    definition of strcasecmp and no non-inline implementation is
    supplied anywhere, which is, eh, "unusual".  We cannot take an
    address of such a function to store it in namemap.cmp.
    
    Work it around by introducing our own level of indirection.
    
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
Commits on Sep 11, 2013
  1. @gitster

    Merge branch 'sb/mailmap-freeing-NULL-is-ok'

    gitster authored
    * sb/mailmap-freeing-NULL-is-ok:
      mailmap: remove redundant check for freeing memory
Commits on Sep 9, 2013
  1. @gitster

    Merge branch 'jk/mailmap-incomplete-line'

    gitster authored
    * jk/mailmap-incomplete-line:
      mailmap: handle mailmap blobs without trailing newlines
Commits on Aug 28, 2013
  1. @peff @gitster

    mailmap: handle mailmap blobs without trailing newlines

    peff authored gitster committed
    The read_mailmap_buf function reads each line of the mailmap
    using strchrnul, like:
    
        const char *end = strchrnul(buf, '\n');
        unsigned long linelen = end - buf + 1;
    
    But that's off-by-one when we actually hit the NUL byte; our
    line does not have a terminator, and so is only "end - buf"
    bytes long. As a result, when we subtract the linelen from
    the total len, we end up with (unsigned long)-1 bytes left
    in the buffer, and we start reading random junk from memory.
    
    We could fix it with:
    
        unsigned long linelen = end - buf + !!*end;
    
    but let's take a step back for a moment. It's questionable
    in the first place for a function that takes a buffer and
    length to be using strchrnul. But it works because we only
    have one caller (and are only likely to ever have this one),
    which is handing us data from read_sha1_file. Which means
    that it's always NUL-terminated.
    
    Instead of tightening the assumptions to make the
    buffer/length pair work for a caller that doesn't actually
    exist, let's let loosen the assumptions to what the real
    caller has: a modifiable, NUL-terminated string.
    
    This makes the code simpler and shorter (because we don't
    have to correlate strchrnul with the length calculation),
    correct (because the code with the off-by-one just goes
    away), and more efficient (we can drop the extra allocation
    we needed to create NUL-terminated strings for each line,
    and just terminate in place).
    
    Signed-off-by: Jeff King <peff@peff.net>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
Commits on Aug 20, 2013
  1. @stefanbeller @gitster

    mailmap: remove redundant check for freeing memory

    stefanbeller authored gitster committed
    The condition as it is written in that line has already been checked
    in the beginning of the function, which was introduced in
    8503ee4 (2007-05-01, Fix read_mailmap to handle a caller uninterested
    in repo abbreviation)
    
    Helped-by: Jeff King <peff@peff.net>
    Helped-by: Thomas Rast <trast@inf.ethz.ch>
    Signed-off-by: Stefan Beller <stefanbeller@googlemail.com>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
Commits on Jul 15, 2013
  1. @gitster

    mailmap: style fixes

    gitster authored
    Wrap overlong lines and format the multi-line comments to match our
    coding style.
    
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
    Signed-off-by: Eric Sunshine <sunshine@sunshineco.com>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
  2. @sunshineco @gitster

    mailmap: debug: avoid passing NULL to fprintf() '%s' conversion speci…

    sunshineco authored gitster committed
    …fication
    
    POSIX does not state the behavior of '%s' conversion when passed a
    NULL pointer. Some implementations interpolate literal "(null)";
    others may crash.
    
    Callers of debug_mm() often pass NULL as indication of either a
    missing name or email address.  Instead, let's always supply a
    proper string pointer, and make it a bit more descriptive: "(none)"
    
    Signed-off-by: Eric Sunshine <sunshine@sunshineco.com>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
  3. @sunshineco @gitster

    mailmap: debug: eliminate -Wformat field precision type warning

    sunshineco authored gitster committed
    The compiler complains that '*' in fprintf() format "%.*s" should
    have type int, but we pass size_t. Fix this.
    
    Signed-off-by: Eric Sunshine <sunshine@sunshineco.com>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
  4. @sunshineco @gitster

    mailmap: debug: fix malformed fprintf() format conversion specification

    sunshineco authored gitster committed
    Resolve segmentation fault due to size_t variable being consumed by
    '%s'.
    
    Signed-off-by: Eric Sunshine <sunshine@sunshineco.com>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
  5. @sunshineco @gitster

    mailmap: debug: fix out-of-order fprintf() arguments

    sunshineco authored gitster committed
    Resolve segmentation fault due to arguments passed in wrong order.
    
    Signed-off-by: Eric Sunshine <sunshine@sunshineco.com>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
  6. @gitster

    mailmap: do not downcase mailmap entries

    gitster authored
    The email addresses in the records read from the .mailmap file are
    downcased very early, and then used to match against e-mail
    addresses in the input.  Because we do use case insensitive version
    of string list to manage these entries, there is no need to do this,
    and worse yet, downcasing the rewritten/canonical e-mail read from
    the .mailmap file loses information.
    
    Stop doing that, and also make the string list used to keep multiple
    names for an mailmap entry case insensitive (the code that uses the
    list, lookup_prefix(), expects a case insensitive match).
    
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
    Signed-off-by: Eric Sunshine <sunshine@sunshineco.com>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
  7. @gitster

    mailmap: do not lose single-letter names

    gitster authored
    In parse_name_and_email() function, there is this line:
    
    	*name = (nstart < nend ? nstart : NULL);
    
    When the function is given a buffer "A <A@example.org> <old@x.z>",
    nstart scans from the beginning of the buffer, skipping whitespaces
    (there isn't any, so nstart points at the buffer), while nend starts
    from one byte before the first '<' and skips whitespaces backwards
    and stops at the first non-whitespace (i.e. it hits "A" at the
    beginning of the buffer).  nstart == nend in this case for a
    single-letter name, and an off-by-one error makes it fail to pick up
    the name, which makes the entry equivalent to
    
    	<A@example.org> <old@x.z>
    
    without the name.
    
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
    Signed-off-by: Eric Sunshine <sunshine@sunshineco.com>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
Commits on Jan 21, 2013
  1. @gitster

    Merge branch 'ap/log-mailmap'

    gitster authored
    Teach commands in the "log" family to optionally pay attention to
    the mailmap.
    
    * ap/log-mailmap:
      log --use-mailmap: optimize for cases without --author/--committer search
      log: add log.mailmap configuration option
      log: grep author/committer using mailmap
      test: add test for --use-mailmap option
      log: add --use-mailmap option
      pretty: use mailmap to display username and email
      mailmap: add mailmap structure to rev_info and pp
      mailmap: simplify map_user() interface
      mailmap: remove email copy and length limitation
      Use split_ident_line to parse author and committer
      string-list: allow case-insensitive string list
Commits on Jan 10, 2013
  1. @apelisse @gitster

    mailmap: simplify map_user() interface

    apelisse authored gitster committed
    Simplify map_user(), mostly to avoid copies of string buffers. It
    also simplifies caller functions.
    
    map_user() directly receive pointers and length from the commit buffer
    as mail and name. If mapping of the user and mail can be done, the
    pointer is updated to a new location. Lengths are also updated if
    necessary.
    
    The caller of map_user() can then copy the new email and name if
    necessary.
    
    Signed-off-by: Antoine Pelisse <apelisse@gmail.com>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
  2. @gitster

    mailmap: remove email copy and length limitation

    gitster authored
    In map_user(), we have email pointer that points at the beginning of
    an e-mail address, but the buffer is not terminated with a NUL after
    the e-mail address.  It typically has ">" after the address, and it
    could have even more if it comes from author/committer line in a
    commit object.  Or it may not have ">" after it.
    
    We used to copy the e-mail address proper into a temporary buffer
    before asking the string-list API to find the e-mail address in the
    mailmap, because string_list_lookup() function only takes a NUL
    terminated full string.
    
    Introduce a helper function lookup_prefix that takes the email
    pointer and the length, and finds a matching entry in the string
    list used for the mailmap, by doing the following:
    
     - First ask string_list_find_insert_index() where in its sorted
       list the e-mail address we have (including the possible trailing
       junk ">...") would be inserted.
    
     - It could find an exact match (e.g. we had a clean e-mail address
       without any trailing junk).  We can return the item in that case.
    
     - Or it could return the index of an item that sorts after the
       e-mail address we have.
    
     - If we did not find an exact match against a clean e-mail address,
       then the record we are looking for in the mailmap has to exist
       before the index returned by the function (i.e. "email>junk"
       always sorts later than "email").  Iterate, starting from that
       index, down the map->items[] array until we find the exact record
       we are looking for, or we see a record with a key that definitely
       sorts earlier than the e-mail we are looking for (i.e. when we
       are looking for "email" in "email>junk", a record in the mailmap
       that begins with "emaik" strictly sorts before "email", if such a
       key existed in the mailmap).
    
    This, together with the earlier enhancement to support
    case-insensitive sorting, allow us to remove an extra copy of email
    buffer to downcase it.
    
    A part of this is based on Antoine Pelisse's previous work.
    
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
Commits on Dec 13, 2012
  1. @peff @gitster

    mailmap: default mailmap.blob in bare repositories

    peff authored gitster committed
    The motivation for mailmap.blob is to let users of bare
    repositories use the mailmap feature, as they would not have
    a checkout containing the .mailmap file. We can make it even
    easier for them by just looking in HEAD:.mailmap by default.
    
    We can't know for sure that this is where they would keep a
    mailmap, of course, but it is the best guess (and it matches
    the non-bare behavior, which reads from HEAD:.mailmap in the
    working tree). If it's missing, git will silently ignore the
    setting.
    
    We do not do the same magic in the non-bare case, because:
    
      1. In the common case, HEAD:.mailmap will be the same as
         the .mailmap in the working tree, which is a no-op.
    
      2. In the uncommon case, the user has modified .mailmap
         but not yet committed it, and would expect the working
         tree version to take precedence.
    
    Signed-off-by: Jeff King <peff@peff.net>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
Commits on Dec 12, 2012
  1. @peff @gitster

    mailmap: clean up read_mailmap error handling

    peff authored gitster committed
    The error handling for the read_mailmap function is odd. It
    returns 1 on error, rather than -1. And it treats a
    non-existent mailmap as an error, even though there is no
    reason that one needs to exist. Unless some other mailmap
    source loads successfully, in which case the original error
    is completely masked.
    
    This does not cause any bugs, however, because no caller
    bothers to check the return value, anyway. Let's make this a
    little more robust to real errors and less surprising for
    future callers that do check the error code:
    
      1. Return -1 on errors.
    
      2. Treat a missing entry (e.g., no mailmap.file given),
         ENOENT, or a non-existent blob (for mailmap.blob) as
         "no error".
    
      3. Complain loudly when a real error (e.g., a transient
         I/O error, no permission to open the mailmap file,
         missing or corrupted blob object, etc) occurs.
    
    Signed-off-by: Jeff King <peff@peff.net>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
  2. @peff @gitster

    mailmap: support reading mailmap from blobs

    peff authored gitster committed
    In a bare repository, there isn't a simple way to respect an
    in-tree mailmap without extracting it to a temporary file.
    This patch provides a config variable, similar to
    mailmap.file, which reads the mailmap from a blob in the
    repository.
    
    Signed-off-by: Jeff King <peff@peff.net>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
  3. @peff @gitster

    mailmap: refactor mailmap parsing for non-file sources

    peff authored gitster committed
    The read_single_mailmap function opens a mailmap file and
    parses each line. In preparation for having non-file
    mailmaps, let's pull out the line-parsing logic into its own
    function (read_mailmap_line), and rename the file-parsing
    function to match (read_mailmap_file).
    
    Signed-off-by: Jeff King <peff@peff.net>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
Commits on Oct 28, 2012
  1. @orebokech @peff

    mailmap: avoid out-of-bounds memory access

    orebokech authored peff committed
    AddressSanitizer (http://clang.llvm.org/docs/AddressSanitizer.html)
    complains of a one-byte buffer underflow in parse_name_and_email() while
    running the test suite. And indeed, if one of the lines in the mailmap
    begins with '<', we dereference the address just before the beginning of
    the buffer when looking for whitespace to remove, before checking that
    we aren't going too far.
    
    So reverse the order of the tests to make sure that we don't read
    outside the buffer.
    
    Signed-off-by: Romain Francoise <romain@orebokech.com>
    Signed-off-by: Jeff King <peff@peff.net>
Commits on Feb 6, 2012
  1. @gitster

    mailmap: always return a plain mail address from map_user()

    gitster authored
    The callers of map_user() give email and name to it, and expect to get the
    up-to-date email and/or name to be used in their output. The function
    rewrites the given buffers in place. To optimize the majority of cases,
    the function returns 0 when it did not do anything, and it returns 1 when
    the caller should use the updated contents.
    
    The 'email' input to the function is terminated by '>' or a NUL (whichever
    comes first) for historical reasons, but when a rewrite happens, the value
    is replaced with the mailbox inside the <> pair.  However, it failed to
    meet this expectation when it only rewrote the name part without rewriting
    the email part, and the email in the input was terminated by '>'.
    
    This causes an extra '>' to appear in the output of "blame -e", because the
    caller does send in '>'-terminated email, and when the function returned 1
    to tell it that rewriting happened, it appends '>' that is necessary when
    the email part was rewritten.
    
    The patch looks bigger than it actually is, because this change makes a
    variable that points at the end of the email part in the input 'p' live
    much longer than it used to, deserving a more descriptive name.
    
    Noticed and diagnosed by Felipe Contreras and Jeff King.
    
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
Commits on Dec 14, 2011
  1. @gitster

    Merge branch 'ml/mailmap' into maint-1.7.6

    gitster authored
    * ml/mailmap:
      mailmap: xcalloc mailmap_info
    
    Conflicts:
    	mailmap.c
Commits on Nov 17, 2011
  1. @elmarco @gitster

    mailmap: xcalloc mailmap_info

    elmarco authored gitster committed
    This is to avoid reaching free of uninitialized members.
    
    With an invalid .mailmap (and perhaps in other cases), it can reach
    free(mi->name) with garbage for example.
    
    Signed-off-by: Marc-André Lureau <marcandre.lureau@gmail.com>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
Commits on Oct 14, 2010
  1. @meyering @gitster

    mailmap: fix use of freed memory

    meyering authored gitster committed
    On an x86_64 system (F13-based), I ran these commands in an empty directory:
    
        git init
        printf '%s\n' \
          '<jdoe@example.com> <jdoe@example.COM>' \
          'John <jdoe@example.com>' > .mailmap
        git shortlog < /dev/null
    
    Here's the result:
    
        (reading log message from standard input)
        *** glibc detected *** git: free(): invalid pointer: 0x0000000000f53730 ***
        ======= Backtrace: =========
        /lib64/libc.so.6[0x31ba875676]
        git[0x48c2a5]
        git[0x4b9858]
        ...
        zsh: abort (core dumped)  git shortlog
    
    What happened?
    
    Some .mailmap entry is of the <email1> <email2> form,
    while a subsequent one looks like "User Name <Email2>,
    and the two email addresses on the right are not identical
    but are "equal" when using a case-insensitive comparator.
    
    Then, when add_mapping is processing the latter line, new_email is NULL
    and we free me->email, yet do not replace it with a new strdup'd string.
    Thus, when later we attempt to use the buffer behind that ->email pointer,
    we reference freed memory.
    
    The solution is to free ->email and ->name only if we're about to replace them.
    
    [jc: squashed in the tests from Jonathan]
    
    Signed-off-by: Jim Meyering <meyering@redhat.com>
    Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
Commits on Jun 27, 2010
  1. @qur @gitster

    string_list: Fix argument order for string_list_lookup

    qur authored gitster committed
    Update the definition and callers of string_list_lookup to use the
    string_list as the first argument.  This helps make the string_list
    API easier to use by being more consistent.
    
    Signed-off-by: Julian Phillips <julian@quantumfyre.co.uk>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
  2. @qur @gitster

    string_list: Fix argument order for string_list_insert_at_index

    qur authored gitster committed
    Update the definition and callers of string_list_insert_at_index to
    use the string_list as the first argument.  This helps make the
    string_list API easier to use by being more consistent.
    
    Signed-off-by: Julian Phillips <julian@quantumfyre.co.uk>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
  3. @qur @gitster

    string_list: Fix argument order for string_list_insert

    qur authored gitster committed
    Update the definition and callers of string_list_insert to use the
    string_list as the first argument.  This helps make the string_list
    API easier to use by being more consistent.
    
    Signed-off-by: Julian Phillips <julian@quantumfyre.co.uk>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
Commits on Jan 12, 2010
  1. @gitster

    mailmap.c: remove unused function

    gitster authored
    map_email() is not used anywhere.
    
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
Commits on Jun 21, 2009
  1. @torvalds @gitster

    Fix various sparse warnings in the git source code

    torvalds authored gitster committed
    There are a few remaining ones, but this fixes the trivial ones. It boils
    down to two main issues that sparse complains about:
    
     - warning: Using plain integer as NULL pointer
    
       Sparse doesn't like you using '0' instead of 'NULL'. For various good
       reasons, not the least of which is just the visual confusion. A NULL
       pointer is not an integer, and that whole "0 works as NULL" is a
       historical accident and not very pretty.
    
       A few of these remain: zlib is a total mess, and Z_NULL is just a 0.
       I didn't touch those.
    
     - warning: symbol 'xyz' was not declared. Should it be static?
    
       Sparse wants to see declarations for any functions you export. A lack
       of a declaration tends to mean that you should either add one, or you
       should mark the function 'static' to show that it's in file scope.
    
       A few of these remain: I only did the ones that should obviously just
       be made static.
    
    That 'wt_status_submodule_summary' one is debatable. It has a few related
    flags (like 'wt_status_use_color') which _are_ declared, and are used by
    builtin-commit.c. So maybe we'd like to export it at some point, but it's
    not declared now, and not used outside of that file, so 'static' it is in
    this patch.
    
    Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
Commits on Apr 2, 2009
  1. @gitster

    Merge branch 'maint'

    gitster authored
    * maint:
      Documentation: Remove an odd "instead"
      fix portability problem with IS_RUN_COMMAND_ERR
      mailmap: resurrect lower-casing of email addresses
Commits on Apr 1, 2009
  1. @dotdash @gitster

    Mailmap: Allow empty email addresses to be mapped

    dotdash authored gitster committed
    While it makes no sense to map some email address to an empty one, doing
    things the other way around can be useful. For example when using
    filter-branch with an env-filter that employs a mailmap to fix up an
    import that created such broken commits with empty email addresses.
    
    Signed-off-by: Björn Steinbrink <B.Steinbrink@gmx.de>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
  2. @dscho @gitster

    mailmap: resurrect lower-casing of email addresses

    dscho authored gitster committed
    Commit 0925ce4(Add map_user() and clear_mailmap() to mailmap) broke the
    lower-casing of email addresses.  This mostly did not matter if your
    .mailmap has only lower-case email addresses;  However, we did not
    require .mailmap to contain lowercase-only email addresses.
    
    Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
Commits on Feb 8, 2009
  1. @gitster

    Add map_user() and clear_mailmap() to mailmap

    Marius Storm-Olsen authored gitster committed
    map_user() allows to lookup and replace both email and
    name of a user, based on a new style mailmap file.
    
    The possible mailmap definitions are now:
    
      proper_name <commit_email>                             # Old style
      <proper_email> <commit_email>                          # New style
      proper_name <proper_email> <commit_email>              # New style
      proper_name <proper_email> commit_name <commit_email>  # New style
    
    map_email() operates the same as before, with the
    exception that it also will to try to match on a name
    passed in through the name return buffer.
    
    clear_mailmap() is needed to now clear the more complex
    mailmap structure.
    
    Signed-off-by: Marius Storm-Olsen <marius@trolltech.com>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
Something went wrong with that request. Please try again.