2

私は Git には比較的慣れていませんが、ゲーム デザイン コンテストに参加してきたため、より高度なことを学んでいます。2 つのブランチ間で変更をスプライスしようとしている過程で、私は を紹介されましgit checkout --patchた。ただし、yornを使用してハンクを適用するだけで機能し、分割も同様に機能するという事実にもかかわらず、 を使用してハンクを手動で編集することを選択するとe、一貫して失敗します。たとえば、次のパッチを見てください。

# Manual hunk edit mode -- see bottom for a quick guide
@@ -102,12 +80,12 @@ enum Facing {
     int stunTimer;
     int m_health;

-    bool m_softStun = true;
     bool hitFlag;
     bool jumpFlag;
     SoundGroup contactSounds;

     float movementInput;
+    float verticalInput;

     [SerializeField]
     public GameObject opponent;
# ---
# To remove '-' lines, make them ' ' lines (context).
# To remove '+' lines, delete them.
# Lines starting with # will be removed.
#
# If the patch applies cleanly, the edited hunk will immediately be
# marked for applying. If it does not apply cleanly, you will be given
# an opportunity to edit again. If all lines of the hunk are removed,
# then the edit is aborted and the hunk is left unchanged.

これは、分割することで問題を解決できる単純なパッチですが、例として使用します。m_softStunbool 変数とverticalInputfloat 変数の両方を保持しようとしているとします。私がする必要があるのはこれだけのように見えるはずです:

# Manual hunk edit mode -- see bottom for a quick guide
@@ -102,12 +80,12 @@ enum Facing {
     int stunTimer;
     int m_health;

     bool m_softStun = true;
     bool hitFlag;
     bool jumpFlag;
     SoundGroup contactSounds;

     float movementInput;
+    float verticalInput;

     [SerializeField]
     public GameObject opponent;
# ---
# To remove '-' lines, make them ' ' lines (context).
# To remove '+' lines, delete them.
# Lines starting with # will be removed.
#
# If the patch applies cleanly, the edited hunk will immediately be
# marked for applying. If it does not apply cleanly, you will be given
# an opportunity to edit again. If all lines of the hunk are removed,
# then the edit is aborted and the hunk is left unchanged.

私が行ったのは、の-前を削除しbool m_softStun、ドキュメントや他の回答が教えてくれたように、スペースを追加することだけです。

ただし、このパッチを適用しようとすると、次のエラーが返されます。

error: patch failed: Assets/Scripts/Fighter.cs:23
error: Assets/Scripts/Fighter.cs: patch does not apply

このエラー、または行番号が異なるバリエーションは、次のすべての修正試行を通じて返されました。

  • 標準の Windows 10 メモ帳、メモ帳 ++、さらには Vim を使用しました
  • 最初にタブによって消費される空白がないことを確認するためにチェックしました。それを確認するためにVimの16進数分析に入っても
  • 行末から改行を削除して保持しようとしました
  • Vim、メモ帳、メモ帳++を介してANSIとUTF-8の両方でエンコードしようとしました
  • パッチをまったく編集しないようにしましたが、それでもエラーが発生し、git のエラーか、ファイルの保存方法に問題があるのではないかと疑われます。

私は事実上、何がうまくいかなかったのかを理解しようとして頭がいっぱいですが、それを見つけ始めるための技術的知識はありません。16 進数のチェックなどを提案した私の地元の「git ガイ」でさえ、助けることができず、バグ レポートを電子メールで送るように私に送りましたが、これまでのところ何も見つかりませんでした。手動パッチを作成できない理由を誰かが知っていますか?

4

0 に答える 0