Skip to content
Commits on Jan 15, 2016
  1. @gitster

    strbuf: introduce strbuf_getline_{lf,nul}()

    gitster committed Jan 13, 2016
    The strbuf_getline() interface allows a byte other than LF or NUL as
    the line terminator, but this is only because I wrote these
    codepaths anticipating that there might be a value other than NUL
    and LF that could be useful when I introduced line_termination long
    time ago.  No useful caller that uses other value has emerged.
    
    By now, it is clear that the interface is overly broad without a
    good reason.  Many codepaths have hardcoded preference to read
    either LF terminated or NUL terminated records from their input, and
    then call strbuf_getline() with LF or NUL as the third parameter.
    
    This step introduces two thin wrappers around strbuf_getline(),
    namely, strbuf_getline_lf() and strbuf_getline_nul(), and
    mechanically rewrites these call sites to call either one of
    them.  The changes contained in this patch are:
    
     * introduction of these two functions in strbuf.[ch]
    
     * mechanical conversion of all callers to strbuf_getline() with
       either '\n' or '\0' as the third parameter to instead call the
       respective thin wrapper.
    
    After this step, output from "git grep 'strbuf_getline('" would
    become a lot smaller.  An interim goal of this series is to make
    this an empty set, so that we can have strbuf_getline_crlf() take
    over the shorter name strbuf_getline().
    
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
Commits on Nov 20, 2015
  1. @bk2204 @peff

    Remove get_object_hash.

    bk2204 committed with peff Nov 10, 2015
    Convert all instances of get_object_hash to use an appropriate reference
    to the hash member of the oid member of struct object.  This provides no
    functional change, as it is essentially a macro substitution.
    
    Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
    Signed-off-by: Jeff King <peff@peff.net>
  2. @bk2204 @peff

    Convert struct object to object_id

    bk2204 committed with peff Nov 10, 2015
    struct object is one of the major data structures dealing with object
    IDs.  Convert it to use struct object_id instead of an unsigned char
    array.  Convert get_object_hash to refer to the new member as well.
    
    Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
    Signed-off-by: Jeff King <peff@peff.net>
  3. @bk2204 @peff

    Add several uses of get_object_hash.

    bk2204 committed with peff Nov 10, 2015
    Convert most instances where the sha1 member of struct object is
    dereferenced to use get_object_hash.  Most instances that are passed to
    functions that have versions taking struct object_id, such as
    get_sha1_hex/get_oid_hex, or instances that can be trivially converted
    to use struct object_id instead, are not converted.
    
    Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
    Signed-off-by: Jeff King <peff@peff.net>
  4. @bk2204 @peff

    Convert struct ref to use object_id.

    bk2204 committed with peff Nov 10, 2015
    Use struct object_id in three fields in struct ref and convert all the
    necessary places that use it.
    
    Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
    Signed-off-by: Jeff King <peff@peff.net>
Commits on Oct 5, 2015
  1. @peff @gitster

    drop strcpy in favor of raw sha1_to_hex

    peff committed with gitster Sep 24, 2015
    In some cases where we strcpy() the result of sha1_to_hex(),
    there's no need; the result goes directly into a printf
    statement, and we can simply pass the return value from
    sha1_to_hex() directly.
    
    When this code was originally written, sha1_to_hex used a
    single buffer, and it was not safe to use it twice within a
    single expression. That changed as of dcb3450 (sha1_to_hex()
    usage cleanup, 2006-05-03), but this code was never updated.
    
    History-dug-by: Eric Sunshine <sunshine@sunshineco.com>
    Signed-off-by: Jeff King <peff@peff.net>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
Commits on May 25, 2015
  1. @mhagger @gitster

    mark_complete(): rewrite to take an object_id argument

    mhagger committed with gitster May 25, 2015
    Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
    Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
  2. @mhagger @gitster

    each_ref_fn: change to take an object_id parameter

    mhagger committed with gitster May 25, 2015
    Change typedef each_ref_fn to take a "const struct object_id *oid"
    parameter instead of "const unsigned char *sha1".
    
    To aid this transition, implement an adapter that can be used to wrap
    old-style functions matching the old typedef, which is now called
    "each_ref_sha1_fn"), and make such functions callable via the new
    interface. This requires the old function and its cb_data to be
    wrapped in a "struct each_ref_fn_sha1_adapter", and that object to be
    used as the cb_data for an adapter function, each_ref_fn_adapter().
    
    This is an enormous diff, but most of it consists of simple,
    mechanical changes to the sites that call any of the "for_each_ref"
    family of functions. Subsequent to this change, the call sites can be
    rewritten one by one to use the new interface.
    
    Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
    Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
Commits on Feb 17, 2015
  1. @mhagger @gitster

    ref_transaction_update(): remove "have_old" parameter

    mhagger committed with gitster Feb 17, 2015
    Instead, verify the reference's old value if and only if old_sha1 is
    non-NULL.
    
    ref_transaction_delete() will get the same treatment in a moment.
    
    Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
    Reviewed-by: Stefan Beller <sbeller@google.com>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
Commits on Feb 11, 2015
  1. @gitster

    Merge branch 'jk/blame-commit-label'

    gitster committed Feb 11, 2015
    "git blame HEAD -- missing" failed to correctly say "HEAD" when it
    tried to say "No such path 'missing' in HEAD".
    
    * jk/blame-commit-label:
      blame.c: fix garbled error message
      use xstrdup_or_null to replace ternary conditionals
      builtin/commit.c: use xstrdup_or_null instead of envdup
      builtin/apply.c: use xstrdup_or_null instead of null_strdup
      git-compat-util: add xstrdup_or_null helper
Commits on Jan 13, 2015
  1. @peff @gitster

    use xstrdup_or_null to replace ternary conditionals

    peff committed with gitster Jan 12, 2015
    This replaces "x ? xstrdup(x) : NULL" with xstrdup_or_null(x).
    The change is fairly mechanical, with the exception of
    resolve_refdup, which can eliminate a temporary variable.
    
    There are still a few hits grepping for "?.*xstrdup", but
    these are of slightly different forms and cannot be
    converted (e.g., "x ? xstrdup(x->foo) : NULL").
    
    Signed-off-by: Jeff King <peff@peff.net>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
Commits on Oct 15, 2014
  1. @rsahlberg @gitster

    refs.c: pass the ref log message to _create/delete/update instead of …

    rsahlberg committed with gitster Apr 30, 2014
    …_commit
    
    Change the ref transaction API so that we pass the reflog message to the
    create/delete/update functions instead of to ref_transaction_commit.
    This allows different reflog messages for each ref update in a multi-ref
    transaction.
    
    Signed-off-by: Ronnie Sahlberg <sahlberg@google.com>
    Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
    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 Sep 16, 2014
    Signed-off-by: Rene Scharfe <l.s.r@web.de>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
Commits on Sep 11, 2014
  1. @gitster

    Merge branch 'rs/list-optim'

    gitster committed Sep 11, 2014
    Fix a couple of "accumulate into a sorted list" to "accumulate and
    then sort the list".
    
    * rs/list-optim:
      walker: avoid quadratic list insertion in mark_complete
      sha1_name: avoid quadratic list insertion in handle_one_ref
  2. @gitster

    Merge branch 'rs/ref-transaction-1'

    gitster committed Sep 11, 2014
    The second batch of the transactional ref update series.
    
    * rs/ref-transaction-1: (22 commits)
      update-ref --stdin: pass transaction around explicitly
      update-ref --stdin: narrow scope of err strbuf
      refs.c: make delete_ref use a transaction
      refs.c: make prune_ref use a transaction to delete the ref
      refs.c: remove lock_ref_sha1
      refs.c: remove the update_ref_write function
      refs.c: remove the update_ref_lock function
      refs.c: make lock_ref_sha1 static
      walker.c: use ref transaction for ref updates
      fast-import.c: use a ref transaction when dumping tags
      receive-pack.c: use a reference transaction for updating the refs
      refs.c: change update_ref to use a transaction
      branch.c: use ref transaction for all ref updates
      fast-import.c: change update_branch to use ref transactions
      sequencer.c: use ref transactions for all ref updates
      commit.c: use ref transactions for updates
      replace.c: use the ref transaction functions for updates
      tag.c: use ref transactions when doing updates
      refs.c: add transaction.status and track OPEN/CLOSED
      refs.c: make ref_transaction_begin take an err argument
      ...
Commits on Sep 3, 2014
  1. @rsahlberg @gitster

    walker.c: use ref transaction for ref updates

    rsahlberg committed with gitster Apr 17, 2014
    Switch to using ref transactions in walker_fetch(). As part of the refactoring
    to use ref transactions we also fix a potential memory leak where in the
    original code if write_ref_sha1() would fail we would end up returning from
    the function without free()ing the msg string.
    
    Note that this function is only called when fetching from a remote HTTP
    repository onto the local (most of the time single-user) repository which
    likely means that the type of collisions that the previous locking would
    protect against and cause the fetch to fail for are even more rare.
    
    Signed-off-by: Ronnie Sahlberg <sahlberg@google.com>
    Reviewed-by: Michael Haggerty <mhagger@alum.mit.edu>
    Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
Commits on Aug 25, 2014
  1. @gitster

    walker: avoid quadratic list insertion in mark_complete

    René Scharfe committed with gitster Aug 21, 2014
    Similar to 1644524 (fetch-pack: avoid quadratic list insertion in
    mark_complete), sort only after all refs are collected instead of while
    inserting.  The result is the same, but it's more efficient that way.
    The difference will only be measurable in repositories with a large
    number of refs.
    
    Signed-off-by: Rene Scharfe <l.s.r@web.de>
    Acked-by: Jeff King <peff@peff.net>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
Commits on Jun 19, 2014
  1. @peff @gitster

    walker_fetch: fix minor memory leak

    peff committed with gitster Jun 19, 2014
    We sometimes allocate "msg" on the heap, but will fail to
    free it if we hit the failure code path. We can instead keep
    a separate variable that is safe to be freed no matter how
    we get to the failure code path.
    
    While we're here, we can also do two readability
    improvements:
    
      1. Use xstrfmt instead of a manual malloc/sprintf
    
      2. Due to the "maybe we allocate msg, maybe we don't"
         strategy, the logic for deciding which message to show
         was split into two parts. Since the deallocation is now
         pushed onto a separate variable, this is no longer a
         concern, and we can keep all of the logic in the same
         place.
    
    Signed-off-by: Jeff King <peff@peff.net>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
Commits on Mar 25, 2014
  1. @pclouds @gitster

    object.h: centralize object flag allocation

    pclouds committed with gitster Mar 25, 2014
    While the field "flags" is mainly used by the revision walker, it is
    also used in many other places. Centralize the whole flag allocation to
    one place for a better overview (and easier to move flags if we have
    too).
    
    Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
Commits on Jun 6, 2013
  1. @peff @gitster

    clear parsed flag when we free tree buffers

    peff committed with gitster Jun 5, 2013
    Many code paths will free a tree object's buffer and set it
    to NULL after finishing with it in order to keep memory
    usage down during a traversal. However, out of 8 sites that
    do this, only one actually unsets the "parsed" flag back.
    Those sites that don't are setting a trap for later users of
    the tree object; even after calling parse_tree, the buffer
    will remain NULL, causing potential segfaults.
    
    It is not known whether this is triggerable in the current
    code. Most commands do not do an in-memory traversal
    followed by actually using the objects again. However, it
    does not hurt to be safe for future callers.
    
    In most cases, we can abstract this out to a
    "free_tree_buffer" helper. However, there are two
    exceptions:
    
      1. The fsck code relies on the parsed flag to know that we
         were able to parse the object at one point. We can
         switch this to using a flag in the "flags" field.
    
      2. The index-pack code sets the buffer to NULL but does
         not free it (it is freed by a caller). We should still
         unset the parsed flag here, but we cannot use our
         helper, as we do not want to free the buffer.
    
    Signed-off-by: Jeff King <peff@peff.net>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
Commits on Oct 5, 2011
  1. @mhagger @gitster

    Change check_ref_format() to take a flags argument

    mhagger committed with gitster Sep 15, 2011
    Change check_ref_format() to take a flags argument that indicates what
    is acceptable in the reference name (analogous to "git
    check-ref-format"'s "--allow-onelevel" and "--refspec-pattern").  This
    is more convenient for callers and also fixes a failure in the test
    suite (and likely elsewhere in the code) by enabling "onelevel" and
    "refspec-pattern" to be allowed independently of each other.
    
    Also rename check_ref_format() to check_refname_format() to make it
    obvious that it deals with refnames rather than references themselves.
    
    Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
Commits on Nov 29, 2010
  1. @gitster

    commit: Add commit_list prefix in two function names.

    Thiago Farina committed with gitster Nov 26, 2010
    Add commit_list prefix to insert_by_date function and to sort_by_date,
    so it's clear that these functions refer to commit_list structure.
    
    Signed-off-by: Thiago Farina <tfransosi@gmail.com>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
Commits on Jul 23, 2009
  1. @gitster

    janitor: useless checks before free

    Pierre Habouzit committed with gitster Jul 22, 2009
    Signed-off-by: Pierre Habouzit <madcoder@debian.org>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
Commits on Feb 11, 2009
  1. @gitster

    Drop double-semicolon in C

    gitster committed Feb 10, 2009
    The worst offenders are "continue;;" and "break;;" in switch statements.
    
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
Commits on Oct 18, 2008
  1. @gitster

    make alloc_ref_from_str() the new alloc_ref()

    René Scharfe committed with gitster Oct 18, 2008
    With all calls to alloc_ref() gone, we can remove it and then we're free
    to give alloc_ref_from_str() the shorter name.  It's a much nicer
    interface, as the callers always need to have a name string when they
    allocate a ref anyway and don't need to calculate and pass its length+1
    any more.
    
    Signed-off-by: Rene Scharfe <rene.scharfe@lsrfire.ath.cx>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
Commits on Oct 12, 2008
  1. @spearce

    Replace calls to strbuf_init(&foo, 0) with STRBUF_INIT initializer

    Brandon Casey committed with spearce Oct 9, 2008
    Many call sites use strbuf_init(&foo, 0) to initialize local
    strbuf variable "foo" which has not been accessed since its
    declaration. These can be replaced with a static initialization
    using the STRBUF_INIT macro which is just as readable, saves a
    function call, and takes up fewer lines.
    
    Signed-off-by: Brandon Casey <casey@nrlssc.navy.mil>
    Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
Commits on Jun 4, 2008
  1. @peff @gitster

    Fix "git clone http://$URL" to check out the worktree when asked

    peff committed with gitster Jun 4, 2008
    The builtin-clone now does the http commit walking and the tree unpacking
    in the same process, and the commit walker leaves the in-core objects in a
    funny state.  When forgetting the data read from the tree object, the
    object should be marked "not parsed yet" for later users.
    
    Acked-by: Linus Torvalds <torvalds@linux-foundation.org>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
Commits on May 11, 2008
  1. @kjk @gitster

    alloc_ref_from_str(): factor out a common pattern of alloc_ref from s…

    kjk committed with gitster May 10, 2008
    …tring
    
    Also fix an underallocation in walker.c::interpret_target().
    
    Signed-off-by: Krzysztof Kowalczyk <kkowalczyk@gmail.com>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
Commits on Apr 27, 2008
  1. @gitster

    Make walker.fetch_ref() take a struct ref.

    Daniel Barkalow committed with gitster Apr 26, 2008
    This simplifies a few things, makes a few things slightly more
    complicated, but, more importantly, allows that, when struct ref can
    represent a symref, http_fetch_ref() can return one.
    
    Incidentally makes the string that http_fetch_ref() gets include "refs/"
    (if appropriate), because that's how the name field of struct ref works.
    As far as I can tell, the usage in walker:interpret_target() wouldn't have
    worked previously, if it ever would have been used, which it wouldn't
    (since the fetch process uses the hash instead of the name of the ref
    there).
    
    Signed-off-by: Daniel Barkalow <barkalow@iabervon.org>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
Commits on Feb 26, 2008
  1. @gitster

    Remove unused object-ref code

    Martin Koegler committed with gitster Feb 25, 2008
    Signed-off-by: Martin Koegler <mkoegler@auto.tuwien.ac.at>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
Commits on Dec 18, 2007
  1. @samv @gitster

    Clarify error response from 'git fetch' for bad responses

    samv committed with gitster Dec 18, 2007
    This error message prints the reponse from the server at this point.
    Label it as such in the output.
    
    Signed-off-by: Sam Vilain <sam@vilain.net>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
Commits on Oct 16, 2007
  1. @spearce

    Merge branch 'master' into db/fetch-pack

    spearce committed Oct 16, 2007
    There's a number of tricky conflicts between master and
    this topic right now due to the rewrite of builtin-push.
    Junio must have handled these via rerere; I'd rather not
    deal with them again so I'm pre-merging master into the
    topic.  Besides this topic somehow started to depend on
    the strbuf series that was in next, but is now in master.
    It no longer compiles on its own without the strbuf API.
    
    * master: (184 commits)
      Whip post 1.5.3.4 maintenance series into shape.
      Minor usage update in setgitperms.perl
      manual: use 'URL' instead of 'url'.
      manual: add some markup.
      manual: Fix example finding commits referencing given content.
      Fix wording in push definition.
      Fix some typos, punctuation, missing words, minor markup.
      manual: Fix or remove em dashes.
      Add a --dry-run option to git-push.
      Add a --dry-run option to git-send-pack.
      Fix in-place editing functions in convert.c
      instaweb: support for Ruby's WEBrick server
      instaweb: allow for use of auto-generated scripts
      Add 'git-p4 commit' as an alias for 'git-p4 submit'
      hg-to-git speedup through selectable repack intervals
      git-svn: respect Subversion's [auth] section configuration values
      gtksourceview2 support for gitview
      fix contrib/hooks/post-receive-email hooks.recipients error message
      Support cvs via git-shell
      rebase -i: use diff plumbing instead of porcelain
      ...
    
    Conflicts:
    
    	Makefile
    	builtin-push.c
    	rsh.c
Commits on Sep 19, 2007
  1. @gitster

    Modularize commit-walker

    Daniel Barkalow committed with gitster Sep 10, 2007
    This turns the extern functions to be provided by the backend into a
    struct of pointers, renames the functions to be more
    namespace-friendly, and updates http-fetch to this interface. It
    removes the unused include from http-push.c. It makes git-http-fetch a
    builtin (with the implementation a separate file, accessible
    directly).
    
    Signed-off-by: Daniel Barkalow <barkalow@iabervon.org>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
Something went wrong with that request. Please try again.