Re: What's in git.git
- From
Luck, Tony <tony.luck@intel.com>
- Date
- Feb 14, 2006, 23:10 UTC
- Message-ID
- <20060214231039.GA15680@agluck-lia64.sc.intel.com>
- In-Reply-To
- <7v3bis59un.fsf@assigned-by-dhcp.cox.net>
Show 23 quoted lines
> > (1) First merge "master" into "topic": > > > > $ git checkout topic > > $ git pull . master > > > > (3) Pick commits only on "topic" branch but not on "master" > > > > $ git rev-list --pretty --no-merges master..topic >P.log > > > > This will pick up the three 'o' commits on the lower > > development track and show their commit log message. > > > > > > This obviously would work equally well for single strand of > > pearls case. Maybe you can package the above up, and send in a > > patch to add "git-squash" command? > > I am stupid. (4) can be done a lot more easily. Do not do step > (2) -- you do not need a diff at all. But do do step (3) to get > the logs. Then: > > $ git reset --soft master > $ git commit -F P.log -e
Yes, that all seems to work as advertised. One extra wrinkle was to preserve the author information by grepping out the last Author: line from the log. Here's the work-in-progress version of git-squash (I don't have a "master" branch, so I stuck in the "mbranch" shell variable so there is only one place for me to change ... to mbranch=linus).
Any style (or other) comments? If not I'll package into patch format with a manual page in a few days.
-Tony
#!/bin/sh
. git-sh-setup
branch="$1" mbranch=master
if [ ! -f .git/refs/heads/"$branch" ] then die "Can't see branch '$branch'" fi
if [ -f .git/refs/heads/"$branch"-unsquashed ] then die "Branch '$branch' has been squashed before" fi
cp .git/refs/heads/"$branch" .git/refs/heads/"$branch"-unsquashed
git checkout "$branch" || die "Couldn't checkout '$branch'"
git pull . $mbranch || die "Can't merge $mbranch into $branch"
git-rev-list --pretty --no-merges $mbranch..$branch > /tmp/git-squash-$$
git reset --soft $mbranch
author=$(sed -n -e '/^Author: /s///p' /tmp/git-squash-$$ | tail -1)
git commit --author "$author" -F /tmp/git-squash-$$ -e
rm -f /tmp/git-squash-$$