Thread (1 message) 1 message, 1 author, 2016-06-15
  • (off-list ancestor, not in this archive)
  • Re: What's in git.git · Junio C Hamano <hidden> · 2016-06-15

Re: What's in git.git

From: Junio C Hamano <hidden>
Date: 2016-06-15 22:42:18

"Luck, Tony" [off-list ref] writes:
Looks very close to what I want.
quoted
git checkout topic
git format-patch --stdout origin > topic-diff
 topic-diff contains each commit as a separate message
quoted
$VISUAL topic-diff
# Fix comments
 so this needs some skill & care to rearrange the pieces
 and end up with legal input to git-am

Perhaps I'd like to have:

 git diff SHA-where-I-branched..HEAD

but I don't see the way to compute the SHA-where-I-branched

-Tony
If what you want to end up with is a single commit, that is
easy.

If your topic branch is only "fork from master and never
re-merge with master but just pile new commits on top of the
tip, single strand of pearls" kind,

        git-merge-base master topic

would find the 'x' commit, where you forked from:

                           "master"
        ---x---o---o---o---o
            \
             o---o---o---o
                          "topic"

If you have "my topic will conflict with a change recently done
in master so let's merge up from master to resolve conflict
before going further" kind of merge commit on your topic branch,
then you cannot have a single two-tree diff easily anyway, but
in such a case, the following steps would work.

                           "master"
        ---o---o---o---o---o
            \       \
             o---o---*---o
                          "topic"

  (1) First merge "master" into "topic":

        $ git checkout topic
        $ git pull . master

                           "master"
        ---o---o---o---o---o
            \       \       \ 
             o---o---*---o---*
                             "topic"

      which would give you the rightmost '*' merge.

  (2) Extract diff from "master" to '*':

        $ git diff HEAD^2 HEAD >P.diff

      HEAD^1 is previous "topic" head and HEAD^2 is what you
      merged ("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.


  (4) Reset the "topic" branch to "master", and do the squashed
      commit:

	$ git reset --hard master
        $ git apply --index P.diff
        $ git commit -F P.log -e

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?
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help