class Gollum::Wiki

Attributes

default_committer_email[RW]

Sets the default email for commits.

default_committer_name[RW]

Sets the default name for commits.

default_options[RW]

Hash for setting different default wiki options These defaults can be overridden by options passed directly to initialize()

default_ref[RW]

Sets the default ref for the wiki.

default_ws_subs[RW]

Array of chars to substitute whitespace for when trying to locate file in git repo.

file_class[W]

Sets the file class used by all instances of this Wiki.

history_sanitization[W]

Sets sanitization options. Set to false to deactivate sanitization altogether.

markup_classes[W]

Sets the markup class used by all instances of this Wiki.

page_class[W]

Sets the page class used by all instances of this Wiki.

sanitization[W]

Sets sanitization options. Set to false to deactivate sanitization altogether.

bar_side[R]

Gets side on which the sidebar should be shown

base_path[R]

The String base path to prefix to internal links. For example, when set to “/wiki”, the page “Hobbit” will be linked as “/wiki/Hobbit”. Defaults to “/”.

collapse_tree[R]

Start with collapsed file view. Default: false

css[R]

Injects custom css from custom.css in root repo. Defaults to false

file_class[R]

Gets the file class used by all instances of this Wiki.

h1_title[R]

Sets page title to value of first h1 Defaults to false

history_sanitization[R]

Gets the sanitization options for older page revisions used by this Wiki.

index_page[R]

Gets the custom index page for / and subdirs (e.g. foo/)

live_preview[R]

Gets the boolean live preview value.

markup_classes[R]

Gets the markup class used by all instances of this Wiki.

mathjax[R]

Toggles mathjax.

page_class[R]

Gets the page class used by all instances of this Wiki.

page_file_dir[R]

Gets the String directory in which all page files reside.

path[R]

The String path to the Git repository that holds the Gollum site.

Returns the String path.

ref[R]

Gets the String ref in which all page files reside.

repo[R]

The Grit::Repo associated with the wiki.

Returns the Grit::Repo.

sanitization[R]

Gets the sanitization options for current pages used by this Wiki.

show_all[R]

Toggles showing all files in files view. Default is false. When false, only valid pages in the git repo are displayed.

universal_toc[R]

Toggles display of universal table of contents

user_icons[R]

Toggles user icons. Default: 'none'

ws_subs[R]

Gets the Array of chars to sub for ws in filenames.

Public Class Methods

default_markup_class(language=:default)
Alias for: markup_class
default_markup_class=(default)
Alias for: markup_class=
file_class() click to toggle source

Gets the file class used by all instances of this Wiki. Default: Gollum::File.

# File lib/gollum-lib/wiki.rb, line 52
def file_class
  @file_class ||
    if superclass.respond_to?(:file_class)
      superclass.file_class
    else
      ::Gollum::File
    end
end
history_sanitization() click to toggle source

Gets the default sanitization options for older page revisions used by instances of this Wiki.

# File lib/gollum-lib/wiki.rb, line 99
def history_sanitization
  if @history_sanitization.nil?
    @history_sanitization = sanitization ?
      sanitization.history_sanitization  :
      false
  end
  @history_sanitization
end
markup_class(language=:default) click to toggle source

Gets the default markup class used by all instances of this Wiki. Kept for backwards compatibility until Gollum v2.x

# File lib/gollum-lib/wiki.rb, line 74
def markup_class(language=:default)
  markup_classes[language]
end
Also aliased as: default_markup_class
markup_class=(default) click to toggle source

Sets the default markup class used by all instances of this Wiki. Kept for backwards compatibility until Gollum v2.x

# File lib/gollum-lib/wiki.rb, line 80
def markup_class=(default)
  @markup_classes = Hash.new(default).update(markup_classes)
  default
end
Also aliased as: default_markup_class=
markup_classes() click to toggle source

Gets the markup class used by all instances of this Wiki. Default: Gollum::Markup

# File lib/gollum-lib/wiki.rb, line 63
def markup_classes
  @markup_classes ||=
    if superclass.respond_to?(:markup_classes)
      superclass.markup_classes
    else
      Hash.new(::Gollum::Markup)
    end
end
new(path, options = {}) click to toggle source

Public: Initialize a new Gollum Repo.

path - The String path to the Git repository that holds the Gollum

site.

options - Optional Hash:

:universal_toc - Table of contents on all pages.  Default: false
:live_preview  - Livepreview editing for markdown files. Default: true
:base_path     - String base path for all Wiki links.
                 Default: "/"
:page_class    - The page Class. Default: Gollum::Page
:file_class    - The file Class. Default: Gollum::File
:markup_classes - A hash containing the markup Classes for each
                  document type. Default: { Gollum::Markup }
:sanitization  - An instance of Sanitization.
:page_file_dir - String the directory in which all page files reside
:ref - String the repository ref to retrieve pages from
:ws_subs       - Array of chars to sub for ws in filenames.
:mathjax       - Set to false to disable mathjax.
:user_icons    - Enable user icons on the history page. [gravatar, identicon, none].
                 Default: none
:show_all      - Show all files in file view, not just valid pages.
                 Default: false
:collapse_tree - Start with collapsed file view. Default: false
:css           - Include the custom.css file from the repo.
:h1_title      - Concatenate all h1's on a page to form the
                 page title.
:index_page    - The default page to retrieve or create if the 
                 a directory is accessed.
:bar_side      - Where the sidebar should be displayed, may be:
                  - :left
                  - :right

Returns a fresh Gollum::Repo.

# File lib/gollum-lib/wiki.rb, line 186
def initialize(path, options = {})
  options = self.class.default_options.merge(options)
  if path.is_a?(GitAccess)
    options[:access] = path
    path             = path.path
  end

  # Use .fetch instead of ||
  #
  # o = { :a => false }
  # o[:a] || true # => true
  # o.fetch :a, true # => false

  @path                 = path
  @repo_is_bare         = options.fetch :repo_is_bare, nil
  @page_file_dir        = options.fetch :page_file_dir, nil
  @access               = options.fetch :access, GitAccess.new(path, @page_file_dir, @repo_is_bare)
  @base_path            = options.fetch :base_path, "/"
  @page_class           = options.fetch :page_class, self.class.page_class
  @file_class           = options.fetch :file_class, self.class.file_class
  @markup_classes       = options.fetch :markup_classes, self.class.markup_classes
  @repo                 = @access.repo
  @ref                  = options.fetch :ref, self.class.default_ref
  @sanitization         = options.fetch :sanitization, self.class.sanitization
  @ws_subs              = options.fetch :ws_subs, self.class.default_ws_subs
  @history_sanitization = options.fetch :history_sanitization, self.class.history_sanitization
  @live_preview         = options.fetch :live_preview, true
  @universal_toc        = options.fetch :universal_toc, false
  @mathjax              = options.fetch :mathjax, false
  @show_all             = options.fetch :show_all, false
  @collapse_tree        = options.fetch :collapse_tree, false
  @css                  = options.fetch :css, false
  @h1_title             = options.fetch :h1_title, false
  @index_page           = options.fetch :index_page, 'Home'
  @bar_side             = options.fetch :sidebar, :right
  @user_icons           = ['gravatar', 'identicon'].include?( options[:user_icons] ) ?
                          options[:user_icons] : 'none'
end
page_class() click to toggle source

Gets the page class used by all instances of this Wiki. Default: Gollum::Page.

# File lib/gollum-lib/wiki.rb, line 41
def page_class
  @page_class ||
    if superclass.respond_to?(:page_class)
      superclass.page_class
    else
      ::Gollum::Page
    end
end
sanitization() click to toggle source

Gets the default sanitization options for current pages used by instances of this Wiki.

# File lib/gollum-lib/wiki.rb, line 90
def sanitization
  if @sanitization.nil?
    @sanitization = Sanitization.new
  end
  @sanitization
end

Public Instance Methods

clear_cache() click to toggle source

Public: Refreshes just the cached Git reference data. This should be called after every Gollum update.

Returns nothing.

# File lib/gollum-lib/wiki.rb, line 637
def clear_cache
  @access.refresh
end
commit_for(ref) click to toggle source

Gets the commit object for the given ref or sha.

ref - A string ref or SHA pointing to a valid commit.

Returns a Grit::Commit instance.

# File lib/gollum-lib/wiki.rb, line 805
def commit_for(ref)
  @access.commit(ref)
rescue Grit::GitRuby::Repository::NoSuchShaFound
end
default_committer_email() click to toggle source

Gets the default email for commits.

Returns the String email address.

# File lib/gollum-lib/wiki.rb, line 795
def default_committer_email
  @default_committer_email ||=          @repo.config['user.email'] || self.class.default_committer_email
end
default_committer_name() click to toggle source

Gets the default name for commits.

Returns the String name.

# File lib/gollum-lib/wiki.rb, line 787
def default_committer_name
  @default_committer_name ||=          @repo.config['user.name'] || self.class.default_committer_name
end
delete_page(page, commit) click to toggle source

Public: Delete a page.

page - The Gollum::Page to delete. commit - The commit Hash details:

:message   - The String commit message.
:name      - The String author full name.
:email     - The String email address.
:parent    - Optional Grit::Commit parent to this update.
:tree      - Optional String SHA of the tree to create the
             index from.
:committer - Optional Gollum::Committer instance.  If provided,
             assume that this operation is part of batch of
             updates and the commit happens later.

Returns the String SHA1 of the newly written version, or the Gollum::Committer instance if this is part of a batch update.

# File lib/gollum-lib/wiki.rb, line 456
def delete_page(page, commit)
  multi_commit = false

  committer = if obj = commit[:committer]
    multi_commit = true
    obj
  else
    Committer.new(self, commit)
  end

  committer.delete(page.path)

  committer.after_commit do |index, sha|
    dir = ::File.dirname(page.path)
    dir = '' if dir == '.'

    @access.refresh
    index.update_working_dir(dir, page.filename_stripped, page.format)
  end

  multi_commit ? committer : committer.commit
end
exist?() click to toggle source

Public: check whether the wiki's git repo exists on the filesystem.

Returns true if the repo exists, and false if it does not.

# File lib/gollum-lib/wiki.rb, line 228
def exist?
  @access.exist?
end
file(name, version = @ref) click to toggle source

Public: Get the static file for a given name.

name - The full String pathname to the file. version - The String version ID to find (default: @ref).

Returns a Gollum::File or nil if no matching file was found.

# File lib/gollum-lib/wiki.rb, line 261
def file(name, version = @ref)
  @file_class.new(self).find(name, version)
end
file_list(ref) click to toggle source

Fill an array with a list of files.

ref - A String ref that is either a commit SHA or references one.

Returns a flat Array of Gollum::File instances.

# File lib/gollum-lib/wiki.rb, line 743
def file_list(ref)
  if sha = @access.ref_to_sha(ref)
    commit = @access.commit(sha)
    tree_map_for(sha).inject([]) do |list, entry|
      next list if entry.name.start_with?('_')
      next list if @page_class.valid_page_name?(entry.name)
      list << entry.file(self, commit)
    end
  else
    []
  end
end
files(treeish = nil) click to toggle source

Public: Lists all non-page files for this wiki.

treeish - The String commit ID or ref to find (default: @ref)

Returns an Array of Gollum::File instances.

# File lib/gollum-lib/wiki.rb, line 568
def files(treeish = nil)
  file_list(treeish || @ref)
end
full_reverse_diff(sha1, sha2 = nil) click to toggle source

Creates a reverse diff for the given SHAs.

sha1 - String SHA1 of the earlier parent if two SHAs are given,

or the child.

sha2 - Optional String SHA1 of the child.

Returns a String of the reverse Diff to apply.

# File lib/gollum-lib/wiki.rb, line 780
def full_reverse_diff(sha1, sha2 = nil)
  full_reverse_diff_for(nil, sha1, sha2)
end
full_reverse_diff_for(page, sha1, sha2 = nil) click to toggle source

Creates a reverse diff for the given SHAs on the given Gollum::Page.

page - The Gollum::Page to scope the patch to, or a String Path. sha1 - String SHA1 of the earlier parent if two SHAs are given,

or the child.

sha2 - Optional String SHA1 of the child.

Returns a String of the reverse Diff to apply.

# File lib/gollum-lib/wiki.rb, line 764
def full_reverse_diff_for(page, sha1, sha2 = nil)
  sha1, sha2 = "#{sha1}^", sha1 if sha2.nil?
  args = [{:R => true}, sha1, sha2]
  if page
    args << '--' << (page.respond_to?(:path) ? page.path : page.to_s)
  end
  repo.git.native(:diff, *args)
end
history_sanitizer() click to toggle source

Public: Creates a Sanitize instance using the Wiki's history sanitization options.

Returns a Sanitize instance.

# File lib/gollum-lib/wiki.rb, line 655
def history_sanitizer
  if options = history_sanitization
    @history_sanitizer ||= options.to_sanitize
  end
end
inspect() click to toggle source
# File lib/gollum-lib/wiki.rb, line 828
def inspect
  %Q(#<#{self.class.name}:#{object_id} #{@repo.path}>)
end
log(options = {}) click to toggle source

Public: All of the versions that have touched the Page.

options - The options Hash:

:page     - The Integer page number (default: 1).
:per_page - The Integer max count of items to return.

Returns an Array of Grit::Commit.

# File lib/gollum-lib/wiki.rb, line 629
def log(options = {})
  @repo.log(@ref, nil, log_pagination_options(options))
end
normalize(data) click to toggle source

Normalize the data.

data - The String data to be normalized.

Returns the normalized data String.

# File lib/gollum-lib/wiki.rb, line 707
def normalize(data)
  data.gsub(/\r/, '')
end
page(name, version = @ref, dir = nil, exact = false) click to toggle source

Public: Get the formatted page for a given page name, version, and dir.

name - The human or canonical String page name of the wiki page. version - The String version ID to find (default: @ref). dir - The directory String relative to the repo.

Returns a Gollum::Page or nil if no matching page was found.

# File lib/gollum-lib/wiki.rb, line 239
def page(name, version = @ref, dir = nil, exact = false)
  version = @ref if version.nil?
  @page_class.new(self).find(name, version, dir, exact)
end
page_file_name(name, format) click to toggle source

Assemble a Page's filename from its name and format.

name - The String name of the page (should be pre-canonicalized). format - The Symbol format of the page.

Returns the String filename.

# File lib/gollum-lib/wiki.rb, line 717
def page_file_name(name, format)
  name + '.' + @page_class.format_to_ext(format)
end
paged(name, dir = nil, exact = false, version = @ref) click to toggle source

Public: Convenience method instead of calling page(name, nil, dir).

name - The human or canonical String page name of the wiki page. version - The String version ID to find (default: @ref). dir - The directory String relative to the repo.

Returns a Gollum::Page or nil if no matching page was found.

# File lib/gollum-lib/wiki.rb, line 251
def paged(name, dir = nil, exact = false, version = @ref)
  page(name, version, dir, exact)
end
pages(treeish = nil) click to toggle source

Public: Lists all pages for this wiki.

treeish - The String commit ID or ref to find (default: @ref)

Returns an Array of Gollum::Page instances.

# File lib/gollum-lib/wiki.rb, line 559
def pages(treeish = nil)
  tree_list(treeish || @ref)
end
preview_page(name, data, format) click to toggle source

Public: Create an in-memory Page with the given data and format. This is useful for previewing what content will look like before committing it to the repository.

name - The String name of the page. format - The Symbol format of the page. data - The new String contents of the page.

Returns the in-memory Gollum::Page.

# File lib/gollum-lib/wiki.rb, line 274
def preview_page(name, data, format)
  page = @page_class.new(self)
  ext  = @page_class.format_to_ext(format.to_sym)
  name = @page_class.cname(name) + '.' + ext
  blob = OpenStruct.new(:name => name, :data => data, :is_symlink => false)
  page.populate(blob)
  page.version = @access.commit('master')
  page
end
rename_page(page, rename, commit = {}) click to toggle source

Public: Rename an existing page without altering content.

page - The Gollum::Page to update. rename - The String extension-less full path of the page (leading '/' is ignored). commit - The commit Hash details:

:message   - The String commit message.
:name      - The String author full name.
:email     - The String email address.
:parent    - Optional Grit::Commit parent to this update.
:tree      - Optional String SHA of the tree to create the
             index from.
:committer - Optional Gollum::Committer instance.  If provided,
             assume that this operation is part of batch of
             updates and the commit happens later.

Returns the String SHA1 of the newly written version, or the Gollum::Committer instance if this is part of a batch update. Returns false if the operation is a NOOP.

# File lib/gollum-lib/wiki.rb, line 347
def rename_page(page, rename, commit = {})
  return false if page.nil?
  return false if rename.nil? or rename.empty?

  (target_dir, target_name) = ::File.split(rename)
  (source_dir, source_name) = ::File.split(page.path)
  source_name = page.filename_stripped

  # File.split gives us relative paths with ".", commiter.add_to_index doesn't like that.
  target_dir = '' if target_dir == '.'
  source_dir = '' if source_dir == '.'
  target_dir = target_dir.gsub(/^\//, '')

  # if the rename is a NOOP, abort
  if source_dir == target_dir and source_name == target_name
    return false
  end

  multi_commit = false
  committer = if obj = commit[:committer]
    multi_commit = true
    obj
  else
    Committer.new(self, commit)
  end

  committer.delete(page.path)
  committer.add_to_index(target_dir, target_name, page.format, page.raw_data, :allow_same_ext)

  committer.after_commit do |index, sha|
    @access.refresh
    index.update_working_dir(source_dir, source_name, page.format)
    index.update_working_dir(target_dir, target_name, page.format)
  end

  multi_commit ? committer : committer.commit
end
revert_commit(sha1, sha2 = nil, commit = {}) click to toggle source

Public: Applies a reverse diff to the repo. If only 1 SHA is given, the reverse diff will be taken from its parent (^SHA…SHA). If two SHAs are given, the reverse diff is taken from SHA1…SHA2.

sha1 - String SHA1 of the earlier parent if two SHAs are given,

or the child.

sha2 - Optional String SHA1 of the child. commit - The commit Hash details:

:message - The String commit message.
:name    - The String author full name.
:email   - The String email address.

Returns a String SHA1 of the new commit, or nil if the reverse diff does not apply.

# File lib/gollum-lib/wiki.rb, line 550
def revert_commit(sha1, sha2 = nil, commit = {})
  revert_page(nil, sha1, sha2, commit)
end
revert_page(page, sha1, sha2 = nil, commit = {}) click to toggle source

Public: Applies a reverse diff for a given page. If only 1 SHA is given, the reverse diff will be taken from its parent (^SHA…SHA). If two SHAs are given, the reverse diff is taken from SHA1…SHA2.

page - The Gollum::Page to delete. sha1 - String SHA1 of the earlier parent if two SHAs are given,

or the child.

sha2 - Optional String SHA1 of the child. commit - The commit Hash details:

:message - The String commit message.
:name    - The String author full name.
:email   - The String email address.
:parent  - Optional Grit::Commit parent to this update.

Returns a String SHA1 of the new commit, or nil if the reverse diff does not apply.

# File lib/gollum-lib/wiki.rb, line 495
def revert_page(page, sha1, sha2 = nil, commit = {})
  if sha2.is_a?(Hash)
    commit = sha2
    sha2   = nil
  end

  patch     = full_reverse_diff_for(page, sha1, sha2)
  committer = Committer.new(self, commit)
  parent    = committer.parents[0]
  committer.options[:tree] = @repo.git.apply_patch(parent.sha, patch)
  return false unless committer.options[:tree]
  committer.after_commit do |index, sha|
    @access.refresh

    files = []
    if page
      files << [page.path, page.filename_stripped, page.format]
    else
      # Grit::Diff can't parse reverse diffs.... yet
      patch.each_line do |line|
        if line =~ %r{^diff --git b/.+? a/(.+)$}
          path = $1
          ext  = ::File.extname(path)
          name = ::File.basename(path, ext)
          if format = ::Gollum::Page.format_for(ext)
            files << [path, name, format]
          end
        end
      end
    end

    files.each do |(path, name, format)|
      dir = ::File.dirname(path)
      dir = '' if dir == '.'
      index.update_working_dir(dir, name, format)
    end
  end

  committer.commit
end
sanitizer() click to toggle source

Public: Creates a Sanitize instance using the Wiki's sanitization options.

Returns a Sanitize instance.

# File lib/gollum-lib/wiki.rb, line 645
def sanitizer
  if options = sanitization
    @sanitizer ||= options.to_sanitize
  end
end
size(ref = nil) click to toggle source

Public: Returns the number of pages accessible from a commit

ref - A String ref that is either a commit SHA or references one.

Returns a Fixnum

# File lib/gollum-lib/wiki.rb, line 577
def size(ref = nil)
  tree_map_for(ref || @ref).inject(0) do |num, entry|
    num + (@page_class.valid_page_name?(entry.name) ? 1 : 0)
  end
rescue Grit::GitRuby::Repository::NoSuchShaFound
  0
end
tree_list(ref) click to toggle source

Fill an array with a list of pages.

ref - A String ref that is either a commit SHA or references one.

Returns a flat Array of Gollum::Page instances.

# File lib/gollum-lib/wiki.rb, line 726
def tree_list(ref)
  if sha = @access.ref_to_sha(ref)
    commit = @access.commit(sha)
    tree_map_for(sha).inject([]) do |list, entry|
      next list unless @page_class.valid_page_name?(entry.name)
      list << entry.page(self, commit)
    end
  else
    []
  end
end
tree_map_for(ref, ignore_page_file_dir=false) click to toggle source

Finds a full listing of files and their blob SHA for a given ref. Each listing is cached based on its actual commit SHA.

ref - A String ref that is either a commit SHA or references one. ignore_page_file_dir - Boolean, if true, searches all files within the git repo, regardless of dir/subdir

Returns an Array of BlobEntry instances.

# File lib/gollum-lib/wiki.rb, line 817
def tree_map_for(ref, ignore_page_file_dir=false)
  if ignore_page_file_dir && !@page_file_dir.nil?
    @root_access ||= GitAccess.new(path, nil, @repo_is_bare)
    @root_access.tree(ref)
  else
    @access.tree(ref)
  end
rescue Grit::GitRuby::Repository::NoSuchShaFound
  []
end
update_page(page, name, format, data, commit = {}) click to toggle source

Public: Update an existing page with new content. The location of the page inside the repository will not change. If the given format is different than the current format of the page, the filename will be changed to reflect the new format.

page - The Gollum::Page to update. name - The String extension-less name of the page. format - The Symbol format of the page. data - The new String contents of the page. commit - The commit Hash details:

:message   - The String commit message.
:name      - The String author full name.
:email     - The String email address.
:parent    - Optional Grit::Commit parent to this update.
:tree      - Optional String SHA of the tree to create the
             index from.
:committer - Optional Gollum::Committer instance.  If provided,
             assume that this operation is part of batch of
             updates and the commit happens later.

Returns the String SHA1 of the newly written version, or the Gollum::Committer instance if this is part of a batch update.

# File lib/gollum-lib/wiki.rb, line 407
def update_page(page, name, format, data, commit = {})
  name   ||= page.name
  format ||= page.format
  dir      = ::File.dirname(page.path)
  dir      = '' if dir == '.'
  filename = (rename = page.name != name) ?
    Gollum::Page.cname(name) : page.filename_stripped

  multi_commit = false

  committer = if obj = commit[:committer]
    multi_commit = true
    obj
  else
    Committer.new(self, commit)
  end

  if !rename && page.format == format
    committer.add(page.path, normalize(data))
  else
    committer.delete(page.path)
    committer.add_to_index(dir, filename, format, data, :allow_same_ext)
  end

  committer.after_commit do |index, sha|
    @access.refresh
    index.update_working_dir(dir, page.filename_stripped, page.format)
    index.update_working_dir(dir, filename, format)
  end

  multi_commit ? committer : committer.commit
end
write_page(name, format, data, commit = {}, dir = '') click to toggle source

Public: Write a new version of a page to the Gollum repo root.

name - The String name of the page. format - The Symbol format of the page. data - The new String contents of the page. commit - The commit Hash details:

:message   - The String commit message.
:name      - The String author full name.
:email     - The String email address.
:parent    - Optional Grit::Commit parent to this update.
:tree      - Optional String SHA of the tree to create the
             index from.
:committer - Optional Gollum::Committer instance.  If provided,
             assume that this operation is part of batch of
             updates and the commit happens later.

dir - The String subdirectory of the Gollum::Page without any

prefix or suffix slashes (e.g. "foo/bar").

Returns the String SHA1 of the newly written version, or the Gollum::Committer instance if this is part of a batch update.

# File lib/gollum-lib/wiki.rb, line 303
def write_page(name, format, data, commit = {}, dir = '')
  # spaces must be dashes
  name.gsub!(' ', '-')
  dir.gsub!(' ', '-')

  multi_commit = false

  committer = if obj = commit[:committer]
    multi_commit = true
    obj
  else
    Committer.new(self, commit)
  end

  filename = Gollum::Page.cname(name)

  committer.add_to_index(dir, filename, format, data)

  committer.after_commit do |index, sha|
    @access.refresh
    index.update_working_dir(dir, filename, format)
  end

  multi_commit ? committer : committer.commit
end