Skip to contentSkip to conversation

format-patch: Update the `-3` example

PATCH In review Ramkumar Ramachandra 3 participants 7 messages Jun 15, 2016 Documentation

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 format-patch: Update the `-3` example

In the EXAMPLES section, git-format-patch -3 doesn't work anymore. Update it to read git format-patch HEAD~3. The example was introduced in 7c49628 and had not been updated since.

---
 Documentation/git-format-patch.txt |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
Documentation/git-format-patch.txt +1 -1
index 4b3f5ba..2a44472 100644
@@ -271,7 +271,7 @@ use it only when you know the recipient uses git to apply your patch.
 as e-mailable patches:
 +
 ------------
-$ git format-patch -3
+$ git format-patch HEAD~3
 ------------
 
 SEE ALSO
Signature · 1 line
1.7.2.2.409.gdbb11.dirty
#1 lore raw
Quoted 14 lines · Ramkumar Ramachandra

In the EXAMPLES section, git-format-patch -3 doesn't work anymore. Update it to read git format-patch HEAD~3. The example was introduced in 7c49628 and had not been updated since.

---
 Documentation/git-format-patch.txt |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
Documentation/git-format-patch.txt +0 -0
index 4b3f5ba..2a44472 100644

Documentation/git-format-patch.txt use it only when you know the recipient uses git to apply your patch. · line 275

Quoted 6 lines
Documentation/git-format-patch.txt +1 -1
@@ -271,7 +271,7 @@ use it only when you know the recipient uses git to apply your patch.
 as e-mailable patches:
 +
 ------------
-$ git format-patch -3
+$ git format-patch HEAD~3
 ------------

Works for me:

  5031:[gitweb/split@git]# git format-patch -3
  0001-gitweb-Prepare-for-splitting-gitweb.txt
  0002-gitweb-Create-Gitweb-Git-module.txt
  5034:[gitweb/split@git]# git version
  git version 1.7.2.1

The -3 is git-log option:

-<n> Limits the number of commits to show.

and also git-format-patch option:

-<n> Limits the number of patches to prepare.

Signature · 3 lines
Jakub Narebski
Poland
ShadeHawk on #git
#2 lore raw

Hi Jakub,

Quoted 10 lines · Jakub Narebski

Works for me:

  5031:[gitweb/split@git]# git format-patch -3
  0001-gitweb-Prepare-for-splitting-gitweb.txt
  0002-gitweb-Create-Gitweb-Git-module.txt
  5034:[gitweb/split@git]# git version
  git version 1.7.2.1
Quoted 7 lines

The -3 is git-log option:

-<n> Limits the number of commits to show.

and also git-format-patch option:

-<n> Limits the number of patches to prepare.

Hm, doesn't work on the pu Git, but works on master -- I'm currently bisecting to find the problem. git log -3 works though.

-- Ram

#3 lore raw

Hi,

Quoted 17 lines · Ramkumar Ramachandra

Hi Jakub,

Quoted 14 lines · Jakub Narebski

Works for me:

  5031:[gitweb/split@git]# git format-patch -3
  0001-gitweb-Prepare-for-splitting-gitweb.txt
  0002-gitweb-Create-Gitweb-Git-module.txt
  5034:[gitweb/split@git]# git version
  git version 1.7.2.1

The -3 is git-log option:

-<n> Limits the number of commits to show.

Quoted 7 lines
Quoted 3 lines

and also git-format-patch option:

-<n> Limits the number of patches to prepare.

Hm, doesn't work on the pu Git, but works on master -- I'm currently bisecting to find the problem. git log -3 works though.

:facepalm:

Scratch out what I just said -- I just realized that git format-patch HEAD~3 handles merge commits, but git format-patch -3 does not. git format-patch -3 HEAD~3 is even more confusing- should we even advertise the -<n> option in format-patch?

-- Ram

#4 lore raw
Quoted 2 lines · Ramkumar Ramachandra

should we
even advertise the -<n> option in format-patch?

Oh, yeah! IMHO, it is its most useful option.

-- Hannes

#5 lore raw
In reply to Ramkumar Ramachandra
Quoted 24 lines · Ramkumar Ramachandra
Quoted 15 lines · Ramkumar Ramachandra
Quoted 14 lines · Jakub Narebski

Works for me:

  5031:[gitweb/split@git]# git format-patch -3
  0001-gitweb-Prepare-for-splitting-gitweb.txt
  0002-gitweb-Create-Gitweb-Git-module.txt
  5034:[gitweb/split@git]# git version
  git version 1.7.2.1

The -3 is git-log option:

-<n> Limits the number of commits to show.

Quoted 7 lines
Quoted 3 lines

and also git-format-patch option:

-<n> Limits the number of patches to prepare.

Hm, doesn't work on the pu Git, but works on master -- I'm currently bisecting to find the problem. git log -3 works though.

Quoted 6 lines

:facepalm:

Scratch out what I just said -- I just realized that git format-patch HEAD~3 handles merge commits, but git format-patch -3 does not. git format-patch -3 HEAD~3 is even more confusing- should we even advertise the -<n> option in format-patch?

It looks like there is a conceptual bug in how git-format-patch works, namely that '-<n>' is passed to rev-list / log generating machinery, and it limits number of *commits* to consider; if some of those commits are merge commits, which cannot be represented as patches, the number of patches it generates is less than specified <n> (as you can see in the example I have provided, where <n> == 3, and git-format-patch generated 2 patches, not 3). In extreme case (like 'pu') it can generate no patch.

I am not sure what the solution should be. We could either:

A. Update git-format-patch documentation to say 'commits' instead of
'patches', and perhaps also be loud about commits we are skipping, so that my example would look e.g. like this:

     $ git format-patch -3
     0001-gitweb-Prepare-for-splitting-gitweb.txt
     0002-gitweb-Create-Gitweb-Git-module.txt
     Skipping merge commit: Merge branch 'maint'

or

B. Modify git-format-patch so that "git format-patch -<n>" would always
generate <n> patches from specified commits, if there are that many.

But I think that option B.) it might be difficult, so perhaps A.) is "it".

Signature · 2 lines
Jakub Narebski
Poland
#6 lore raw

Hi Jakub,

Quoted 43 lines · Jakub Narebski
Quoted 24 lines · Ramkumar Ramachandra
Quoted 15 lines · Ramkumar Ramachandra
Quoted 14 lines · Jakub Narebski

Works for me:

  5031:[gitweb/split@git]# git format-patch -3
  0001-gitweb-Prepare-for-splitting-gitweb.txt
  0002-gitweb-Create-Gitweb-Git-module.txt
  5034:[gitweb/split@git]# git version
  git version 1.7.2.1

The -3 is git-log option:

-<n> Limits the number of commits to show.

Quoted 7 lines
Quoted 3 lines

and also git-format-patch option:

-<n> Limits the number of patches to prepare.

Hm, doesn't work on the pu Git, but works on master -- I'm currently bisecting to find the problem. git log -3 works though.

Quoted 6 lines

:facepalm:

Scratch out what I just said -- I just realized that git format-patch HEAD~3 handles merge commits, but git format-patch -3 does not. git format-patch -3 HEAD~3 is even more confusing- should we even advertise the -<n> option in format-patch?

It looks like there is a conceptual bug in how git-format-patch works, namely that '-<n>' is passed to rev-list / log generating machinery, and it limits number of *commits* to consider; if some of those commits are merge commits, which cannot be represented as patches, the number of patches it generates is less than specified <n> (as you can see in the example I have provided, where <n> == 3, and git-format-patch generated 2 patches, not 3). In extreme case (like 'pu') it can generate no patch.

I am not sure what the solution should be. We could either:

Quoted 8 lines

A. Update git-format-patch documentation to say 'commits' instead of
'patches', and perhaps also be loud about commits we are skipping, so that my example would look e.g. like this:

     $ git format-patch -3
     0001-gitweb-Prepare-for-splitting-gitweb.txt
     0002-gitweb-Create-Gitweb-Git-module.txt
     Skipping merge commit: Merge branch 'maint'

Thanks for the awesome explanation! A is definitely the way to go- I'll start writing a patch immediately.

-- Ram