[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Condor-devel] Merging only the doc/ subtree
- Date: Mon, 19 Sep 2011 11:52:49 -0700
- From: Erik Erlandson <eje@xxxxxxxxxx>
- Subject: Re: [Condor-devel] Merging only the doc/ subtree
> This will merge only the changes below doc/.
Looking at the way this tool is implemented, it seems like it might make
a cool RFE for the git project, e.g. a new "--path" option on the 'git
merge' command, or expanding the semantic of 'git merge [...] <commit>'
to include 'git merge [...] <commit>[:path]', etc.
>
> #! /usr/bin/env bash
>
> # First check that we have no changes to commit
> if ! git diff --quiet || ! git diff --cached --quiet; then
> echo "You have uncommitted changes"
> echo "Commit your changes; then run again"
> exit 1
> fi
>
> #Check that we are actually on a branch
> if ! git symbolic-ref -q HEAD; then
> echo "You are on a detached HEAD"
> exit 1
> fi
>
> #Find the merge base between HEAD and the merge candidate
> MB="$(git merge-base HEAD $1)"
> if test -z "$MB"; then
> # Exit if there is no merge-base
> echo "No merge base; I won't know how to merge"
> exit 1
> fi
>
> # Get the tree of the merge base
> MT="$(git rev-parse ${MB}^{tree})"
>
> # Get our tree (the one we are sitting on now)
> HT="$(git rev-parse HEAD^{tree})";
>
> # Delete doc/ from our index. This does not mess with our working tree!
> # Even if it did, we checked above that our working tree is clean and
> # everything is committed. (So no data will be lost)
> git rm -rf --cached doc/
>
> # Read in the doc tree from the merge candidate
> git read-tree --prefix=doc/ ${1}:doc/
>
> # Create a new tree
> TT="$(git write-tree)"
>
> # Report on differences we found we should have only one line, that
> # looks like
> #
> # :040000 040000 8091b82... 6c5be8f... M doc
> #
> git diff-tree --abbrev $HT $TT
>
> # This resets our tree
> git reset --hard HEAD
> git read-tree -u -m $MT $HT $TT
> git merge-index -o $(git --exec-path)/git-merge-one-file -a
>
> # This next part is what I left off the last message
> # Tell git we are doing a merge
> git update-ref MERGE_HEAD $(git rev-parse $1)
>
> # Assert in the commit message that we are doing a doc-only merge
> echo "Doing a doc-only merge from '$1'" >> $(git rev-parse --git-dir)/MERGE_MSG
>
> # Now you should be able to resolve conflicts, etc, as after a "normal" merge.
> _______________________________________________
> Condor-devel mailing list
> Condor-devel@xxxxxxxxxxx
> https://lists.cs.wisc.edu/mailman/listinfo/condor-devel