git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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-$$
Previous: Junio C HamanoNext: Ryan Anderson
Message 4 of 6 in “RE: What's in git.git”
  1. Luck, TonyFeb 9, 2006
  2. Junio C HamanoFeb 10, 2006
  3. Junio C HamanoFeb 10, 2006
  4. Luck, TonyFeb 14, 2006
  5. Ryan AndersonFeb 10, 2006
  6. Junio C HamanoFeb 10, 2006

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.