{"thread":{"id":"34497","subject":"Re: One question about git-format-patch","startedAt":"2013-07-19T23:06:08Z","lastAt":"2013-07-20T00:32:46Z","messageCount":2,"participants":["Junio C Hamano"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"223811","messageId":"CAPc5daW6ohYxJP0eyfW0DT_Q-E8v0quweRBwJCAZOVrEMWchjA@mail.gmail.com","threadId":"34497","inReplyTo":"804161F448B352478D7503429A0B7F27CA94AC@ex10-mbx-36002.ant.amazon.com","subject":"Re: One question about git-format-patch","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2013-07-19T23:06:08Z","receivedAt":"2013-07-19T23:06:08Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"> I’m a git user, and recently I’ve noticed there’re some differences between\n> “$ git format-patch –n” and “$ git format-patch HEAD~n”. According to the\n> documentation: “-<n> Prepare patches from the topmost <n> commits.”\n\nCorrect.  However, HEAD~n will prepare patches for commits that are\nnot ancestor of HEAD~n.\n\nAnd there may well be a lot more than n such commits, unless you are\nworking on a strictly linear history.\n"},{"id":"223821","messageId":"7vehaut6j5.fsf@alter.siamese.dyndns.org","threadId":"34497","inReplyTo":"CAPc5daW6ohYxJP0eyfW0DT_Q-E8v0quweRBwJCAZOVrEMWchjA@mail.gmail.com","subject":"Re: One question about git-format-patch","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2013-07-20T00:32:46Z","receivedAt":"2013-07-20T00:32:46Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Junio C Hamano <gitster@pobox.com> writes:\n\n>> I’m a git user, and recently I’ve noticed there’re some differences between\n>> “$ git format-patch –n” and “$ git format-patch HEAD~n”. According to the\n>> documentation: “-<n> Prepare patches from the topmost <n> commits.”\n>\n> Correct.  However, HEAD~n will prepare patches for commits that are\n> not ancestor of HEAD~n.\n>\n> And there may well be a lot more than n such commits, unless you are\n> working on a strictly linear history.\n\nEvery once in a while, a illustration would help new folks.  \n\nIn this history (as always, the time and ancestry topology flows\nfrom left to right):\n\n           E-------F---G\n          /       /\n     A---B---C---D\n\nimagine that your HEAD is at commit G.\n\n - G~1 == G^ == F\n - G~2 == G^^ == E (suppose F is a merge of D made on E)\n - G~3 == G^^^ == B\n - G~4 == G^^^^ == A\n\nso \"git format-patch HEAD~4\" will give you B, C, D, E and G (five\ncommits).\n\nAsking for \"git format-patch -n 4\" does not make much sense in a\nhistory like this, but it will give you G, D, C, E and at that point\nyou have seen 4 commits, so you won't get B.\n\nNote that if F were a merge of E made on D, that would make\n\n - G~2 == G^^ == D\n - G~3 == G^^^ == C\n - G~4 == G^^^^ == B\n\nAnd \"git format-patch HEAD~4\" will give you C, D, E and G (four\ncommits).\n"}]}