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

Re: [PATCH 1/2] remove unnecessary parameter from get_patch_ids()

From
Junio C Hamano <gitster@pobox.com>
Date
Jul 27, 2012, 22:44 UTC
Message-ID
<7v1ujwzuw1.fsf@alter.siamese.dyndns.org>
In-Reply-To
<1343409699-27199-2-git-send-email-martin.von.zweigbergk@gmail.com>
Martin von Zweigbergk <martin.von.zweigbergk@gmail.com> writes:
Show 5 quoted lines
> get_patch_ids() takes an already initialized rev_info and a
> prefix. The prefix is used when initalizing a second rev_info. Since
> the initialized rev_info already has a prefix and it seems the prefix
> doesn't change, we can used the prefix from the initialized rev_info
> to initialize the second rev_info.
s/it seems the prefix doesn't change/the prefix never changes/;
> Signed-off-by: Martin von Zweigbergk <martin.von.zweigbergk@gmail.com>
I think this change shouldn't change the behaviour and is good.

Just FYI, during the revision traversal, prefix affects two things in the current code:

 (1) it is used as the basename for prune data that determine which
     parts of the tree structure to pay attention to (e.g. "cd t &&
     git log .").
 (2) it is used as the basename for diff output when revs->diffopt
     is used (e.g. "cd t && git log -p").

And check_rev is used with neither. It does not want to prune any part of the tree nor it wants to filter with fancier options like grep/pickaxe (i.e. it does not use setup_revisions()).

In that sense it probably does not even matter if you did not pass rev->prefix down to check_rev, and instead gave NULL to it, but that only holds true in the current codebase, so I think what your patch does is the right thing to do.

Thanks.
Show 43 quoted lines
>  builtin/log.c | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/builtin/log.c b/builtin/log.c
> index ecc2793..7a92e3f 100644
> --- a/builtin/log.c
> +++ b/builtin/log.c
> @@ -696,7 +696,7 @@ static int reopen_stdout(struct commit *commit, const char *subject,
>  	return 0;
>  }
>  
> -static void get_patch_ids(struct rev_info *rev, struct patch_ids *ids, const char *prefix)
> +static void get_patch_ids(struct rev_info *rev, struct patch_ids *ids)
>  {
>  	struct rev_info check_rev;
>  	struct commit *commit;
> @@ -717,7 +717,7 @@ static void get_patch_ids(struct rev_info *rev, struct patch_ids *ids, const cha
>  	init_patch_ids(ids);
>  
>  	/* given a range a..b get all patch ids for b..a */
> -	init_revisions(&check_rev, prefix);
> +	init_revisions(&check_rev, rev->prefix);
>  	o1->flags ^= UNINTERESTING;
>  	o2->flags ^= UNINTERESTING;
>  	add_pending_object(&check_rev, o1, "o1");
> @@ -1306,7 +1306,7 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)
>  			if (hashcmp(o[0].item->sha1, o[1].item->sha1) == 0)
>  				return 0;
>  		}
> -		get_patch_ids(&rev, &ids, prefix);
> +		get_patch_ids(&rev, &ids);
>  	}
>  
>  	if (!use_stdout)
> @@ -1525,7 +1525,7 @@ int cmd_cherry(int argc, const char **argv, const char *prefix)
>  			return 0;
>  	}
>  
> -	get_patch_ids(&revs, &ids, prefix);
> +	get_patch_ids(&revs, &ids);
>  
>  	if (limit && add_pending_commit(limit, &revs, UNINTERESTING))
>  		die(_("Unknown commit %s"), limit);
Previous: Martin von ZweigbergkNext: Martin von Zweigbergk
Message 3 of 10 in “Small log simplifications”
  1. 0/2 Small log simplificationsMartin von Zweigbergk, Jul 27, 2012
  2. 1/2 remove unnecessary parameter from get_patch_ids()Martin von Zweigbergk, Jul 27, 2012
  3. Junio C HamanoJul 27, 2012
  4. Martin von ZweigbergkJul 28, 2012
  5. 2/2 log: remove redundant check for merge commitMartin von Zweigbergk, Jul 27, 2012
  6. Junio C HamanoJul 27, 2012
  7. Martin von ZweigbergkJul 28, 2012
  8. Junio C HamanoJul 28, 2012
  9. Martin von ZweigbergkJul 29, 2012
  10. Junio C HamanoJul 29, 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.