{"thread":{"id":"17065","subject":"[PATCH] Get format-patch to show first commit after root commit","startedAt":"2009-01-09T19:35:25Z","lastAt":"2009-01-09T20:29:40Z","messageCount":2,"participants":["Nathan W. Panike","Alexander Potashev"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"99812","messageId":"1231529725-19767-1-git-send-email-nathan.panike@gmail.com","threadId":"17065","inReplyTo":null,"subject":"[PATCH] Get format-patch to show first commit after root commit","fromName":"Nathan W. Panike","fromEmail":"nathan.panike@gmail.com","sentAt":"2009-01-09T19:35:25Z","receivedAt":"2009-01-09T19:35:25Z","isPatch":true,"sender":{"key":"nathan.panike@gmail.com","avatar":"https://avatars.githubusercontent.com/u/389447?v=4"},"body":"Currently, the command\n\ngit format-patch -1 e83c5163316f89bfbde\n\nin the git repository creates an empty file.  Instead, one is\nforced to do\n\ngit format-patch -1 --root e83c5163316f89bfbde\n\nThis seems arbitrary.  This patch fixes this case, so that\n\ngit format-patch -1 e83c5163316f89bfbde\n\nwill produce an actual patch.\n---\n builtin-log.c |    2 ++\n 1 files changed, 2 insertions(+), 0 deletions(-)\n\ndiff --git a/builtin-log.c b/builtin-log.c\nindex 4a02ee9..5e7b61f 100644\n--- a/builtin-log.c\n+++ b/builtin-log.c\n@@ -977,6 +977,8 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)\n \t\tlist[nr - 1] = commit;\n \t}\n \ttotal = nr;\n+\tif (total == 1 && !list[0]->parents)\n+\t\trev.show_root_diff=1;\n \tif (!keep_subject && auto_number && total > 1)\n \t\tnumbered = 1;\n \tif (numbered)\n-- \n1.6.1.76.gc123b.dirty\n"},{"id":"99817","messageId":"20090109202940.GA17501@myhost","threadId":"17065","inReplyTo":"1231529725-19767-1-git-send-email-nathan.panike@gmail.com","subject":"Re: [PATCH] Get format-patch to show first commit after root commit","fromName":"Alexander Potashev","fromEmail":"aspotashev@gmail.com","sentAt":"2009-01-09T20:29:40Z","receivedAt":"2009-01-09T20:29:40Z","isPatch":true,"sender":{"key":"aspotashev@gmail.com","avatar":null},"body":"Hello!\n\nI experienced this problem today while preparing a simple patch for\nreply in \"[PATCH 2/2] Use is_pseudo_dir_name everywhere\" thread.\nI used a workaround: add a file, commit, remove it, commit, add it once\nagain, commit and after all format-patch.\n\nOn 13:35 Fri 09 Jan     , Nathan W. Panike wrote:\n> Currently, the command\n> \n> git format-patch -1 e83c5163316f89bfbde\n> \n> in the git repository creates an empty file.  Instead, one is\n> forced to do\n> \n> git format-patch -1 --root e83c5163316f89bfbde\n> \n> This seems arbitrary.  This patch fixes this case, so that\n> \n> git format-patch -1 e83c5163316f89bfbde\n\nYour patch doesn't solve the problem if there are more than one commit\n(say, 2 commits) and you run 'git format-patch -2'. Even with your patch\nformat-patch writes an empty patch file corresponding to the root commit\n(actually, it creates 2 patches, but the first is empty).\n\nPlease, correct me if I'm wrong.\n\n> \n> will produce an actual patch.\n> ---\n>  builtin-log.c |    2 ++\n>  1 files changed, 2 insertions(+), 0 deletions(-)\n> \n> diff --git a/builtin-log.c b/builtin-log.c\n> index 4a02ee9..5e7b61f 100644\n> --- a/builtin-log.c\n> +++ b/builtin-log.c\n> @@ -977,6 +977,8 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)\n>  \t\tlist[nr - 1] = commit;\n>  \t}\n>  \ttotal = nr;\n> +\tif (total == 1 && !list[0]->parents)\n> +\t\trev.show_root_diff=1;\n>  \tif (!keep_subject && auto_number && total > 1)\n>  \t\tnumbered = 1;\n>  \tif (numbered)\n> -- \n> 1.6.1.76.gc123b.dirty\n"}]}