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

Re: git rev-list ordering

From
Björn Steinbrink <b.steinbrink@gmx.de>
Date
Nov 19, 2008, 08:26 UTC
Message-ID
<20081119082638.GA3538@atjola.homenet>
In-Reply-To
<4923256B.3000807@pcharlan.com>
On 2008.11.18 12:28:27 -0800, Pete Harlan wrote:
Show 21 quoted lines
> I have a script that runs periodically where I need to know the email
> address of who added $file to the system, for a handful of $files,
> because I'm moving them somewhere else and want to let them know.  The
> most recent commits aren't interesting, it's the first commit that matters.
> 
> I use:
> 
>   git rev-list --reverse --pretty=format:%ae HEAD -- $file
> 
> and the second line has the information I need.
> 
> Perhaps there's a more straightforward way to answer the question "who
> first put this file here".
> 
> (One can imagine that may be no "first", because $file merged from
> different paths, but in mine as in many real-world cases, it (a) won't
> happen and (b) whatever happens will be fine if it does.)
> 
> I don't need this to work differently than it does, but perhaps it
> constitutes an "interesting situation where you need to list the oldest
> n commits"?

What you're asking for are commits that added the file, and you can tell git to find them, instead of using the --reverse work-around:

git log --diff-filter=A --pretty=format:%ae HEAD -- $file

If you're running that with a single file, you might want to add --follow and maybe add R to the diff-filter as well (to get the renaming commits).

Björn
Previous: Pete Harlan
Message 8 of 8 in “git rev-list ordering”
  1. Ian HiltNov 16, 2008
  2. Sverre RabbelierNov 16, 2008
  3. Ian HiltNov 16, 2008
  4. Johannes SchindelinNov 16, 2008
  5. Ian HiltNov 17, 2008
  6. Johannes SchindelinNov 17, 2008
  7. Pete HarlanNov 18, 2008
  8. Björn SteinbrinkNov 19, 2008

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.