From: Junio C Hamano <gitster@pobox.com>
To: "Alisha Kim via GitGitGadget" <gitgitgadget@gmail.com>
Cc: git@vger.kernel.org, Alisha Kim <pril@pril.cc>
Subject: Re: [PATCH] git-p4: fix fast import when empty commit is first
Date: Thu, 23 Nov 2023 10:57:53 +0900 [thread overview]
Message-ID: <xmqq1qchcjtq.fsf@gitster.g> (raw)
In-Reply-To: <pull.1609.git.git.1700639764041.gitgitgadget@gmail.com> (Alisha Kim via GitGitGadget's message of "Wed, 22 Nov 2023 07:56:03 +0000")
"Alisha Kim via GitGitGadget" <gitgitgadget@gmail.com> writes:
> From: Alisha Kim <pril@pril.cc>
>
> When executing p4 sync by specifying an excluded path, an empty commit
> will be created if there is only a change in the excluded path in
> revision.
> If git-p4.keepEmptyCommits is turned off and an empty commit is the
> first, fast-import will fail.
The above describe under what condition a failure gets triggered,
but there is no description on what approach the proposed solution
takes. You could teach "fast-import" to deal with an empty commit
properly, you could ignore empty commits and not produce input for
the fast-import command, you could probably turn these initial empty
commits into non-empty commits by adding dummy contents, etc. We
want to see in our proposed log messages what solution was taken and
how the solution was designed to satisfy what requirements. This is
to help future developers who will have to change the code that is
given by this patch, so that their updates can still adhere to what
ever design criteria you had in working on this change [*].
Side note: Your solution might be to ignore empty commits
despite keepEmptyCommits option is set (as I said, you did not
describe it at all in the above, so this is a hypothetical
example). If the reason behind choosing that design were "I
just do not want it to fail---I do not care if the resulting
history coming out of fast-import is crappy (I lose the p4 CL
descriptions for these commits, even though the user wants to
keep them)", then future developers can safely "fix" your fix
here by turning the initial empty commits into non-empty ones by
adding fake contents.
> @@ -3876,10 +3878,12 @@ class P4Sync(Command, P4UserMap):
> self.commit(description, filesForCommit, branch, parent)
> else:
> files = self.extractFilesFromCommit(description)
> - self.commit(description, files, self.branch,
> + isCommitted = self.commit(description, files, self.branch,
> self.initialParent)
> # only needed once, to connect to the previous commit
> - self.initialParent = ""
> + if isCommitted:
> + self.initialParent = ""
"is" does not sound grammatically correct. "didCommit" (i.e., "we
made a commit"), "haveCommitted" (i.e., "we have made a commit")
might be more understandable.
> except IOError:
> print(self.gitError.read())
> sys.exit(1)
>
> base-commit: cfb8a6e9a93adbe81efca66e6110c9b4d2e57169
next prev parent reply other threads:[~2023-11-23 1:57 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-11-22 7:56 [PATCH] git-p4: fix fast import when empty commit is first Alisha Kim via GitGitGadget
2023-11-23 1:57 ` Junio C Hamano [this message]
2023-11-24 6:55 ` Alisha Kim
2023-11-24 6:14 ` [PATCH v2] " Alisha Kim via GitGitGadget
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=xmqq1qchcjtq.fsf@gitster.g \
--to=gitster@pobox.com \
--cc=git@vger.kernel.org \
--cc=gitgitgadget@gmail.com \
--cc=pril@pril.cc \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).