Re: Storing additional information in commit headers

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, Aug 02, 2011 at 09:06:45PM +0200, martin f krafft wrote:

> It just seems to me that per-ref storage is a lot further away than
> per-commit storage, and I'd really like to move forward with TopGit…

I don't think it's that hard. For example:

  # our mapping for all refs, and the history of that mapping, will be
  # stored under this ref
  MAP=refs/topgit/metadata

  refmap_set() {
    (
      # start with a pristine index based on the current map
      GIT_INDEX_FILE="$(git rev-parse --git-dir)/tg-meta-index"
      export GIT_INDEX_FILE
      if git rev-parse -q --verify $MAP >/dev/null; then
        git read-tree $MAP
      fi

      # and then put our new ref and metadata in
      blob=`git hash-object --stdin -w`
      git update-index --add --cacheinfo 100644 $blob $1
      tree=`git write-tree`
      parent=$(git rev-parse -q --verify $MAP)
      commit=`echo 'updated map' | git commit-tree $tree ${parent:+-p $parent}`
      git update-ref $MAP $commit $old
    )
  }

  refmap_get() {
    git cat-file blob $MAP:$1
  }

  # and some examples of use
  echo some metadata | refmap_set refs/heads/foo
  refmap_get refs/heads/foo |
    sed 's/meta/changed &/' |
    refmap_set refs/heads/foo

It's a little more clunky than notes, of course, but it's not too bad to
put into a script. The tricky part is how to handle fetching and merging
the metadata ref from other people. But that's not really different from
notes. In either case, you're probably going to want to make a custom
merge program for combining the meta-information.

-Peff
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]