2016-03-27 27 views
0

önceden uygulanan yama olmadan tespit edildiğinde ben iptal yapýlar önleyebilir nasılOtomatik inşa ve daha önce uygulanmış yamalar

  • Sadece tüm kendisidir kullanıcı girişi

Patch gerektiren yamalar

  • başarısız görmezden Daha önce uygulanan bir yamayu tanımlayabilen Daha önce uygulanan yamalar üzerinde sıfır olmayan çıkış durumundan kaçınmanın bir yolu olmalı, değil mi?

    Bu işe yaramazsa:

    yes 'n' | patch -p<w/e> -i <w/e> 
    

    yama Standart girdi yerine (Ben tahmin ediyorum)/dev/tty okur çünkü. Stdin'den okunduğunda bile, hala bir çıkış durumu 1.

    Bir şey eksik gibi görünüyor. Bu soruna ilk giren kişi ben olamam.

  • cevap

    0

    Sanırım sorunumu çözmüş olabilirim.

    diff --git a/src/common.h b/src/common.h 
    index 9e355fe..e1b1555 100644 
    --- a/src/common.h 
    +++ b/src/common.h 
    @@ -108,8 +108,10 @@ XTERN bool force; 
    XTERN bool batch; 
    XTERN bool noreverse; 
    XTERN bool reverse; 
    +XTERN bool applied; 
    XTERN enum { DEFAULT_VERBOSITY, SILENT, VERBOSE } verbosity; 
    XTERN bool skip_rest_of_patch; 
    +XTERN bool applied_is_cause; 
    XTERN int strippath; 
    XTERN bool canonicalize; 
    XTERN int patch_get; 
    diff --git a/src/patch.c b/src/patch.c 
    index a60e631..3d375b3 100644 
    --- a/src/patch.c 
    +++ b/src/patch.c 
    @@ -613,7 +613,8 @@ main (int argc, char **argv) 
         if (fstat (fileno (rejfp), &rejst) != 0 || fclose (rejfp) != 0) 
          write_fatal(); 
         rejfp = NULL; 
    -  somefailed = true; 
    +  if (! somefailed && ! (applied && applied_is_cause)) 
    +   somefailed = true; 
         say ("%d out of %d hunk%s %s", failed, hunk, "s" + (hunk == 1), 
         skip_rest_of_patch ? "ignored" : "FAILED"); 
         if (outname && (! rejname || strcmp (rejname, "-") != 0)) { 
    @@ -629,7 +630,7 @@ main (int argc, char **argv) 
           rej[len - 1] = '#'; 
          simple_backup_suffix = s; 
         } 
    -  if (! dry_run) 
    +  if (! dry_run && ! (applied && applied_is_cause)) 
          { 
          say (" -- saving rejects to file %s\n", quotearg (rej)); 
          if (rejname) 
    @@ -706,9 +707,10 @@ reinitialize_almost_everything (void) 
    
        reverse = reverse_flag_specified; 
        skip_rest_of_patch = false; 
    + applied_is_cause = false; 
    } 
    
    -static char const shortopts[] = "bB:cd:D:eEfF:g:i:l" 
    +static char const shortopts[] = "abB:cd:D:eEfF:g:i:l" 
    #if 0 && defined ENABLE_MERGE 
           "m" 
    #endif 
    @@ -716,6 +718,7 @@ static char const shortopts[] = "bB:cd:D:eEfF:g:i:l" 
    
    static struct option const longopts[] = 
    { 
    + {"applied", no_argument, NULL, 'a'}, 
        {"backup", no_argument, NULL, 'b'}, 
        {"prefix", required_argument, NULL, 'B'}, 
        {"context", no_argument, NULL, 'c'}, 
    @@ -777,6 +780,7 @@ static char const *const option_help[] = 
    "", 
    " -N --forward Ignore patches that appear to be reversed or already applied.", 
    " -R --reverse Assume patches were created with old and new files swapped.", 
    +" -a --applied Ignore error and save no rejects on applied or reversed patch.", 
    "", 
    " -i PATCHFILE --input=PATCHFILE Read patch from PATCHFILE instead of stdin.", 
    "", 
    @@ -869,6 +873,9 @@ get_some_switches (void) 
        while ((optc = getopt_long (Argc, Argv, shortopts, longopts, (int *) 0)) 
         != -1) { 
        switch (optc) { 
    +  case 'a': 
    +  applied = true; 
    +  break; 
         case 'b': 
         make_backups = true; 
         /* Special hack for backward compatibility with CVS 1.9. 
    diff --git a/src/util.c b/src/util.c 
    index ee88c13..432bc5c 100644 
    --- a/src/util.c 
    +++ b/src/util.c 
    @@ -1056,6 +1056,7 @@ ok_to_reverse (char const *format, ...) 
        { 
         say (" Skipping patch.\n"); 
         skip_rest_of_patch = true; 
    +  applied_is_cause = true; 
        } 
        else if (force) 
        { 
    @@ -1079,6 +1080,7 @@ ok_to_reverse (char const *format, ...) 
          if (verbosity != SILENT) 
         say ("Skipping patch.\n"); 
          skip_rest_of_patch = true; 
    +   applied_is_cause = true; 
          } 
         } 
         } 
    
    İlgili konular