{"thread":{"id":"3279","subject":"RE: What's in git.git","startedAt":"2006-02-09T23:49:16Z","lastAt":"2006-02-14T23:10:39Z","messageCount":6,"participants":["Luck, Tony","Junio C Hamano","Ryan Anderson"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"15820","messageId":"B8E391BBE9FE384DAA4C5C003888BE6F05AA1FB3@scsmsx401.amr.corp.intel.com","threadId":"3279","inReplyTo":null,"subject":"RE: What's in git.git","fromName":"Luck, Tony","fromEmail":"tony.luck@intel.com","sentAt":"2006-02-09T23:49:16Z","receivedAt":"2006-02-09T23:49:16Z","isPatch":false,"sender":{"key":"tony.luck@intel.com","avatar":"https://avatars.githubusercontent.com/u/5446021?v=4"},"body":"Looks very close to what I want.\n\n> git checkout topic\n> git format-patch --stdout origin > topic-diff\n\n topic-diff contains each commit as a separate message\n\n> $VISUAL topic-diff\n> # Fix comments\n\n so this needs some skill & care to rearrange the pieces\n and end up with legal input to git-am\n\nPerhaps I'd like to have:\n\n git diff SHA-where-I-branched..HEAD\n\nbut I don't see the way to compute the SHA-where-I-branched\n\n-Tony\n"},{"id":"15823","messageId":"7v8xsk5a6k.fsf@assigned-by-dhcp.cox.net","threadId":"3279","inReplyTo":"B8E391BBE9FE384DAA4C5C003888BE6F05AA1FB3@scsmsx401.amr.corp.intel.com","subject":"Re: What's in git.git","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2006-02-10T00:28:35Z","receivedAt":"2006-02-10T00:28:35Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"Luck, Tony\" <tony.luck@intel.com> writes:\n\n> Looks very close to what I want.\n>\n>> git checkout topic\n>> git format-patch --stdout origin > topic-diff\n>\n>  topic-diff contains each commit as a separate message\n>\n>> $VISUAL topic-diff\n>> # Fix comments\n>\n>  so this needs some skill & care to rearrange the pieces\n>  and end up with legal input to git-am\n>\n> Perhaps I'd like to have:\n>\n>  git diff SHA-where-I-branched..HEAD\n>\n> but I don't see the way to compute the SHA-where-I-branched\n>\n> -Tony\n\nIf what you want to end up with is a single commit, that is\neasy.\n\nIf your topic branch is only \"fork from master and never\nre-merge with master but just pile new commits on top of the\ntip, single strand of pearls\" kind,\n\n        git-merge-base master topic\n\nwould find the 'x' commit, where you forked from:\n\n                           \"master\"\n        ---x---o---o---o---o\n            \\\n             o---o---o---o\n                          \"topic\"\n\nIf you have \"my topic will conflict with a change recently done\nin master so let's merge up from master to resolve conflict\nbefore going further\" kind of merge commit on your topic branch,\nthen you cannot have a single two-tree diff easily anyway, but\nin such a case, the following steps would work.\n\n                           \"master\"\n        ---o---o---o---o---o\n            \\       \\\n             o---o---*---o\n                          \"topic\"\n\n  (1) First merge \"master\" into \"topic\":\n\n        $ git checkout topic\n        $ git pull . master\n\n                           \"master\"\n        ---o---o---o---o---o\n            \\       \\       \\ \n             o---o---*---o---*\n                             \"topic\"\n\n      which would give you the rightmost '*' merge.\n\n  (2) Extract diff from \"master\" to '*':\n\n        $ git diff HEAD^2 HEAD >P.diff\n\n      HEAD^1 is previous \"topic\" head and HEAD^2 is what you\n      merged (\"master\").\n\n  (3) Pick commits only on \"topic\" branch but not on \"master\"\n\n        $ git rev-list --pretty --no-merges master..topic >P.log\n\n      This will pick up the three 'o' commits on the lower\n      development track and show their commit log message.\n\n\n  (4) Reset the \"topic\" branch to \"master\", and do the squashed\n      commit:\n\n\t$ git reset --hard master\n        $ git apply --index P.diff\n        $ git commit -F P.log -e\n\nThis obviously would work equally well for single strand of\npearls case.  Maybe you can package the above up, and send in a\npatch to add \"git-squash\" command?\n"},{"id":"15824","messageId":"7v3bis59un.fsf@assigned-by-dhcp.cox.net","threadId":"3279","inReplyTo":"7v8xsk5a6k.fsf@assigned-by-dhcp.cox.net","subject":"Re: What's in git.git","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2006-02-10T00:35:44Z","receivedAt":"2006-02-10T00:35:44Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Junio C Hamano <junkio@cox.net> writes:\n\n> \"Luck, Tony\" <tony.luck@intel.com> writes:\n>\n>> Looks very close to what I want.\n>>\n>>> git checkout topic\n>>> git format-patch --stdout origin > topic-diff\n>>\n>>  topic-diff contains each commit as a separate message\n>>\n>>> $VISUAL topic-diff\n>>> # Fix comments\n>>\n>>  so this needs some skill & care to rearrange the pieces\n>>  and end up with legal input to git-am\n>>\n>> Perhaps I'd like to have:\n>>\n>>  git diff SHA-where-I-branched..HEAD\n>>\n>> but I don't see the way to compute the SHA-where-I-branched\n>>\n>> -Tony\n>\n> If what you want to end up with is a single commit, that is\n> easy.\n>\n> If your topic branch is only \"fork from master and never\n> re-merge with master but just pile new commits on top of the\n> tip, single strand of pearls\" kind,\n>\n>         git-merge-base master topic\n>\n> would find the 'x' commit, where you forked from:\n>\n>                            \"master\"\n>         ---x---o---o---o---o\n>             \\\n>              o---o---o---o\n>                           \"topic\"\n>\n> If you have \"my topic will conflict with a change recently done\n> in master so let's merge up from master to resolve conflict\n> before going further\" kind of merge commit on your topic branch,\n> then you cannot have a single two-tree diff easily anyway, but\n> in such a case, the following steps would work.\n>\n>                            \"master\"\n>         ---o---o---o---o---o\n>             \\       \\\n>              o---o---*---o\n>                           \"topic\"\n>\n>   (1) First merge \"master\" into \"topic\":\n>\n>         $ git checkout topic\n>         $ git pull . master\n>\n>                            \"master\"\n>         ---o---o---o---o---o\n>             \\       \\       \\ \n>              o---o---*---o---*\n>                              \"topic\"\n>\n>       which would give you the rightmost '*' merge.\n>\n>   (2) Extract diff from \"master\" to '*':\n>\n>         $ git diff HEAD^2 HEAD >P.diff\n>\n>       HEAD^1 is previous \"topic\" head and HEAD^2 is what you\n>       merged (\"master\").\n>\n>   (3) Pick commits only on \"topic\" branch but not on \"master\"\n>\n>         $ git rev-list --pretty --no-merges master..topic >P.log\n>\n>       This will pick up the three 'o' commits on the lower\n>       development track and show their commit log message.\n>\n>\n>   (4) Reset the \"topic\" branch to \"master\", and do the squashed\n>       commit:\n>\n> \t$ git reset --hard master\n>         $ git apply --index P.diff\n>         $ git commit -F P.log -e\n>\n> This obviously would work equally well for single strand of\n> pearls case.  Maybe you can package the above up, and send in a\n> patch to add \"git-squash\" command?\n\nI am stupid.  (4) can be done a lot more easily.  Do not do step\n(2) -- you do not need a diff at all.  But do do step (3) to get\nthe logs.  Then:\n\n\t$ git reset --soft master\n        $ git commit -F P.log -e\n\nWhat --soft reset does is to keep the index and the working tree\nas is, but just change the current branch head to point at the\nnamed commit.  So, immediately after the above soft reset, your\ncommit ancestry graph looks like this:\n\n                            \"master\"\n         ---o---o---o---o---o\n                            \"topic\"\n\nand the last commit finally would give you:\n\n\n                            \"master\"\n         ---o---o---o---o---o\n                             \\\n                              o\n                              \"topic\"\n"},{"id":"15825","messageId":"20060210004040.GB2866@mythryan2.michonline.com","threadId":"3279","inReplyTo":"B8E391BBE9FE384DAA4C5C003888BE6F05AA1FB3@scsmsx401.amr.corp.intel.com","subject":"Re: What's in git.git","fromName":"Ryan Anderson","fromEmail":"ryan@michonline.com","sentAt":"2006-02-10T00:40:40Z","receivedAt":"2006-02-10T00:40:40Z","isPatch":false,"sender":{"key":"ryan@michonline.com","avatar":null},"body":"On Thu, Feb 09, 2006 at 03:49:16PM -0800, Luck, Tony wrote:\n> Looks very close to what I want.\n> \n> > git checkout topic\n> > git format-patch --stdout origin > topic-diff\n> \n>  topic-diff contains each commit as a separate message\n> \n> > $VISUAL topic-diff\n> > # Fix comments\n> \n>  so this needs some skill & care to rearrange the pieces\n>  and end up with legal input to git-am\n\nDoh, right, I was thinking \"git apply\" actually.  (Apply the whole thing\nas  single diff - the comments from each commit in the middle should get\nignored.)\n\nNote that I don't believe there is any need to combine the hunks, just\nstick them there in order and it *should* do the right thing.\n\n> Perhaps I'd like to have:\n> \n>  git diff SHA-where-I-branched..HEAD\n> \n> but I don't see the way to compute the SHA-where-I-branched\n\ngit-merge-base topic master ?\n\n-- \n\nRyan Anderson\n  sometimes Pug Majere\n"},{"id":"15826","messageId":"7vvevo3us7.fsf@assigned-by-dhcp.cox.net","threadId":"3279","inReplyTo":"20060210004040.GB2866@mythryan2.michonline.com","subject":"Re: What's in git.git","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2006-02-10T00:46:32Z","receivedAt":"2006-02-10T00:46:32Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Ryan Anderson <ryan@michonline.com> writes:\n\n> Note that I don't believe there is any need to combine the hunks, just\n> stick them there in order and it *should* do the right thing.\n\nProbably not.  I suspect it would not like two pieces of diffs\ntouching the same path in a batch.\n\nFeeding one at a time is OK, though.\n"},{"id":"16167","messageId":"20060214231039.GA15680@agluck-lia64.sc.intel.com","threadId":"3279","inReplyTo":"7v3bis59un.fsf@assigned-by-dhcp.cox.net","subject":"Re: What's in git.git","fromName":"Luck, Tony","fromEmail":"tony.luck@intel.com","sentAt":"2006-02-14T23:10:39Z","receivedAt":"2006-02-14T23:10:39Z","isPatch":false,"sender":{"key":"tony.luck@intel.com","avatar":"https://avatars.githubusercontent.com/u/5446021?v=4"},"body":"> >   (1) First merge \"master\" into \"topic\":\n> >\n> >         $ git checkout topic\n> >         $ git pull . master\n> >\n> >   (3) Pick commits only on \"topic\" branch but not on \"master\"\n> >\n> >         $ git rev-list --pretty --no-merges master..topic >P.log\n> >\n> >       This will pick up the three 'o' commits on the lower\n> >       development track and show their commit log message.\n> >\n> >\n> > This obviously would work equally well for single strand of\n> > pearls case.  Maybe you can package the above up, and send in a\n> > patch to add \"git-squash\" command?\n> \n> I am stupid.  (4) can be done a lot more easily.  Do not do step\n> (2) -- you do not need a diff at all.  But do do step (3) to get\n> the logs.  Then:\n> \n> \t$ git reset --soft master\n>         $ git commit -F P.log -e\n\nYes, that all seems to work as advertised.  One extra wrinkle was to\npreserve the author information by grepping out the last Author: line\nfrom the log.  Here's the work-in-progress version of git-squash (I\ndon't have a \"master\" branch, so I stuck in the \"mbranch\" shell variable\nso there is only one place for me to change ... to mbranch=linus).\n\nAny style (or other) comments?  If not I'll package into patch format\nwith a manual page in a few days.\n\n-Tony\n\n#!/bin/sh\n\n. git-sh-setup\n\nbranch=\"$1\"\nmbranch=master\n\nif [ ! -f .git/refs/heads/\"$branch\" ]\nthen\n\tdie \"Can't see branch '$branch'\"\nfi\n\nif [ -f .git/refs/heads/\"$branch\"-unsquashed ]\nthen\n\tdie \"Branch '$branch' has been squashed before\"\nfi\n\ncp .git/refs/heads/\"$branch\" .git/refs/heads/\"$branch\"-unsquashed\n\ngit checkout \"$branch\" || die \"Couldn't checkout '$branch'\"\n\ngit pull . $mbranch || die \"Can't merge $mbranch into $branch\"\n\ngit-rev-list --pretty --no-merges $mbranch..$branch > /tmp/git-squash-$$\n\ngit reset --soft $mbranch\n\nauthor=$(sed -n -e  '/^Author: /s///p' /tmp/git-squash-$$ | tail -1)\n\ngit commit --author \"$author\" -F /tmp/git-squash-$$ -e\n\nrm -f /tmp/git-squash-$$\n"}]}