On Wed, Nov 14, 2018 at 11:28 AM SZEDER Gábor <[email protected]> wrote:
>
> On Tue, Nov 13, 2018 at 04:25:57PM -0800, Elijah Newren wrote:
> > diff --git a/builtin/fast-export.c b/builtin/fast-export.c
> > index 2fef00436b..3cc98c31ad 100644
> > --- a/builtin/fast-export.c
> > +++ b/builtin/fast-export.c
> > @@ -37,6 +37,7 @@ static int fake_missing_tagger;
> > static int use_done_feature;
> > static int no_data;
> > static int full_tree;
> > +static int reference_excluded_commits;
> > static struct string_list extra_refs = STRING_LIST_INIT_NODUP;
> > static struct string_list tag_refs = STRING_LIST_INIT_NODUP;
> > static struct refspec refspecs = REFSPEC_INIT_FETCH;
> > @@ -596,7 +597,8 @@ static void handle_commit(struct commit *commit, struct
> > rev_info *rev,
> > message += 2;
> >
> > if (commit->parents &&
> > - get_object_mark(&commit->parents->item->object) != 0 &&
> > + (get_object_mark(&commit->parents->item->object) != 0 ||
> > + reference_excluded_commits) &&
> > !full_tree) {
> > parse_commit_or_die(commit->parents->item);
> > diff_tree_oid(get_commit_tree_oid(commit->parents->item),
> > @@ -644,13 +646,21 @@ static void handle_commit(struct commit *commit,
> > struct rev_info *rev,
> > unuse_commit_buffer(commit, commit_buffer);
> >
> > for (i = 0, p = commit->parents; p; p = p->next) {
> > - int mark = get_object_mark(&p->item->object);
> > - if (!mark)
> > + struct object *obj = &p->item->object;
> > + int mark = get_object_mark(obj);
> > +
> > + if (!mark && !reference_excluded_commits)
> > continue;
> > if (i == 0)
> > - printf("from :%d\n", mark);
> > + printf("from ");
> > + else
> > + printf("merge ");
> > + if (mark)
> > + printf(":%d\n", mark);
> > else
> > - printf("merge :%d\n", mark);
> > + printf("%s\n", sha1_to_hex(anonymize ?
> > + anonymize_sha1(&obj->oid) :
> > + obj->oid.hash));
>
> Since we intend to move away from SHA-1, would this be a good time to
> add an anonymize_oid() function, "while at it"?
Since I already need to add a cleanup commit to remove the
pre-existing sha1_to_hex() calls, I'll just
s/anonymize_sha1/anonymize_oid/ while at it in the same commit; it's
not called from any other file.
> > i++;
> > }
> >
> > @@ -931,13 +941,22 @@ static void handle_tags_and_duplicates(struct
> > string_list *extras)
> > /*
> > * Getting here means we have a commit which
> > * was excluded by a negative refspec (e.g.
> > - * fast-export ^master master). If the user
> > + * fast-export ^master master). If we are
> > + * referencing excluded commits, set the ref
> > + * to the exact commit. Otherwise, the user
> > * wants the branch exported but every commit
> > - * in its history to be deleted, that sounds
> > - * like a ref deletion to me.
> > + * in its history to be deleted, which
> > basically
> > + * just means deletion of the ref.
> > */
> > - printf("reset %s\nfrom %s\n\n",
> > - name, sha1_to_hex(null_sha1));
> > + if (!reference_excluded_commits) {
> > + /* delete the ref */
> > + printf("reset %s\nfrom %s\n\n",
> > + name, sha1_to_hex(null_sha1));
> > + continue;
> > + }
> > + /* set ref to commit using oid, not mark */
> > + printf("reset %s\nfrom %s\n\n", name,
> > + sha1_to_hex(commit->object.oid.hash));
>
> Please use oid_to_hex(&commit->object.oid) instead.
Yeah, there were a couple others I introduced too. I'll fix them all up.