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

Re: [PATCH 2/2] Add a 'source' decorator for commits

From
Jeff King <peff@peff.net>
Date
Oct 28, 2008, 05:45 UTC
Message-ID
<20081028054539.GA23195@sigill.intra.peff.net>
In-Reply-To
<alpine.LFD.2.00.0810271306230.3386@nehalem.linux-foundation.org>
On Mon, Oct 27, 2008 at 01:07:10PM -0700, Linus Torvalds wrote:
> We already support decorating commits by tags or branches that point to
> them, but especially when we are looking at multiple branches together,
> we sometimes want to see _how_ we reached a particular commit.
I think this is a cool feature, but I have a few questions/complaints:
  - Does it make sense to have this _in addition_ to --decorate (since
    for any commit with a --decorate field, it would likely be the same
    as --source)? Should it be a different type of decorate instead,
    like --decorate=source or --decorate=branch?
  - Should this be triggered by the "%d" --pretty=format specifier? This
    two-liner:
diff --git a/pretty.c b/pretty.c
index f6ff312..bdaad19 100644
--- a/pretty.c
+++ b/pretty.c
@@ -487,6 +487,8 @@ static void format_decoration(struct strbuf *sb, const struct commit *commit)
 	const char *prefix = " (";
 
 	load_ref_decorations();
+	if (commit->util)
+		printf("%s", (char *)commit->util);
 	d = lookup_decoration(&name_decoration, &commit->object);
 	while (d) {
 		strbuf_addstr(sb, prefix);

    works, but:

      - it doesn't check revs->show_source, so is it possible that
        commit->util is being used for something else?

      - using '%d' automatically turns on --decorate, so you end up with
        both the --source and --decorate values. More sensible semantics
        would be "%d turns on --decorate, unless you have done
        --decorate=<explicit format>".

        Alternatively, this should just be "%b" or "%S".

  - If you don't specify --all, you just get "HEAD" for everything.
    Which makes sense when you consider the implementation, but I think
    is probably a bit confusing for users.

> Of course, if the commit is reachable through multiple sources (which is
> common), our particular choice of "first" reachable is entirely random
> and depends on the particular path we happened to follow.

Hmm. It would be nice to keep even a simple counter to get a "distance"
from the ref and choose the one with the smallest distance (I think we
can get away without the complex rules that git-describe uses, since we
are not interested in describing the full commit, but rather finding a
"likely" branch).

However, that would require making multiple passes over the commit
graph, which might impact the startup speed.

-Peff
Previous: Linus TorvaldsNext: Pierre Habouzit
Message 4 of 14 in “Random patches from my tree”
  1. 0/2 Random patches from my treeLinus Torvalds, Oct 27, 2008
  2. 1/2 Add file delete/create info when we overflow rename_limitLinus Torvalds, Oct 27, 2008
  3. 2/2 Add a 'source' decorator for commitsLinus Torvalds, Oct 27, 2008
  4. Jeff KingOct 28, 2008
  5. Pierre HabouzitOct 28, 2008
  6. Pierre HabouzitOct 28, 2008
  7. Jeff KingOct 28, 2008
  8. Jeff KingOct 28, 2008
  9. Pierre HabouzitOct 28, 2008
  10. Jeff KingOct 28, 2008
  11. Linus TorvaldsOct 28, 2008
  12. Linus TorvaldsOct 28, 2008
  13. Jeff KingOct 28, 2008
  14. Linus TorvaldsOct 27, 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.