Skip to content

Commit 8a1d076

Browse files
committed
"format-patch --root rev" is the way to show everything.
We used to trigger the special case "things not in origin" semantics only when one and only one positive ref is given, and no number (e.g. "git format-patch -4 origin") was specified, and used the general revision range semantics for everything else. This narrows the special case a bit more, by making: git format-patch --root this_version to show everything that leads to the named commit. More importantly, document the two different semantics better. The generic revision range semantics came later and bolted on without being clearly documented. Signed-off-by: Junio C Hamano <[email protected]>
1 parent 170c043 commit 8a1d076

File tree

2 files changed

+32
-10
lines changed

2 files changed

+32
-10
lines changed

Documentation/git-format-patch.txt

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,21 +16,32 @@ SYNOPSIS
1616
[--in-reply-to=Message-Id] [--suffix=.<sfx>]
1717
[--ignore-if-in-upstream]
1818
[--subject-prefix=Subject-Prefix]
19-
<since>[..<until>]
19+
[ <since> | <revision range> ]
2020

2121
DESCRIPTION
2222
-----------
2323

24-
Prepare each commit between <since> and <until> with its patch in
24+
Prepare each commit with its patch in
2525
one file per commit, formatted to resemble UNIX mailbox format.
26-
If ..<until> is not specified, the head of the current working
27-
tree is implied. For a more complete list of ways to spell
28-
<since> and <until>, see "SPECIFYING REVISIONS" section in
29-
gitlink:git-rev-parse[1].
30-
3126
The output of this command is convenient for e-mail submission or
3227
for use with gitlink:git-am[1].
3328

29+
There are two ways to specify which commits to operate on.
30+
31+
1. A single commit, <since>, specifies that the commits leading
32+
to the tip of the current branch that are not in the history
33+
that leads to the <since> to be output.
34+
35+
2. Generic <revision range> expression (see "SPECIFYING
36+
REVISIONS" section in gitlink:git-rev-parse[1]) means the
37+
commits in the specified range. A single commit, when
38+
interpreted as a <revision range> expression, means
39+
"everything that leads to that commit", but that is taken as
40+
the special case above. If you want to format everything
41+
since project inception to one commit, say "git format-patch
42+
\--root <that-commit>", as showing the root commit as patch
43+
requires \--root option anyway.
44+
3445
By default, each output file is numbered sequentially from 1, and uses the
3546
first line of the commit message (massaged for pathname safety) as
3647
the filename. With the --numbered-files option, the output file names
@@ -153,6 +164,10 @@ git-format-patch origin::
153164
not in the origin branch. For each commit a separate file
154165
is created in the current directory.
155166

167+
git-format-patch \--root origin::
168+
Extract all commits which that leads to 'origin' since the
169+
inception of the project.
170+
156171
git-format-patch -M -B origin::
157172
The same as the previous one. Additionally, it detects
158173
and handles renames and complete rewrites intelligently to

builtin-log.c

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -585,12 +585,19 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)
585585
}
586586

587587
if (rev.pending.nr == 1) {
588-
if (rev.max_count < 0) {
588+
if (rev.max_count < 0 && !rev.show_root_diff) {
589+
/*
590+
* This is traditional behaviour of "git format-patch
591+
* origin" that prepares what the origin side still
592+
* does not have.
593+
*/
589594
rev.pending.objects[0].item->flags |= UNINTERESTING;
590595
add_head(&rev);
591596
}
592-
/* Otherwise, it is "format-patch -22 HEAD", and
593-
* get_revision() would return only the specified count.
597+
/*
598+
* Otherwise, it is "format-patch -22 HEAD", and/or
599+
* "format-patch --root HEAD". The user wants
600+
* get_revision() to do the usual traversal.
594601
*/
595602
}
596603

0 commit comments

Comments
 (0)