git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] Get format-patch to show first commit after root commit

From
APAlexander Potashev <aspotashev@gmail.com>
Date
Jan 9, 2009, 20:29 UTC
Message-ID
<20090109202940.GA17501@myhost>
In-Reply-To
<1231529725-19767-1-git-send-email-nathan.panike@gmail.com>
Hello!

I experienced this problem today while preparing a simple patch for reply in "[PATCH 2/2] Use is_pseudo_dir_name everywhere" thread. I used a workaround: add a file, commit, remove it, commit, add it once again, commit and after all format-patch.

On 13:35 Fri 09 Jan     , Nathan W. Panike wrote:
Show 12 quoted lines
> Currently, the command
> 
> git format-patch -1 e83c5163316f89bfbde
> 
> in the git repository creates an empty file.  Instead, one is
> forced to do
> 
> git format-patch -1 --root e83c5163316f89bfbde
> 
> This seems arbitrary.  This patch fixes this case, so that
> 
> git format-patch -1 e83c5163316f89bfbde

Your patch doesn't solve the problem if there are more than one commit (say, 2 commits) and you run 'git format-patch -2'. Even with your patch format-patch writes an empty patch file corresponding to the root commit (actually, it creates 2 patches, but the first is empty).

Please, correct me if I'm wrong.
Show 21 quoted lines
> 
> will produce an actual patch.
> ---
>  builtin-log.c |    2 ++
>  1 files changed, 2 insertions(+), 0 deletions(-)
> 
> diff --git a/builtin-log.c b/builtin-log.c
> index 4a02ee9..5e7b61f 100644
> --- a/builtin-log.c
> +++ b/builtin-log.c
> @@ -977,6 +977,8 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)
>  		list[nr - 1] = commit;
>  	}
>  	total = nr;
> +	if (total == 1 && !list[0]->parents)
> +		rev.show_root_diff=1;
>  	if (!keep_subject && auto_number && total > 1)
>  		numbered = 1;
>  	if (numbered)
> -- 
> 1.6.1.76.gc123b.dirty
Previous: Nathan W. Panike
Message 2 of 2 in “Get format-patch to show first commit after root commit”
  1. Get format-patch to show first commit after root commitNathan W. Panike, Jan 9, 2009
  2. Alexander PotashevJan 9, 2009

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.