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

Re: [PATCH 0/1] log: make the --oneline option work with -L

From
Beat Bolli <dev+git@drbeat.li>
Date
Mar 13, 2024, 18:08 UTC
Message-ID
<a675ab4d-7dde-4630-9de6-970f05225271@drbeat.li>
In-Reply-To
<xmqqr0geca36.fsf@gitster.g>
On 13.03.24 18:31, Junio C Hamano wrote:
Show 40 quoted lines
> James Liu <james@jamesliu.io> writes:
> 
>> git-log accepts the --oneline option to display the short commit SHA and
>> title only. This is a convenient option when searching through Git
>> history, as it gives a rough idea of the changes introduced in each
>> commit. git-log also accepts the -L flag, which lets us provide a line
>> range for a given file. This is handy for limiting the search to a given
>> area of interest.
>>
>> However, when --oneline is used in combination with -L, Git actually
>> outputs the single line commit information _as well_ as the full diff.
>> For example:
>>
>>          git log --oneline -L 660:Documentation/MyFirstObjectWalk.txt
>>
>> will incorrectly display the diffs too.
> 
> Why is it incorrect?
> 
>   * "git log" takes options to tweak formatting of the commit log,
>     options to tweak what commits are chosen, and options to tweak
>     how the diff are shown.
> 
>   * "--oneline" tweaks how the log message gets shown.  Others in the
>     family are --pretty=fuller, --format='%h %s', etc.
> 
>   * "-L" tweaks how the diff gets shown (e.g. limits which part of
>     the diff is shown) and what commits are shown (e.g. limits to
>     commits that touch the specified area).
> 
> So, just like "git log -L <range>:<file>" shows the commit log for
> each commit that touches the specified area of the file, followed by
> the diff that shows how the commit modified the range, it is natural
> to expect "git log --oneline -L <range>:<file>" to show the same diff
> after showing the commit log for these commits in the specified format,
> namely, with just a one-line description.
> 
> It is not limited to "-L"; "git log --oneline -p" is expected to
> show the patch after a one-line description for the commit.
> 

There's also "--no-patch" to suppress the patch. It combines well with "--oneline".

-- 
Cheers, Beat
Previous: Junio C HamanoNext: James Liu
Message 4 of 7 in “log: make the --oneline option work with -L”
  1. 0/1 log: make the --oneline option work with -LJames Liu, Mar 13, 2024
  2. 1/1 log: ensure diffs are omitted with --onelineJames Liu, Mar 13, 2024
  3. Junio C HamanoMar 13, 2024
  4. Beat BolliMar 13, 2024
  5. James LiuMar 13, 2024
  6. James LiuMar 13, 2024
  7. Junio C HamanoMar 13, 2024

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.