git-format-patch --start-number <n>
Since the "a..b c..d" syntax is interpreted as "b ^a d ^c" as other range-ish commands, if you want to format a..b and then c..d and end up with files consecutively numbered, the second run needs to be able to tell the command what number to start from. This does not imply --numbered (which gives [PATCH n/m] to the subject). Signed-off-by: Junio C Hamano <junkio@cox.net>
Johannes Schindelin committed
May 25, 2006 at 23:55 UTC
fa0f02dfa15d0d95f8b6d27688bbf8ac940e3354
1 file changed
+13
-3
builtin-log.c
+13
-3
@@ -148,6 +148,7 @@ int cmd_format_patch(int argc, const char **argv, char **envp)
148
int nr = 0, total, i, j;
149
int use_stdout = 0;
150
int numbered = 0;
151
+ int start_number = -1;
152
int keep_subject = 0;
153
154
init_revisions(&rev);
@@ -171,7 +172,14 @@ int cmd_format_patch(int argc, const char **argv, char **envp)
172
else if (!strcmp(argv[i], "-n") ||
173
!strcmp(argv[i], "--numbered"))
174
numbered = 1;
174
- else if (!strcmp(argv[i], "-k") ||
175
+ else if (!strncmp(argv[i], "--start-number=", 15))
176
+ start_number = strtol(argv[i] + 15, NULL, 10);
177
+ else if (!strcmp(argv[i], "--start-number")) {
178
+ i++;
179
+ if (i == argc)
180
+ die("Need a number for --start-number");
181
+ start_number = strtol(argv[i], NULL, 10);
182
+ } else if (!strcmp(argv[i], "-k") ||
183
!strcmp(argv[i], "--keep-subject")) {
184
keep_subject = 1;
185
rev.total = -1;
@@ -193,6 +201,8 @@ int cmd_format_patch(int argc, const char **argv, char **envp)
201
}
202
argc = j;
203
204
+ if (numbered && start_number < 0)
205
+ start_number = 1;
206
if (numbered && keep_subject < 0)
207
die ("-n and -k are mutually exclusive.");
208
@@ -219,11 +229,11 @@ int cmd_format_patch(int argc, const char **argv, char **envp)
229
}
230
total = nr;
231
if (numbered)
222
- rev.total = total;
232
+ rev.total = total + start_number - 1;
233
while (0 <= --nr) {
234
int shown;
235
commit = list[nr];
226
- rev.nr = total - nr;
236
+ rev.nr = rev.total - nr;
237
if (!use_stdout)
238
reopen_stdout(commit, rev.nr, keep_subject);
239
shown = log_tree_commit(&rev, commit);