将添加物从大块中间移到最后

时间:2018-11-04 14:18:25

标签: git staging

我在将手动编辑补丁应用于文件时遇到困难。我从分支A中获取了一个文件,并将其复制到当前分支中,并使用git add --patch <file>进行了更改,然后上演了我想要的。直到我到达文件末尾为止,一切都很好,大块与我要执行的操作相冲突:

我不想删除当前分支中的任何现有行,而从另一个分支中添加所有新行。要注意的是,其他分支行都应该添加到文件的底部,但是git试图将它们添加到函数中:-(

我该如何解决? (拆分无济于事,我以为编辑可能会有用,但是在我看来,我需要的编辑是具有正确上下文的全插入式编辑,似乎在滥用git系统)

  1 # Manual hunk edit mode -- see bottom for a quick guide
  2 @@ -3239,38 +3222,37 @@ static void showSystemUptime(int argc, char *argv[],FILE *fin, FILE *fout,pedro_
  3         }
  4  }
  5
  6 -
  7 -/**
  8 - * @brief shows CPU temperature
  9 - *
 10 - * @param int argc, char *argv[],FILE *fin, FILE *fout,pedro_callback_func_args_t *pedro
 11 - *
 12 - * @return void
 13 - */
 14 -static void showSystemTemperature(int argc, char *argv[],FILE *fin, FILE *fout,pedro_callback_func_args_t *pedro)
 15 +void factory_default_hook(int argc, char *argv[],FILE *fin, FILE *fout,pedro_callback_func_args_t *pedro)
 16  {
 17 -       int     cpuTemp = 0;
 18 -
 19 -       FILE *tempFile = fopen("/sys/class/i2c-adapter/i2c-1/1-0048/hwmon/hwmon0/temp1_input", "r");
 20 -       if (tempFile != NULL)
 21 +       RF_BOOL use_user_defaults = RF_FALSE;
 22 +       if (SECURE_get_users_confirmation(fin, fout, FACTORY_DEFAULT_PROMPT))
 23         {
 24 -               // Display the contents to the user
 25 -               fprintf(fout,"\nCPU temperature: ");
 26 +               deleteStarupCfg(fout, use_user_defaults);
 27 +               OS_RunCommand("reboot\n");
 28 +       }
 29 +}
 30
 31 -               fscanf(tempFile, "%d", &cpuTemp);
 32 +void delete_startup_config_hook(int argc, char *argv[],FILE *fin, FILE *fout,pedro_callback_func_args_t *pedro)
 33 +{
 34 +       RF_BOOL use_user_defaults = access(USER_DEFAULTS_FILE, F_OK) ? RF_FALSE : RF_TRUE;
 35 +       deleteStarupCfg(fout, use_user_defaults);
 36 +       fprintf(fout,"Completed OK, reboot to activate\n");
 37 +}
 38
 39 -               fprintf(fout, "+%d.%d C\n", cpuTemp/1000, (cpuTemp % 1000)/100);
 40 -               fclose(tempFile);
 41 -               return;
 42 -       }
 43 -       else
 44 +void user_default_hook(int argc, char *argv[],FILE *fin, FILE *fout,pedro_callback_func_args_t *pedro)
 45 +{
 46 +       RF_BOOL use_user_defaults = RF_TRUE;
 47 +       if (SECURE_get_users_confirmation(fin, fout, USER_DEFAULT_PROMPT))
 48         {
 49 -               // The HW is not available on this machine
 50 -               fprintf(fout,"\nCPU temperature measurement is not available on this machine\n");
 51 -               return;
 52 +               if(!access(USER_DEFAULTS_FILE, F_OK))
 53 +               {
 54 +                       deleteStarupCfg(fout, use_user_defaults);
 55 +                       OS_RunCommand("reboot\n");
 56 +               }
 57 +               else
 58 +               {
 59 +                       fprintf(fout, "Cannot execute, user-default-config does not exist\n");
 60 +               }
 61         }
 62 -
 63 -} // End function showSystemTemperature
 64 -
 65 -

0 个答案:

没有答案