summaryrefslogtreecommitdiff
path: root/builtin/name-rev.c
diff options
context:
space:
mode:
authorSZEDER Gábor <szeder.dev@gmail.com>2019-11-12 10:38:19 (GMT)
committerJunio C Hamano <gitster@pobox.com>2019-12-06 21:29:04 (GMT)
commit8c5724c585791662ec5701719e8665a2db5517fd (patch)
treea9130035c3dd90bb09ab47a4a84fec3c0682e1a8 /builtin/name-rev.c
parent3a521503019de7ca0c550c3861619bb8881c388c (diff)
downloadgit-8c5724c585791662ec5701719e8665a2db5517fd.zip
git-8c5724c585791662ec5701719e8665a2db5517fd.tar.gz
git-8c5724c585791662ec5701719e8665a2db5517fd.tar.bz2
name-rev: drop name_rev()'s 'generation' and 'distance' parameters
Following the previous patches in this series we can get the values of name_rev()'s 'generation' and 'distance' parameters from the 'stuct rev_name' associated with the commit as well. Let's simplify the function's signature and remove these two unnecessary parameters. Note that at this point we could do the same with the 'tip_name', 'taggerdate' and 'from_tag' parameters as well, but those parameters will be necessary later, after the recursion is eliminated. Signed-off-by: SZEDER Gábor <szeder.dev@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin/name-rev.c')
-rw-r--r--builtin/name-rev.c25
1 files changed, 13 insertions, 12 deletions
diff --git a/builtin/name-rev.c b/builtin/name-rev.c
index 6416c49..fc61d6f 100644
--- a/builtin/name-rev.c
+++ b/builtin/name-rev.c
@@ -106,8 +106,9 @@ copy_data:
static void name_rev(struct commit *commit,
const char *tip_name, timestamp_t taggerdate,
- int generation, int distance, int from_tag)
+ int from_tag)
{
+ struct rev_name *name = get_commit_rev_name(commit);
struct commit_list *parents;
int parent_number = 1;
@@ -116,7 +117,7 @@ static void name_rev(struct commit *commit,
parents = parents->next, parent_number++) {
struct commit *parent = parents->item;
const char *new_name;
- int new_generation, new_distance;
+ int generation, distance;
parse_commit(parent);
if (parent->date < cutoff)
@@ -126,25 +127,25 @@ static void name_rev(struct commit *commit,
size_t len;
strip_suffix(tip_name, "^0", &len);
- if (generation > 0)
+ if (name->generation > 0)
new_name = xstrfmt("%.*s~%d^%d", (int)len, tip_name,
- generation, parent_number);
+ name->generation,
+ parent_number);
else
new_name = xstrfmt("%.*s^%d", (int)len, tip_name,
parent_number);
- new_generation = 0;
- new_distance = distance + MERGE_TRAVERSAL_WEIGHT;
+ generation = 0;
+ distance = name->distance + MERGE_TRAVERSAL_WEIGHT;
} else {
new_name = tip_name;
- new_generation = generation + 1;
- new_distance = distance + 1;
+ generation = name->generation + 1;
+ distance = name->distance + 1;
}
if (create_or_update_name(parent, new_name, taggerdate,
- new_generation, new_distance,
+ generation, distance,
from_tag))
- name_rev(parent, new_name, taggerdate,
- new_generation, new_distance, from_tag);
+ name_rev(parent, new_name, taggerdate, from_tag);
}
}
@@ -288,7 +289,7 @@ static int name_ref(const char *path, const struct object_id *oid, int flags, vo
tip_name = xstrdup(path);
if (create_or_update_name(commit, tip_name, taggerdate,
0, 0, from_tag))
- name_rev(commit, tip_name, taggerdate, 0, 0,
+ name_rev(commit, tip_name, taggerdate,
from_tag);
else
free(to_free);