Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Commits on Nov 17, 2010
  1. @jherland @gitster

    git notes merge: Add another auto-resolving strategy: "cat_sort_uniq"

    jherland authored gitster committed
    This new strategy is similar to "concatenate", but in addition to
    concatenating the two note candidates, this strategy sorts the resulting
    lines, and removes duplicate lines from the result. This is equivalent to
    applying the "cat | sort | uniq" shell pipeline to the two note candidates.
    
    This strategy is useful if the notes follow a line-based format where one
    wants to avoid duplicate lines in the merge result.
    
    Note that if either of the note candidates contain duplicate lines _prior_
    to the merge, these will also be removed by this merge strategy.
    
    The patch also contains tests and documentation for the new strategy.
    
    Signed-off-by: Johan Herland <johan@herland.net>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
  2. @jherland @gitster

    notes.h/c: Propagate combine_notes_fn return value to add_note() and …

    jherland authored gitster committed
    …beyond
    
    The combine_notes_fn functions uses a non-zero return value to indicate
    failure. However, this return value was converted to a call to die()
    in note_tree_insert().
    
    Instead, propagate this return value out to add_note(), and return it
    from there to enable the caller to handle errors appropriately.
    
    Existing add_note() callers are updated to die() upon failure, thus
    preserving the current behaviour. The only exceptions are copy_note()
    and notes_cache_put() where we are able to propagate the add_note()
    return value instead.
    
    This patch has been improved by the following contributions:
    - Jonathan Nieder: Future-proof by always checking add_note() return value
    - Jonathan Nieder: Improve clarity of final if-condition in note_tree_insert()
    
    Thanks-to: Jonathan Nieder <jrnieder@gmail.com>
    Signed-off-by: Johan Herland <johan@herland.net>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
Commits on Nov 10, 2010
  1. @jherland @gitster

    notes.h/c: Allow combine_notes functions to remove notes

    jherland authored gitster committed
    Allow combine_notes functions to request that a note be removed, by setting
    the resulting note SHA1 to null_sha1 (0000000...).
    
    For consistency, also teach note_tree_insert() to skip insertion of an empty
    note (a note with entry->val_sha1 equal to null_sha1) when there is no note
    to combine it with.
    
    In general, an empty note (null_sha1) is treated identically to no note at
    all, but when adding an empty note where there already exists a non-empty
    note, we allow the combine_notes function to potentially record a new/changed
    note. Document this behaviour, and clearly specify how combine_notes functions
    are expected to handle null_sha1 in input.
    
    Before this patch, storing null_sha1s in the notes tree were silently allowed,
    causing an invalid notes tree (referring to blobs with null_sha1) to be
    produced by write_notes_tree().
    
    Signed-off-by: Johan Herland <johan@herland.net>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
  2. @jherland @gitster

    notes.h: Make default_notes_ref() available in notes API

    jherland authored gitster committed
    Signed-off-by: Johan Herland <johan@herland.net>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
  3. @jherland @gitster

    (trivial) notes.h: Minor documentation fixes to copy_notes()

    jherland authored gitster committed
    Signed-off-by: Johan Herland <johan@herland.net>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
Commits on Aug 31, 2010
  1. @jherland @gitster

    notes: Don't create (empty) commit when removing non-existing notes

    jherland authored gitster committed
    Extend remove_note() in the notes API to return whether or not a note was
    actually removed. Use this in 'git notes remove' to skip the creation of
    a notes commit when no notes were actually removed.
    
    Also add a test illustrating the change in behavior.
    
    Signed-off-by: Johan Herland <johan@herland.net>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
Commits on Feb 14, 2010
  1. @jherland @gitster

    Notes API: prune_notes(): Prune notes that belong to non-existing obj…

    jherland authored gitster committed
    …ects
    
    When an object is made unreachable by Git, any notes that annotate that object
    are not automagically made unreachable, since all notes are always trivially
    reachable from a notes ref. In order to remove notes for non-existing objects,
    we therefore need to add functionality for traversing the notes tree and
    explicitly removing references to notes that annotate non-reachable objects.
    Thus the notes objects themselves also become unreachable, and are removed
    by a later garbage collect.
    
    prune_notes() performs this traversal (by using for_each_note() internally),
    and removes the notes in question from the notes tree.
    
    Note that the effect of prune_notes() is not persistent unless a subsequent
    call to write_notes_tree() is made.
    
    Signed-off-by: Johan Herland <johan@herland.net>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
  2. @jherland @gitster

    Teach notes code to properly preserve non-notes in the notes tree

    jherland authored gitster committed
    The note tree structure allows for non-note entries to coexist with note
    entries in a notes tree. Although we certainly expect there to be very
    few non-notes in a notes tree, we should still support them to a certain
    degree.
    
    This patch teaches the notes code to preserve non-notes when updating the
    notes tree with write_notes_tree(). Non-notes are not affected by fanout
    restructuring.
    
    For non-notes to be handled correctly, we can no longer allow subtree
    entries that do not match the fanout structure produced by the notes code
    itself. This means that fanouts like 4/36, 6/34, 8/32, 4/4/32, etc. are
    no longer recognized as note subtrees; only 2-based fanouts are allowed
    (2/38, 2/2/36, 2/2/2/34, etc.). Since the notes code has never at any point
    _produced_ non-2-based fanouts, it is highly unlikely that this change will
    cause problems for anyone.
    
    The patch also adds some tests verifying the correct handling of non-notes
    in a notes tree.
    
    Signed-off-by: Johan Herland <johan@herland.net>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
  3. @jherland @gitster

    Refactor notes concatenation into a flexible interface for combining …

    jherland authored gitster committed
    …notes
    
    When adding a note to an object that already has an existing note, the
    current solution is to concatenate the contents of the two notes. However,
    the caller may instead wish to _overwrite_ the existing note with the new
    note, or maybe even _ignore_ the new note, and keep the existing one. There
    might also be other ways of combining notes that are only known to the
    caller.
    
    Therefore, instead of unconditionally concatenating notes, we let the caller
    specify how to combine notes, by passing in a pointer to a function for
    combining notes. The caller may choose to implement its own function for
    notes combining, but normally one of the following three conveniently
    supplied notes combination functions will be sufficient:
    
    - combine_notes_concatenate() combines the two notes by appending the
      contents of the new note to the contents of the existing note.
    
    - combine_notes_overwrite() replaces the existing note with the new note.
    
    - combine_notes_ignore() keeps the existing note, and ignores the new note.
    
    A combine_notes function can be passed to init_notes() to choose a default
    combine_notes function for that notes tree. If NULL is given, the notes tree
    falls back to combine_notes_concatenate() as the ultimate default.
    
    A combine_notes function can also be passed directly to add_note(), to
    control the notes combining behaviour for a note addition in particular.
    If NULL is passed, the combine_notes function registered for the given
    notes tree is used.
    
    Signed-off-by: Johan Herland <johan@herland.net>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
  4. @jherland @gitster

    Notes API: Allow multiple concurrent notes trees with new struct note…

    jherland authored gitster committed
    …s_tree
    
    The new struct notes_tree encapsulates access to a specific notes tree.
    It is provided to allow callers to make use of several different notes trees
    simultaneously.
    
    A struct notes_tree * parameter is added to every function in the notes API.
    In all cases, NULL can be passed, in which case the fallback "default" notes
    tree (default_notes_tree) is used.
    
    Signed-off-by: Johan Herland <johan@herland.net>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
  5. @jherland @gitster

    Notes API: write_notes_tree(): Store the notes tree in the database

    jherland authored gitster committed
    Uses for_each_note() to traverse the notes tree, and produces tree
    objects on the fly representing the "on-disk" version of the notes
    tree with appropriate fanout.
    
    Signed-off-by: Johan Herland <johan@herland.net>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
  6. @jherland @gitster

    Notes API: for_each_note(): Traverse the entire notes tree with a cal…

    jherland authored gitster committed
    …lback
    
    This includes a first attempt at creating an optimal fanout scheme (which
    is calculated on-the-fly, while traversing).
    
    Signed-off-by: Johan Herland <johan@herland.net>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
  7. @jherland @gitster

    Notes API: get_note(): Return the note annotating the given object

    jherland authored gitster committed
    Created by a simple cleanup and rename of lookup_notes().
    
    Signed-off-by: Johan Herland <johan@herland.net>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
  8. @jherland @gitster

    Notes API: remove_note(): Remove note objects from the notes tree str…

    jherland authored gitster committed
    …ucture
    
    This includes adding internal functions for maintaining a healthy notes tree
    structure after removing individual notes.
    
    Signed-off-by: Johan Herland <johan@herland.net>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
  9. @jherland @gitster

    Notes API: add_note(): Add note objects to the internal notes tree st…

    jherland authored gitster committed
    …ructure
    
    Signed-off-by: Johan Herland <johan@herland.net>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
  10. @jherland @gitster

    Notes API: init_notes(): Initialize the notes tree from the given not…

    jherland authored gitster committed
    …es ref
    
    Created by a simple refactoring of initialize_notes().
    
    Also add a new 'flags' parameter, which is a bitwise combination of notes
    initialization flags. For now, there is only one flag - NOTES_INIT_EMPTY -
    which indicates that the notes tree should not auto-load the contents of
    the given (or default) notes ref, but rather should leave the notes tree
    initialized to an empty state. This will become useful in the future when
    manipulating the notes tree through the notes API.
    
    Signed-off-by: Johan Herland <johan@herland.net>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
  11. @jherland @gitster

    Notes API: get_commit_notes() -> format_note() + remove the commit re…

    jherland authored gitster committed
    …striction
    
    There is really no reason why only commit objects can be annotated. By
    changing the struct commit parameter to get_commit_notes() into a sha1 we
    gain the ability to annotate any object type. To reflect this in the function
    naming as well, we rename get_commit_notes() to format_note().
    
    This patch also fixes comments and variable names throughout notes.c as a
    consequence of the removal of the unnecessary 'commit' restriction.
    
    Signed-off-by: Johan Herland <johan@herland.net>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
Commits on Oct 20, 2009
  1. @jherland @gitster

    Teach notes code to free its internal data structures on request

    jherland authored gitster committed
    There's no need to be rude to memory-concious callers...
    
    This patch has been improved by the following contributions:
    - Junio C Hamano: avoid old-style declaration
    
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
    Signed-off-by: Johan Herland <johan@herland.net>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
  2. @jherland @gitster

    Add flags to get_commit_notes() to control the format of the note string

    jherland authored gitster committed
    This patch adds the following flags to get_commit_notes() for adjusting the
    format of the produced note string:
    - NOTES_SHOW_HEADER: Print "Notes:" line before the notes contents
    - NOTES_INDENT: Indent notes contents by 4 spaces
    
    Suggested-by: Johannes Schindelin <johannes.schindelin@gmx.de>
    Signed-off-by: Johan Herland <johan@herland.net>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
Something went wrong with that request. Please try again.