Cygwin下的Git P4:提交失败,并且#34; Patch不适用"

时间:2015-05-11 18:58:04

标签: python git cygwin git-p4

我试图在Cygwin下使用git-p4。 "克隆"和" rebase"工作流程的某些部分似乎工作正常,但我无法提交"。我猜测它可能与行结束约定有关。我查看了this git-p4 issue及其链接的项目,但是对行结尾和空白配置的操作迄今为止都没有成功。我配置中的注意事项:

(1)我使用bash shell函数技巧让路径正常工作:

//
//  AppDelegate.m
//  Listo
//
//  Created by Amit Baz on 5/12/15.
//  Copyright (c) 2015 Amit Baz. All rights reserved.
//

#import "AppDelegate.h"
#import <FBSDKCoreKit/FBSDKCoreKit.h>
#import <FBSDKLoginKit/FBSDKLoginKit.h>
#import <ParseFacebookUtilsV4/PFFacebookUtils.h>
#import <Parse/Parse.h>

@interface AppDelegate ()

@end

@implementation AppDelegate


- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    // Override point for customization after application launch.

    [FBSDKLoginButton class];

    [Parse setApplicationId:@""
                  clientKey:@""];

    [PFFacebookUtils initializeFacebookWithApplicationLaunchOptions:launchOptions];

    [PFAnalytics trackAppOpenedWithLaunchOptions:launchOptions];

    return YES;
}

- (void)applicationWillResignActive:(UIApplication *)application {
    // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
    // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
}

- (void)applicationDidEnterBackground:(UIApplication *)application {
    // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
    // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
}

- (void)applicationWillEnterForeground:(UIApplication *)application {
    // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
}

- (void)applicationDidBecomeActive:(UIApplication *)application {
    // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
    [FBSDKAppEvents activateApp];
}

- (void)applicationWillTerminate:(UIApplication *)application {
    // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
}
- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation {
    return [[FBSDKApplicationDelegate sharedInstance] application:application
                                                          openURL:url
                                                sourceApplication:sourceApplication
                                                       annotation:annotation];
}

@end

(2)我已经尝试了git&#39; s $ type p4 p4 is a function p4 () { P4=`which p4`; PWD=$(cygpath -wa .) "${P4}" "$@" } 值的所有设置 - 无论是(true,false,input),结果都是失败的。目前正在尝试&#34; false&#34;因为在与仓库进行区分时最有意义。

(3)我也玩过p4 clientspec的lineend值;目前正在尝试&#34; unix&#34;,Cygwin的b / c和在OSX下运行的P4沙箱服务器。

测试很简单。 repo包含一个文件foo1。软件仓库版本看起来像(使用autocrlf输出):

od -c

local-git-committed版本如下:

0000000   f   o   o   1  \n  \n
0000006

我在git-p4中为0000000 f o o 1 i s t h e o n e ! 0000020 \n \n 0000022 方法添加了一些额外的诊断输出。这与使用--verbose:

运行提交相结合
applyCommit()

注意&#34; Sanity:&#34;诊断线。这是在 $ git p4 submit --verbose Reading pipe: git name-rev HEAD Reading pipe: ['git', 'config', 'git-p4.allowSubmit'] Reading pipe: git rev-parse --symbolic --remotes Reading pipe: git rev-parse p4/master Reading pipe: git cat-file commit ce414288d1b5d52dbad20c1a29f1875cfff7c281 Reading pipe: git cat-file commit HEAD~0 Reading pipe: git cat-file commit HEAD~1 Reading pipe: ['git', 'config', 'git-p4.conflict'] Origin branch is remotes/p4/master Reading pipe: ['git', 'config', '--bool', 'git-p4.useclientspec'] Opening pipe: ['p4', '-G', 'where', '//depot/foo/...'] Perforce checkout for depot path //depot/foo/ located at c:\git\foo\ Synchronizing p4 checkout... ... - file(s) up-to-date. Opening pipe: p4 -G opened ... Reading pipe: ['git', 'rev-list', '--no-merges', 'remotes/p4/master..master'] Reading pipe: ['git', 'config', '--bool', 'git-p4.skipUserNameCheck'] Reading pipe: ['git', 'config', 'git-p4.detectRenames'] Reading pipe: ['git', 'config', 'git-p4.detectCopies'] Reading pipe: ['git', 'config', '--bool', 'git-p4.detectCopiesHarder'] Reading pipe: ['git', 'show', '-s', '--format=format:%h %s', '2303176ae8c575313616ae2c4a35358258742598'] Applying 2303176 updating foo1 Opening pipe: p4 -G users Reading pipe: ['git', 'log', '--max-count=1', '--format=%ae', '2303176ae8c575313616ae2c4a35358258742598'] Reading pipe: git diff-tree -r "2303176ae8c575313616ae2c4a35358258742598^" "2303176ae8c575313616ae2c4a35358258742598" //depot/foo/foo1#1 - opened for edit Sanity: git diff-tree --full-index -p "2303176ae8c575313616ae2c4a35358258742598" | git apply --verbose --check - Checking patch foo1... error: while searching for: foo1 error: patch failed: foo1:1 error: foo1: patch does not apply Unfortunately applying the change failed! Reading pipe: ['git', 'config', '--bool', 'git-p4.attemptRCSCleanup'] //depot/foo/foo1#1 - was edit, reverted 方法中失败的tryPatchCmd的值。如果我在bash命令行执行语句的第一部分,我会看到:

applyCommit()

将此管道连接到命令的第二部分不会导致错误。我很困惑,为什么在Python脚本中使用 2303176ae8c575313616ae2c4a35358258742598 diff --git a/foo1 b/foo1 index 630baf44b0874b3319c2814399f0b03106912183..4c23e4512b3347ec31068e464b64cbd99851cc9a 100644 --- a/foo1 +++ b/foo1 @@ -1,2 +1,2 @@ -foo1 +foo1 is the one! 执行时命令失败,否则成功。想法?

1 个答案:

答案 0 :(得分:2)

我相信我已经解决了这个问题。问题是双重的。第一个主要罪 - 不仔细阅读手册。 documentation in the Submit section州:

  

将更改从Git存储库提交回p4存储库需要单独的p4客户端工作区。应使用P4CLIENT环境变量或Git配置变量git-p4.client指定。 p4客户端必须存在,但如果客户端根目录尚未存在,则将创建并填充客户端根目录。

我需要花一些时间才能知道这实际上意味着两个物理工作副本 - 一个用于git,一个用于p4。 git-p4脚本在尝试在同一文件夹中执行git和p4操作时会感到窒息,而这种就地操作与Perforce的checkout模型不兼容。我是通过在Mac上执行相同的测试工作流程来发现这一点的,这更加明显地错误地说“不能破坏可写文件”。通过在p4 clientspec中使用“clobber”,我能够让Mac和Cygwin中的提交工作,这让我走上了正确的道路。

this Perforce page处设置了双工作空间结构的详细演练。

第二:有趣的是,我仍然需要--ignore-whitespace作为Cygwin环境中git apply逻辑的一部分。那是我愿意忍受的git-p4黑客。