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

Re: [PATCH v2] log: Handle new repository case.

From
Leila <muhtasib@gmail.com>
Date
Jun 26, 2012, 02:42 UTC
Message-ID
<CAA3EhHK25rLU-gQNUG0cmJ4E1g+Ce6AHcMF6jzcco5QaTJE+jA@mail.gmail.com>
In-Reply-To
<7vobo7dlyl.fsf@alter.siamese.dyndns.org>
On Mon, Jun 25, 2012 at 7:13 PM, Junio C Hamano <gitster@pobox.com> wrote:
Show 19 quoted lines
> Leila Muhtasib <muhtasib@gmail.com> writes:
>
>> @@ -553,8 +562,13 @@ int cmd_log(int argc, const char **argv, const char *prefix)
>>       init_revisions(&rev, prefix);
>>       rev.always_show_header = 1;
>>       memset(&opt, 0, sizeof(opt));
>> -     opt.def = "HEAD";
>> +     opt.def = default_to_head_if_exists();
>> +
>>       cmd_log_init(argc, argv, prefix, &rev, &opt);
>> +
>> +     if (!opt.def && !rev.cmdline.nr)
>> +             return 0;
>> +
>>       return cmd_log_walk(&rev);
>
> Do you even need these four new lines if you do not error out?
> Doesn't log_walk() return successfully if there is nothing in the
> queue anyway?

Actually, yes. This was left behind because I was printing a success message "No commit(s) to display". Thanks for catching this.

Show 12 quoted lines
>
>> @@ -1128,7 +1142,7 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)
>>       DIFF_OPT_SET(&rev.diffopt, RECURSIVE);
>>       rev.subject_prefix = fmt_patch_subject_prefix;
>>       memset(&s_r_opt, 0, sizeof(s_r_opt));
>> -     s_r_opt.def = "HEAD";
>> +     s_r_opt.def = default_to_head_if_exists();
>
> I didn't think about other commands, but I do not think format-patch
> wants to silently succeed without doing anything---it is definitely
> a user error, no?
>

The other changed commands are git show, git whatchanged, git reflog. And I think for the initial repo case, they can just silently succeed vs display that error message.

'git format-patch' on a regular repo with commits, did nothing for me. That's why I had originally included it. Though I think I'm changing my mind about this because it's about generating a patch -- not just displaying info.

Previous: Junio C HamanoNext: Junio C Hamano
Message 3 of 4 in “log: Handle new repository case.”
  1. log: Handle new repository case.Leila Muhtasib, Jun 25, 2012
  2. Junio C HamanoJun 25, 2012
  3. LeilaJun 26, 2012
  4. Junio C HamanoJun 26, 2012

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.