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

Re: [PATCH v7 6/7] submodule: refactor show_submodule_summary with helper function

From
David Aguilar <davvid@gmail.com>
Date
Aug 18, 2016, 07:00 UTC
Message-ID
<20160818070023.GA30666@gmail.com>
In-Reply-To
<20160818005131.31600-7-jacob.e.keller@intel.com>
On Wed, Aug 17, 2016 at 05:51:30PM -0700, Jacob Keller wrote:
Show 18 quoted lines
> [snip]
> @@ -333,31 +326,23 @@ static void print_submodule_summary(struct rev_info *rev, FILE *f,
>  	strbuf_release(&sb);
>  }
>  
> -void show_submodule_summary(FILE *f, const char *path,
> +/* Helper function to display the submodule header line prior to the full
> + * summary output. If it can locate the submodule objects directory it will
> + * attempt to lookup both the left and right commits and put them into the
> + * left and right pointers.
> + */
> +static void show_submodule_header(FILE *f, const char *path,
>  		const char *line_prefix,
>  		unsigned char one[20], unsigned char two[20],
>  		unsigned dirty_submodule, const char *meta,
> -		const char *del, const char *add, const char *reset)
> +		const char *reset,
> +		struct commit **left, struct commit **right)
Note the pre-existing unsigned char[20]s in the signature above...
Show 15 quoted lines
> [snip]
> @@ -381,14 +401,39 @@ void show_submodule_summary(FILE *f, const char *path,
>  		strbuf_addf(&sb, "%s:%s\n", fast_backward ? " (rewind)" : "", reset);
>  	fwrite(sb.buf, sb.len, 1, f);
>  
> -	if (!message) /* only NULL if we succeeded in setting up the walk */
> -		print_submodule_summary(&rev, f, line_prefix, del, add, reset);
> +	strbuf_release(&sb);
> +}
> +
> +void show_submodule_summary(FILE *f, const char *path,
> +		const char *line_prefix,
> +		unsigned char one[20], unsigned char two[20],
> +		unsigned dirty_submodule, const char *meta,
> +		const char *del, const char *add, const char *reset)
... and here too.

There's an ongoing effort to replace unsigned char sha1[20] with struct object_id. It might make sense to pass "one" and "two" as "unsigned char*" instead of hard-coding the SHA1-length here. Alternatively, we could pass in the struct object_id* instead.

The [20] in the show_submodule_header() function above is pre-existing and not added by this patch, but that function's signature is touched by this patch so it might make sense to tidy that up while we're in here, possibly as a separate patch.

-- 
David
Previous: Jacob KellerNext: Jacob Keller
Message 4 of 24 in “implement inline submodule diff format”
  1. 0/7 implement inline submodule diff formatJacob Keller, Aug 18, 2016
  2. 1/7 diff.c: remove output_prefix_length fieldJacob Keller, Aug 18, 2016
  3. 6/7 submodule: refactor show_submodule_summary with helper functionJacob Keller, Aug 18, 2016
  4. David AguilarAug 18, 2016
  5. Jacob KellerAug 18, 2016
  6. Stefan BellerAug 18, 2016
  7. Jacob KellerAug 18, 2016
  8. Stefan BellerAug 18, 2016
  9. Jacob KellerAug 18, 2016
  10. Junio C HamanoAug 18, 2016
  11. Jacob KellerAug 18, 2016
  12. 7/7 diff: teach diff to display submodule difference with an inline diffJacob Keller, Aug 18, 2016
  13. Stefan BellerAug 18, 2016
  14. Jacob KellerAug 18, 2016
  15. 3/7 diff: prepare for additional submodule formatsJacob Keller, Aug 18, 2016
  16. Stefan BellerAug 18, 2016
  17. 5/7 submodule: correct output of submodule log formatJacob Keller, Aug 18, 2016
  18. Stefan BellerAug 18, 2016
  19. Jacob KellerAug 18, 2016
  20. 4/7 submodule: allow do_submodule_path to work if given gitdir directlyJacob Keller, Aug 18, 2016
  21. Junio C HamanoAug 18, 2016
  22. Jacob KellerAug 18, 2016
  23. Stefan BellerAug 18, 2016
  24. 2/7 graph: add support for --line-prefix on all graph-aware outputJacob Keller, Aug 18, 2016

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.